Favour per town; bank slot prices restart in each town
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
22635504e8
commit
a4c9977e5c
4 changed files with 146 additions and 28 deletions
60
game.py
60
game.py
|
|
@ -1684,7 +1684,7 @@ RAID_TRAITS = ["lightly armoured, heavy on archers", "mounted and fast, few bows
|
|||
|
||||
# --- world ---------------------------------------------------------------
|
||||
|
||||
WORLD_VERSION = 41
|
||||
WORLD_VERSION = 42
|
||||
HOME_CITY = "guildhall"
|
||||
CITY_KEYS = ("events", "next_event_at", "next_minor_at", "next_hardship_at", "next_fortune_at", "caravan", "orders")
|
||||
TRAVEL_TIME = 12 * 60 # game seconds on the road between two towns
|
||||
|
|
@ -2066,6 +2066,13 @@ def migrate(world: dict, now: float | None = None) -> World:
|
|||
# The war council, and guards on the march.
|
||||
world.doc.update(marches=[], council=[], next_march_id=1)
|
||||
world["version"] = 41
|
||||
if world["version"] < 42:
|
||||
# Favour belongs to the town it was earned in. All of it so far counts as the first town's.
|
||||
for player in world["players"].values():
|
||||
player.update(town_favour={}, town_slots={}, town_rented={})
|
||||
if player["at"] != HOME_CITY:
|
||||
player["town_favour"][HOME_CITY], player["favour"] = player["favour"], 0
|
||||
world["version"] = 42
|
||||
return world
|
||||
|
||||
|
||||
|
|
@ -2404,6 +2411,9 @@ def new_player(uid: str, name: str, cls: str, now: float) -> dict:
|
|||
"rented": 0, "boosts": [], "bought": None, "deeds": {}, "owned": [], "look": dict(DEFAULT_LOOK),
|
||||
"garrison": False,
|
||||
"at": HOME_CITY, "banks": {}, "travel": None, # banks: what you left in the towns you're not in
|
||||
"town_favour": {}, # likewise your favour: `favour` is what you hold in the town you're in
|
||||
"town_slots": {}, # bank slots bought with favour, each good only in its town
|
||||
"town_rented": {}, # and those rented with gold
|
||||
"donated": 0,
|
||||
"gave": {}, # item (or "gold"): {qty, worth, favour} given to the city, see credit()
|
||||
"ledger": [], # what you did, see note() and track()
|
||||
|
|
@ -2418,7 +2428,8 @@ def skill_level(player: dict, skill: str) -> int:
|
|||
|
||||
def bank_slots(world: dict, player: dict) -> int:
|
||||
return (BASE_SLOTS + 3 * building_level(world, "storehouse") + TIER_SLOTS * world["city"]["tier"]
|
||||
+ player["perks"]["bank_slot"] + player["rented"] + fitted(world, "shelving") + int(gear_bonus(player, "slots")))
|
||||
+ player["perks"]["bank_slot"] + player["town_slots"].get(world.here, 0)
|
||||
+ player["rented"] + player["town_rented"].get(world.here, 0) + fitted(world, "shelving") + int(gear_bonus(player, "slots")))
|
||||
|
||||
|
||||
def stack_size(world: dict, player: dict | None = None) -> int:
|
||||
|
|
@ -4419,7 +4430,11 @@ def _to_city(world: dict, order: dict, giver: dict, qty: int, now: float, used:
|
|||
if not helper:
|
||||
continue
|
||||
for reagent, n in items.items():
|
||||
favour[uid] = favour.get(uid, 0) + credit(helper, reagent, n, rate, ITEMS[reagent]["value"] * n * scale)
|
||||
earned = credit(helper, reagent, n, rate, ITEMS[reagent]["value"] * n * scale)
|
||||
favour[uid] = favour.get(uid, 0) + earned
|
||||
if helper["at"] != world.here: # earned here, though they've moved on
|
||||
helper["favour"] -= earned
|
||||
helper["town_favour"][world.here] = helper["town_favour"].get(world.here, 0) + earned
|
||||
note(world, helper, now, "Donated", reagent, n, label=label)
|
||||
favour[giver["id"]] = favour.get(giver["id"], 0) + credit(giver, item, qty, rate, worth - pooled * scale)
|
||||
note(world, giver, now, "Donated", item, qty, label=label)
|
||||
|
|
@ -4596,7 +4611,9 @@ def arrive(world: World, player: dict) -> None:
|
|||
"""Off the road: into this town's bank, pouch unpacked, and back to work."""
|
||||
trip, player["travel"] = player["travel"], None
|
||||
player["banks"][player["at"]] = player["bank"]
|
||||
player["town_favour"][player["at"]] = player["favour"]
|
||||
player["at"], player["bank"] = trip["to"], player["banks"].pop(trip["to"], {})
|
||||
player["favour"] = player["town_favour"].pop(trip["to"], 0)
|
||||
player["arrived"] = trip["arrive"]
|
||||
world = here(world, player)
|
||||
for item, qty in trip["pouch"].items():
|
||||
|
|
@ -5757,7 +5774,7 @@ def _loot_banks(world: World, event: dict, share: float, now: float) -> bool:
|
|||
looted = False
|
||||
for player in world["players"].values():
|
||||
bank = player["bank"] if player["at"] == world.here else player["banks"].get(world.here, {})
|
||||
locked = (player["rented"] + gear_bonus(player, "slots")) / max(1, bank_slots(world, player))
|
||||
locked = (player["rented"] + player["town_rented"].get(world.here, 0) + gear_bonus(player, "slots")) / max(1, bank_slots(world, player))
|
||||
for item in list(bank):
|
||||
gone = int(bank[item] * share * BANK_LOOT * (1 - min(1, locked)))
|
||||
if gone:
|
||||
|
|
@ -6615,16 +6632,19 @@ RENT_BASE = 1000 # gold for the first rented bank slot...
|
|||
RENT_GROWTH = 1.35 # ...and each one after costs this much more
|
||||
|
||||
|
||||
def rent_cost(player: dict) -> int:
|
||||
return int(round(RENT_BASE * RENT_GROWTH ** player["rented"] / 50) * 50)
|
||||
def rent_cost(world: World, player: dict) -> int:
|
||||
"""Each slot rented in a town costs more there. The first town's carries on from the
|
||||
slots rented before they became per town, which stay good everywhere."""
|
||||
rented = player["town_rented"].get(world.here, 0) + (player["rented"] if world.here == HOME_CITY else 0)
|
||||
return int(round(RENT_BASE * RENT_GROWTH ** rented / 50) * 50)
|
||||
|
||||
|
||||
def rent_slot(player: dict) -> str | None:
|
||||
cost = rent_cost(player)
|
||||
def rent_slot(world: World, player: dict) -> str | None:
|
||||
cost = rent_cost(world, player)
|
||||
if player["gold"] < cost:
|
||||
return f"Needs {cost:,} gold"
|
||||
player["gold"] -= cost
|
||||
player["rented"] += 1
|
||||
player["town_rented"][world.here] = player["town_rented"].get(world.here, 0) + 1
|
||||
return None
|
||||
|
||||
|
||||
|
|
@ -7095,20 +7115,28 @@ def spend_favour(world: dict, player: dict, kind: str, now: float) -> str | None
|
|||
return None
|
||||
|
||||
|
||||
def perk_cost(player: dict, perk: str) -> int:
|
||||
def perk_cost(world: World, player: dict, perk: str) -> int:
|
||||
"""A bank slot's price doubles with each bought in this town. The first town's carries on from
|
||||
the slots bought before they became per town, which stay good everywhere."""
|
||||
if perk == "bank_slot":
|
||||
return 500 * 2 ** player["perks"]["bank_slot"]
|
||||
bought = player["town_slots"].get(world.here, 0)
|
||||
return 500 * 2 ** (bought + (player["perks"]["bank_slot"] if world.here == HOME_CITY else 0))
|
||||
raise KeyError(perk)
|
||||
|
||||
|
||||
def buy_perk(player: dict, perk: str) -> str | None:
|
||||
def favour_saved(player: dict) -> float:
|
||||
"""Your favour across every town."""
|
||||
return player["favour"] + sum(player["town_favour"].values())
|
||||
|
||||
|
||||
def buy_perk(world: World, player: dict, perk: str) -> str | None:
|
||||
if perk not in player["perks"]:
|
||||
return "No such perk"
|
||||
cost = perk_cost(player, perk)
|
||||
cost = perk_cost(world, player, perk)
|
||||
if player["favour"] < cost:
|
||||
return f"Needs {cost:,} favour"
|
||||
player["favour"] -= cost
|
||||
player["perks"][perk] += 1
|
||||
player["town_slots"][world.here] = player["town_slots"].get(world.here, 0) + 1
|
||||
return None
|
||||
|
||||
|
||||
|
|
@ -7398,6 +7426,10 @@ ORDER_RECIPES, ORDER_RAW = _order_sources()
|
|||
# What changed, shown on the Patch notes page. Newest first; every shipped change adds a
|
||||
# line here (new / balance / fix), and a new release a new entry on top.
|
||||
PATCH_NOTES = [
|
||||
{"date": "2026-11-04", "title": "Favour per town", "notes": [
|
||||
("new", "Favour is earned and spent per town. What you've saved so far stays in Guildhall."),
|
||||
("new", "Bank slots: favour price starts at 500 and gold at 1,000 in each town, rising there. New ones work only in that town. Ones you already own work everywhere."),
|
||||
]},
|
||||
{"date": "2026-11-04", "title": "War council", "notes": [
|
||||
("new", "War council on the Kingdom page: propose sending guards to another town. 1h vote: a majority of active players settles it, else the votes cast. Tie: they stay."),
|
||||
("new", "Guards march 20h with their kit and wage, stand one fight, then march home. Lost fight: some die. Their posts stay empty while they're away."),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue