diff --git a/README.md b/README.md index 872ca79..a3eafa6 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,9 @@ Alpha. One season, bandit raids plus two friendly events, six buildings. city). Gear needs a combat level to wear, tools a skill level to use. - **Classes:** warrior, scout, artisan, pioneer. Every class can train every skill; a class makes some skills 20% faster and has one signature ability. -- **Bank:** 12 slots of up to 1,000 each to start. When something doesn't - fit it goes to the city stockpile (or the action stops, if you prefer). +- **Bank:** 12 slots of 1,000 each to start; more than a stack of one item + spills into another slot. When something doesn't fit it goes to the city + stockpile (or the action stops, if you prefer). Raids never touch your bank. Players can give items to each other. - **City:** each building collects its own fund, from players' banks or the city's stockpile and treasury. Funds are safe from raiders, and a funded diff --git a/app.py b/app.py index 5f4b7de..323e83d 100644 --- a/app.py +++ b/app.py @@ -107,6 +107,7 @@ def player_view(world: dict, player: dict, now: float) -> dict: view["labour_per_action"] = game.labour_per_action(player) 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["power"] = game.combat_power(player) view["perk_costs"] = {perk: game.perk_cost(player, perk) for perk in player["perks"]} diff --git a/game.py b/game.py index 5da8349..088e4e4 100644 --- a/game.py +++ b/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]: diff --git a/static/app.js b/static/app.js index 19c832a..deb3ea8 100644 --- a/static/app.js +++ b/static/app.js @@ -239,7 +239,7 @@ function sidebar() { ${nav("roster", "👥", "Guild roster", `${S.players.length}`)}
${nav("character", cls.icon, "Character", `${skillOf("combat").icon} ${me.levels.combat}`)} - ${nav("bank", "🏦", "Bank", `${Object.keys(me.bank).length}/${me.slots}`)}`; + ${nav("bank", "🏦", "Bank", `${me.slots_used}/${me.slots}`)}`; let group = null; for (const skill of C.skills) { if (skill.class && skill.class !== me.cls) continue; @@ -518,16 +518,22 @@ function bank() { const me = S.me; const entries = Object.entries(me.bank).sort((x, y) => Object.keys(C.items).indexOf(x[0]) - Object.keys(C.items).indexOf(y[0])); if (selected && !me.bank[selected]) selected = null; - let slots = entries.map(([id, q]) => ` -