From 0780fec1fbada2a2035525980a4cb66bf81baf15 Mon Sep 17 00:00:00 2001 From: Nate Bowman Date: Mon, 16 Nov 2026 19:19:26 -0500 Subject: [PATCH] Fix bug in housing check and add test --- aoe/housing.py | 6 +++--- tests/test.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/aoe/housing.py b/aoe/housing.py index 3134ed4..2859048 100644 --- a/aoe/housing.py +++ b/aoe/housing.py @@ -16,14 +16,14 @@ class Housing(): if world.get_effective_population() + required > pop_space: raise YallGotHousedException + return True + def check_housing_safe(self, world, thing): try: - self.check_housing(world, thing) + return self.check_housing(world, thing) except YallGotHousedException: return False - else: - return True def __init__(self): diff --git a/tests/test.py b/tests/test.py index c023069..a69d5ed 100644 --- a/tests/test.py +++ b/tests/test.py @@ -949,3 +949,27 @@ class TestWorld(unittest.TestCase): 100, 200], game.world) + + + def test_production_queue_two_units(self): + game = Gameplay() + + game.world._add_building(Buildings.BARRACKS, {}, {}) + game.world._add_building(Buildings.HOUSE, {}, {}) + + training = 21 + + game.queue_unit(0, Units.MILITIA) + game.queue_unit(0, Units.MILITIA) + + game.play_until(1) + self.assertEqual(4, game.world.population) + + game.play_until(training) + self.assertEqual(5, game.world.population) + + game.play_until(training + 10) + self.assertEqual(5, game.world.population) + + game.play_until(2*training) + self.assertEqual(6, game.world.population)