Raids wear out the armoury: issued swords and shields break, worst first
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f2e4ea39de
commit
366a195c6d
4 changed files with 91 additions and 10 deletions
|
|
@ -1025,6 +1025,38 @@ class HappeningsTest(unittest.TestCase):
|
|||
|
||||
|
||||
|
||||
class WearTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.world = world_with(("fred", "warrior"))
|
||||
self.city = self.world["city"]
|
||||
self.city["population"] = 40.0 # 20 defenders
|
||||
|
||||
def test_wear_follows_how_close_the_fight_was(self):
|
||||
self.assertAlmostEqual(game.wear_share(3), 0.1)
|
||||
self.assertAlmostEqual(game.wear_share(1.5), 0.2)
|
||||
self.assertAlmostEqual(game.wear_share(1), 0.3)
|
||||
self.assertAlmostEqual(game.wear_share(0.5), 0.4)
|
||||
|
||||
def test_only_issued_gear_breaks_worst_first(self):
|
||||
self.city["stockpile"] = {"iron_sword": 10, "copper_sword": 30}
|
||||
rng = random.Random()
|
||||
rng.random = lambda: 0.0
|
||||
broken = game.wear_kit(self.world, 0.4, rng)
|
||||
# 20 defenders take 10 iron and 10 copper; 8 break, all copper.
|
||||
self.assertEqual(broken, {"copper_sword": 8})
|
||||
self.assertEqual(self.city["stockpile"], {"iron_sword": 10, "copper_sword": 22})
|
||||
|
||||
def test_a_won_raid_breaks_some_kit_and_reports_it(self):
|
||||
self.city["stockpile"] = {"copper_sword": 20, "arrows": 100}
|
||||
event = {"strength": 1, "sabotage": 0, "group": "the Red Hand"}
|
||||
game._resolve_raid(self.world, event, T0, random.Random(1))
|
||||
self.assertLess(self.city["stockpile"]["copper_sword"], 20)
|
||||
self.assertEqual(self.city["stockpile"]["arrows"], 70)
|
||||
text = " ".join(event["report"]["lines"])
|
||||
self.assertIn("used 30 arrows", text)
|
||||
self.assertIn("broken in the fighting", text)
|
||||
|
||||
|
||||
class FittingTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.world = world_with(("fred", "artisan"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue