Drill the militia; drill sergeant replaces rallying

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-19 15:21:49 +01:00
parent fd66b69401
commit 1c80bd80f7
6 changed files with 102 additions and 31 deletions

View file

@ -592,20 +592,39 @@ class FavourTest(unittest.TestCase):
event["recon"] = game.intel_costs(event)[-1]
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):
def test_drilling_adds_defence_up_to_half_the_population(self):
world, p = self.world, self.p
self.assertEqual(game.spend_favour(world, p, "militia", T0), "No raid to prepare for")
self.assertEqual(game.start_action(world, p, "drill_militia", T0), "No raid to prepare for")
world["next_event_at"] = T0
game.tick(world, T0, random.Random(2))
world["city"]["population"] = 20.0
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)
self.assertIsNone(game.start_action(world, p, "drill_militia", T0))
game.process_player(world, p, T0 + 50 * 4 + 1, random.Random(1))
self.assertEqual(game.defence(world)["parts"]["drilled"], 2.0)
self.assertEqual(game.defence(world)["total"], before + 2)
self.assertEqual(p["xp"]["combat"], 40)
self.assertEqual(p["hp"], 44) # drilling is not a fight
game.process_player(world, p, T0 + 50 * 40, random.Random(1))
self.assertEqual(game.defence(world)["parts"]["drilled"], 10.0)
self.assertIsNone(p["action"]) # stops once the militia is fully drilled
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)
self.assertEqual(game.defence(world)["parts"]["drilled"], 0)
def test_drill_sergeant_doubles_drilling_for_a_while(self):
world, p = self.world, self.p
self.assertEqual(game.spend_favour(world, p, "sergeant", T0), "No raid to prepare for")
world["next_event_at"] = T0
game.tick(world, T0, random.Random(2))
self.assertIsNone(game.spend_favour(world, p, "sergeant", T0))
self.assertEqual(game.defence(world)["parts"]["drilled"], 0) # a sergeant drills nobody by himself
self.assertEqual(game.favours(world, T0)["sergeant"]["cost"], 225)
game.start_action(world, p, "drill_militia", T0)
game.process_player(world, p, T0 + 50 * 4 + 1, random.Random(1))
self.assertEqual(game.upcoming_raid(world)["drilled"], 4.0)
self.assertEqual(p["xp"]["combat"], 80)
self.assertEqual(world["city"]["drill_boost"], 13)
self.assertEqual(p["favour"], 5000 - 150)
def test_not_enough_favour(self):
self.p["favour"] = 10