Combat HP, food and retreat; armour, leatherworking, fishing, tools
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3716df7493
commit
d2991ebf7a
6 changed files with 381 additions and 44 deletions
20
app.py
20
app.py
|
|
@ -91,7 +91,14 @@ class Store:
|
|||
|
||||
|
||||
def player_view(world: dict, player: dict, now: float) -> dict:
|
||||
view = {key: value for key, value in player.items() if key != "last_active"}
|
||||
game.regen(world, player, now)
|
||||
view = {key: value for key, value in player.items() if key not in ("last_active", "hp_at")}
|
||||
view["hp"] = int(player["hp"])
|
||||
view["max_hp"] = game.max_hp(player)
|
||||
view["armour"] = game.armour(player)
|
||||
view["reduction"] = round(game.damage_reduction(player), 3)
|
||||
view["edible"] = game.edible(player)
|
||||
view["fight_damage"] = {a["id"]: round(game.fight_damage(player, a), 1) for a in game.ACTIONS if a["skill"] == "combat"}
|
||||
view["levels"] = {skill: game.skill_level(player, skill) for skill in game.SKILL_IDS}
|
||||
view["slots"] = game.bank_slots(world, player)
|
||||
view["stack"] = game.stack_size(world)
|
||||
|
|
@ -224,6 +231,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||
summary = None
|
||||
if player:
|
||||
summary = game.process_player(world, player, now, self.store.rng)
|
||||
game.regen(world, player, now)
|
||||
player["last_active"] = now
|
||||
self.store.save()
|
||||
self.send_json(self.state(uid, summary))
|
||||
|
|
@ -253,6 +261,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||
return self.fail("Create your adventurer first", HTTPStatus.CONFLICT)
|
||||
else:
|
||||
summary = game.process_player(world, player, now, self.store.rng)
|
||||
game.regen(world, player, now)
|
||||
player["last_active"] = now
|
||||
error = self.player_route(path, player, body, now)
|
||||
if error is None:
|
||||
|
|
@ -306,6 +315,12 @@ class Handler(BaseHTTPRequestHandler):
|
|||
return "There's no raid to stand guard for"
|
||||
player["garrison"] = bool(body.get("join"))
|
||||
return None
|
||||
if path == "/api/food":
|
||||
food = body.get("item")
|
||||
if food is not None and "heal" not in game.ITEMS.get(str(food), {}):
|
||||
return "That isn't food"
|
||||
player["food"] = food
|
||||
return None
|
||||
if path == "/api/perk":
|
||||
return game.buy_perk(player, str(body.get("perk")))
|
||||
if path == "/api/settings":
|
||||
|
|
@ -341,6 +356,9 @@ class Handler(BaseHTTPRequestHandler):
|
|||
game.bank_take(player, item, 1)
|
||||
current = player["equip"][spec["slot"]]
|
||||
if current:
|
||||
if game.bank_room(self.store.world, player, current) < 1:
|
||||
player["bank"][item] = player["bank"].get(item, 0) + 1
|
||||
return "No room in the bank for what you're wearing"
|
||||
player["bank"][current] = player["bank"].get(current, 0) + 1
|
||||
player["equip"][spec["slot"]] = item
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue