Bank: a full stack spills into another slot
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fb37bcef98
commit
71d7ca704b
5 changed files with 41 additions and 15 deletions
15
game.py
15
game.py
|
|
@ -718,12 +718,19 @@ def stack_size(world: dict) -> int:
|
|||
return BASE_STACK + 250 * building_level(world, "storehouse")
|
||||
|
||||
|
||||
def slots_used(world: dict, player: dict) -> int:
|
||||
"""Bank slots taken: an item spills into another slot every full stack."""
|
||||
stack = stack_size(world)
|
||||
return sum(-(-qty // stack) for qty in player["bank"].values())
|
||||
|
||||
|
||||
def bank_room(world: dict, player: dict, item: str) -> int:
|
||||
"""How many more of `item` fit in the bank."""
|
||||
"""How many more of `item` fit: the rest of its last stack, plus any free slots."""
|
||||
stack = stack_size(world)
|
||||
have = player["bank"].get(item, 0)
|
||||
if have == 0 and len(player["bank"]) >= bank_slots(world, player):
|
||||
return 0
|
||||
return max(0, stack_size(world) - have)
|
||||
partial = -have % stack # room left in the item's last, part-filled stack
|
||||
free = max(0, bank_slots(world, player) - slots_used(world, player))
|
||||
return partial + free * stack
|
||||
|
||||
|
||||
def city_uses(item: str) -> list[str]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue