diff --git a/app.py b/app.py index f230cd9..bf174cd 100644 --- a/app.py +++ b/app.py @@ -229,7 +229,7 @@ def roster(world: dict, now: float) -> list[dict]: return sorted(people, key=lambda p: -p["donated"]) -ROAD_ROUTES = ("/api/board", "/api/board/delete", "/api/charter/sign", "/api/charter/cancel") # what you can still do on the road +ROAD_ROUTES = ("/api/seen", "/api/pin", "/api/track", "/api/board", "/api/board/delete", "/api/charter/sign", "/api/charter/cancel") # what you can still do on the road class Handler(BaseHTTPRequestHandler): diff --git a/game.py b/game.py index 2e911a8..3925403 100644 --- a/game.py +++ b/game.py @@ -2159,7 +2159,7 @@ def last_threat(world: dict) -> dict | None: def unseen_threat(world: dict, player: dict) -> dict | None: """The latest raid or dragon attack this player hasn't watched yet, if it happened while they were here.""" event = last_threat(world) - if event and event["id"] > player.get("seen_threat", 0) and event["resolved"] >= player["joined"]: + if event and event["id"] > player.get("seen_threat", 0) and event["resolved"] >= max(player["joined"], player.get("arrived", 0)): return event return None @@ -2260,6 +2260,8 @@ def upper_first(text: str) -> str: def log(world: dict, now: float, kind: str, text: str, who: str | None = None) -> None: + if world.here != HOME_CITY: + text = f"{world['city']['name']}: {text}" world["ledger"].append({"at": now, "kind": kind, "text": text, "who": who}) del world["ledger"][:-MAX_LOG] @@ -3198,7 +3200,7 @@ def fires_view(world: dict, now: float) -> dict: users = {} for player in world["players"].values(): action = player["action"] and ACTION_BY_ID.get(player["action"]["id"]) - if action and (action.get("fire") or action.get("tend")): + if action and (action.get("fire") or action.get("tend")) and player["at"] == world.here and not player["travel"]: users.setdefault(action.get("fire") or action["tend"], []).append( {"id": player["id"], "name": player["name"], "action": action["id"]}) return {key: {**fire, "heat": heat(world, key), "speed": speed(world), "users": users.get(key, [])} @@ -4610,6 +4612,8 @@ def propose_charter(world: World, player: dict, name, region, now: float) -> str return "A charter is already waiting to be signed" if len(world.doc["cities"]) >= MAX_CITIES: return "The kingdom can't hold another town yet" + if not _slug(name): + return "A town's name takes 3 to 24 letters" if _slug(name) in world.doc["cities"]: return "There's already a town by that name" error = _founding_short(world) @@ -7183,6 +7187,14 @@ 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": "Kingdom", "notes": [ + ("new", "Kingdom: found a new town. Needs a city, a charter and a second signature. Costs 20 settlers, 5,000 gold, 200 provisions."), + ("new", "Regions: ⛰️ mining, 🌲 woodcutting + hunting, 🌊 fishing, 🌾 farming. Up to +100% yield on basic materials, grows with the town. One town per region."), + ("new", "Travel between towns: 12 min, no work on the road. Pouch: 6 items, 100 each."), + ("new", "Banks and work orders are per town. Shared fights need the same town. Raids strike every town in the same hour."), + ("new", "Garrison: be there before the gates close."), + ("balance", "⚠️ From the raid after next, a lost raid loots banks in that town: 6-21%. Strongbox slots protect their share. Worn gear and pouches are safe."), + ]}, {"date": "2026-11-04", "title": "Crucible", "notes": [ ("new", "Crucible: 5th fire, for silver and gold bars."), ("balance", "Gold bar: +1 willow log. White flame or hotter pays it."), diff --git a/tests/test_game.py b/tests/test_game.py index 6e00102..36658b8 100644 --- a/tests/test_game.py +++ b/tests/test_game.py @@ -3826,6 +3826,30 @@ class KingdomTest(unittest.TestCase): self.assertEqual(self.a["banks"][game.HOME_CITY]["stone"], 40) self.assertNotIn("stone", self.a["bank"]) + def test_a_town_needs_a_real_name(self): + self.assertIn("name", game.propose_charter(self.world, self.a, "!!!!", "coast", T0)) + + def test_a_report_from_before_you_arrived_stays_shut(self): + new = self.found() + new["events"].append({"id": 50, "kind": "raid", "status": "done", "resolved": T0 + 10, "report": {"title": "Victory"}}) + self.a["at"] = new.here + self.a["arrived"] = T0 + 20 + self.assertIsNone(game.unseen_threat(new, self.a)) + self.a["arrived"] = T0 + 5 + self.assertIsNotNone(game.unseen_threat(new, self.a)) + + def test_fires_list_only_who_is_here(self): + new = self.found() + tend = next(a for a in game.ACTIONS if a.get("tend")) + self.a["action"] = {"id": tend["id"], "start": T0} + self.assertTrue(game.fires_view(self.world, T0)[tend["tend"]]["users"]) + self.assertFalse(game.fires_view(new, T0)[tend["tend"]]["users"]) + + def test_the_log_says_which_town(self): + new = self.found() + game.log(new, T0, "raid", "Trouble") + self.assertIn("Saltmere", self.world["ledger"][-1]["text"]) + def test_old_saves_gain_towns(self): doc = json.loads(json.dumps(self.world.doc)) doc["version"] = 39