Garrison on by default, active since last threat
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6697545ba0
commit
5809be59de
4 changed files with 63 additions and 28 deletions
|
|
@ -696,7 +696,17 @@ class EventTest(unittest.TestCase):
|
|||
self.assertTrue(raid["report"]["title"].startswith("Victory"))
|
||||
self.assertEqual(world["city"]["repelled"], 1)
|
||||
self.assertEqual(p["favour"], 25)
|
||||
self.assertFalse(p["garrison"])
|
||||
self.assertTrue(p["garrison"]) # still on guard for the next one
|
||||
|
||||
def test_garrison_needs_activity_since_the_last_threat(self):
|
||||
world = world_with(("wil", "commoner"))
|
||||
raid = self.announce(world)
|
||||
p = world["players"]["wil"]
|
||||
game.tick(world, raid["fire_at"], random.Random(1))
|
||||
p["last_active"] = raid["resolved"] - 1
|
||||
self.assertEqual(game.defence(world)["garrison"], [])
|
||||
p["last_active"] = raid["resolved"] + 1
|
||||
self.assertEqual([g["id"] for g in game.defence(world)["garrison"]], ["wil"])
|
||||
|
||||
def test_defeat_culls_and_loots_banks_too(self):
|
||||
world = world_with(("fred", "commoner"))
|
||||
|
|
@ -1450,6 +1460,7 @@ class FavourTest(unittest.TestCase):
|
|||
|
||||
def test_drilling_takes_as_long_as_the_scouting(self):
|
||||
world, p = self.world, self.p
|
||||
p["garrison"] = False # drilling earns combat XP, which would raise the garrison too
|
||||
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))
|
||||
|
|
@ -3702,12 +3713,20 @@ class KingdomTest(unittest.TestCase):
|
|||
|
||||
def test_garrison_counts_only_where_you_stand(self):
|
||||
new = self.found()
|
||||
self.a["garrison"] = True
|
||||
before = game.defence(self.world)["parts"]["garrison"]
|
||||
self.assertGreater(before, 0)
|
||||
self.assertEqual(game.defence(new)["parts"]["garrison"], 0)
|
||||
self.go(self.a, new.here)
|
||||
self.assertFalse(self.a["garrison"])
|
||||
ids = lambda town: [g["id"] for g in game.defence(town)["garrison"]]
|
||||
self.assertIn(self.a["id"], ids(self.world))
|
||||
self.assertNotIn(self.a["id"], ids(new))
|
||||
self.assertIsNone(game.travel(self.world, self.a, new.here, {}, T0))
|
||||
self.assertNotIn(self.a["id"], ids(self.world)) # on the road
|
||||
game.process_player(self.world, self.a, self.a["travel"]["arrive"])
|
||||
self.assertIn(self.a["id"], ids(new))
|
||||
|
||||
def test_stepping_down_lasts_until_you_rejoin(self):
|
||||
ids = lambda: [g["id"] for g in game.defence(self.world)["garrison"]]
|
||||
self.assertIsNone(game.stand_guard(self.world, self.a, False, T0))
|
||||
self.assertNotIn(self.a["id"], ids())
|
||||
self.assertIsNone(game.stand_guard(self.world, self.a, True, T0)) # no raid needed to step back in
|
||||
self.assertIn(self.a["id"], ids())
|
||||
|
||||
def test_gates_close_on_latecomers(self):
|
||||
new = self.found()
|
||||
|
|
@ -3716,6 +3735,7 @@ class KingdomTest(unittest.TestCase):
|
|||
self.a["at"] = new.here
|
||||
self.a["arrived"] = T0 + 3600 - game.GATES_WARNING + 1
|
||||
self.assertIn("gates", game.stand_guard(new, self.a, True, T0 + 3599))
|
||||
self.assertEqual(game.defence(new)["garrison"], []) # the default doesn't get you past the gates
|
||||
self.a["arrived"] = T0
|
||||
self.assertIsNone(game.stand_guard(new, self.a, True, T0 + 3599))
|
||||
self.assertTrue(self.a["garrison"])
|
||||
|
|
@ -4534,6 +4554,12 @@ class SiegeworksTest(unittest.TestCase):
|
|||
self.assertEqual(city["works_base"], 8)
|
||||
self.assertEqual(city["buildings"]["outworks"]["level"], 0)
|
||||
|
||||
def test_migration_puts_everyone_on_guard(self):
|
||||
world = world_with(("fred", "builder"))
|
||||
world["players"]["fred"]["garrison"] = False
|
||||
world.doc["version"] = 44
|
||||
self.assertTrue(game.migrate(world.doc, T0)["players"]["fred"]["garrison"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue