Fittings: Construction-made building upgrades from planks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fb4b8bf7c8
commit
cdb109e554
7 changed files with 218 additions and 14 deletions
|
|
@ -1025,6 +1025,66 @@ class HappeningsTest(unittest.TestCase):
|
|||
|
||||
|
||||
|
||||
class FittingTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.world = world_with(("fred", "artisan"))
|
||||
self.p = self.world["players"]["fred"]
|
||||
self.buildings = self.world["city"]["buildings"]
|
||||
|
||||
def test_install_needs_the_building_level(self):
|
||||
self.p["bank"] = {"shelving": 1}
|
||||
self.buildings["storehouse"]["level"] = 1
|
||||
self.assertEqual(game.install(self.world, self.p, "shelving", "bank", T0), "Needs Storehouse level 2")
|
||||
self.buildings["storehouse"]["level"] = 2
|
||||
slots = game.bank_slots(self.world, self.p)
|
||||
self.assertIsNone(game.install(self.world, self.p, "shelving", "bank", T0))
|
||||
self.assertEqual(game.bank_slots(self.world, self.p), slots + 1)
|
||||
self.assertNotIn("shelving", self.p["bank"])
|
||||
self.assertGreater(self.p["favour"], 0)
|
||||
self.p["bank"] = {"shelving": 1}
|
||||
self.assertEqual(game.install(self.world, self.p, "shelving", "bank", T0), "The storehouse already has that")
|
||||
|
||||
def test_install_from_the_stockpile(self):
|
||||
self.world["city"]["stockpile"] = {"hoardings": 1}
|
||||
self.buildings["walls"]["level"] = 3
|
||||
walls = game.defence(self.world)["parts"]["walls"]
|
||||
self.assertIsNone(game.install(self.world, self.p, "hoardings", "city", T0))
|
||||
self.assertEqual(game.defence(self.world)["parts"]["walls"], walls + 25)
|
||||
self.assertEqual(self.p["favour"], 0)
|
||||
self.assertIn("Walls", game.city_uses("hoardings"))
|
||||
|
||||
def test_damage_pauses_a_fitting(self):
|
||||
self.buildings["smithy"].update(level=3, fittings=["bellows"])
|
||||
action = game.ACTION_BY_ID["smith_copper_bar"]
|
||||
fitted = game.action_time(self.world, self.p, action)
|
||||
self.buildings["smithy"]["damaged"] = True
|
||||
self.assertFalse(game.fitted(self.world, "bellows"))
|
||||
self.assertGreater(game.action_time(self.world, self.p, action), fitted)
|
||||
|
||||
def test_pump_can_put_out_a_fire(self):
|
||||
self.buildings["well"].update(level=2, fittings=["well_pump"])
|
||||
self.world["city"]["stockpile"] = {"logs": 100}
|
||||
rng = random.Random()
|
||||
rng.random = lambda: 0.1
|
||||
game._hardship(self.world, T0, rng, "fire")
|
||||
self.assertEqual(self.world["city"]["stockpile"], {"logs": 100})
|
||||
|
||||
def test_every_fitting_can_be_made(self):
|
||||
for fitting in game.FITTINGS:
|
||||
action = game.ACTION_BY_ID[f"make_{fitting[0]}"]
|
||||
self.assertEqual(action["skill"], "construction")
|
||||
self.assertEqual(action["outputs"], {fitting[0]: 1})
|
||||
self.assertIn(fitting[2], game.BUILDINGS)
|
||||
|
||||
def test_migration_adds_fittings(self):
|
||||
world = game.new_world(T0)
|
||||
world["version"] = 9
|
||||
for building in world["city"]["buildings"].values():
|
||||
del building["fittings"]
|
||||
game.migrate(world, T0)
|
||||
self.assertEqual(world["city"]["buildings"]["houses"]["fittings"], [])
|
||||
|
||||
|
||||
class IconTest(unittest.TestCase):
|
||||
def test_everything_has_a_glyph_in_the_sprite(self):
|
||||
sprite = (Path(__file__).resolve().parent.parent / "static" / "icons.svg").read_text()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue