diff --git a/app.py b/app.py index 07e7e16..1f5178f 100644 --- a/app.py +++ b/app.py @@ -653,6 +653,7 @@ class Handler(BaseHTTPRequestHandler): "history": history, "orders": world["orders"], "kingdom": game.kingdom_view(world, now), + "city_speed": game.speed(world), "threat_report": unseen and {"id": unseen["id"], "kind": unseen["kind"], "at": unseen["resolved"], "report": unseen["report"]}, "players": roster(world, now), diff --git a/game.py b/game.py index 16b2f64..99a4948 100644 --- a/game.py +++ b/game.py @@ -7334,7 +7334,7 @@ def content() -> dict: "city_uses": {item: city_uses(item) for item in ITEMS}, "prayers": [{**prayer, "text": describe_prayer(prayer)} for prayer in PRAYERS], "max_prayers": MAX_PRAYERS, "potion_charges": POTION_CHARGES, "kit_defence": KIT_DEFENCE, "salve_cap": SALVE_CAP, "order_recipes": ORDER_RECIPES, "order_raw": ORDER_RAW, - "make_max": MAKE_MAX, "input_share": INPUT_SHARE, "problems": PROBLEMS, "fittings": list(FITTING_BY_ID.values()), + "make_max": MAKE_MAX, "travel_time": TRAVEL_TIME, "input_share": INPUT_SHARE, "problems": PROBLEMS, "fittings": list(FITTING_BY_ID.values()), "equip_slots": EQUIP_SLOTS, "class_speed": CLASS_SPEED, "rest_rate": REST_RATE, "bite": BITE, "eat_below": EAT_BELOW, "eat_choices": EAT_CHOICES, "abilities": combat.ABILITIES, "enemy_abilities": combat.ENEMY_ABILITIES, "unlock": combat.UNLOCK, "auto_cd": combat.AUTO_CD, "watch": combat.WATCH, "gcd": combat.GCD, "weapon_kits": combat.WEAPON_KITS, "group_size": GROUP_SIZE, "dungeon_size": DUNGEON_SIZE, "dungeon_wipes": DUNGEON_WIPES, "trade_ability": combat.TRADE_ABILITY, "potion_below": combat.POTION_BELOW, diff --git a/static/app.js b/static/app.js index 70a0d2c..2934c38 100644 --- a/static/app.js +++ b/static/app.js @@ -775,6 +775,7 @@ function sidebar() { ${nav("town", "🏘️", "Town square", `${S.city.population}`, "", `Population ${S.city.population}`)} ${nav("council", "πŸ“œ", "Council & threats", "", raid ? `` : "", raid ? "A threat is coming" : "")} + ${nav("kingdom", "πŸ—ΊοΈ", "Kingdom", `${S.kingdom.cities.length}`, S.kingdom.charter ? `sign` : "", S.kingdom.charter ? "A charter is waiting to be signed" : "")} ${nav("orders", ORDER_ICON(), "Work orders", "", takeable ? `${takeable}` : "", takeable ? `${takeable} for you` : "")} ${nav("board", "πŸ’¬", "Town board")} ${rosterNav()} @@ -810,7 +811,7 @@ function devbar() { `; } -const TITLES = { town: "Town square", council: "Council & threats", orders: "Work orders", board: "Town board", roster: "Guild roster", notes: "Patch notes", bank: "Bank", character: "Character" }; +const TITLES = { town: "Town square", kingdom: "Kingdom", council: "Council & threats", orders: "Work orders", board: "Town board", roster: "Guild roster", notes: "Patch notes", bank: "Bank", character: "Character" }; function topbar() { let title = TITLES[page] || "Guildhall"; @@ -818,7 +819,9 @@ function topbar() { if (page.startsWith("character:")) title = S.players.find((p) => p.id === page.slice(10))?.name || "Character"; if (!S.me) title = "Welcome to Guildhall"; let chips = ""; - if (S.me?.action) { + if (S.me?.travel) { + chips += ``; + } else if (S.me?.action) { const action = C.actions.find((a) => a.id === (S.me.action.growing || S.me.action.id)); chips += ``; } else if (S.me) { @@ -926,7 +929,53 @@ function pageHtml() { } if (page.startsWith("character:")) return characterSheet(page.slice(10)); if (page === "character") return characterSheet(S.uid); - return ({ town, council, orders, board, roster, notes, bank, achievements }[page] || town)(); + return ({ town, kingdom, council, orders, board, roster, notes, bank, achievements }[page] || town)(); +} + +// --- kingdom ---------------------------------------------------------------- +let pouch = {}; + +function townName(id) { + return S.kingdom.cities.find((c) => c.id === id)?.name || id; +} + +function kingdom() { + const me = S.me, k = S.kingdom; + const towns = k.cities.map((c) => { + const here = c.id === me.at && !me.travel; + const road = k.road.filter((r) => r.to === c.id).length; + return `
+

${esc(c.name)} ${here ? `πŸ“ Here` : ""}

+

${esc(c.tier)} Β· πŸ‘₯ ${fmt(c.population)} Β· πŸ›‘οΈ ${fmt(c.repelled)}${road ? ` Β· πŸ›€οΈ ${road}` : ""}

+

${c.people.length ? c.people.map((uid) => esc(playerName(uid))).join(", ") : `Nobody here`}

+ ${here || me.travel ? "" : ``} +
`; + }).join(""); + const kinds = Object.keys(pouch).length; + const stock = Object.keys(me.bank).filter((id) => !pouch[id]).sort((a, b) => item(a).name.localeCompare(item(b).name)); + const pack = me.travel + ? `

πŸ›€οΈ ${esc(townName(me.travel.from))} β†’ ${esc(townName(me.travel.to))}: ${dur(Math.max(0, me.travel.arrive - S.now))}

+

${Object.entries(me.travel.pouch).map(([id, qty]) => itemChip(id, qty)).join(" ") || `Empty pouch`}

` + : `

${kinds} / ${k.pouch.slots} Β· up to ${k.pouch.stack} each

+

${Object.entries(pouch).map(([id, qty]) => ``).join(" ") || `Empty`}

+
+ +
`; + const charter = k.charter; + const full = k.cities.length >= k.max; + const cost = `${COIN} ${fmt(S.city.treasury)} / ${fmt(k.founding.gold)} Β· ${itemChip("provisions", S.city.stockpile.provisions || 0)} / ${fmt(k.founding.provisions)} Β· πŸ‘₯ ${k.founding.settlers}`; + const founding = charter + ? `

πŸ“œ ${esc(charter.name)} Β· ${esc(playerName(charter.by))}

+ ${charter.by === me.id ? `` : ``}` + : full ? `

${k.cities.length} / ${k.max} towns

` + : `

${cost}

+ ${S.city.next_tier ? `

${esc(k.short)}

` : `
+
`}`; + return `
${towns}
+
+

${me.travel ? "On the road" : "Travel pouch"}

${pack}
+

Found a town

${founding}
+
`; } // Where an item comes from: the recipe that makes it, else what finds it, else the fight that drops it. @@ -1992,7 +2041,7 @@ function itemPanel(id) { const me = S.me, it = item(id), have = me.bank[id]; const merchant = S.city.merchant_until > serverNow(); const price = it.value * (merchant ? 1.5 : 1); - const others = S.players.filter((p) => p.id !== S.uid); + const others = S.players.filter((p) => p.id !== S.uid && p.at === S.me.at && !p.travel); const qtyBox = (kind, label) => `
` + ``; return `
@@ -3287,6 +3336,28 @@ document.addEventListener("click", (e) => { if (d.install) return act("/api/install", { fitting: d.install, source: d.source }); if ("plot" in d) return act("/api/plot", { id: d.plot || null }); if (d.garrison) return act("/api/garrison", { join: d.garrison === "1" }); + if (d.travel) { + if (!confirm(`Travel to ${townName(d.travel)}? Work stops on the road.`)) return; + const sent = pouch; + pouch = {}; + return act("/api/travel", { to: d.travel, pouch: sent }); + } + if ("pouchAdd" in d) { + const id = $("[data-keep^=pouch-item]").value; + const qty = Math.min(Number($("[data-keep=pouch-qty]").value) || 0, S.kingdom.pouch.stack, S.me.bank[id] || 0); + if (id && qty > 0) pouch[id] = qty; + return render(); + } + if (d.pouchDrop) { delete pouch[d.pouchDrop]; return render(); } + if ("charterNew" in d) { + if (!confirm(`Draw up a charter? Once signed, ${S.kingdom.founding.settlers} settlers, gold and provisions leave this town.`)) return; + return act("/api/charter", { name: $("[data-keep=charter-name]").value }); + } + if ("charterSign" in d) { + if (!confirm(`Sign the charter for ${S.kingdom.charter.name}? The town is founded at once.`)) return; + return act("/api/charter/sign", {}); + } + if ("charterCancel" in d) return act("/api/charter/cancel", {}); if (d.perk) return act("/api/perk", { perk: d.perk }); if (d.pin) return act("/api/pin", { skill: d.pin }); if (d.track) return act("/api/track", { id: d.track }); diff --git a/static/styles.css b/static/styles.css index 3451127..f0ea0e7 100644 --- a/static/styles.css +++ b/static/styles.css @@ -952,3 +952,6 @@ button.swatch { width: 36px; height: 36px; } .food-kinds .missing .gi { color: var(--bad) !important; opacity: .3; } .food-kinds > span[data-goto]:hover { border-color: var(--muted); } .mood-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; } + +.pouch-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; } +.pouch-row select, .pouch-row input[type=text] { min-width: 0; flex: 1 1 140px; }