"""What each thing on the map says when you ask about it: a mission, a region, the fort, the unit. Pure text from the campaign's state, for any view of the map (the 2D window, the 3D war room).""" from __future__ import annotations from . import campaign as K from . import data as D def mission_order(c): """The missions as numbered on the map: soonest to expire first (number = index + 1).""" return sorted(c.missions, key=lambda m: m.expires) def standing_line(c, rid, g): """Your affinity with one group: "The Ferrymen: 45 (trade)"; the tier reached, or none yet.""" tier = c.tier(rid, g) name = D.REGIONS[rid]["groups"][g]["name"] return f"{name}: {c.standing(rid, g)}" + (f" ({D.AFFINITY_TIERS[tier - 1][1]})" if tier else "") def mission_brief(c, m): info = D.REGIONS[m.region] road = (f"{m.expires - c.day} days left; {K.region_km(m.region):.0f} km, " f"{K.travel_days(m.region, 'on foot')} days on foot.") pay = D.MISSION_KINDS[m.kind]["supplies"] if m.group is None: # an incursion: you pick the side sides = [] for g, grp in enumerate(info["groups"]): kinds = ", ".join(sorted({k for p in info["groups"][1 - g]["pods"] for k in p})) sides.append(f"Back {grp['name']} ({grp['about']}): fight {info['groups'][1 - g]['name']} " f"({kinds}).") return (f"{info['name']}: {m.about()}. Pick a side when you plan the unit.\n{info['dilemma']}\n" + "\n".join(sides) + f"\nWin: +{pay} supplies, the county leans to the side you back, and " f"they think better of you (+{D.AFFINITY_WON}; +{D.AFFINITY_LOST} even if you lose).\n" f"Your standing: {standing_line(c, m.region, 0)}; {standing_line(c, m.region, 1)}.\n" + road) helped, fought = m.names() kinds = ", ".join(sorted({k for p in m.pods for k in p})) return (f"{info['name']}: {m.about()}.\n{info['dilemma']}\nWin: +{pay} " f"supplies, and the county leans toward {helped}. Lose or let it go: toward {fought}.\n" f"Expect {len(m.pods)} groups of {fought} ({kinds}). " + road) def region_brief(c, rid): info, reg = D.REGIONS[rid], c.regions[rid] a, b = (g["name"] for g in info["groups"]) if reg.owner is not None: holder = info["groups"][reg.owner]["name"] state = (f"ALLY: {holder} hold it, with your help." if reg.ally else f"HOSTILE: {holder} hold it, against you.") elif reg.lean == 0: state = f"Undecided between {a} and {b}." else: state = f"In play: leaning to {a if reg.lean > 0 else b} ({abs(reg.lean)} of 100)." waiting = sum(1 for m in c.missions if m.region == rid) return (f"{info['name']}, {info['area']}. {state}\n{info['dilemma']}\n" f"Your standing: {standing_line(c, rid, 0)}; {standing_line(c, rid, 1)}.\n" f"Its town: {info['town']}; {K.region_km(rid):.0f} km from the fort" + (f"; {waiting} mission{'s' * (waiting > 1)} waiting." if waiting else ".")) def fort_brief(c): wk = c.weekly() built = ", ".join(f"{f} {lv}" for f, lv in c.facilities.items() if lv) or "none yet" return (f"Fort Leonard Wood, {D.HOME} County. Day {c.day}.\n" f"Supplies {c.supplies}, intel {c.intel}, recruits waiting {c.recruits}.\n" f"Next week: {wk['supplies']:+} supplies, +{wk['intel']} intel. Facilities: {built}.") def unit_brief(c): alive = [s for s in c.roster if not s.dead] ready = [s for s in alive if s.status(c.day) == "ready"] if c.trip and c.trip.get("caravan"): rid, g = c.trip["caravan"] return (f"The unit is out with a caravan, {c.trip['travel']}, bound for {D.REGIONS[rid]['town']} " f"and {D.REGIONS[rid]['groups'][g]['name']}.") if c.trip: m = next((m for m in c.missions if m.id == c.trip["mission"]), None) where = D.REGIONS[m.region]["name"] if m else "the field" return f"The unit is out, {c.trip['travel']}, bound for {where}." return (f"The unit, at the fort: {len(ready)} of {len(alive)} soldiers ready.\n" + ", ".join(f"{s.name} ({s.cls})" for s in ready[:8]) + ("..." if len(ready) > 8 else "")) # ── the memorial (Step 3f; Dillon, 2026-11-16: "where all members who fall in combat or are MIA go, # with how many missions they went on and other details ... and the moments of how they died") ── KIND_WORDS = {"raid": "a raid", "defend": "a defence", "escort": "a convoy escort"} def fallen(c): """Everyone the fort has lost, the most recent first (those gone before records were kept last).""" gone = [s for s in c.roster if s.dead] return sorted(gone, key=lambda s: (-(s.fate or {}).get("day", 0), s.name)) def memorial_line(s): """One name on the wall: rank, name, class, and how they were lost.""" how = s.fate["how"] if s.fate else "killed in action" when = f", day {s.fate['day']}" if s.fate else "" return f"{D.RANK_NAMES[s.rank]} {s.name}, {s.cls}: {how}{when}" def memorial_entry(s): """Everything the fort remembers of one of its lost: the service, every mission, and the end.""" out = [f"{D.RANK_NAMES[s.rank]} {s.name}, {s.cls}.", f"{s.missions} mission{'s' * (s.missions != 1)}, {s.kills} kill{'s' * (s.kills != 1)}, {s.xp} XP."] if s.skills: out.append("Skills: " + ", ".join(s.skills) + ".") out.append(f"Carried: {s.gun()}, {s.armor}" + (", " + ", ".join(s.utility) if s.utility else "") + ".") if s.record: out.append("") out.append("Service:") for r in s.record: hurt = {"downed": ", went down", "wounded": ", wounded"}.get(r["hurt"], "") kills = f", {r['kills']} kill{'s' * (r['kills'] != 1)}" if r["kills"] else "" out.append(f" Day {r['day']}: {KIND_WORDS.get(r['kind'], r['kind'])} in {r['region']} for {r['for']}" f" against {r['against']}: {'won' if r['won'] else 'lost'}{kills}{hurt}.") out.append("") if s.fate: f = s.fate out.append(f"{f['how'].capitalize()}, day {f['day']}, {f['where']}: {f['story']}.") else: out.append("Killed in action, before the fort kept its records.") return "\n".join(out)