From 9ccf25f0ab35c4351d0978bcd76bf8684a9d3e0a Mon Sep 17 00:00:00 2001 From: Nate Bowman Date: Sun, 8 Nov 2026 21:04:05 -0500 Subject: [PATCH] Require a market to use buying and selling --- aoe/world.py | 4 +++- tests/test.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/aoe/world.py b/aoe/world.py index c578087..778690b 100644 --- a/aoe/world.py +++ b/aoe/world.py @@ -49,7 +49,6 @@ class World(): # results. Similarly, adding builders in the middle of building something # is not supported - # TODO require market to use market buy/sell # TODO allow automation: # reseeding of farms # possibly other things @@ -73,6 +72,9 @@ class World(): def _use_market(self, resource, amount, buy=True): + if Buildings.MARKET not in self.buildings: + raise MissingDependencyException + if amount % self.costs.market_transaction_amount != 0: raise InvalidMarketAmountException diff --git a/tests/test.py b/tests/test.py index 0421e49..69dbee3 100644 --- a/tests/test.py +++ b/tests/test.py @@ -354,6 +354,18 @@ class TestWorld(unittest.TestCase): self.assertResourcesMatch([500, 400, 450 + gathered, 500], game.world) + def test_market_buy_without_market(self): + game = Gameplay() + + game.world.age = Ages.FEUDAL + game.world.gather.resources = [500, 500, 1000, 500] + + game.market_buy(0, Resources.FOOD, 100) + + with self.assertRaises(MissingDependencyException): + game.play_until(1) + + def test_market_buy(self): game = Gameplay()