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
|
|
@ -935,6 +935,11 @@ function pageHtml() {
|
|||
// --- kingdom ----------------------------------------------------------------
|
||||
let pouch = {};
|
||||
|
||||
function regionPerks(region, scale) {
|
||||
const y = S.kingdom.region_yield;
|
||||
return `${region.skills.map((id) => skillOf(id).icon).join("")} +${pct(y[0] * scale)} → +${pct(y.at(-1) * scale)}`;
|
||||
}
|
||||
|
||||
function townName(id) {
|
||||
return S.kingdom.cities.find((c) => c.id === id)?.name || id;
|
||||
}
|
||||
|
|
@ -944,9 +949,11 @@ function 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;
|
||||
const region = k.regions[c.region];
|
||||
return `<div class="panel">
|
||||
<h2>${esc(c.name)} ${here ? `<span class="tag">📍 Here</span>` : ""}</h2>
|
||||
<p class="small">${esc(c.tier)} · 👥 ${fmt(c.population)} · 🛡️ ${fmt(c.repelled)}${road ? ` · 🛤️ ${road}` : ""}</p>
|
||||
${region ? `<p class="small" title="More per trip, by material tier. Grows with the town.">${region.icon} ${esc(region.name)} · ${regionPerks(region, c.town_scale)}</p>` : ""}
|
||||
<p class="small">${c.people.length ? c.people.map((uid) => esc(playerName(uid))).join(", ") : `<span class="muted">Nobody here</span>`}</p>
|
||||
${here || me.travel ? "" : `<button class="btn primary" data-travel="${esc(c.id)}">🛤️ Travel (${dur(C.travel_time / S.city_speed)})</button>`}
|
||||
</div>`;
|
||||
|
|
@ -963,13 +970,15 @@ function kingdom() {
|
|||
<button class="btn sm" data-pouch-add ${kinds >= k.pouch.slots || !stock.length ? "disabled" : ""}>+</button></div>`;
|
||||
const charter = k.charter;
|
||||
const full = k.cities.length >= k.max;
|
||||
const open = Object.entries(k.regions).filter(([id]) => !k.cities.some((c) => c.region === id));
|
||||
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
|
||||
? `<p class="small">📜 <b>${esc(charter.name)}</b> · ${esc(playerName(charter.by))}</p>
|
||||
? `<p class="small">📜 <b>${esc(charter.name)}</b> · ${k.regions[charter.region].icon} ${esc(k.regions[charter.region].name)} · ${esc(playerName(charter.by))}</p>
|
||||
${charter.by === me.id ? `<button class="btn" data-charter-cancel>Tear up</button>` : `<button class="btn primary" data-charter-sign>✍️ Sign</button>`}`
|
||||
: full ? `<p class="small muted">${k.cities.length} / ${k.max} towns</p>`
|
||||
: `<p class="small">${cost}</p>
|
||||
${S.city.next_tier ? `<p class="small muted">${esc(k.short)}</p>` : `<div class="pouch-row"><input type="text" maxlength="24" placeholder="Town name" data-keep="charter-name">
|
||||
<select data-keep="charter-region">${open.map(([id, r]) => `<option value="${id}">${r.icon} ${esc(r.name)} · ${regionPerks(r, 0.5)}</option>`).join("")}</select>
|
||||
<button class="btn primary" data-charter-new ${k.short ? "disabled" : ""}>📜 Draw up</button></div>`}`;
|
||||
return `<div class="grid">${towns}</div>
|
||||
<div class="grid" style="margin-top:14px">
|
||||
|
|
@ -1948,7 +1957,7 @@ function actionCard(a) {
|
|||
return `
|
||||
<div class="action ${active || second ? "active" : ""} ${locked ? "locked" : ""}" data-card="${a.id}">
|
||||
<div class="top"><div class="ico">${icon}</div><div>
|
||||
<div class="name">${esc(a.name)} ${Object.keys(a.outputs).map((id) => needTag(id) + fittedTag(id)).join("")}</div>
|
||||
<div class="name">${esc(a.name)} ${Object.keys(a.outputs).map((id) => needTag(id) + fittedTag(id)).join("")}${me.region_yield[a.id] ? ` <span class="tag good" title="This town's region: more per trip">+${pct(me.region_yield[a.id])}</span>` : ""}</div>
|
||||
<div class="sub">Level ${a.level} · ${dur(time)} · ${a.xp} XP</div>
|
||||
</div><span class="tools">${orderable ? `<button class="order-it" data-order-item="${out}" title="${esc(`Work order: ${item(out).name}`)}">${glyph("claw-hammer", "#e3c060")}</button>` : ""}${Object.keys(a.inputs).length ? `<button class="pin ${me.tracked === a.id ? "on" : ""}" data-track="${a.id}" title="${me.tracked === a.id ? "Untrack" : "Track"}">📌</button>` : ""}</span></div>
|
||||
${io ? `<div class="io">${io}</div>` : ""}
|
||||
|
|
@ -3351,7 +3360,7 @@ document.addEventListener("click", (e) => {
|
|||
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 });
|
||||
return act("/api/charter", { name: $("[data-keep=charter-name]").value, region: $("[data-keep=charter-region]").value });
|
||||
}
|
||||
if ("charterSign" in d) {
|
||||
if (!confirm(`Sign the charter for ${S.kingdom.charter.name}? The town is founded at once.`)) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue