Crafting queue

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-26 22:51:56 +00:00
parent 912f94f775
commit 40e5274c4e
5 changed files with 207 additions and 17 deletions

10
app.py
View file

@ -146,6 +146,8 @@ def player_view(world: dict, player: dict, now: float) -> dict:
/ game.speed(world)
if "enemy" in action else game.action_time(world, player, action) for action in game.ACTIONS}
view["blocked"] = {action["id"]: game.can_start(world, player, action) for action in game.ACTIONS}
view["queue_why"] = {action["id"]: game.queue_reason(world, player, action) for action in game.ACTIONS
if game.queueable(action)}
view["drill_per_action"] = game.drill_per_action(player)
view["recon_gain"] = {action["id"]: game.recon_gain(world, player, action) for action in game.ACTIONS
if action.get("special") == "recon"}
@ -363,6 +365,14 @@ class Handler(BaseHTTPRequestHandler):
if not isinstance(once, int) or not 0 <= once <= game.MAKE_MAX:
return f"1 to {game.MAKE_MAX:,}"
return game.start_action(world, player, str(body.get("id")), now, once=int(once))
if path == "/api/queue":
qty = body.get("qty")
if not isinstance(qty, int) or not 1 <= qty <= game.MAKE_MAX:
return f"1 to {game.MAKE_MAX:,}"
return game.queue_add(world, player, str(body.get("id")), qty, now)
if path == "/api/queue/remove":
index = body.get("index")
return game.queue_remove(player, index) if isinstance(index, int) else "Not in the queue"
if path == "/api/join":
return game.join_fight(world, player, str(body.get("id")), now)
if path == "/api/press":