Work orders: fill a reagent slot after posting; no auto-reload while writing an order
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
326437ddf9
commit
1488692463
4 changed files with 39 additions and 3 deletions
16
game.py
16
game.py
|
|
@ -2125,6 +2125,22 @@ def post_order(world: dict, player: dict, kind: str, item: str, qty, provide, re
|
|||
return None
|
||||
|
||||
|
||||
def provide_reagent(world: dict, player: dict, order_id, item: str) -> str | None:
|
||||
"""Put a reagent into your own order after posting it, enough for what's still to be made."""
|
||||
order = order_by_id(world, order_id)
|
||||
if not order or order["by"] != player["id"] or order["status"] != "open" or order["kind"] != "craft":
|
||||
return "No such order"
|
||||
action = ACTION_BY_ID[order["action"]]
|
||||
if item not in action["inputs"] or item in order["provided"]:
|
||||
return "Already provided" if item in order["provided"] else "That isn't in the recipe"
|
||||
need = action["inputs"][item] * _batches(action, order["item"], order["qty"] - order["delivered"])
|
||||
if player["bank"].get(item, 0) < need:
|
||||
return f"{ITEMS[item]['name']}: {player['bank'].get(item, 0)} / {need}"
|
||||
bank_take(player, item, need)
|
||||
order["provided"][item] = need
|
||||
return None
|
||||
|
||||
|
||||
def _refund(world: dict, order: dict, now: float) -> None:
|
||||
owner = world["players"].get(order["by"])
|
||||
if not owner:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue