Construction frames: mid-tier craft for later building levels
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
46540c69cf
commit
3f30e8ccdd
3 changed files with 74 additions and 17 deletions
69
game.py
69
game.py
|
|
@ -151,6 +151,10 @@ STATIONS = {
|
|||
# Storage: a builder's strongbox adds bank slots, a homesteader's bag a bigger stack.
|
||||
STRONGBOX_SLOTS = [2, 4, 6, 8, 11, 14]
|
||||
BAG_STACK = [250, 500, 750, 1000, 1500, 2000]
|
||||
# Frames: a builder's mid-tier craft for the later building levels, from the tier's
|
||||
# planks and hardware. A building takes one in place of FRAME_FOR_PLANKS planks.
|
||||
FRAME_PLANKS = 4
|
||||
FRAME_FOR_PLANKS = 5
|
||||
|
||||
# item id, name, icon, value, action id, verb
|
||||
TREES = [
|
||||
|
|
@ -385,6 +389,9 @@ for _tier, _wood in enumerate(WOODS):
|
|||
"speed": TOOL_SPEED[_tier], "req": [_skill, TIER_LEVELS[_tier]], "value": 0}
|
||||
ITEMS[f"{_wood}_strongbox"] = {"name": f"{WOOD_NAMES[_tier]} strongbox", "plural": f"{WOOD_NAMES[_tier]} strongboxes",
|
||||
"icon": "🧰", "tier": _tier, "slot": "storage", "slots": STRONGBOX_SLOTS[_tier], "value": 0}
|
||||
_hardware, *_rest, _made = HARDWARE[_tier]
|
||||
ITEMS[f"{_wood}_frame"] = {"name": f"{WOOD_NAMES[_tier]} frame", "icon": "🪟", "tier": _tier, "value": round(
|
||||
(FRAME_PLANKS * ITEMS[PLANKS[_tier][0]]["value"] + _made * ITEMS[_hardware]["value"]) * CRAFT_MARKUP)}
|
||||
for _tier, (_fibre, _level, _time, _xp, _cloth, _prefix, _label) in enumerate(CLOTHS):
|
||||
ITEMS[f"{_prefix}_bag"] = {"name": f"{_label} bag", "icon": "👜", "tier": _tier, "slot": "bag",
|
||||
"stack": BAG_STACK[_tier], "value": 0}
|
||||
|
|
@ -1370,6 +1377,10 @@ ACTIONS = [
|
|||
*[_action(f"saw_{plank}", "construction", f"Saw {name.lower()}s", TIER_LEVELS[tier], 25 + 3 * tier,
|
||||
[6, 14, 22, 32, 44, 58][tier], {TREES[tier][0]: 2}, {plank: 1}, group="Planks")
|
||||
for tier, (plank, name) in enumerate(PLANKS)],
|
||||
*[_action(f"make_{wood}_frame", "construction", f"{WOOD_NAMES[tier]} frame", TIER_LEVELS[tier] + 11, 45 + 2 * tier,
|
||||
[24, 52, 80, 112, 148, 192][tier], {PLANKS[tier][0]: FRAME_PLANKS, HARDWARE[tier][0]: HARDWARE[tier][4]},
|
||||
{f"{wood}_frame": 1}, group="Frames")
|
||||
for tier, wood in enumerate(WOODS)],
|
||||
_action("mason_bricks", "construction", "Bricks", 1, 25, 6, {"stone": 2, "logs": 1}, {"bricks": 2}, group="Masonry",
|
||||
fire="kiln", fuel=0),
|
||||
_action("mason_cut_stone", "construction", "Cut stone", 10, 30, 12, {"stone": 3}, {"cut_stone": 1}, group="Masonry"),
|
||||
|
|
@ -1524,75 +1535,75 @@ BUILDINGS = {
|
|||
"name": "Houses", "icon": "🏠", "max": 8, "gold": 200,
|
||||
"base": {"logs": 300, "bricks": 150, "thatch": 300, "provisions": 80, "copper_rivets": 60},
|
||||
"advanced": {"oak_logs": 100, "leather": 80, "rope": 40, "iron_nails": 150},
|
||||
"late": {"willow_logs": 80, "oak_plank": 35, "hide_glue": 50, "steel_hinges": 20},
|
||||
"final": {"maple_logs": 50, "willow_plank": 30, "hard_leather": 60, "mithril_brackets": 15},
|
||||
"late": {"willow_logs": 80, "oak_frame": 7, "hide_glue": 50, "steel_hinges": 20},
|
||||
"final": {"maple_logs": 50, "willow_frame": 6, "hard_leather": 60, "mithril_brackets": 15},
|
||||
"effect": "+20 homes per level",
|
||||
},
|
||||
"walls": {
|
||||
"name": "Walls", "icon": "🏰", "max": 5, "gold": 300,
|
||||
"base": {"stone": 1000, "bricks": 250, "provisions": 90},
|
||||
"advanced": {"cut_stone": 150, "beam": 20, "rope": 50, "iron_nails": 200},
|
||||
"late": {"steel_bar": 60, "oak_plank": 25, "hide_glue": 50, "steel_hinges": 30},
|
||||
"final": {"mithril_brackets": 60, "maple_plank": 20, "hide_glue": 60, "adamant_chain": 10},
|
||||
"late": {"steel_bar": 60, "oak_frame": 5, "hide_glue": 50, "steel_hinges": 30},
|
||||
"final": {"mithril_brackets": 60, "maple_frame": 4, "hide_glue": 60, "adamant_chain": 10},
|
||||
"effect": "+20 defence per level, less plunder lost",
|
||||
},
|
||||
"barracks": {
|
||||
"name": "Barracks", "icon": "⛺", "max": 5, "gold": 300,
|
||||
"base": {"logs": 300, "bricks": 200, "thatch": 200, "leather": 80, "copper_sword": 25, "provisions": 80, "copper_rivets": 60},
|
||||
"advanced": {"iron_bar": 60, "hard_leather": 40},
|
||||
"late": {"steel_bar": 40, "oak_plank": 30, "hide_glue": 40},
|
||||
"final": {"mithril_bar": 25, "willow_plank": 25, "bear_leather": 40},
|
||||
"late": {"steel_bar": 40, "oak_frame": 6, "hide_glue": 40},
|
||||
"final": {"mithril_bar": 25, "willow_frame": 5, "bear_leather": 40},
|
||||
"effect": "More defence per townsperson",
|
||||
},
|
||||
"smithy": {
|
||||
"name": "Smithy", "icon": "⚒️", "max": 5, "gold": 250,
|
||||
"base": {"stone": 400, "logs": 250, "copper_bar": 180, "provisions": 60},
|
||||
"advanced": {"iron_bar": 180, "leather": 70},
|
||||
"late": {"steel_bar": 100, "oak_plank": 25, "hide_glue": 40},
|
||||
"final": {"mithril_bar": 70, "maple_plank": 20, "bear_leather": 35},
|
||||
"late": {"steel_bar": 100, "oak_frame": 5, "hide_glue": 40},
|
||||
"final": {"mithril_bar": 70, "maple_frame": 4, "bear_leather": 35},
|
||||
"effect": "Smithing 8% faster and one more metal per level",
|
||||
},
|
||||
"temple": {
|
||||
"name": "Temple", "icon": "⛪", "max": 3, "gold": 300,
|
||||
"base": {"stone": 700, "bricks": 200, "cut_stone": 60, "provisions": 60},
|
||||
"advanced": {"beam": 15, "rope": 40, "iron_nails": 150},
|
||||
"late": {"willow_logs": 80, "oak_plank": 35, "hide_glue": 40, "steel_hinges": 20},
|
||||
"late": {"willow_logs": 80, "oak_frame": 7, "hide_glue": 40, "steel_hinges": 20},
|
||||
"effect": "Per level: +25% prayer points from bones, +25% devotion",
|
||||
},
|
||||
"granary": {
|
||||
"name": "Granary", "icon": "🌾", "max": 3, "gold": 150,
|
||||
"base": {"logs": 200, "bricks": 100, "plank": 40, "thatch": 300, "provisions": 50, "copper_rivets": 40},
|
||||
"advanced": {"cut_stone": 40, "rope": 40, "iron_nails": 100},
|
||||
"late": {"oak_plank": 35, "hide_glue": 35, "steel_hinges": 15},
|
||||
"late": {"oak_frame": 7, "hide_glue": 35, "steel_hinges": 15},
|
||||
"effect": "Guards 25% of food from pests per level",
|
||||
},
|
||||
"lumber_shed": {
|
||||
"name": "Lumber shed", "icon": "🪵", "max": 3, "gold": 120,
|
||||
"base": {"logs": 200, "stone": 250, "plank": 50, "thatch": 180, "provisions": 40, "copper_rivets": 40},
|
||||
"advanced": {"oak_plank": 40, "rope": 40, "iron_nails": 100},
|
||||
"late": {"willow_plank": 25, "hide_glue": 35},
|
||||
"late": {"willow_frame": 5, "hide_glue": 35},
|
||||
"effect": "Guards 25% of wood from rot per level",
|
||||
},
|
||||
"well": {
|
||||
"name": "Well", "icon": "🪣", "max": 3, "gold": 120,
|
||||
"base": {"stone": 500, "bricks": 80, "rope": 50, "provisions": 40},
|
||||
"advanced": {"cut_stone": 40, "leather": 60, "iron_nails": 125},
|
||||
"late": {"oak_plank": 25, "hide_glue": 35, "steel_hinges": 15},
|
||||
"late": {"oak_frame": 5, "hide_glue": 35, "steel_hinges": 15},
|
||||
"effect": "Fire damage -25% per level",
|
||||
},
|
||||
"spymaster": {
|
||||
"name": "Spymaster's guild", "icon": "🕵️", "max": 3, "gold": 400,
|
||||
"base": {"logs": 200, "bricks": 150, "hide": 120, "feathers": 300, "provisions": 60},
|
||||
"advanced": {"cut_stone": 80, "hard_leather": 40, "iron_nails": 100},
|
||||
"late": {"bear_leather": 50, "oak_plank": 25, "steel_hinges": 15},
|
||||
"late": {"bear_leather": 50, "oak_frame": 5, "steel_hinges": 15},
|
||||
"effect": "+25% recon per level, plus some each hour",
|
||||
},
|
||||
"storehouse": {
|
||||
"name": "Storehouse", "icon": "📦", "max": 5, "gold": 200,
|
||||
"base": {"logs": 400, "stone": 800, "thatch": 200, "provisions": 60, "copper_rivets": 60},
|
||||
"advanced": {"oak_logs": 150, "cut_stone": 100, "rope": 50, "iron_nails": 150},
|
||||
"late": {"willow_logs": 120, "oak_plank": 45, "hide_glue": 45, "steel_hinges": 25},
|
||||
"final": {"yew_logs": 40, "yew_plank": 20, "bear_leather": 40, "rune_lock": 6},
|
||||
"late": {"willow_logs": 120, "oak_frame": 9, "hide_glue": 45, "steel_hinges": 25},
|
||||
"final": {"yew_logs": 40, "yew_frame": 4, "bear_leather": 40, "rune_lock": 6},
|
||||
"effect": "Per level: +3 bank slots, +250 stack size",
|
||||
},
|
||||
}
|
||||
|
|
@ -1629,7 +1640,7 @@ RAID_TRAITS = ["lightly armoured, heavy on archers", "mounted and fast, few bows
|
|||
|
||||
# --- world ---------------------------------------------------------------
|
||||
|
||||
WORLD_VERSION = 36
|
||||
WORLD_VERSION = 37
|
||||
|
||||
|
||||
def new_world(now: float, speed: float = 1.0) -> dict:
|
||||
|
|
@ -1900,9 +1911,30 @@ def migrate(world: dict, now: float | None = None) -> dict:
|
|||
for player in world["players"].values():
|
||||
player.setdefault("ledger", [])
|
||||
world["version"] = 36
|
||||
if world["version"] < 37:
|
||||
_planks_to_frames(world)
|
||||
world["version"] = 37
|
||||
return world
|
||||
|
||||
|
||||
def _planks_to_frames(world: dict) -> None:
|
||||
"""Later building levels take frames instead of planks: planks already in a fund count
|
||||
FRAME_FOR_PLANKS to a frame, and any odd ones over go to the stockpile."""
|
||||
city = world["city"]
|
||||
for key, building in city["buildings"].items():
|
||||
costs = [BUILDINGS[key].get(part, {}) for part in ("base", "advanced", "late", "final")]
|
||||
for (plank, _name), wood in zip(PLANKS, WOODS):
|
||||
fund = building["fund"]
|
||||
if plank not in fund or any(plank in cost for cost in costs) \
|
||||
or not any(f"{wood}_frame" in cost for cost in costs):
|
||||
continue
|
||||
frames, odd = divmod(fund.pop(plank), FRAME_FOR_PLANKS)
|
||||
if frames:
|
||||
fund[f"{wood}_frame"] = fund.get(f"{wood}_frame", 0) + frames
|
||||
if odd:
|
||||
city["stockpile"][plank] = city["stockpile"].get(plank, 0) + odd
|
||||
|
||||
|
||||
def _precision_to_haste(world: dict) -> None:
|
||||
"""Rings of precision became rings of haste: same gem, same slot."""
|
||||
rename = lambda item: item.replace("_precision", "_haste") if item and item.endswith("_precision") else item
|
||||
|
|
@ -6686,6 +6718,7 @@ def _assign_glyphs() -> None:
|
|||
for suffix, _noun, glyph, _kind in STATIONS.values():
|
||||
ITEMS[f"{wood}_{suffix}"].update(glyph=glyph, tint=tint)
|
||||
ITEMS[f"{wood}_strongbox"].update(glyph="locked-chest", tint=tint)
|
||||
ITEMS[f"{wood}_frame"].update(glyph="wood-frame", tint=tint)
|
||||
for cloth, tint in zip(CLOTHS, CLOTH_TINTS):
|
||||
ITEMS[f"{cloth[5]}_bag"].update(glyph="shoulder-bag", tint=tint)
|
||||
for gem, _name, _value, tint, glyph in GEMS:
|
||||
|
|
@ -6756,6 +6789,10 @@ ORDER_RECIPES, ORDER_RAW = _order_sources()
|
|||
# What changed, shown on the Patch notes page. Newest first; every shipped change adds a
|
||||
# line here (new / balance / fix), and a new release a new entry on top.
|
||||
PATCH_NOTES = [
|
||||
{"date": "2026-10-29", "title": "Frames", "notes": [
|
||||
("new", "Construction: frames for every wood, Lv 12 / 26 / 41 / 56 / 71 / 86. 4 planks + hardware."),
|
||||
("balance", "Building levels 3+ take frames instead of planks: 1 frame per 5 planks. Funded planks became frames, odd ones went to the stockpile."),
|
||||
]},
|
||||
{"date": "2026-10-28", "title": "Queue", "notes": [
|
||||
("fix", "The page no longer redraws itself when an action finishes or a poll lands: scroll, hovers and tooltips stay put."),
|
||||
("fix", "Crafting cards: buttons stay on one row on phones and narrow cards."),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 448 KiB After Width: | Height: | Size: 449 KiB |
|
|
@ -297,6 +297,16 @@ class ActionTest(unittest.TestCase):
|
|||
game.migrate(world, T0)
|
||||
self.assertEqual(world["players"]["fred"]["gave"], {})
|
||||
|
||||
def test_migrate_turns_funded_planks_into_frames(self):
|
||||
world = world_with(("fred", "commoner"))
|
||||
world["city"]["buildings"]["houses"]["fund"] = {"oak_plank": 210, "willow_plank": 32, "bricks": 5}
|
||||
world["city"]["buildings"]["lumber_shed"]["fund"] = {"oak_plank": 40} # still planks at that level
|
||||
world["version"] = 36
|
||||
game.migrate(world, T0)
|
||||
self.assertEqual(world["city"]["buildings"]["houses"]["fund"], {"oak_frame": 42, "willow_frame": 6, "bricks": 5})
|
||||
self.assertEqual(world["city"]["buildings"]["lumber_shed"]["fund"], {"oak_plank": 40})
|
||||
self.assertEqual(world["city"]["stockpile"].get("willow_plank"), 2)
|
||||
|
||||
def test_full_bank_sells_what_the_city_cannot_use(self):
|
||||
world = world_with(("fred", "commoner"))
|
||||
p = world["players"]["fred"]
|
||||
|
|
@ -1868,7 +1878,7 @@ class ConstructionTest(unittest.TestCase):
|
|||
self.assertIn(f"saw_{plank}", game.ACTION_BY_ID)
|
||||
for key, *_ in game.METALS:
|
||||
self.assertIn(f"smith_{key}_hammer", game.ACTION_BY_ID)
|
||||
self.assertIn("oak_plank", game.build_cost("houses", 3))
|
||||
self.assertIn("oak_frame", game.build_cost("houses", 3))
|
||||
|
||||
def test_v6_timer_becomes_labour(self):
|
||||
world = world_with(("fred", "miner"))
|
||||
|
|
@ -2321,6 +2331,15 @@ class TradeSkillsTest(unittest.TestCase):
|
|||
self.assertNotIn("iron_bar", game.build_cost("houses", 2))
|
||||
self.assertIn("iron_nails", game.build_cost("houses", 2))
|
||||
|
||||
def test_builders_frame_the_later_building_levels(self):
|
||||
frame = game.ACTION_BY_ID["make_maple_frame"]
|
||||
self.assertEqual((frame["level"], frame["inputs"]), (56, {"maple_plank": 4, "mithril_brackets": 2}))
|
||||
self.assertEqual(game.build_cost("walls", 5)["maple_frame"], 4)
|
||||
self.assertNotIn("maple_plank", game.build_cost("walls", 5))
|
||||
for spec in game.BUILDINGS.values():
|
||||
for part in ("late", "final"):
|
||||
self.assertFalse([item for item in spec.get(part, {}) if item.endswith("_plank")])
|
||||
|
||||
def test_homesteader_focuses_or_tends_two_plots(self):
|
||||
world = world_with(("hom", "homesteader"), ("com", "commoner"))
|
||||
h, c = world["players"]["hom"], world["players"]["com"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue