Phase 2: client military/social screens, WebSocket push, trade + endgame, review findings pending

Built: units/movements/reports/send/expansion screens, alliance/messages/rankings screens, ws client + server /ws push
(docs/PROTOCOL.md), Internet exchange trade, backbone endgame + world end, shared reports, buildDone relative levels.
Tested: npm test 175/175. Two adversarial reviews found issues (trade-leg recall exploit, __proto__ via validate.js,
rankings DoS, static headers, ...): fixes follow in the next commit.
NOT done: bots/balance, e2e suite, real-device checks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
jvanvik 2026-10-11 19:05:03 +02:00
parent 249818a7aa
commit b18645dca1
87 changed files with 10201 additions and 71 deletions

View file

@ -275,10 +275,7 @@
function header(t) {
const st = App.state;
const bonus = D.RESOURCES.filter((r) => (t.bonus && t.bonus[r] > 0)).map((r) => h('span', { class: 'pill res-' + r }, icon(r), '+' + Math.round(t.bonus[r] * 100) + '% ' + App.resName(r)));
const title = st.towns.length > 1
? h('select', { class: 'town-select', 'aria-label': App.t('screen.pop'), onchange: (e) => App.setTown(Number(e.target.value)) },
st.towns.map((x) => h('option', { value: x.id, selected: x.id === t.id, text: x.name })))
: h('h1', { class: 'town-name', text: t.name });
const title = h('h1', { class: 'town-name', text: t.name }); // switching POPs lives in the resource bar (main.js)
return h('section', { class: 'card pop-head' },
h('div', { class: 'pop-title' }, title,
h('button', { class: 'icon-btn', type: 'button', 'aria-label': App.t('pop.rename'), onclick: openRename }, icon('pencil'))),
@ -376,8 +373,12 @@
const t = td();
if (!App.state.townId) { box.appendChild(h('p', { class: 'empty pad', text: App.t('pop.noTown') })); return; }
if (!t) { box.appendChild(h('div', { class: 'boot' }, h('div', { class: 'spinner', 'aria-hidden': 'true' }), h('p', { text: App.t('common.loading') }))); return; }
// other screens add cards here through App.popSections (military: incoming banner on top, expansion below the power card)
const extra = (slot) => (App.popSections || []).filter((s) => s.slot === slot).map((s) => { try { return s.render(t); } catch (e) { console.error(e); return null; } });
const tops = extra('top');
if (tops.some(Boolean)) box.appendChild(h('div', { class: 'pop-top' }, tops));
box.appendChild(h('div', { class: 'cols' },
h('div', { class: 'col' }, header(t), queueCard(t), powerCard()),
h('div', { class: 'col' }, header(t), queueCard(t), powerCard(), extra('main')),
h('div', { class: 'col' }, fieldsCard(t), infraCard(t))));
tick(App.now());
}
@ -482,6 +483,7 @@
App.on('town', onTown);
App.on('session', () => { dirty = true; prevQueue = null; });
App.on('townchange', () => { dirty = true; if (visible) draw(); });
App.on('towns', () => { dirty = true; if (visible) draw(); });
},
onShow() {
visible = true;