Regions: each new town favours its gathering trades, common materials most
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ad5317e554
commit
01df1924c0
4 changed files with 102 additions and 15 deletions
45
game.py
45
game.py
|
|
@ -1690,7 +1690,17 @@ CITY_KEYS = ("events", "next_event_at", "next_minor_at", "next_hardship_at", "ne
|
|||
TRAVEL_TIME = 12 * 60 # game seconds on the road between two towns
|
||||
POUCH_SLOTS = 6 # kinds of item you can carry on the road...
|
||||
POUCH_STACK = 100 # ...and how many of each
|
||||
MAX_CITIES = 3
|
||||
# Where a town stands: one town to a region, between them every gathering trade. Each trip out brings
|
||||
# back more, most of all of the commonest stuff, and more as the town grows. XP stays the same.
|
||||
REGIONS = {
|
||||
"mountains": {"name": "Mountains", "icon": "⛰️", "skills": ["mining"]},
|
||||
"forest": {"name": "Forest", "icon": "🌲", "skills": ["woodcutting", "hunting"]},
|
||||
"coast": {"name": "Coast", "icon": "🌊", "skills": ["fishing"]},
|
||||
"plains": {"name": "Plains", "icon": "🌾", "skills": ["farming"]},
|
||||
}
|
||||
REGION_YIELD = [1.0, 0.75, 0.5, 0.3, 0.2, 0.1] # more per trip at each material tier, for a full city
|
||||
TOWN_SCALE = [0.5, 0.7, 0.85, 1.0] # how much of that a hamlet, village, town and city get
|
||||
MAX_CITIES = 1 + len(REGIONS)
|
||||
FOUNDING = {"settlers": 20, "gold": 5000, "provisions": 200} # what a new town takes from the one it leaves
|
||||
FOUNDING_GRACE = 24 # game hours a new town gets before its first threat lands
|
||||
|
||||
|
|
@ -4427,9 +4437,13 @@ def _store(world: dict, order: dict, qty: int, now: float) -> None:
|
|||
|
||||
|
||||
def _hand_over(world: dict, order: dict, owner: dict, now: float) -> None:
|
||||
"""Put delivered items in the requester's bank; what doesn't fit waits on the order,
|
||||
as it does while they're in another town."""
|
||||
"""Put delivered items in the requester's bank in the order's town, whether or not they're
|
||||
there; if they are, what doesn't fit waits on the order."""
|
||||
if owner["at"] != world.here:
|
||||
bank = owner["banks"].setdefault(world.here, {})
|
||||
bank[order["item"]] = bank.get(order["item"], 0) + order["held"]
|
||||
note(world, owner, now, "Received", order["item"], order["held"], label=f"Work order · {world['city']['name']}")
|
||||
order["held"] = 0
|
||||
return
|
||||
fits = min(order["held"], bank_room(world, owner, order["item"]))
|
||||
if fits:
|
||||
|
|
@ -4583,11 +4597,15 @@ def arrive(world: World, player: dict) -> None:
|
|||
note(world, player, trip["arrive"], "Arrived", label=world["city"]["name"])
|
||||
|
||||
|
||||
def propose_charter(world: World, player: dict, name, now: float) -> str | None:
|
||||
def propose_charter(world: World, player: dict, name, region, now: float) -> str | None:
|
||||
"""Ask the guild to found a new town. A second founder has to sign before it happens."""
|
||||
name = str(name or "").strip()
|
||||
if not 3 <= len(name) <= 24:
|
||||
return "A town's name takes 3 to 24 letters"
|
||||
if region not in REGIONS:
|
||||
return "Pick a region"
|
||||
if any(city.get("region") == region for city in world.doc["cities"].values()):
|
||||
return f"There's already a town in the {REGIONS[region]['name'].lower()}"
|
||||
if world["charter"]:
|
||||
return "A charter is already waiting to be signed"
|
||||
if len(world.doc["cities"]) >= MAX_CITIES:
|
||||
|
|
@ -4597,7 +4615,7 @@ def propose_charter(world: World, player: dict, name, now: float) -> str | None:
|
|||
error = _founding_short(world)
|
||||
if error:
|
||||
return error
|
||||
world["charter"] = {"name": name, "by": player["id"], "from": world.here, "at": now}
|
||||
world["charter"] = {"name": name, "region": region, "by": player["id"], "from": world.here, "at": now}
|
||||
log(world, now, "tier", f"{player['name']} drew up a charter for a new town: {name}")
|
||||
return None
|
||||
|
||||
|
|
@ -4633,6 +4651,7 @@ def sign_charter(world: World, player: dict, now: float) -> str | None:
|
|||
del giving["stockpile"]["provisions"]
|
||||
city = _new_city(now, speed(world), charter["name"])
|
||||
city["population"] = float(FOUNDING["settlers"])
|
||||
city["region"] = charter["region"]
|
||||
city["stockpile"]["provisions"] = FOUNDING["provisions"]
|
||||
city["next_event_at"] = now
|
||||
world.doc["cities"][_slug(charter["name"])] = city
|
||||
|
|
@ -4653,12 +4672,14 @@ def kingdom_view(world: World, now: float) -> dict:
|
|||
cities = []
|
||||
for key, city in world.doc["cities"].items():
|
||||
people = [p for p in world["players"].values() if p["at"] == key and not p["travel"]]
|
||||
cities.append({"id": key, "name": city["name"], "population": int(city["population"]),
|
||||
cities.append({"id": key, "name": city["name"], "region": city.get("region"), "town_scale": TOWN_SCALE[city["tier"]],
|
||||
"population": int(city["population"]),
|
||||
"tier": TIERS[city["tier"]]["name"], "repelled": city["repelled"],
|
||||
"people": [p["id"] for p in people], "founded": city["founded"]})
|
||||
charter = world["charter"]
|
||||
return {"cities": cities, "charter": charter, "pouch": {"slots": POUCH_SLOTS, "stack": POUCH_STACK},
|
||||
"founding": FOUNDING, "max": MAX_CITIES, "short": _founding_short(world),
|
||||
"regions": REGIONS, "region_yield": REGION_YIELD,
|
||||
"road": [{"id": p["id"], **{k: p["travel"][k] for k in ("from", "to", "arrive")}}
|
||||
for p in world["players"].values() if p["travel"]]}
|
||||
|
||||
|
|
@ -5944,10 +5965,20 @@ def _modifier_sources(world: dict) -> list[dict]:
|
|||
return sources
|
||||
|
||||
|
||||
def region_yield(world: dict, action: dict) -> float:
|
||||
"""How much more this gathering brings back in this town, for standing where it does."""
|
||||
city = world["city"]
|
||||
region = REGIONS.get(city.get("region"))
|
||||
if not region or action["skill"] not in region["skills"] or not action["outputs"]:
|
||||
return 1.0
|
||||
tier = sum(action["level"] >= level for level in TIER_LEVELS) - 1
|
||||
return 1 + REGION_YIELD[tier] * TOWN_SCALE[city["tier"]]
|
||||
|
||||
|
||||
def skill_mods(world: dict, action: dict) -> dict:
|
||||
"""How weather, happenings and problems change this action right now."""
|
||||
skill = action["skill"]
|
||||
mods = {"speed": 1.0, "yield": 1.0, "xp": 1.0, "blocked": None}
|
||||
mods = {"speed": 1.0, "yield": region_yield(world, action), "xp": 1.0, "blocked": None}
|
||||
for source in _modifier_sources(world):
|
||||
mods["speed"] *= source.get("speed", {}).get(skill, 1)
|
||||
mods["yield"] *= source.get("yield", {}).get(skill, 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue