Six tiers of ore, trees, hides and gear; dragons; tier tabs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a18e8e5bb7
commit
ba68a62080
6 changed files with 319 additions and 103 deletions
|
|
@ -12,6 +12,7 @@ let skew = 0; // server clock minus client clock, seconds
|
|||
let page = decodeURIComponent(location.hash.slice(1)) || remember("page") || "town";
|
||||
let selected = null; // bank item
|
||||
let pickedClass = null; // registration
|
||||
const tabs = {}; // skill -> selected recipe tab
|
||||
let refreshing = false;
|
||||
let refreshedFor = null; // action start a completion refresh was sent for
|
||||
let version = null; // server build this page was loaded from
|
||||
|
|
@ -315,8 +316,18 @@ function skillPage(id) {
|
|||
if (id === "combat") html += combatPanel();
|
||||
if (`tool_${id}` in me.equip) html += toolPanel(id);
|
||||
if (id === "reconnaissance") html += `<div class="panel small muted">Every ${8} reconnaissance points on an upcoming event raises its intel by one level, on top of what the spymaster's guild provides. The council & threats page shows the progress.</div>`;
|
||||
const actions = C.actions.filter((a) => a.skill === id);
|
||||
const groups = [...new Set(actions.map((a) => a.group).filter(Boolean))];
|
||||
if (groups.length > 2) {
|
||||
// Many tiers: one tab per tier, opening on the highest one you can work.
|
||||
const open = (g) => actions.some((a) => a.group === g && !isLocked(a));
|
||||
let current = tabs[id] || remember(`tab.${id}`);
|
||||
if (!groups.includes(current)) current = [...groups].reverse().find(open) || groups[0];
|
||||
const bar = groups.map((g) => `<button class="tab ${g === current ? "on" : ""} ${open(g) ? "" : "dim"}" data-tab="${id}" data-group="${esc(g)}">${esc(g)}</button>`).join("");
|
||||
return html + `<div class="tabs">${bar}</div><div class="grid">${actions.filter((a) => a.group === current).map(actionCard).join("")}</div>`;
|
||||
}
|
||||
let group = null, cards = "";
|
||||
for (const a of C.actions.filter((a) => a.skill === id)) {
|
||||
for (const a of actions) {
|
||||
if (a.group && a.group !== group) {
|
||||
group = a.group;
|
||||
cards += `<div class="section-title grid-head">${esc(group)}</div>`;
|
||||
|
|
@ -326,6 +337,12 @@ function skillPage(id) {
|
|||
return html + `<div class="grid">${cards}</div>`;
|
||||
}
|
||||
|
||||
// Locked: missing a level, class or building, as opposed to just out of materials.
|
||||
function isLocked(a) {
|
||||
const why = S.me.blocked[a.id];
|
||||
return Boolean(why && (why.startsWith("Needs") || why.startsWith("Only")));
|
||||
}
|
||||
|
||||
function toolPanel(skill) {
|
||||
const tool = S.me.equip[`tool_${skill}`];
|
||||
return `<div class="panel tool-panel">${tool
|
||||
|
|
@ -365,7 +382,7 @@ function actionCard(a) {
|
|||
const me = S.me;
|
||||
const active = me.action?.id === a.id;
|
||||
const why = me.blocked[a.id];
|
||||
const locked = why && (why.startsWith("Needs") || why.startsWith("Only"));
|
||||
const locked = isLocked(a);
|
||||
const out = Object.keys(a.outputs)[0];
|
||||
const icon = out ? item(out).icon : skillOf(a.skill).icon;
|
||||
const time = me.times[a.id];
|
||||
|
|
@ -440,7 +457,7 @@ function itemPanel(id) {
|
|||
<div class="ico">${it.icon}</div>
|
||||
<h3>${esc(it.name)}</h3>
|
||||
<div class="muted small">You have ${fmt(have)} · worth ${price % 1 ? price.toFixed(1) : price} gold each${merchant ? " (merchant in town!)" : ""}</div>
|
||||
${it.slot ? `<div class="row"><button class="btn gold" data-equip="${id}">${equipLabel(it)}</button></div>` : ""}
|
||||
${it.slot ? equipRow(id, it) : ""}
|
||||
${it.heal ? `<div class="row"><div class="small muted">Heals ${it.heal} in fights.</div>
|
||||
${S.me.food === id ? `<span class="tag good">Your fighting food</span>` : `<button class="btn sm" data-food="${id}">Eat this first in fights</button>`}</div>` : ""}
|
||||
${it.food ? `<div class="row small muted">Feeds ${it.food} townsfolk for two days in the city granary.</div>` : ""}
|
||||
|
|
@ -451,6 +468,13 @@ function itemPanel(id) {
|
|||
</div>${goldPanel()}`;
|
||||
}
|
||||
|
||||
function equipRow(id, it) {
|
||||
const [skill, level] = it.req || [];
|
||||
const short = skill && S.me.levels[skill] < level;
|
||||
return `<div class="row"><button class="btn gold" data-equip="${id}" ${short ? "disabled" : ""}>${equipLabel(it)}</button>
|
||||
${skill ? `<div class="small ${short ? "why" : "muted"}">Needs ${esc(skillOf(skill).name.toLowerCase())} level ${level}</div>` : ""}</div>`;
|
||||
}
|
||||
|
||||
function equipLabel(it) {
|
||||
if (it.tool) return `Use as ${skillOf(it.tool).name.toLowerCase()} tool (${Math.round(it.speed * 100)}% faster)`;
|
||||
const stats = [it.power && `+${it.power} power`, it.armour && `+${it.armour} armour`].filter(Boolean).join(", ");
|
||||
|
|
@ -609,7 +633,7 @@ function raidPrep(ev) {
|
|||
const names = { rallied: "Rallied militia (favour)", townsfolk: "Townsfolk with pitchforks", walls: "Walls", militia: "Militia (barracks)", weapons: "Swords in the armoury", shields: "Shields in the armoury", arrows: "Arrows", garrison: "Garrison" };
|
||||
const reqs = (ev.requests || []).map((r) => {
|
||||
const mine = me.bank[r.item] || 0;
|
||||
return `<div class="req"><span>${item(r.item).icon}</span><span>${r.item === "bread" ? "Food (any)" : esc(item(r.item).name)} <span class="muted small">${fmt(r.have)} / ${fmt(r.want)}</span></span>
|
||||
return `<div class="req"><span>${item(r.item).icon}</span><span>${esc(r.label)} <span class="muted small">${fmt(r.have)} / ${fmt(r.want)}</span></span>
|
||||
${mine ? `<button class="btn sm gold" data-donate="${r.item}" data-qty="all">Give ${fmt(mine)}</button>` : "<span></span>"}
|
||||
<div class="bar"><span style="width:${Math.min(100, r.have / r.want * 100)}%"></span></div></div>`;
|
||||
}).join("");
|
||||
|
|
@ -812,6 +836,7 @@ document.addEventListener("click", (e) => {
|
|||
if (d.food) return act("/api/food", { item: d.food });
|
||||
if (d.overflow) return act("/api/settings", { overflow: d.overflow });
|
||||
if (d.class) { pickedClass = d.class; render(); return; }
|
||||
if (d.tab) { tabs[d.tab] = d.group; remember(`tab.${d.tab}`, d.group); render(); return; }
|
||||
if (d.devAdvance) return act("/api/dev/advance", { hours: Number(d.devAdvance) });
|
||||
if ("devEvent" in d) return act("/api/dev/event", {});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue