Masonry joins Construction; smith hardware; homesteader plots

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-19 23:17:23 +01:00
parent f4b2bb1320
commit e825518c5e
6 changed files with 258 additions and 72 deletions

View file

@ -719,9 +719,9 @@ class TierTest(unittest.TestCase):
def test_higher_building_levels_need_higher_tiers(self):
self.assertNotIn("steel_bar", game.build_cost("walls", 2))
self.assertEqual(game.build_cost("walls", 3)["steel_bar"], 80)
self.assertEqual(game.build_cost("walls", 5)["mithril_bar"], 50)
self.assertEqual(game.build_cost("walls", 5)["steel_bar"], 240)
self.assertEqual(game.build_cost("walls", 3)["steel_bar"], 60)
self.assertEqual(game.build_cost("walls", 5)["mithril_brackets"], 60)
self.assertEqual(game.build_cost("walls", 5)["steel_bar"], 180)
def test_dragons_drop_dragonhide(self):
world = world_with(("wil", "commoner"))
@ -1246,6 +1246,59 @@ class ClassTest(unittest.TestCase):
self.assertEqual(world["city"]["stockpile"], {"bricks": 250})
class TradeSkillsTest(unittest.TestCase):
def test_masonry_is_part_of_construction(self):
self.assertNotIn("masonry", game.SKILL_IDS)
bricks = game.ACTION_BY_ID["mason_bricks"]
self.assertEqual((bricks["skill"], bricks["group"]), ("construction", "Masonry"))
world = world_with(("swa", "builder"))
p = world["players"]["swa"]
world["version"] = 12
p["xp"]["masonry"], p["xp"]["construction"] = 5000, 1000
p["bank"] = {"masonry_potion_2": 3}
p["potions"] = {"masonry": {"item": "masonry_potion_1", "charges": 20}}
p["action"] = {"id": "brew_masonry_potion_3", "start": T0}
game.migrate(world, T0)
self.assertEqual(p["xp"]["construction"], 6000)
self.assertNotIn("masonry", p["xp"])
self.assertEqual(p["bank"], {"construction_potion_2": 3})
self.assertEqual(p["potions"], {"construction": {"item": "construction_potion_1", "charges": 20}})
self.assertEqual(p["action"]["id"], "brew_construction_potion_3")
def test_smiths_make_hardware_for_builders(self):
nails = game.ACTION_BY_ID["smith_iron_nails"]
self.assertEqual((nails["inputs"], nails["outputs"], nails["group"]), ({"iron_bar": 1}, {"iron_nails": 5}, "Hardware"))
self.assertIn("iron_nails", game.ACTION_BY_ID["mason_beam"]["inputs"])
self.assertIn("rune_lock", game.ACTION_BY_ID["make_enchanted_chests"]["inputs"])
self.assertNotIn("iron_bar", game.build_cost("houses", 2))
self.assertIn("iron_nails", game.build_cost("houses", 2))
def test_homesteader_focuses_or_tends_two_plots(self):
world = world_with(("hom", "homesteader"), ("com", "commoner"))
h, c = world["players"]["hom"], world["players"]["com"]
h["xp"]["farming"] = game.XP_TABLE[10]
wheat = game.ACTION_BY_ID["farm_wheat"]
self.assertAlmostEqual(game.action_time(world, h, wheat), wheat["time"] * 0.7) # focused
self.assertEqual(game.plant_second_plot(world, c, "grow_thatch"), "Only homesteaders tend two plots")
self.assertEqual(game.plant_second_plot(world, h, "grow_thatch"), "Plant your first plot first")
game.start_action(world, h, "farm_wheat", T0)
self.assertEqual(game.plant_second_plot(world, h, "farm_wheat"), "That's already growing in your first plot")
self.assertIsNone(game.plant_second_plot(world, h, "grow_thatch"))
self.assertAlmostEqual(game.action_time(world, h, wheat), wheat["time"] * 0.8)
summary = game.process_player(world, h, T0 + 0.8 * (25 + 30) * 10 + 1, random.Random(1))
self.assertEqual(summary["done"], 20)
self.assertEqual((h["bank"]["wheat"], h["bank"]["thatch"]), (20, 30)) # ten harvests from each plot
# Replanting the first plot keeps the second; a "make one" elsewhere comes back to both.
game.start_action(world, h, "grow_guam_leaf", T0 + 1000)
self.assertEqual(h["action"]["plot2"], "grow_thatch")
h["bank"].update(wheat=10, logs=10)
game.start_action(world, h, "cook_bread", T0 + 1000, once=True)
game.process_player(world, h, T0 + 1000 + 30, random.Random(1))
self.assertEqual((h["action"]["id"], h["action"]["plot2"]), ("grow_guam_leaf", "grow_thatch"))
game.start_action(world, h, "mine_stone", T0 + 2000)
self.assertNotIn("plot2", h["action"])
class FittingTest(unittest.TestCase):
def setUp(self):
self.world = world_with(("fred", "miner"))