Compare commits

...

2 Commits

Author SHA1 Message Date
Nate Bowman
9ccf25f0ab Require a market to use buying and selling 2026-11-08 21:06:48 -05:00
Nate Bowman
e94af31828 Remove old comments 2026-11-08 21:01:38 -05:00
3 changed files with 15 additions and 3 deletions

View File

@@ -117,7 +117,6 @@ class Gameplay():
def _check_time(self, action_time): def _check_time(self, action_time):
# TODO will it work if we do something at current time?
if self.world.current_time > action_time: if self.world.current_time > action_time:
raise CannotChangeThePastException raise CannotChangeThePastException

View File

@@ -49,10 +49,8 @@ class World():
# results. Similarly, adding builders in the middle of building something # results. Similarly, adding builders in the middle of building something
# is not supported # is not supported
# TODO require market to use market buy/sell
# TODO allow automation: # TODO allow automation:
# reseeding of farms # reseeding of farms
# queuing of villagers
# possibly other things # possibly other things
@@ -74,6 +72,9 @@ class World():
def _use_market(self, resource, amount, buy=True): 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: if amount % self.costs.market_transaction_amount != 0:
raise InvalidMarketAmountException raise InvalidMarketAmountException

View File

@@ -354,6 +354,18 @@ class TestWorld(unittest.TestCase):
self.assertResourcesMatch([500, 400, 450 + gathered, 500], game.world) 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): def test_market_buy(self):
game = Gameplay() game = Gameplay()