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
50 lines
3.3 KiB
JavaScript
50 lines
3.3 KiB
JavaScript
'use strict';
|
|
/*
|
|
* Expansion on the POP screen (App.popSections, slot 'main'): your POPs (switch between them), and what founding the next
|
|
* one takes: rollout crews at home, the footprint gate, a shortcut to the map to pick a site (the map tile sheet then offers
|
|
* "Send" -> Settle with the wild-slot choice, see send.js). The founding itself is a settle movement; the settle report has
|
|
* an "Open POP" button. The POP switcher in the resource bar lives in main.js.
|
|
*/
|
|
(function () {
|
|
const { h, icon, toast } = UI;
|
|
const R = UpstreamRules;
|
|
const D = UpstreamData;
|
|
const mil = () => App.mil;
|
|
|
|
function popsList(t) {
|
|
const st = App.state;
|
|
return h('ul', { class: 'mil-list' }, st.towns.map((x) => h('li', { class: 'mil-row' + (x.id === t.id ? ' current' : '') },
|
|
h('span', { class: 'row-ic' }, icon('pop')),
|
|
h('span', { class: 'row-main' },
|
|
h('span', { class: 'row-title' }, h('b', { text: x.name }), x.isCapital ? h('span', { class: 'pill accent', text: App.t('pop.capital') }) : null),
|
|
h('span', { class: 'row-sub' }, mil().coordLink(x.x, x.y))),
|
|
x.id === t.id ? h('span', { class: 'pill green', text: App.t('exp.current') })
|
|
: h('button', { class: 'btn small', type: 'button', onclick: () => { App.setTown(x.id); } }, App.t('exp.open')))));
|
|
}
|
|
|
|
function card(t) {
|
|
const m = t.military;
|
|
const owned = App.state.towns.length;
|
|
const need = R.footprintNeeded(owned);
|
|
const crews = m ? (m.units.home[D.EXPANSION.settleUnit] || 0) : 0;
|
|
const canTrain = m && m.trainable.some((u) => u.unit === D.EXPANSION.settleUnit && !u.locked);
|
|
const rows = [
|
|
h('div', { class: 'kv' }, h('span', { class: 'k', text: App.t('exp.crews') }), h('span', { class: 'v mono' + (crews >= D.EXPANSION.crews ? ' good' : ''), text: crews + ' / ' + D.EXPANSION.crews })),
|
|
h('div', { class: 'kv' }, h('span', { class: 'k', text: App.t('exp.footprint') }), h('span', { class: 'v mono', text: App.t('exp.footprint.v', { have: App.fmt.num(t.footprint), need: App.fmt.num(need) }) })),
|
|
h('div', { class: 'kv' }, h('span', { class: 'k', text: App.t('exp.range') }), h('span', { class: 'v mono', text: D.EXPANSION.maxDistance + ' ' + App.t('common.tiles') })),
|
|
];
|
|
const actions = [];
|
|
if (crews >= D.EXPANSION.crews) {
|
|
actions.push(h('button', { class: 'btn primary wide', type: 'button', onclick: () => { App.go('map', { x: t.x, y: t.y, zoom: 24 }); toast(App.t('exp.pick'), 'ok'); } }, icon('flag'), App.t('exp.found')));
|
|
} else {
|
|
actions.push(h('p', { class: 'row-sub wrap', text: canTrain ? App.t('exp.needCrews', { n: D.EXPANSION.crews - crews, unit: mil().unitName(D.EXPANSION.settleUnit) }) : App.t('exp.needDepot') }));
|
|
if (canTrain) actions.push(h('button', { class: 'btn wide', type: 'button', onclick: () => App.go('units') }, icon('units'), App.t('exp.train')));
|
|
}
|
|
return h('section', { class: 'card' },
|
|
h('div', { class: 'card-head' }, h('h2', null, icon('flag'), App.t('exp.title')), h('span', { class: 'pill', text: App.t('exp.count', { n: owned }) })),
|
|
rows, h('p', { class: 'row-sub wrap', text: App.t('exp.hint') }), actions,
|
|
owned > 1 ? [h('h3', { class: 'sub', text: App.t('exp.pops') }), popsList(t)] : null);
|
|
}
|
|
|
|
App.popSections.push({ slot: 'main', render: card });
|
|
}());
|