Spend favour on the city: builders, informants, militia
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
34dc85284d
commit
67a5db86ff
5 changed files with 142 additions and 3 deletions
|
|
@ -464,5 +464,54 @@ class NewSkillsTest(unittest.TestCase):
|
|||
self.assertEqual(p["xp"]["fishing"], 0)
|
||||
|
||||
|
||||
|
||||
class FavourTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.world = world_with(("fred", "pioneer"))
|
||||
self.p = self.world["players"]["fred"]
|
||||
self.p["favour"] = 5000
|
||||
|
||||
def test_builders_halve_the_time_left(self):
|
||||
world, p = self.world, self.p
|
||||
self.assertEqual(game.spend_favour(world, p, "builders", T0), "Nothing is being built")
|
||||
world["city"]["construction"] = {"building": "walls", "repair": False, "start": T0, "done_at": T0 + 4 * 3600}
|
||||
cost = game.favours(world, T0)["builders"]["cost"]
|
||||
self.assertEqual(cost, 160)
|
||||
self.assertIsNone(game.spend_favour(world, p, "builders", T0))
|
||||
self.assertEqual(world["city"]["construction"]["done_at"], T0 + 2 * 3600)
|
||||
self.assertEqual(p["favour"], 5000 - 160)
|
||||
|
||||
def test_informant_raises_intel(self):
|
||||
world, p = self.world, self.p
|
||||
self.assertEqual(game.spend_favour(world, p, "informant", T0), "No news to dig into")
|
||||
world["next_event_at"] = T0
|
||||
game.tick(world, T0, random.Random(2))
|
||||
event = game.upcoming_event(world)
|
||||
for level in (1, 2, 3):
|
||||
self.assertIsNone(game.spend_favour(world, p, "informant", T0))
|
||||
self.assertEqual(game.intel_level(world, event), level)
|
||||
self.assertEqual(game.spend_favour(world, p, "informant", T0), "Nothing more to learn")
|
||||
|
||||
def test_rallies_cost_more_each_time_and_end_with_the_raid(self):
|
||||
world, p = self.world, self.p
|
||||
self.assertEqual(game.spend_favour(world, p, "militia", T0), "No raid to prepare for")
|
||||
world["next_event_at"] = T0
|
||||
game.tick(world, T0, random.Random(2))
|
||||
before = game.defence(world)["total"]
|
||||
game.spend_favour(world, p, "militia", T0)
|
||||
self.assertEqual(game.favours(world, T0)["militia"]["cost"], 300)
|
||||
game.spend_favour(world, p, "militia", T0)
|
||||
self.assertEqual(game.defence(world)["total"], before + 20)
|
||||
self.assertEqual(p["favour"], 5000 - 150 - 300)
|
||||
game.tick(world, game.upcoming_raid(world)["fire_at"], random.Random(1))
|
||||
self.assertEqual(game.defence(world)["parts"]["rallied"], 0)
|
||||
self.assertEqual(game.favours(world, T0)["militia"]["cost"], 150)
|
||||
|
||||
def test_not_enough_favour(self):
|
||||
self.p["favour"] = 10
|
||||
self.world["city"]["construction"] = {"building": "walls", "repair": False, "start": T0, "done_at": T0 + 3600}
|
||||
self.assertEqual(game.spend_favour(self.world, self.p, "builders", T0), "Needs 40 favour")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue