Each zone (Vanua Levu & Taveuni off Suva, the Out Islands off Nassau, and 16 more) is a pool of island homes at your POP in its city: no node and no link on the map, its Gbps join the city's demand. Rent backhaul at the city's teleport (about 35% sign up over GEO, 75% over MEO, 90% over Starblink from a gateway there) or, from level 3, lay a spur cable and everyone may sign up. The first order brings the island kit. Islanders pay island prices, their homes are IPv6-only in the NAT64 pool, and investors on a revenue share take their cut. A spur can be cut for weeks (failure 'wspur', chaos only): a satellite kept beside it carries the islands. Zones are off in puzzles, the Architect, scenarios and below level 2. The satellite geometry works on points now (satSeesAt, satPairAt, satKmAt; the city functions wrap them, with the same answers). Starblink serves a zone only from a gateway in its own city (16 of 18; a gateway anywhere in reach would serve the same 16), with its storm and rival rule; Nunavut and Southeast Alaska stay on GEO. Rules W6 and F12.
375 lines
24 KiB
JavaScript
375 lines
24 KiB
JavaScript
// Island Wi-Fi (#83): 18 zones of outer islands, each a pool of homes hanging off one island city. Your POP there brings
|
||
// them online over satellite capacity from its teleport (GEO about 35% sign up, MEO about 75%, Starblink LEO from a
|
||
// gateway there about 90%) or a spur cable (all of them). Their Gbps join the city's demand; they are IPv6-only homes;
|
||
// a spur can be cut for weeks, and a satellite kept beside it carries the islands meanwhile.
|
||
const test = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const fs = require('node:fs');
|
||
const path = require('node:path');
|
||
const { load } = require('./harness');
|
||
|
||
const SAVE = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8');
|
||
// Level 3, Change Freeze (nothing breaks by itself, lead times quick), plenty of cash.
|
||
const BASE = "ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;S.lvl=3;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');";
|
||
// Suva: a POP with transit (so its traffic gets out) and a teleport.
|
||
const SUV = "ACT.buildPop({city:'suv'});ACT.buyTransit({city:'suv',net:NETS.find(n=>sellsAt(n,'suv')).id,tier:1});ACT.teleBuild({city:'suv'});";
|
||
const VL = "ACT.wispSat({z:'vanualevu',bird:'kac1',g:2});";
|
||
function game(t, setup = '') {
|
||
const h = load();
|
||
t.after(() => h.dom.window.close());
|
||
h.ev(BASE + setup);
|
||
return h;
|
||
}
|
||
const J = (ev, s) => JSON.parse(ev(`JSON.stringify(${s})`));
|
||
const Z = "wispZ('vanualevu')";
|
||
// Past the day the zone's circuit (or a move) is commissioned.
|
||
const ready = `S.day=Math.max(${Z}.sat?${Z}.sat.ready:0,${Z}.nxt?${Z}.nxt.ready:0,${Z}.sp?${Z}.sp.ready:0);compute()`;
|
||
const days = (ev, n) => ev(`for(let i=0;i<${n};i++)dayTick()`);
|
||
// The first top-level keys whose JSON differs between two states (never deepEqual on S).
|
||
const firstDiff = (a, b) => { const A = JSON.parse(a), B = JSON.parse(b); return [...new Set([...Object.keys(A), ...Object.keys(B)])].filter((k) => JSON.stringify(A[k]) !== JSON.stringify(B[k])).slice(0, 5); };
|
||
|
||
test('the catalog and the geometry: zones off satellite cities, seen by a GEO bird; points give exactly the city answers', (t) => {
|
||
const { ev, errors } = game(t);
|
||
const ids = J(ev, 'Object.keys(WISP)');
|
||
assert.equal(ids.length, 18);
|
||
assert.deepEqual(ids, [...ids].sort(), 'ids sorted');
|
||
const bad = J(ev, `Object.keys(WISP).filter(z=>{const W=WISP[z],C=CITY[W.c];return !C||!satRemote(W.c)||hav(C.lon,C.lat,W.lon,W.lat)>1000||!Object.keys(SATS).some(id=>SATS[id].orb==='geo'&&satPairAt(id,C,W))
|
||
||!(W.P>=3&&W.P<=12)||!(W.km===0||W.km>=50&&W.km<=1500)||typeof W.n!=='string'||!W.n;})`);
|
||
assert.deepEqual(bad, []);
|
||
// The point versions, on cities, are the city versions: every bird, every satellite city against every city.
|
||
const diff = J(ev, `(()=>{const out=[];for(const id of Object.keys(SATS))for(const A of CITIES.filter(C=>satRemote(C.id))){if(satSeesAt(id,A)!==satSees(id,A.id))out.push('sees '+id+A.id);
|
||
for(const B of CITIES){if(A.id===B.id)continue;const p=satPairOk(id,A.id,B.id);if(p!==satPairAt(id,A,B))out.push(id+A.id+B.id);else if(p&&satKmAt(id,A,B)!==satKm(id,A.id,B.id))out.push('km '+id+A.id+B.id);}}return out.slice(0,5);})()`);
|
||
assert.deepEqual(diff, []);
|
||
// Starblink reaches a zone from a gateway in its own city wherever both are under the shell: all but the two beyond 56°.
|
||
assert.deepEqual(J(ev, "Object.keys(WISP).filter(z=>!wispBirds(z).includes(LEO_BIRD))"), ['nunavut', 'seak']);
|
||
assert.deepEqual(J(ev, "wispBirds('nunavut').map(b=>SATS[b].orb)"), ['geo'], 'Nunavut: GEO only');
|
||
assert.deepEqual(J(ev, "wispBirds('vanualevu').map(b=>SATS[b].orb)"), ['geo', 'geo', 'meo', 'leo'], 'GEO first, cheapest first, then MEO and LEO');
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('launch over GEO: the kit and the first month, homes at the floor, then the city carries them and they pay island prices', (t) => {
|
||
const { ev, errors } = game(t, SUV + "ACT.launchBB({city:'suv'});");
|
||
ev('compute()');
|
||
const eye0 = ev('R.cityEye.suv'), c0 = ev('S.cash');
|
||
ev(VL);
|
||
assert.equal(c0 - ev('S.cash'), ev("wispKit('vanualevu')+wispSatMo('kac1',2)"), 'the island kit and the first month');
|
||
assert.equal(ev(`${Z}.d`), ev("wispStart('vanualevu')"));
|
||
assert.equal(ev('R.wisp.vanualevu.car'), 0, 'nothing before the circuit is commissioned');
|
||
assert.equal(ev('R.cost.sat'), ev("TPORT_MO+wispSatMo('kac1',2)"), 'the rent from the order on');
|
||
assert.equal(ev('R.cost.wisp'), ev("wispUpMo('vanualevu')"));
|
||
ev(ready);
|
||
const car = ev('R.wisp.vanualevu.car');
|
||
assert.ok(car > 0);
|
||
assert.ok(Math.abs(ev('R.cityWisp.suv') - car) < 1e-9, 'the city carries the homes');
|
||
assert.ok(Math.abs(ev('R.cityEye.suv') - eye0) < 1e-9, 'broadband stays broadband');
|
||
assert.ok(ev('R.wisp.vanualevu.sf') > 0.9, 'served');
|
||
assert.ok(Math.abs(ev('R.rev.wisp') - ev('R.wisp.vanualevu.d*R.wisp.vanualevu.sf*wispRate("vanualevu")')) < 1e-6);
|
||
assert.equal(ev("wispRate('vanualevu')"), ev('EYE_RATE*14'), 'island prices');
|
||
assert.ok(ev('R.revMo') >= ev('R.rev.eyeballs+R.rev.wisp') - 1e-6);
|
||
// Investors on a revenue share take their slice of island homes too.
|
||
ev("S.loans=[{id:'v',bank:'vult',share:0.1,bal:0}];compute()");
|
||
assert.ok(Math.abs(ev('R.cost.revshare') - 0.1 * ev('R.rev.eyeballs+R.rev.business+R.rev.ix+(R.rev.orbit||0)+R.rev.wisp')) < 1e-6);
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('take-up grows to the link\'s cap and no further; a small circuit fills, and growing it lets homes in', (t) => {
|
||
const { ev, errors } = game(t, SUV + "ACT.wispSat({z:'vanualevu',bird:'kac1',g:5});");
|
||
ev(ready);
|
||
const K = ev(`wispK('vanualevu',${Z})`);
|
||
assert.ok(Math.abs(K - ev("wispPool('vanualevu')*SAT_ORB.geo.wisp")) < 1e-9, 'about 35% over GEO');
|
||
let top = 0;
|
||
for (let i = 0; i < 40; i++) { days(ev, 10); top = Math.max(top, ev(`${Z}.d`)); }
|
||
assert.ok(top <= K + 1e-9, `never past the cap: ${top} of ${K}`);
|
||
assert.ok(ev(`${Z}.d`) > 0.9 * K, 'close to it after a year');
|
||
// A 1G circuit: homes hover where it serves 90% of them.
|
||
ev("ACT.wispSatSize({z:'vanualevu',g:1})");
|
||
days(ev, 200);
|
||
const d1 = ev(`${Z}.d`);
|
||
assert.ok(d1 > 0.95 && d1 < 1.25, `about 1/0.9 G: ${d1}`);
|
||
ev("selectCity('suv');UI.tab='cust';UI.wz='vanualevu';renderPanel()");
|
||
assert.match(ev("document.getElementById('panel').textContent"), /The link is full: homes are waiting/);
|
||
const c0 = ev('S.cash');
|
||
ev("ACT.wispSatSize({z:'vanualevu',g:5})");
|
||
assert.equal(c0 - ev('S.cash'), ev("wispSatMo('kac1',5)"), 'a bigger one pays its month up front');
|
||
days(ev, 100);
|
||
assert.ok(ev(`${Z}.d`) > 1.5, 'more homes come in');
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('moving to MEO: tracking antennas first, then the old circuit carries until the new one is up', (t) => {
|
||
const { ev, errors } = game(t, SUV + VL);
|
||
ev(ready);
|
||
const c0 = ev('S.cash');
|
||
ev("ACT.wispSat({z:'vanualevu',bird:'o3b',g:5})");
|
||
assert.equal(ev('S.cash'), c0, 'nothing charged');
|
||
assert.match(ev("wispSatWhy('vanualevu','o3b',5)"), /tracking antennas/);
|
||
ev("ACT.teleTrk({city:'suv'});ACT.wispSat({z:'vanualevu',bird:'o3b',g:5})");
|
||
assert.equal(ev(`${Z}.nxt.bird`), 'o3b');
|
||
assert.equal(ev(`${Z}.sat.bird`), 'kac1');
|
||
assert.match(ev("wispSatWhy('vanualevu','is18',2)"), /move to another satellite is under way/);
|
||
ev('compute()');
|
||
assert.equal(ev(`wispLink('vanualevu',${Z})===${Z}.sat`), true, 'the old circuit carries meanwhile');
|
||
assert.ok(ev('R.wisp.vanualevu.car') > 0);
|
||
assert.equal(ev('R.cost.sat'), ev("TPORT_MO+TRK_MO+wispSatMo('kac1',2)+wispSatMo('o3b',5)"), 'both rents while it moves');
|
||
ev(`S.day=${Z}.nxt.ready-1;dayTick()`);
|
||
assert.equal(ev(`${Z}.sat.bird`), 'o3b');
|
||
assert.equal(ev(`${Z}.nxt`), undefined);
|
||
assert.ok(Math.abs(ev(`wispK('vanualevu',${Z})`) - ev("wispPool('vanualevu')*SAT_ORB.meo.wisp")) < 1e-9, 'about 75% over MEO');
|
||
assert.match(ev("JSON.stringify(S.log.slice(0,8).map(e=>e.t))"), /Vanua Levu & Taveuni now rides O3bservant/);
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('the spur: level 3, never where one cannot be laid, the price of the day; lit, everyone signs up and the satellite stands by', (t) => {
|
||
const { ev, errors } = game(t, SUV + VL + "ACT.buildPop({city:'yfb'});");
|
||
ev('S.lvl=2');
|
||
assert.match(ev("wispSpurWhy('vanualevu')"), /level 3/);
|
||
ev('S.lvl=3');
|
||
assert.match(ev("wispSpurWhy('nunavut')"), /sea ice/);
|
||
const c0 = ev('S.cash');
|
||
ev("ACT.wispSpur({z:'nunavut'})");
|
||
assert.equal(ev('S.cash'), c0, 'refused');
|
||
ev("ACT.wispSpur({z:'vanualevu'})");
|
||
assert.equal(c0 - ev('S.cash'), ev("wispSpurCost('vanualevu')"));
|
||
assert.equal(ev("wispSpurCost('vanualevu')"), Math.round((150000 + 600 * 220) / 1000) * 1000, 'today\'s price, no market under Change Freeze');
|
||
assert.match(ev("wispSpurWhy('vanualevu')"), /laid already/);
|
||
ev(ready);
|
||
assert.ok(Math.abs(ev(`wispK('vanualevu',${Z})`) - ev("wispPool('vanualevu')")) < 1e-9, 'everyone may sign up');
|
||
assert.equal(ev(`wispLink('vanualevu',${Z}).sp`), true, 'the spur carries');
|
||
ev(`${Z}.d=5;compute()`);
|
||
assert.ok(ev('R.wisp.vanualevu.car') > 2 + 1e-6, 'more than the 2G circuit could');
|
||
assert.equal(ev('R.cost.sat'), ev("TPORT_MO+wispSatMo('kac1',2)"), 'the circuit standing by is still rented');
|
||
assert.equal(ev('R.cost.wisp'), ev("wispUpMo('vanualevu')+wispSpurMo('vanualevu')"));
|
||
ev("UI.sel={type:'city',id:'suv'};UI.tab='links';renderAll()");
|
||
assert.match(ev("document.getElementById('panel').textContent"), /Vanua Levu & Taveuni[^]*Standby/);
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('the single-spur trap: a cut takes weeks; a satellite beside it carries the islands, without one they go dark and leave', (t) => {
|
||
const { ev, errors } = game(t, SUV + VL + "ACT.wispSpur({z:'vanualevu'});");
|
||
ev(ready + `;${Z}.d=5;compute()`);
|
||
// A spur that is lit and whole is something a failure can find; nothing else gives it a weight.
|
||
const opts = "(()=>{window.__opts=null;runNow(eval('('+failureRun.toString().replace('if(!opts.length)return;','window.__opts=opts.map(o=>o.join(\":\"));return;')+')')());return __opts;})()";
|
||
assert.ok(J(ev, opts).includes('wspur:1.5'));
|
||
ev('fireFailure("wspur")');
|
||
const inc = J(ev, "S.inc.find(i=>i.type==='wspur')");
|
||
assert.ok(inc && inc.z === 'vanualevu' && inc.ref === 'suv' && inc.cost === 250000);
|
||
assert.ok(inc.until - ev('S.day') >= 14, 'weeks for the repair ship');
|
||
assert.match(inc.msg, /The satellite circuit carries the islands meanwhile/);
|
||
assert.equal(ev("incTitle('wspur')"), 'Spur cut');
|
||
assert.ok(!J(ev, opts).some((o) => o.startsWith('wspur')), 'a cut spur is not cut again');
|
||
ev('compute()');
|
||
assert.ok(Math.abs(ev('R.wisp.vanualevu.car') - 2) < 1e-9, 'the 2G circuit carries what it can');
|
||
// The rush button charges the ship and mends it.
|
||
const c0 = ev('S.cash');
|
||
ev(`ACT.fixInc({id:${JSON.stringify(inc.id)}})`);
|
||
assert.equal(c0 - ev('S.cash'), 250000);
|
||
assert.equal(ev("wispCut('vanualevu')"), 0);
|
||
assert.ok(ev('R.wisp.vanualevu.car') > 2 + 1e-6, 'the spur carries again');
|
||
// Without a satellite: dark, and homes leave toward the floor.
|
||
ev("ACT.wispSatRm({z:'vanualevu'});ACT.wispSatRm({z:'vanualevu'});fireFailure('wspur')");
|
||
assert.match(J(ev, "S.inc.find(i=>i.type==='wspur')").msg, /offline until it is mended/);
|
||
ev('compute()');
|
||
assert.equal(ev('R.wisp.vanualevu.car'), 0);
|
||
assert.equal(ev('R.wisp.vanualevu.sf'), 0);
|
||
const d0 = ev(`${Z}.d`);
|
||
days(ev, 5);
|
||
assert.ok(ev(`${Z}.d`) < d0, 'homes leave');
|
||
assert.ok(ev(`${Z}.d`) >= ev("wispStart('vanualevu')") - 1e-9, 'never below the floor');
|
||
// The intern's repair order rushes it, once its budget is raised past the ship.
|
||
ev("ACT.opsHire({id:'kevin'});S.ops.floor=0;closeModal();S.ops.on.repair=true;S.ops.cap.repair=1e6;");
|
||
ev('opsDay(S.day)');
|
||
assert.equal(ev("S.inc.some(i=>i.type==='wspur')"), false, 'rushed');
|
||
// No spur at all: the failure has nothing to find.
|
||
ev("S.inc=[];ACT.wispRm({z:'vanualevu'});ACT.wispRm({z:'vanualevu'})");
|
||
assert.ok(!J(ev, opts).some((o) => o.startsWith('wspur')));
|
||
const n = ev('S.inc.length');
|
||
ev("fireFailure('wspur')");
|
||
assert.equal(ev('S.inc.length'), n, 'nothing to cut');
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('IPv4: island homes are IPv6-only from day one, in the NAT64 pool, never behind CGNAT', (t) => {
|
||
const { ev, errors } = game(t, "S.rules=makeRules('oncall');" + SUV);
|
||
assert.equal(ev('ip4On()'), true);
|
||
const u0 = J(ev, 'ip4Use()');
|
||
ev(VL + `${Z}.d=3;compute()`);
|
||
const u1 = J(ev, 'ip4Use()');
|
||
assert.ok(Math.abs(u1.H6 - u0.H6 - 30) <= 1, `H6 grows by d×${ev('IP4_BB')}: ${u0.H6} → ${u1.H6}`);
|
||
assert.equal(u1.cg, u0.cg, 'no home behind CGNAT for it');
|
||
ev("selectCity('suv');UI.tab='cust';UI.wz='vanualevu';renderPanel()");
|
||
assert.match(ev("document.getElementById('panel').textContent"), /IPv6-only \(464XLAT\) from day one/);
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('saves: zones and circuits survive a reload, broken ones are repaired, and the state stays canonical', (t) => {
|
||
const { ev, errors } = game(t, SUV + VL + "ACT.wispSpur({z:'vanualevu'});ACT.buildPop({city:'tbu'});ACT.buildPop({city:'yfb'});");
|
||
ev(ready + ";fireFailure('wspur');compute()");
|
||
const s0 = ev('JSON.stringify(S)'), s1 = ev('JSON.stringify(migrate(JSON.parse(JSON.stringify(S))))');
|
||
assert.ok(s0 === s1, 'a reload changes nothing: ' + firstDiff(s0, s1).join(', '));
|
||
// Broken saves.
|
||
const fix = (code) => J(ev, `(()=>{const s=JSON.parse(JSON.stringify(S));${code};return migrate(s);})()`);
|
||
let s = fix("s.pops.suv.wisp.bogus={day:0,d:1};s.pops.suv.wisp.vavau={day:0,d:1};s.pops.suv.wisp.constructor={day:0,d:1}");
|
||
assert.deepEqual(Object.keys(s.pops.suv.wisp), ['vanualevu'], 'unknown and misplaced zones go');
|
||
s = fix("s.pops.suv.wisp.vanualevu.sat.bird='is37'");
|
||
assert.equal(s.pops.suv.wisp.vanualevu.sat, undefined, 'a bird that does not see the islands');
|
||
s = fix("s.pops.suv.wisp.vanualevu.sat.bird='o3b'");
|
||
assert.equal(s.pops.suv.wisp.vanualevu.sat, undefined, 'MEO without tracking antennas');
|
||
s = fix("s.pops.suv.wisp.vanualevu.nxt=s.pops.suv.wisp.vanualevu.sat;delete s.pops.suv.wisp.vanualevu.sat");
|
||
assert.equal(s.pops.suv.wisp.vanualevu.sat.bird, 'kac1', 'a move without a circuit is the circuit');
|
||
assert.equal(s.pops.suv.wisp.vanualevu.nxt, undefined);
|
||
s = fix("s.pops.suv.wisp.vanualevu.sat.g=3;s.pops.suv.wisp.vanualevu.d='x'");
|
||
assert.equal(s.pops.suv.wisp.vanualevu.sat.g, 2, 'a size the orbit sells');
|
||
assert.equal(s.pops.suv.wisp.vanualevu.d, 0);
|
||
s = fix("s.pops.yfb.wisp={nunavut:{day:0,d:1,sp:{day:0,ready:5}}}");
|
||
assert.deepEqual(s.pops.yfb.wisp.nunavut, { day: 0, d: 1 }, 'no spur where none can be laid');
|
||
s = fix("delete s.pops.suv.wisp.vanualevu.sp");
|
||
assert.equal(s.inc.some((i) => i.type === 'wspur'), false, 'a cut without its spur goes');
|
||
s = fix("delete s.pops.suv.tele");
|
||
assert.equal(s.pops.suv.wisp.vanualevu.sat, undefined, 'no teleport, no circuit');
|
||
s = fix("s.pops.suv.wisp=[1]");
|
||
assert.equal(s.pops.suv.wisp, undefined);
|
||
// The gate flipping (below level 2) leaves the homes as they were, and nothing in the money.
|
||
const d0 = ev(`${Z}.d`);
|
||
ev('S.lvl=1;compute();dayTick()');
|
||
assert.equal(ev(`${Z}.d`), d0);
|
||
assert.ok(Number.isFinite(ev(`${Z}.d`)));
|
||
assert.equal(ev("'wisp' in R.rev||'wisp' in R.cost"), false);
|
||
assert.deepEqual(J(ev, 'R.cityWisp'), {});
|
||
// An old save has no zones and runs as it did.
|
||
ev(`S=migrate(JSON.parse(${JSON.stringify(SAVE)}));compute()`);
|
||
assert.equal(ev("Object.values(S.pops).some(p=>'wisp' in p)"), false);
|
||
assert.equal(ev("'wisp' in R.cost||'wisp' in R.rev"), false);
|
||
assert.ok(ev('R.served') > 0);
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('the teleport stays while a zone rides it; decommissioning the city closes its zones and their cuts at once', (t) => {
|
||
const { ev, errors } = game(t, SUV + VL + "ACT.wispSpur({z:'vanualevu'});ACT.buildPop({city:'syd'});");
|
||
ev(ready + ";fireFailure('wspur')");
|
||
ev("ACT.teleRm({city:'suv'})");
|
||
assert.equal(ev('teleOf("suv")'), 1, 'refused');
|
||
assert.match(ev("JSON.stringify(S.log.slice(0,3).map(e=>e.t))"), /Cancel its satellite circuit first/);
|
||
ev("UI.sel={type:'city',id:'suv'};UI.tab='links';renderAll()");
|
||
assert.ok(!J(ev, "[...document.querySelectorAll('#panel [data-act]')].map(b=>b.dataset.act)").includes('teleRm'), 'no close button');
|
||
ev("ACT.decomOpen({city:'suv'})");
|
||
assert.match(ev("document.getElementById('modalCard').textContent"), /Island Wi-Fi closes with it: Vanua Levu & Taveuni/);
|
||
ev('ACT.decomGo()');
|
||
assert.equal(ev('!!S.pops.suv'), false);
|
||
assert.equal(ev("S.inc.some(i=>i.type==='wspur')"), false, 'the cut goes with it');
|
||
assert.equal(ev('wispAll().length'), 0);
|
||
assert.equal(ev('R.cost.sat||0'), 0);
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('gates: never in puzzles, the Architect or scenarios, and not below level 2', (t) => {
|
||
const { ev, errors } = game(t, SUV + VL);
|
||
ev(ready);
|
||
assert.equal(ev('wispOn()'), true);
|
||
ev("S.lvl=1;compute();UI.sel={type:'city',id:'suv'};UI.tab='cust';renderAll()");
|
||
assert.equal(ev('wispOn()'), false);
|
||
assert.doesNotMatch(ev("document.getElementById('panel').textContent"), /Island Wi-Fi/);
|
||
assert.equal(ev("wispFact('suv')+wispHtml('suv')"), '');
|
||
assert.equal(ev('R.wispL.length'), 0, 'its homes are no demand');
|
||
assert.match(ev("wispSatWhy('vanualevu','kac1',2)"), /level 2/);
|
||
ev("ACT.startScn({id:SCN[0].id})");
|
||
assert.equal(ev('!!S.scn&&wispOn()'), false, 'scenarios');
|
||
ev("ACT.pzStart({id:PZ[0].id})");
|
||
assert.equal(ev("S.mode==='puzzle'&&wispOn()"), false, 'puzzles');
|
||
ev("ACT.pzArStart({id:'euro'})");
|
||
assert.equal(ev('!!S.ar&&wispOn()'), false, 'the Architect');
|
||
ev("ACT.pzLeave();ACT.modeSet({m:'sandbox'});ACT.start({});if(UI.pendGame)ACT.pitchSkip()");
|
||
assert.equal(ev("S.mode==='sandbox'&&wispOn()"), true, 'sandbox has them');
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('Starblink: a gateway on your fiber in the zone\'s own city brings 90% of the islands online at about 30 ms', (t) => {
|
||
const { ev, errors } = game(t, 'S.lvl=5;' + SUV + "ACT.buildPop({city:'yfb'});ACT.teleBuild({city:'yfb'});");
|
||
assert.match(ev("wispSatWhy('vanualevu','sb53',5)"), /gateway/);
|
||
ev("ACT.wispSat({z:'vanualevu',bird:'sb53',g:5})");
|
||
assert.equal(ev(Z), null, 'refused without a gateway');
|
||
ev("ACT.teleLeo({city:'suv'})");
|
||
assert.equal(ev("wispSatWhy('vanualevu','sb53',5)"), '');
|
||
assert.equal(ev(`leoReachLL('suv',WISP.vanualevu.lat,WISP.vanualevu.lon)`), true);
|
||
const rtt = ev("Math.round(2*wispMs('vanualevu','sb53'))");
|
||
assert.ok(rtt >= 25 && rtt <= 45, `about 30 ms round trip, got ${rtt}`);
|
||
// Nunavut is past the shell: GEO only, whatever you build.
|
||
assert.ok(!J(ev, "wispBirds('nunavut')").includes('sb53'));
|
||
assert.match(ev("wispSatWhy('nunavut','sb53',5)"), /does not see both/);
|
||
const c0 = ev('S.cash');
|
||
ev("ACT.wispSat({z:'vanualevu',bird:'sb53',g:5})");
|
||
assert.equal(c0 - ev('S.cash'), ev("wispKit('vanualevu')+wispSatMo('sb53',5)"));
|
||
assert.equal(ev("wispSatMo('sb53',5)"), Math.round(ev("satMo('sb53',5)") * 0.6 / 10) * 10, 'a contended share of Starblink\'s own price');
|
||
ev(ready);
|
||
assert.ok(Math.abs(ev(`wispK('vanualevu',${Z})`) - ev("wispPool('vanualevu')*SAT_ORB.leo.wisp")) < 1e-9, 'about 90% over LEO');
|
||
ev(`${Z}.d=4;compute()`);
|
||
assert.ok(Math.abs(ev('R.wisp.vanualevu.car') - 4) < 1e-9);
|
||
assert.equal(ev('R.cost.sat'), ev("TPORT_MO*2+LEO_GW_MO+wispSatMo('sb53',5)"));
|
||
// The gateway's readout counts the islands landing there; it stays while they ride it.
|
||
ev("UI.sel={type:'city',id:'suv'};UI.tab='links';renderAll()");
|
||
const infra = ev("document.getElementById('panel').textContent");
|
||
assert.match(infra, /Landing here from orbit4\.0 Gbps/);
|
||
assert.ok(!J(ev, "[...document.querySelectorAll('#panel [data-act]')].map(b=>b.dataset.act)").includes('teleLeoRm'));
|
||
ev("ACT.teleLeoRm({city:'suv'});ACT.teleLeoRm({city:'suv'})");
|
||
assert.equal(ev("leoGw('suv')"), true, 'not while a zone rides it');
|
||
// A storm puts it in safe mode too, and a zone alone is enough for one to come.
|
||
assert.equal(ev('leoLive()'), true, 'a zone over LEO is in the sky');
|
||
ev('fireFailure("leostorm");compute()');
|
||
assert.ok(ev('S.ev.sky') > ev('S.day'));
|
||
assert.equal(ev('R.wisp.vanualevu.car'), 0, 'safe mode');
|
||
ev("UI.sel={type:'city',id:'suv'};UI.tab='cust';UI.wz='vanualevu';renderAll()");
|
||
assert.match(ev("document.getElementById('panel').textContent"), /Safe mode through a solar storm/);
|
||
ev('S.day=S.ev.sky;compute()');
|
||
assert.ok(ev('R.wisp.vanualevu.car') > 0, 'back after the storm');
|
||
// Once your own constellation carries, Starblink sells nothing new: no growth, no new zone; the circuit keeps running.
|
||
ev("S.pieV=1;pieInit();S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:false}];compute()");
|
||
assert.equal(ev('leoRival()'), true);
|
||
ev("ACT.wispSatSize({z:'vanualevu',g:10})");
|
||
assert.equal(ev(`${Z}.sat.g`), 5, 'no growth');
|
||
assert.match(ev("wispSatWhy('santo','sb53',5)"), /rival constellation|POP in/);
|
||
assert.ok(ev('R.wisp.vanualevu.car') > 0, 'the circuit already rented keeps carrying');
|
||
ev("ACT.wispSatSize({z:'vanualevu',g:5})");
|
||
// A reload without the gateway drops the LEO circuit; a GEO one stays.
|
||
const s = J(ev, "(()=>{const s=JSON.parse(JSON.stringify(S));delete s.pops.suv.leo;return migrate(s);})()");
|
||
assert.equal(s.pops.suv.wisp.vanualevu.sat, undefined);
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
|
||
test('on a phone: the zones in the Customers tab, the order rows, the spur and the teleport rows, at 360 px', (t) => {
|
||
const { ev, errors } = game(t, SUV);
|
||
ev('window.innerWidth=360;window.innerHeight=740;window.dispatchEvent(new window.Event("resize"))');
|
||
assert.equal(ev('isPhone()'), true);
|
||
const text = (sel) => ev(`(document.querySelector('${sel}')||{}).textContent||''`);
|
||
const acts = (sel) => J(ev, `[...document.querySelectorAll('${sel} [data-act]')].map(b=>b.dataset.act)`);
|
||
// A city with zones and no POP: the chip and the teaser.
|
||
ev("UI.sel={type:'city',id:'tbu'};renderAll()");
|
||
assert.match(text('#panel'), /1 island zone/);
|
||
assert.match(text('#panel'), /Open a POP here to bring Wi-Fi to the islands around it: Vava’u & Ha’apai \(3\.\d Gbps of homes\)/);
|
||
// With a POP and no teleport yet, the teleport's reach counts the islands too.
|
||
ev("ACT.buildPop({city:'tbu'});UI.sel={type:'city',id:'tbu'};UI.tab='links';renderAll()");
|
||
assert.match(text('#panel'), /in reach at your level\.\s*Island Wi-Fi from this teleport: 1 island zone/);
|
||
// The zone, opened, before anything is bought: the birds, the kit, the spur.
|
||
ev("UI.sel={type:'city',id:'suv'};UI.tab='cust';renderAll();ACT.wispOpen({z:'vanualevu'})");
|
||
assert.equal(ev('UI.wz'), 'vanualevu');
|
||
assert.match(text('#panel'), /Island Wi-Fi[^]*No link yet[^]*Backhaul[^]*island kit[^]*Spur cable[^]*Lay the spur/);
|
||
assert.ok(acts('#panel').filter((a) => a === 'wispSat').length >= 4, 'sizes as buttons');
|
||
assert.ok(acts('#panel').includes('teleTrk'), 'MEO: the tracking antennas first');
|
||
ev(VL + ready + ';renderAll()');
|
||
assert.match(text('#panel'), /Homes online[^]*Served on the islands[^]*Towers, solar and crews/);
|
||
assert.ok(acts('#panel').includes('wispSatSize') && acts('#panel').includes('wispSatRm') && acts('#panel').includes('wispRm'));
|
||
// The same button folds it.
|
||
ev("ACT.wispOpen({z:'vanualevu'})");
|
||
assert.equal(ev('UI.wz'), null);
|
||
ev("ACT.wispOpen({z:'vanualevu'})");
|
||
const h = ev("[...document.querySelectorAll('#panel section')].filter(s=>/Island Wi-Fi/.test(s.querySelector('h3').textContent)).map(s=>s.innerHTML).join('')");
|
||
assert.match(h, /Homes online/);
|
||
assert.doesNotMatch(h, /width:\s*\d+px|min-width|color:var\(--bad\)/, 'no fixed widths, no red that dark mode cannot read');
|
||
for (const s of ['#panel', '#toasts']) assert.doesNotMatch(text(s), /wisp\.|satellites\.|undefined|NaN/, s);
|
||
// The teleport lists the zone's circuit, which opens the zone.
|
||
ev("UI.tab='links';renderAll()");
|
||
assert.match(text('#panel'), /Island Wi-Fi from this teleport:[^]*Vanua Levu & Taveuni/);
|
||
assert.ok(acts('#panel').includes('wispOpen'));
|
||
// The dashboard's cost row.
|
||
ev("ACT.wispSpur({z:'vanualevu'});" + ready + ";ACT.dash&&ACT.dash();renderDash&&renderDash()");
|
||
assert.equal(ev("tr('wisp.costs_row')"), 'Island Wi-Fi: towers and spurs');
|
||
assert.deepEqual(errors, []);
|
||
});
|