Drilling scales with the threat, like scouting

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

View file

@ -592,25 +592,34 @@ 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_drilling_adds_defence_up_to_half_the_population(self):
def test_drilling_takes_as_long_as_the_scouting(self):
world, p = self.world, self.p
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))
raid = game.upcoming_raid(world)
world["city"]["population"] = 20.0
needed = game.drill_needed(raid)
self.assertEqual(needed, game.intel_costs(raid)[-1])
before = game.defence(world)["total"]
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)
game.process_player(world, p, T0 + 60 * 10 + 1, random.Random(1))
self.assertEqual(raid["drilled"], 10)
self.assertAlmostEqual(game.defence(world)["parts"]["drilled"], round(20 * 10 / needed, 1))
self.assertAlmostEqual(game.defence(world)["total"], before + 20 * 10 / needed, places=0)
self.assertEqual(p["xp"]["combat"], 120)
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)
game.process_player(world, p, T0 + 60 * (needed + 5), random.Random(1))
self.assertEqual(game.defence(world)["parts"]["drilled"], 20.0)
self.assertIsNone(p["action"]) # stops once the militia is fully drilled
game.tick(world, game.upcoming_raid(world)["fire_at"], random.Random(1))
game.tick(world, raid["fire_at"], random.Random(1))
self.assertEqual(game.defence(world)["parts"]["drilled"], 0)
def test_seasoned_fighters_drill_a_little_faster(self):
self.assertEqual(game.drill_per_action(self.p), 1.0)
self.p["xp"]["combat"] = game.XP_TABLE[40]
self.assertEqual(game.drill_per_action(self.p), 1.5)
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")
@ -620,10 +629,10 @@ class FavourTest(unittest.TestCase):
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)
game.process_player(world, p, T0 + 60 * 4 + 1, random.Random(1))
self.assertEqual(game.upcoming_raid(world)["drilled"], 8)
self.assertEqual(p["xp"]["combat"], 96)
self.assertEqual(world["city"]["drill_boost"], 26)
self.assertEqual(p["favour"], 5000 - 150)
def test_not_enough_favour(self):