Crafting stations, strongboxes and bags

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-20 21:00:31 +01:00
parent 636123e454
commit 722cf0b382
6 changed files with 182 additions and 14 deletions

12
app.py
View file

@ -108,7 +108,7 @@ def player_view(world: dict, player: dict, now: float) -> dict:
view["levels"] = {skill: game.skill_level(player, skill) for skill in game.SKILL_IDS}
view["slots"] = game.bank_slots(world, player)
view["slots_used"] = game.slots_used(world, player)
view["stack"] = game.stack_size(world)
view["stack"] = game.stack_size(world, player)
view["power"] = game.combat_power(player)
me = game.fighter(player, game.blessing(player), game.potion_effect(player, "combat"))
view["fighter"] = {"max_hit": me["max_hit"], "accuracy": round(me["accuracy"]), "evasion": me["evasion"],
@ -429,6 +429,16 @@ class Handler(BaseHTTPRequestHandler):
return "Not found"
def equip(self, player: dict, item: str | None, slot: str | None) -> str | None:
# A smaller strongbox or bag can't go on while the bank holds more than it would.
world = self.store.world
over, bank, equip = game.overfull(world, player), dict(player["bank"]), dict(player["equip"])
error = self._equip(player, item, slot)
if not error and game.overfull(world, player) > max(0, over):
player["bank"], player["equip"] = bank, equip
return "Bank too full for that"
return error
def _equip(self, player: dict, item: str | None, slot: str | None) -> str | None:
if item is None:
if slot not in player["equip"]:
return "No such slot"