Server-run play, part 1: game prerequisites and shared contracts
Groundwork for running multiplayer games on the session server; nothing
of it is switched on yet, and the plain build is unchanged.
- A new network in two halves (beginState/beginShow), the coach split into
tutAdvance/coachDom, toastPop split out of toast, bootNotes() for the
once-per-load toasts, the five text actions take their text as an
argument, and srvOn() with its two checks in the loop.
- Live state is what a reload makes of it (migrate() is a no-op on it):
new POPs, ports, PNIs, customers, attacks, dark fiber and the intern's
notes are written in their saved shape; a 365-day test proves it.
- pniAll and bstdApply check the quote the sheet showed (bstdApply by its
plan, within 1% for the daily hardware drift; utilityKit too).
- assemble({mp}) leaves src/game/98-server-play/ and its CSS out of every
page but a multiplayer build's, which also gets a SIM_ID build id.
- Contracts for the server, protocol and browser parts: the action tables
and envelope check (scripts/lib/mp-sim-acts.js), event fixtures, a shape
checker, a fake engine, and load({mp:true}) in the test harness.
- route-fuzz judges both pages with one migrate(), so reload repairs of
the base no longer count as divergences.
This commit is contained in:
parent
e25f843526
commit
d1e127da67
60 changed files with 2200 additions and 105 deletions
|
|
@ -1,8 +1,11 @@
|
|||
/* ---------- toasts & modals ---------- */
|
||||
function toast(html,kind='',actions=[],open=null){
|
||||
if(S)logNote(html,kind,actions,open);
|
||||
toastPop(html,kind,actions,UI.tick);}
|
||||
// The toast on screen only (the log line is toast()'s). tick: the day announced it (UI.tick when it was said).
|
||||
function toastPop(html,kind='',actions=[],tick=false){
|
||||
// Quiet notifications: what the day announces pops up only for trouble and milestones; the rest stays in the NOC log.
|
||||
if(UI.tick&&kind!=='bad'&&kind!=='goal'&&quietOn())return;
|
||||
if(tick&&kind!=='bad'&&kind!=='goal'&&quietOn())return;
|
||||
const el=document.createElement('div');el.className='toast '+kind;el.dataset.born=performance.now();
|
||||
el.innerHTML=`<div class="tx">${html}</div>${actions.map(a=>btn(a.l,a.act,a.args,'sm')).join('')}`;
|
||||
const box=$('toasts');box.prepend(el);const max=innerWidth<760?2:3;while(box.children.length>max)box.lastChild.remove();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
function pniAllModal(net,tier=1){const b=pniBatch(net,tier);if(!b)return;UI.pniAll={net,tier};
|
||||
// msg: why the sheet is shown again (the quote changed).
|
||||
function pniAllModal(net,tier=1,msg=''){const b=pniBatch(net,tier);if(!b)return;UI.pniAll={net,tier};
|
||||
const all=net===null,n=NET[net],port=tier===-1?'1G':PORT[tier].n,up=b.orders.filter(q=>q.ex).length,byNet={};
|
||||
if(all)for(const q of b.orders)(byNet[q.net]||(byNet[q.net]=[])).push(q.city);
|
||||
const controls=`<div class="btns">${btn(all?tr('pni_all.all_at_port',{port}):tr('pni_all.peer_at_port',{port}),'pniAll',{net,tier},'pink',!b.orders.length||S.cash<b.cost)}${btn(tr('common.cancel'),'closeModal',{},'ghost')}</div>`;
|
||||
const controls=`<div class="btns">${btn(all?tr('pni_all.all_at_port',{port}):tr('pni_all.peer_at_port',{port}),'pniAll',{net,tier,q:b.cost},'pink',!b.orders.length||S.cash<b.cost)}${btn(tr('common.cancel'),'closeModal',{},'ghost')}</div>`;
|
||||
const blocked=b.blocked.map(q=>`<p class="why"><b>${all?esc(NET[q.net].name)+' · ':''}${esc(CITY[q.city].name)}:</b> ${q.why}</p>`).join('');
|
||||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${all?tr('common.all_networks'):`AS${n.asn} · ${esc(n.name)}`}</div><h2>${all?tr('pni_all.peer_all_networks'):tr('pni_all.peer_on_all_pops')}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>
|
||||
<p class="lead">${tr('pni_all.order_missing_and_upgrade_smaller')}</p>
|
||||
<p class="lead">${tr('pni_all.order_missing_and_upgrade_smaller')}</p>${msg?`<p class="why">${esc(msg)}</p>`:''}
|
||||
<div class="trsel"><label>${tr('pni_all.pni_size')}<select data-chg="pniAllSize">${pniG1(net)?`<option value="-1"${tier===-1?' selected':''}>1G</option>`:''}${PORT.map((p,i)=>portShown(i)&&(all||i>=pniMin(net))?`<option value="${i}"${tier===i?' selected':''}>${p.n}</option>`:'').join('')}</select></label></div>
|
||||
<div class="kv"><span>${tr('pni_all.new_and_upgrades',{fresh:b.orders.length-up,up})}</span><b>${all?tr('pni_all.n_of_total_connections',{n:b.orders.length,total:b.shared.length}):tr('pni_all.n_of_total_pops',{n:b.orders.length,total:b.shared.length})}</b></div>
|
||||
<div class="kv"><span>${tr('pni_all.setup_total')}</span><b>${fmt$(b.cost)}</b></div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue