${btn(UI.confirm==='leo:'+c?tr('satellites.really_close_it'):tr('satellites.close_the_leo_gateway'),'teleLeoRm',{city:c},'ghost sm')}
`;
+ const land=out.reduce((a,l)=>a+(R.load[l.id]||0),0),nl=R.nodeLoad[c]||0,nc=R.nodeCap[c]||nodeCap(c)||1,un=nl/nc,
+ ws=S.links.filter(l=>(l.a===c||l.b===c)&&wiredLink(l)&&!linkDown(l)&&!l.standby),wl=ws.reduce((a,l)=>a+(R.load[l.id]||0),0),wc=ws.reduce((a,l)=>a+capOf(l),0),uw=wc>0?wl/wc:0;
+ return h+`${from.slice(0,4).map(a=>btn(tr('fiber_modals.from_city',{city:CITY[a].name}),'satOpen',{a,b:c},'ghost sm')).join('')}
`;
// Whether a satellite can get to city c: a teleport of yours reaches it, or (once teleports are on sale) a bird you may
@@ -48,6 +66,7 @@ function satModal(a,b){a=isCity(a)?a:null;b=isCity(b)?b:null;
return `${satLogo(P)}
${esc(B.n)} ${O.n}
${esc(P.n)} · ${tr(B.sea)} · ${tr('satellites.ms_round_trip',{ms:satRtt(id,a,b)})} · ${trn('satellites.up_in_n_days',leadDays(O.days))}
${esc(P.blurb)}
${why?`
${esc(why)}
`:''}
${O.g.map(g=>btn(`${fmtCap(g)} ${tr('common.price_mo',{price:fmt$(satMo(id,g))})}`,'buySat',{a,b,bird:id,g},'sm',!!why||S.cash
`;}).join('');
openModal(satModalHead(tr('satellites.satellite_capacity'),`${CITY[a].name} → ${CITY[b].name}`)+`
${tr('satellites.users_notice_geo_meo')}
`
+ +(birds.some(id=>SATS[id].orb==='leo')?`
${tr('satellites.users_notice_leo')}
`:'')
+(pop?`
${tr('satellites.no_pop_there_yet',{city:CITY[b].name,cost:fmt$(pop)})}
`:'')+(sib?`
${tr('satellites.it_waits_on_standby')}
`:'')
+(rows||`
${tr('satellites.no_bird_sees_both',{a:CITY[a].name,b:CITY[b].name})}
`));}
// A circuit's panel: what it carries, its latency and rent, a size up or down, standby and the metric, cancel.
@@ -58,10 +77,11 @@ function satPanel(l){const B=SATS[l.bird],O=SAT_ORB[B.orb],P=SAT_PROV[B.p],load=
if(l.ready>S.day){const tot=Math.max(1,l.ready-l.day),done=clamp((S.day-l.day)/tot,0,1);
h+=`
${tr('satellites.being_commissioned')}
${tr('satellites.pointing_dishes_and_testing')}${tr('common.n_days_left',{n:l.ready-S.day})}
`;}
h+=`
${tr('common.capacity')}
${capName(l)}${l.standby?' · '+tr('common.standby'):''}${fmtG(load)} / ${fmtG(cap)}
+ ${leoDown(l)?`${trn('satellites.leo_safe_mode_n_days',S.ev.sky-S.day)}
`:''}
${tr('common.latency')}${tr('satellites.ms_one_way_rtt',{ms:Math.round(ms),rtt:Math.round(2*ms)})}
${tr('satellites.radio_path')}${l.km.toLocaleString()} km
${tr('satellites.rent')}${tr('common.price_mo',{price:fmt$(l.mo)})}
- ${B.orb==='geo'?tr('satellites.geo_users_notice',{p:pct(O.loss)}):tr('satellites.meo_users_notice',{p:pct(O.loss)})} ${esc(P.blurb)}
+ ${B.orb==='geo'?tr('satellites.geo_users_notice',{p:pct(O.loss)}):B.orb==='meo'?tr('satellites.meo_users_notice',{p:pct(O.loss)}):tr('satellites.leo_users_notice',{p:pct(O.loss),city:CITY[l.a].name})} ${esc(P.blurb)}
${O.g.filter(g=>g!==l.g).map(g=>btn(`${g>l.g?tr('satellites.grow_to',{cap:fmtCap(g)}):tr('satellites.shrink_to',{cap:fmtCap(g)})} ${tr('common.price_mo',{price:fmt$(satMo(l.bird,g))})}`,'satSize',{id:l.id,g},'sm',g>l.g&&S.cash
${trafficSection(l)}${metricSection(l)}
${btn(UI.confirm===l.id?tr('common.really_cancel'):tr('common.cancel_circuit'),'rmLink',{id:l.id},'ghost sm')}
`;
diff --git a/src/i18n/en.js b/src/i18n/en.js
index 1b8c63b..5f796a0 100644
--- a/src/i18n/en.js
+++ b/src/i18n/en.js
@@ -4777,16 +4777,33 @@
"satellites.cancel_n_circuits_first":{"one":"Cancel its satellite circuit first.","other":"Cancel its {n} satellite circuits first."},
"satellites.choose":"Choose",
"satellites.circuit_ordered":{"one":"{cap} on {bird} ordered. {a} ⇄ {b} is being pointed and tested: up in {n} day.","other":"{cap} on {bird} ordered. {a} ⇄ {b} is being pointed and tested: up in {n} days."},
+"satellites.close_the_leo_gateway":"Close the LEO gateway",
"satellites.close_the_teleport":"Close the teleport",
"satellites.costs_row":"Teleports and satellites",
"satellites.geo_dishes":"GEO dishes",
"satellites.geo_dishes_and_meo_tracking":"GEO dishes and MEO tracking antennas",
"satellites.geo_users_notice":"From 36,000 km up the round trip is about 600 ms: video calls and games stutter, and users count {p} of the service as bad.",
"satellites.grow_to":"Grow to {cap}",
+"satellites.host_leo_gateway_cost_mo":"LEO gateway {cost} + {mo}/mo",
"satellites.in_view_list":"In view: {list}.",
"satellites.it_waits_on_standby":"You already have a link between these two: the satellite waits on standby and carries traffic only when that link is down.",
"satellites.its_blurb":"Old-school C-band and Ku-band beams that cover a whole ocean. Reliable, everywhere, and priced like it.",
"satellites.kac_blurb":"Ka-band spot beams over the western Pacific: the cheapest Gbps in orbit, if your island is under a beam.",
+"satellites.leo_backhaul":"Fiber and cables out of {city}",
+"satellites.leo_bottleneck":"{city} is full: every island behind this gateway slows down with it. Add routers, a bigger wave or transit here.",
+"satellites.leo_comes_at_level":"Low-orbit capacity (about 30 ms round trip) comes at level {lv}.",
+"satellites.leo_gateway":"LEO gateway",
+"satellites.leo_gateway_closed":"The LEO gateway in {city} is closed.",
+"satellites.leo_gateway_unwired":"No fiber of yours leaves {city} any more: the islands behind this gateway reach the rest of your network over another satellite.",
+"satellites.leo_gateway_up":"{prov} gateway up in {city}. Their antennas on your roof: rent low-orbit capacity from here to islands within {km} km.",
+"satellites.leo_landing":"Landing here from orbit",
+"satellites.leo_needs_fiber":"A LEO gateway has to sit on your fiber: {city} reaches the rest of your network only by satellite. Land a cable or a wave there, or buy transit, first.",
+"satellites.leo_no_rivals":"{prov} does not sell capacity to a rival constellation, and yours is flying: put a pie dish on the island instead.",
+"satellites.leo_out_of_reach":"{prov} is a bent pipe: one satellite has to see your gateway and the island at once, so they can be at most {km} km apart. {a} to {b} is {d} km.",
+"satellites.leo_safe_mode_n_days":{"one":"Safe mode through a solar storm: back in {n} day.","other":"Safe mode through a solar storm: back in {n} days."},
+"satellites.leo_shell_misses_city":"{prov} does not reach {city}: its shells cover {lat}° either side of the equator.",
+"satellites.leo_storm_msg":"A geomagnetic storm: {prov} puts its satellites in safe mode. Your LEO circuits carry nothing until it passes; standby circuits and cables take what they can.",
+"satellites.leo_users_notice":"Bent pipe from 550 km up, about 30 ms round trip: users hardly notice ({p} of the service counts as bad), and selective networks peer with you as over a cable. It lands at your gateway in {city}: when that POP's routers or fiber fill up, every island behind it slows down.",
"satellites.meo_comes_at_level":"The MEO ring (about 130 ms round trip) comes at level {lv}.",
"satellites.meo_ring_misses_city":"The MEO ring does not see {city}: it covers {lat}° either side of the equator.",
"satellites.meo_users_notice":"Much closer to the ground, about 130 ms round trip: users barely notice ({p} of the service counts as bad).",
@@ -4795,7 +4812,9 @@
"satellites.ms_round_trip":"{ms} ms round trip",
"satellites.n_birds_see_both":{"one":"{n} satellite sees both","other":"{n} satellites see both"},
"satellites.n_circuits_go_on_standby":{"one":"Your satellite circuit between {a} and {b} goes on standby beside the new link: it carries traffic only when that link is down.","other":"Your {n} satellite circuits between {a} and {b} go on standby beside the new link: they carry traffic only when that link is down."},
+"satellites.n_in_leo_reach":{"one":"{n} island or remote town within {km} km of this gateway.","other":"{n} islands and remote towns within {km} km of this gateway."},
"satellites.n_places_in_reach":{"one":"{n} island or remote town in reach at your level.","other":"{n} islands and remote towns in reach at your level."},
+"satellites.needs_leo_gateway":"LEO capacity needs a gateway at your teleport in {city}.",
"satellites.needs_tracking_antennas":"The MEO ring needs tracking antennas at your teleport in {city}.",
"satellites.new_pop_cost":"new POP {cost}",
"satellites.no_bird_sees_both":"No satellite on sale sees both {a} and {b}.",
@@ -4819,9 +4838,11 @@
"satellites.rent_satellite_capacity":"Rent satellite capacity",
"satellites.satellite_capacity":"Satellite capacity",
"satellites.satellites":"Satellites",
+"satellites.sbk_blurb":"Thousands of small satellites 550 km up, about 30 ms there and back: the first satellite your users will not complain about. They blink from one satellite to the next every few seconds; nobody notices.",
"satellites.sea_americas":"Americas",
"satellites.sea_atlantic":"Atlantic",
"satellites.sea_indian":"Indian Ocean",
+"satellites.sea_leo":"within 56° of the equator, 550 km up",
"satellites.sea_pacific":"Pacific",
"satellites.sea_tropics":"within 50° of the equator",
"satellites.sea_west_pacific":"Western Pacific",
@@ -4833,7 +4854,8 @@
"satellites.teleports_unlock_at_level":"Teleports unlock at level {lv}.",
"satellites.tracking_antennas_up":"Tracking antennas up in {city}. They follow the MEO ring across the sky.",
"satellites.up_in_n_days":{"one":"up in {n} day","other":"up in {n} days"},
-"satellites.users_notice_geo_meo":"Users notice the lag: broadband over GEO counts as half the service, over MEO almost all of it. A cable always beats it, so your routers only send traffic up when there is no other way.",
+"satellites.users_notice_geo_meo":"Users notice the lag: broadband over GEO counts as half the service, over MEO almost all of it. A cable beats both, so your routers only send traffic up there when there is no other way.",
+"satellites.users_notice_leo":"Over LEO, about 30 ms round trip, users hardly notice, and selective networks peer as they would over a cable. Next to a cable it waits on standby.",
"satellites.users_ride_a_satellite":"users ride a satellite",
"satellites.via_bird":"via {bird}",
"satellites.who_a_satellite_serves":"Satellites serve small islands and remote towns that the same satellite sees as your teleport. Pick where to.",
diff --git a/tests/canonical-state.test.js b/tests/canonical-state.test.js
index b6efd87..be64b9d 100644
--- a/tests/canonical-state.test.js
+++ b/tests/canonical-state.test.js
@@ -2,8 +2,9 @@
// A server-run network's page loads the server's state with migrate() (it never trusts state it did not check), and
// the server checks every action against the save path; both need migrate(live S) to change nothing. A year of a big
// network with everything on (DDoS, failures, events, the intern on every order, the sales desk on auto, IPv6-only, and
-// once before the year everything else a network can own: an own exchange, scrubbing centers, teleports, satellites,
-// dark fiber, an own cable, a subsea seat, exchange points, the backbone core, the redundancy kit, the bulk orders),
+// once before the year everything else a network can own: an own exchange, scrubbing centers, teleports, LEO gateways,
+// satellites, dark fiber, an own cable, a subsea seat, exchange points, the backbone core, the redundancy kit, the bulk
+// orders),
// checked every day. T1_BASE= also plays the same year on the page at that ref: the same money, customers,
// incidents, dice and ids every day, so making the state canonical changed no play.
const test = require('node:test');
@@ -29,6 +30,8 @@ function open(file) {
for(const c of pops.slice(0,40)){if(Object.keys(S.myIx).length)break;tryA('foundIx',{city:c});}
for(const c of pops.slice(0,6))tryA('buildScrub',{city:c});
for(const c of pops.slice(0,4))tryA('teleBuild',{city:c});
+ for(const c of pops.slice(0,4))tryA('teleLeo',{city:c});
+ {let n=0;for(const a of pops.slice(0,4))for(const b of satTargets(a)){if(n>=1)break;if(!satWhy(a,b,LEO_BIRD,5)){tryA('buySat',{a,b,bird:LEO_BIRD,g:5});n++;}}}
{let n=0;for(const a of pops.slice(0,12))for(const b of pops.slice(12,30)){if(n>=2)break;for(const bird of Object.keys(SATS))for(const g of [1,2,5,10]){if(n>=2)break;if(!satWhy(a,b,bird,g)){tryA('buySat',{a,b,bird,g});n++;}}}}
{let n=0;for(const a of pops.slice(0,10))for(const b of pops.slice(10,40)){if(n>=2)break;if(kmBetween(a,b)<900&&!noTalk(a,b)){UI.pending={a,b};UI.dfSrc='build';const k=S.links.length;tryA('orderDf');if(S.links.length>k)n++;}}}
{let n=0;for(const a of pops.slice(0,30))for(const b of Object.keys(CITY)){if(n>=1)break;if(S.pops[b]||a===b)continue;UI.pending={a,b};const k=S.links.length;if(!ownCabWhy(a,b)){tryA('orderCable');if(S.links.length>k)n++;}}}
@@ -41,7 +44,7 @@ function open(file) {
UI.pending=null;closeModal();compute();`);
return h;
}
-const BUILT = ['foundIx', 'buildScrub', 'teleBuild', 'buySat', 'orderDf', 'orderCable', 'seatBuy', 'coreUp', 'xpBuild', 'utilityKit', 'pniAll', 'bstdApply'];
+const BUILT = ['foundIx', 'buildScrub', 'teleBuild', 'teleLeo', 'buySat', 'orderDf', 'orderCable', 'seatBuy', 'coreUp', 'xpBuild', 'utilityKit', 'pniAll', 'bstdApply'];
// In the page: every top-level key whose JSON differs between live S and what a reload makes of it, both ways a reload
// happens (the full state a page takes, and the save text). uidN and the dice are put back: a reload may draw ids.
@@ -82,6 +85,7 @@ test(`a year of a big network with everything on: live state is what a reload ma
const did = JSON.parse(head.ev('JSON.stringify(__did)'));
assert.deepEqual(did.filter((x) => / threw /.test(x)), [], 'nothing threw while building');
for (const a of BUILT) assert.ok(did.includes(a), `${a} built something before the year (${did.join(', ')})`);
+ assert.ok(head.ev('S.links.some(l=>l.bird===LEO_BIRD)'), 'a LEO circuit before the year');
assert.equal(head.ev('S.slAuto.on'), true);
assert.ok(head.ev("Object.values(S.pops).filter(p=>p.bb&&(p.bb.v6||p.bb.v6e)).length") >= 3, 'IPv6-only homes on the way');
const seen = { ddos: 0, inc: 0, starts: 0 };
diff --git a/tests/gameplay-rules.test.js b/tests/gameplay-rules.test.js
index 80b06db..d66e58f 100644
--- a/tests/gameplay-rules.test.js
+++ b/tests/gameplay-rules.test.js
@@ -733,6 +733,32 @@ test('O7: a fresh Tier 1 cannot afford a full Shortcrust in its first year', ()
// O7's other half (a full lasered Shortcrust pays back in 5 to 10 years, never sooner) is played through the game loop
// in tests/pie-balance.test.js, so it counts launches, aging, incidents, churn and every running cost.
+test('O8: rented LEO reaches only near a gateway on your fiber under its shell, stops selling once your crust carries, and costs more than a subsea wave', () => {
+ const g = load();
+ g.ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e9;S.lvl=SAT_ORB.leo.lv;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze')");
+ // Every pair the bird is sold on: at most km apart, both ends under the shell.
+ fail('O8', JSON.parse(g.ev("JSON.stringify((()=>{const O=SAT_ORB.leo,out=[];for(const A of CITIES)for(const B of CITIES){if(A.id>=B.id||!satPairOk(LEO_BIRD,A.id,B.id))continue;if(kmBetween(A.id,B.id)>O.km||Math.abs(A.lat)>O.lat||Math.abs(B.lat)>O.lat)out.push(A.id+'-'+B.id+' '+kmBetween(A.id,B.id)+' km');}return out;})())")),
+ 'a LEO circuit beyond one satellite\'s bent pipe: keep SAT_ORB.leo.km and lat in satPairOk');
+ assert.ok(g.ev("Object.keys(SATS).filter(id=>SATS[id].orb==='leo').join()===LEO_BIRD"), 'O8: one rented LEO bird');
+ // The gateway sits on your fiber: an island only a satellite reaches cannot host one; beyond the shell, nobody can.
+ g.ev("ACT.buildPop({city:'suv'});ACT.teleBuild({city:'suv'});ACT.buildPop({city:'anc'});S.pops.anc.tele=1;ACT.buildPop({city:'ccs'});ACT.teleBuild({city:'ccs'})");
+ assert.notEqual(g.ev("leoGwWhy('suv')"), '', 'O8: a gateway on an island off your fiber');
+ assert.notEqual(g.ev("leoGwWhy('anc')"), '', 'O8: a gateway beyond the shell');
+ assert.notEqual(g.ev("satWhy('ccs','cur',LEO_BIRD,10)"), '', 'O8: a LEO circuit without a gateway');
+ g.ev("ACT.teleLeo({city:'ccs'});ACT.buySat({a:'ccs',b:'cur',bird:LEO_BIRD,g:10});closeModal();ACT.buyTransit({city:'ccs',net:'drz',tier:1});ACT.launchBB({city:'cur'});closeModal()");
+ assert.equal(g.ev('S.links.filter(l=>l.bird===LEO_BIRD).length'), 1, 'O8: a gateway on the mainland sells');
+ // Your own crust carries: nothing new from Starblink, not even growth; what you rent keeps running.
+ g.ev('S.pieV=1;pieInit();S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:false}];S.day=S.links.find(l=>l.bird===LEO_BIRD).ready;compute()');
+ assert.ok(g.ev('Object.keys(CRUSTS).some(id=>pieCarry(id)>0)'), 'a crust carries');
+ for (const x of ["satWhy('ccs','gnd',LEO_BIRD,10)", "leoGwWhy('ccs')", 'leoGrowWhy(S.links.find(l=>l.bird===LEO_BIRD))']) assert.notEqual(g.ev(x), '', `O8: ${x} once your own constellation carries`);
+ assert.equal(g.ev("leoReachLL('ccs',CITY.cur.lat,CITY.cur.lon)"), false, 'O8: no WISP reach either');
+ assert.ok(g.ev('R.load[S.links.find(l=>l.bird===LEO_BIRD).id]') > 0, 'O8: a circuit you rent keeps carrying');
+ // Dearer per Gbps than any subsea wave over its whole reach, so a cable is always the better buy where one can go.
+ const dear = JSON.parse(g.ev('JSON.stringify(SAT_ORB.leo.g.flatMap(n=>LT.map((t,i)=>[n,t.g,satMo(LEO_BIRD,n)/n,waveMo(SAT_ORB.leo.km,true,i)/t.g])))'));
+ fail('O8', dear.filter((x) => x[2] <= x[3]).map((x) => `${x[0]}G LEO at ${Math.round(x[2])}/G is no dearer than a ${x[1]}G subsea wave at ${Math.round(x[3])}/G`), 'raise SAT_PROV.sbk.pg');
+ assert.deepEqual(g.errors, []);
+});
+
test('no page errors while checking the rules', () => {
assert.deepEqual(errors, []);
});
diff --git a/tests/leo.test.js b/tests/leo.test.js
new file mode 100644
index 0000000..47b640e
--- /dev/null
+++ b/tests/leo.test.js
@@ -0,0 +1,364 @@
+// Rented low-orbit capacity (#83): a Starblink gateway on a teleport at a POP on your fiber sells LEO circuits (5 to
+// 50 Gbps, about 30 ms round trip) to small islands and remote towns within 1,200 km. A circuit is a link (kind 'sat') like
+// GEO and MEO ones; selective networks peer over it as over a cable; the islands behind a gateway lean on its POP; a rare
+// solar storm puts every LEO circuit in safe mode; once your own constellation carries traffic Starblink sells you nothing.
+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 { createSession, TOOLS } = require('../scripts/lib/mcp-game');
+
+const SAVE = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8');
+// Level 5, Change Freeze (nothing breaks, 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=5;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');";
+// Caracas: a POP with transit (Caracas sells drz, mvs and llt) and a teleport.
+const CAR = "ACT.buildPop({city:'ccs'});ACT.buyTransit({city:'ccs',net:'drz',tier:1});ACT.teleBuild({city:'ccs'});";
+const GW = CAR + "ACT.teleLeo({city:'ccs'});";
+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 leo = "S.links.find(l=>l.bird==='sb53')", geo = "S.links.find(l=>l.kind==='sat'&&SATS[l.bird].orb==='geo')";
+const ready = 'S.day=Math.max(...S.links.map(l=>l.ready||0));compute()';
+const pie = "S.pieV=1;pieInit();S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:false}];";
+
+test('the footprint and the physics: a bent pipe 550 km up, regional, about 30 ms', (t) => {
+ const { ev, errors } = game(t);
+ assert.deepEqual(J(ev, "['tbu','cur','ome','hpa'].map(c=>satSees('sb53',c))"), [true, true, false, false], 'the shell misses Nome and Haparanda');
+ assert.deepEqual(J(ev, "[['suv','tbu'],['suv','vli'],['ccs','cur'],['syd','tbu']].map(([a,b])=>satPairOk('sb53',a,b))"), [true, true, true, false], 'Sydney to Tonga is too far for one satellite');
+ // Every LEO pair on sale with an island or a remote town in it clears the floor at the midpoint and the reach.
+ const bad = J(ev, "(()=>{const O=SAT_ORB.leo,out=[];for(const A of CITIES)for(const B of CITIES){if(A.id>=B.id||!(satRemote(A.id)||satRemote(B.id))||!satPairOk('sb53',A.id,B.id))continue;if(satElev(satArc(A.lat,A.lon,B.lat,B.lon)/2,O.h)O.km||satKm('sb53',A.id,B.id)<2*O.h)out.push(A.id+'-'+B.id);}return out;})()");
+ assert.deepEqual(bad, []);
+ for (const [a, b] of [['ccs', 'cur'], ['suv', 'vli']]) {
+ const rtt = ev(`satRtt('sb53','${a}','${b}')`);
+ assert.ok(rtt >= 25 && rtt <= 45, `${a}-${b}: about 30 ms round trip, got ${rtt}`);
+ }
+ assert.ok(ev("satKm('sb53','ccs','cur')") >= 2 * 550, 'up to the shell and back down');
+ // The orbits are told apart by their loss in satEdges/satAfter, so none may share one.
+ assert.equal(new Set(J(ev, 'Object.values(SAT_ORB).map(o=>o.loss)')).size, 3);
+ assert.deepEqual(J(ev, 'Object.keys(SAT_ORB)'), ['geo', 'meo', 'leo']);
+ assert.equal(J(ev, "satBirds('ccs','cur')").pop(), 'sb53', 'orbit order: GEO, MEO, then LEO');
+ assert.deepEqual(errors, []);
+});
+
+test('the WISP hooks: radio path, one-way ms and reach for any point on the globe, and they change nothing', (t) => {
+ const { ev, errors } = game(t, CAR);
+ const P = "CITY.cur.lat,CITY.cur.lon";
+ assert.equal(ev(`leoKmLL('ccs',${P})`), ev("satKm('sb53','ccs','cur')"), 'the same radio path as a circuit to the city there');
+ assert.ok(Math.abs(ev(`leoMsLL('ccs',${P})`) - ev("satLat({bird:'sb53',km:satKm('sb53','ccs','cur')})")) < 1e-9);
+ assert.equal(ev(`leoReachLL('ccs',${P})`), false, 'no gateway yet');
+ ev("ACT.teleLeo({city:'ccs'})");
+ const s0 = ev('JSON.stringify(S)');
+ assert.equal(ev(`leoReachLL('ccs',${P})`), true);
+ assert.equal(ev("leoReachLL('ccs',25,-77)"), false, 'Nassau’s point is too far for one satellite');
+ assert.equal(ev("leoReachLL('ccs',60,-66)"), false, 'beyond the shell');
+ assert.equal(ev('JSON.stringify(S)'), s0, 'pure');
+ assert.equal(ev(`S.lvl=4;leoReachLL('ccs',${P})`), false, 'below level 5');
+ ev('S.lvl=5;' + pie);
+ assert.equal(ev(`leoReachLL('ccs',${P})`), false, 'your own constellation flies');
+ assert.equal(ev('leoStorm()'), false);
+ assert.deepEqual(errors, []);
+});
+
+test('a gateway: level 5, a teleport under the shell on your fiber, its price; closing it asks twice', (t) => {
+ const { ev, errors } = game(t, CAR);
+ let c0 = ev('S.cash');
+ ev("S.lvl=4;ACT.teleLeo({city:'ccs'})");
+ assert.equal(ev("'leo' in S.pops.ccs"), false, 'LEO unlocks at level 5');
+ assert.equal(ev('S.cash'), c0, 'nothing charged');
+ ev("S.lvl=5;ACT.teleLeo({city:'ccs'});compute()");
+ assert.equal(ev('S.pops.ccs.leo'), 1);
+ assert.equal(c0 - ev('S.cash'), ev('LEO_GW_COST'));
+ assert.equal(ev('R.cost.sat'), ev('TPORT_MO+LEO_GW_MO'), 'the gateway bills with the teleports');
+ // Suva with a teleport and only a satellite out: no gateway until a wave of yours is lit there.
+ ev("ACT.buildPop({city:'syd'});ACT.buyTransit({city:'syd',net:'cog',tier:1});ACT.buildPop({city:'suv'});ACT.teleBuild({city:'suv'})");
+ assert.equal(ev("teleOf('suv')"), 1);
+ assert.match(ev("leoGwWhy('suv')"), /fiber/);
+ c0 = ev('S.cash');
+ ev("ACT.teleLeo({city:'suv'})");
+ assert.equal(ev("'leo' in S.pops.suv"), false);
+ assert.equal(ev('S.cash'), c0);
+ ev("UI.pending={a:'syd',b:'suv'};ACT.buildLink({tier:1});closeModal();S.links.find(l=>l.kind==='wave').ready=S.day+5");
+ assert.match(ev("leoGwWhy('suv')"), /fiber/, 'still being built');
+ ev("S.day=S.links.find(l=>l.kind==='wave').ready");
+ assert.equal(ev("leoGwWhy('suv')"), '', 'lit: Suva is on your fiber');
+ // Anchorage is beyond the shell; Edinburgh, just inside it, needs no tracking antennas.
+ ev("ACT.buildPop({city:'anc'});S.pops.anc.tele=1;ACT.buildPop({city:'edi'});ACT.teleBuild({city:'edi'})");
+ assert.match(ev("leoGwWhy('anc')"), /56°/);
+ assert.equal(ev("leoGwWhy('edi')"), '');
+ assert.match(ev("leoGwWhy('lon')"), /no POP/);
+ // Closing: refused while a LEO circuit starts there, and two taps.
+ ev("ACT.buySat({a:'ccs',b:'cur',bird:'sb53',g:5});closeModal();ACT.teleLeoRm({city:'ccs'});ACT.teleLeoRm({city:'ccs'})");
+ assert.equal(ev('S.pops.ccs.leo'), 1, 'not while a LEO circuit starts there');
+ ev(`ACT.rmLink({id:${leo}.id});ACT.rmLink({id:${leo}.id})`);
+ assert.equal(ev(`!!${leo}`), false);
+ ev("UI.confirm=null;ACT.teleLeoRm({city:'ccs'})");
+ assert.equal(ev('S.pops.ccs.leo'), 1, 'the first tap only arms it');
+ ev("ACT.teleLeoRm({city:'ccs'})");
+ assert.equal(ev("'leo' in S.pops.ccs"), false);
+ assert.equal(ev("teleOf('ccs')"), 1, 'the teleport stays');
+ // Closing the teleport takes the gateway along.
+ ev("ACT.teleLeo({city:'ccs'});UI.confirm=null;ACT.teleRm({city:'ccs'});ACT.teleRm({city:'ccs'})");
+ assert.equal(ev("teleOf('ccs')"), 0);
+ assert.equal(ev("'leo' in S.pops.ccs"), false);
+ assert.deepEqual(errors, []);
+});
+
+test('a LEO circuit: price, lead time, about 30 ms, users hardly notice; refused without a gateway or beyond the bent pipe', (t) => {
+ const { ev, errors } = game(t, CAR);
+ assert.match(ev("satWhy('ccs','cur','sb53',10)"), /gateway/);
+ ev("ACT.buySat({a:'ccs',b:'cur',bird:'sb53',g:10})");
+ assert.equal(ev(`!!${leo}`), false, 'no gateway, no circuit');
+ ev("ACT.teleLeo({city:'ccs'})");
+ const c0 = ev('S.cash');
+ ev("ACT.buySat({a:'ccs',b:'cur',bird:'sb53',g:10})");
+ const l = J(ev, leo);
+ assert.ok(ev('!!S.pops.cur'), 'the order builds the POP');
+ assert.equal(c0 - ev('S.cash'), ev("satMo('sb53',10)+popCost('cur')"));
+ assert.equal(l.mo, ev("satMo('sb53',10)"));
+ assert.equal(l.ready, ev('S.day+leadDays(14)'));
+ assert.equal(!!l.standby, false);
+ ev('compute()');
+ assert.equal(ev(`linkDown(${leo})`), true, 'down while it is pointed');
+ ev("ACT.launchBB({city:'cur'});closeModal();" + ready);
+ assert.ok(ev(`R.load[${leo}.id]`) > 0);
+ const ms = ev(`linkLat(${leo})`);
+ assert.ok(ms >= 12 && ms <= 23, 'one way: ' + ms);
+ assert.ok(Math.abs(ev('R.latF.cur') - 0.97) < 1e-9, 'users count 3% as bad');
+ assert.ok(ev("sfOf(R,'cur')") >= 0.95, 'so broadband keeps growing');
+ assert.equal(ev("/fact bad/.test(satFact('cur'))"), false, 'a plain chip: they hardly notice');
+ assert.match(ev("satFact('cur')"), /users ride a satellite/);
+ // Beyond the bent pipe: both under the shell but 1,958 km apart.
+ assert.match(ev("satWhy('ccs','nas','sb53',10)"), /bent pipe.*1,200 km.*1,958 km/);
+ assert.match(ev("satWhy('ccs','cur','sb53',7)"), /No such satellite circuit/);
+ // The price ladder: half MEO per Gbps; the smallest order dearer than the cheapest GEO; far dearer than a subsea wave.
+ assert.ok(ev("satMo('sb53',20)/20") < ev("satMo('o3b',20)/20"));
+ assert.ok(ev("satMo('sb53',5)") > ev("satMo('kac1',1)"));
+ const wave = ev("waveMo(kmBetween('suv','tbu'),true,1)/LT[1].g");
+ for (const g of [10, 50]) assert.ok(ev(`satMo('sb53',${g})/${g}`) > 3 * wave, `LEO ${g}G per Gbps against a wave`);
+ assert.deepEqual(errors, []);
+});
+
+test('selective peers do not refuse an island only LEO reaches; a circuit being pointed does not change their verdict', (t) => {
+ const { ev, errors } = game(t, CAR + "ACT.buySat({a:'ccs',b:'cur',bird:'is37',g:5});closeModal();");
+ ev(ready + ";ACT.buyIx({city:'cur',tier:0});closeModal();compute()");
+ assert.equal(ev("satOnly('cur').bird"), 'is37');
+ const sel = J(ev, "ixMembers('cur').filter(id=>NET[id].pol==='selective')");
+ const geoNo = sel.filter((id) => ev(`noSat('${id}','geo')`));
+ assert.ok(geoNo.length > 0, 'some members of Blue-Curaçao-IX refuse GEO: ' + sel.join(','));
+ for (const id of geoNo) assert.equal(J(ev, `peerOk('${id}','ix','cur')`).sat, true, id + ' over GEO');
+ // LEO ordered: the GEO circuit goes on standby, but until LEO is commissioned the GEO one is the way out they judge.
+ ev("ACT.teleLeo({city:'ccs'});ACT.buySat({a:'ccs',b:'cur',bird:'sb53',g:10});closeModal();compute()");
+ assert.equal(ev(`${geo}.standby`), true);
+ assert.equal(ev("satOnly('cur').bird"), 'is37', 'a circuit being pointed does not count yet');
+ ev(ready);
+ assert.equal(ev("satOnly('cur').bird"), 'sb53', 'still a satellite island');
+ for (const id of geoNo) {
+ for (const via of ['ix', 'pni']) assert.ok(!J(ev, `peerOk('${id}','${via}','cur')`).sat, `${id} ${via} over LEO`);
+ ev(`S.peers['${id}@cur']=true`);
+ }
+ ev('compute()');
+ for (const id of geoNo) assert.equal(ev(`ixSessions('cur').has('${id}')`), true, id + ' peers over LEO');
+ assert.ok(J(ev, 'NETS.map(n=>n.id)').every((id) => !ev(`noSat('${id}','leo')`)), 'nobody minds LEO');
+ // MEO first, commissioned, then LEO being pointed: the MEO circuit, on standby now, is still the one they judge.
+ ev("S.links=S.links.filter(l=>l.kind!=='sat');S.pops.ccs.tele=2;ACT.buySat({a:'ccs',b:'cur',bird:'o3b',g:5});closeModal();" + ready);
+ ev("ACT.buySat({a:'ccs',b:'cur',bird:'sb53',g:10});closeModal();compute()");
+ assert.equal(ev("S.links.find(l=>l.bird==='o3b').standby"), true);
+ assert.equal(ev("satOnly('cur').bird"), 'o3b');
+ assert.deepEqual(errors, []);
+});
+
+test('one satellite a pair: LEO puts GEO on standby, GEO ordered beside LEO waits, and carries when LEO is down', (t) => {
+ const { ev, errors } = game(t, GW + "ACT.buySat({a:'ccs',b:'cur',bird:'is37',g:5});closeModal();");
+ ev(ready + ";ACT.launchBB({city:'cur'});closeModal();ACT.buySat({a:'ccs',b:'cur',bird:'sb53',g:10});closeModal();renderAll()");
+ assert.equal(ev(`${geo}.standby`), true, 'the GEO circuit waits');
+ assert.equal(!!ev(`${leo}.standby`), false);
+ assert.match(ev("document.querySelector('#toasts').textContent"), /goes on standby/);
+ ev(ready);
+ assert.ok(ev(`R.load[${leo}.id]`) > 0 && !(ev(`R.load[${geo}.id]`) > 0), 'LEO carries, GEO stands by');
+ // A solar storm: the GEO circuit carries the island.
+ ev('S.ev.sky=S.day+2;compute()');
+ assert.equal(ev(`linkDown(${leo})`), true);
+ assert.ok(ev(`R.load[${geo}.id]`) > 0, 'GEO takes over');
+ // GEO ordered beside an active LEO circuit starts on standby.
+ ev(`S.ev.sky=0;S.links=S.links.filter(l=>l.bird!=='is37');ACT.buySat({a:'ccs',b:'cur',bird:'gx19',g:5});closeModal()`);
+ assert.equal(ev("S.links.find(l=>l.bird==='gx19').standby"), true);
+ assert.equal(!!ev(`${leo}.standby`), false);
+ // A cable laid later puts LEO on standby too.
+ ev("UI.pending={a:'ccs',b:'cur'};ACT.buildLink({tier:1});closeModal()");
+ assert.equal(ev(`${leo}.standby`), true);
+ assert.deepEqual(errors, []);
+});
+
+test('the gateway POP is the islands’ bottleneck: its fiber full, every island behind it slows down, and the Infra tab says so', (t) => {
+ const isl = ['cur', 'gnd', 'svd', 'slu'];
+ const { ev, errors } = game(t, "ACT.buildPop({city:'ccs'});ACT.teleBuild({city:'ccs'});ACT.teleLeo({city:'ccs'});ACT.buildPop({city:'bog'});ACT.buyTransit({city:'bog',net:NETS.find(n=>sellsAt(n,'bog')).id,tier:1});UI.pending={a:'ccs',b:'bog'};ACT.buildLink({tier:0});closeModal();");
+ assert.equal(ev("noTalk('ccs','bog')"), '');
+ ev(`for(const c of ${JSON.stringify(isl)}){ACT.buySat({a:'ccs',b:c,bird:'sb53',g:10});closeModal();ACT.launchBB({city:c});closeModal();S.pops[c].bb.d=7;}` + ready);
+ const srv = () => ev(`${JSON.stringify(isl)}.reduce((a,c)=>a+(R.citySrv[c]||0),0)`);
+ assert.ok(ev(`${JSON.stringify(isl)}.reduce((a,c)=>a+R.cityDem[c],0)`) >= 25);
+ assert.ok(srv() <= 10 + 1e-6, 'four islands through one 10G wave: ' + srv());
+ const panel = () => { ev("UI.sel={type:'city',id:'ccs'};UI.tab='links';renderAll()"); return ev("document.querySelector('#panel').textContent"); };
+ let p = panel();
+ assert.match(p, /every island behind this gateway slows down/);
+ assert.match(p, /Landing here from orbit/);
+ assert.match(p, /Fiber and cables out of Caracas/);
+ ev("UI.pending={a:'ccs',b:'bog'};ACT.buildLink({tier:1});closeModal();" + ready);
+ assert.ok(srv() >= 0.9 * 28, 'a 100G wave lets them through: ' + srv());
+ p = panel();
+ assert.doesNotMatch(p, /every island behind this gateway slows down/);
+ assert.deepEqual(errors, []);
+});
+
+test('Pie in the Sky: once your crust carries, Starblink sells you nothing new; what you rent keeps running, on its own bill', (t) => {
+ const { ev, errors } = game(t, GW + "ACT.buySat({a:'ccs',b:'cur',bird:'sb53',g:10});closeModal();ACT.launchBB({city:'cur'});closeModal();ACT.buildPop({city:'bog'});ACT.teleBuild({city:'bog'});");
+ ev(ready);
+ assert.equal(ev('leoRival()'), false);
+ ev(pie + 'compute()');
+ assert.equal(ev('leoRival()'), true, 'a full Shortcrust carries');
+ assert.match(ev("satWhy('ccs','gnd','sb53',10)"), /rival constellation/);
+ ev("ACT.buySat({a:'ccs',b:'gnd',bird:'sb53',g:10})");
+ assert.equal(ev("S.links.some(l=>l.b==='gnd')"), false, 'no new circuit');
+ const c0 = ev('S.cash');
+ ev(`ACT.satSize({id:${leo}.id,g:20})`);
+ assert.equal(ev(`${leo}.g`), 10, 'no growing');
+ assert.equal(ev('S.cash'), c0);
+ assert.match(ev(`leoGrowWhy(${leo})`), /rival constellation/);
+ assert.match(ev("leoGwWhy('bog')"), /rival constellation/);
+ ev("ACT.teleLeo({city:'bog'})");
+ assert.equal(ev("'leo' in S.pops.bog"), false, 'no new gateway');
+ ev(`ACT.satSize({id:${leo}.id,g:5});compute()`);
+ assert.equal(ev(`${leo}.g`), 5, 'shrinking works');
+ assert.ok(ev(`R.load[${leo}.id]`) > 0, 'the circuit still carries');
+ assert.ok(ev('R.cost.sat') >= ev(`${leo}.mo+LEO_GW_MO`), 'rented LEO is on the satellite bill');
+ const spent = ev('S.pie.book.spent');
+ ev('dayTick()');
+ assert.equal(ev('S.pie.book.spent'), spent, 'never on the rocket company’s books');
+ assert.deepEqual(errors, []);
+});
+
+test('a solar storm: every LEO circuit in safe mode for a day or two, no cut, no bill; Pie’s storms are the same sun', (t) => {
+ const { ev, errors } = game(t, GW + "ACT.buySat({a:'ccs',b:'cur',bird:'sb53',g:10});closeModal();ACT.buySat({a:'ccs',b:'gnd',bird:'is37',g:5});closeModal();");
+ ev(ready);
+ assert.equal(ev('leoLive()'), true);
+ const c0 = ev('S.cash');
+ ev("fireFailure('leostorm')");
+ const d = ev('S.ev.sky-S.day');
+ assert.ok(d >= 1 && d <= 2, 'one or two days: ' + d);
+ assert.equal(ev(`linkDown(${leo})`), true);
+ assert.equal(ev(`linkDown(${geo})`), false, 'GEO flies on');
+ assert.equal(ev("S.links.filter(l=>l.kind==='sat').every(l=>!l.cut)"), true, 'nobody cut a satellite');
+ assert.equal(ev("incTitle('leostorm')"), 'Solar storm');
+ const i = J(ev, "S.inc.find(x=>x.type==='leostorm')");
+ assert.equal(i.until, ev('S.ev.sky'));
+ assert.equal(i.cost, 0, 'nothing to rush');
+ assert.equal(ev('S.cash'), c0);
+ assert.match(ev(`satPanel(${leo})`), /Safe mode through a solar storm: back in \d days?\./);
+ ev('S.day=S.ev.sky');
+ assert.equal(ev(`linkDown(${leo})`), false, 'back when it passes');
+ // Clearing the incident clears the storm, and leaves the key.
+ ev("S.inc=[];S.ev.sky=0;fireFailure('leostorm');clearInc(S.inc.find(x=>x.type==='leostorm'))");
+ assert.equal(ev('S.ev.sky'), 0);
+ // Spicy chaos stretches it, and the outage follows, within what a save keeps.
+ ev("S.inc=[];S.rules.chaos='spicy';fireFailure('leostorm');S.rules.chaos='none'");
+ assert.equal(ev("S.inc.find(x=>x.type==='leostorm').until"), ev('S.ev.sky'));
+ assert.ok(ev('S.ev.sky-S.day') <= ev('LEO_STORM_MAX'));
+ // Saves: the day is a number no later than LEO_STORM_MAX ahead, and the key stays.
+ ev("S.ev.sky='junk';S=migrate(JSON.parse(JSON.stringify(S)))");
+ assert.equal(ev('S.ev.sky'), 0);
+ assert.equal(ev("'sky' in S.ev"), true);
+ ev('S.ev.sky=S.day+999;S=migrate(JSON.parse(JSON.stringify(S)))');
+ assert.ok(ev('S.ev.sky') <= ev('S.day+LEO_STORM_MAX'));
+ ev('S.ev.sky=0');
+ const ev0 = ev('JSON.stringify(S.ev)');
+ ev('S=migrate(JSON.parse(JSON.stringify(S)))');
+ assert.equal(ev('JSON.stringify(S.ev)'), ev0, 'a live 0 loads as it was');
+ // One sun: a storm that drags your own pies down puts Starblink in safe mode too, but only with LEO circuits up.
+ ev("S.inc=[];" + pie + "S.pie.co={name:PIE_NAMES[0]};pieIncFire('storm')");
+ assert.ok(ev('S.ev.sky>S.day'), 'Starblink in safe mode');
+ assert.ok(ev("S.inc.some(x=>x.type==='piestorm')&&S.inc.some(x=>x.type==='leostorm')"));
+ ev("S.inc=[];S.ev.sky=0;S.links=S.links.filter(l=>l.bird!=='sb53');pieIncFire('storm')");
+ assert.equal(ev('S.ev.sky'), 0, 'no LEO circuits, nothing to put in safe mode');
+ assert.deepEqual(errors, []);
+});
+
+test('saves: gateways and circuits survive a round trip, broken ones are repaired, old saves load as they were', (t) => {
+ const { ev, errors } = game(t, GW + "ACT.buySat({a:'ccs',b:'cur',bird:'sb53',g:10});closeModal();ACT.buySat({a:'ccs',b:'gnd',bird:'is37',g:5});closeModal();");
+ const before = ev("JSON.stringify([S.pops.ccs,S.links.filter(l=>l.kind==='sat')])");
+ ev('S=migrate(JSON.parse(JSON.stringify(S)));compute()');
+ assert.equal(ev("JSON.stringify([S.pops.ccs,S.links.filter(l=>l.kind==='sat')])"), before);
+ ev('S.pops.ccs.leo=7;S=migrate(JSON.parse(JSON.stringify(S)))');
+ assert.equal(ev("'leo' in S.pops.ccs"), false, 'a gateway is 1');
+ assert.equal(ev(`!!${leo}`), false, 'no gateway, no LEO circuit');
+ assert.equal(ev(`!!${geo}`), true, 'the GEO circuit stays');
+ ev('S.pops.ccs.leo=1;delete S.pops.ccs.tele;S=migrate(JSON.parse(JSON.stringify(S)))');
+ assert.equal(ev("'leo' in S.pops.ccs"), false, 'no teleport, no gateway');
+ // A save from before LEO: nothing about it changes.
+ ev('S=migrate(JSON.parse(' + JSON.stringify(SAVE) + '));UI.started=true;UI.pitched=true;UI.speed=0;closeModal();compute()');
+ assert.equal(ev("Object.values(S.pops).some(p=>'leo' in p)||'sky' in S.ev"), false);
+ assert.equal(ev("'sat' in R.cost"), false);
+ assert.ok(ev('R.served') > 0);
+ assert.deepEqual(errors, []);
+});
+
+test('on a phone: the gateway, its readout, the order sheet and a LEO circuit’s panel, at 360 px', (t) => {
+ const { ev, errors } = game(t, CAR);
+ 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)`);
+ const infra = "UI.sel={type:'city',id:'ccs'};UI.tab='links';renderAll()";
+ ev('S.lvl=4;' + infra);
+ assert.match(text('#panel'), /Low-orbit capacity \(about 30 ms round trip\) comes at level 5/);
+ ev('S.lvl=5;' + infra);
+ assert.match(text('#panel'), /LEO gateway/);
+ assert.ok(acts('#panel').includes('teleLeo'));
+ ev("ACT.teleLeo({city:'ccs'});" + infra);
+ assert.match(text('#panel'), /islands and remote towns within 1,200 km of this gateway/);
+ assert.ok(acts('#panel').includes('teleLeoRm'));
+ ev("ACT.satOpen({a:'ccs',b:'cur'})");
+ assert.ok(J(ev, "[...document.querySelectorAll('#modalCard [data-act=\"buySat\"]')].filter(b=>JSON.parse(b.dataset.args).bird==='sb53')").length >= 4, 'four sizes');
+ assert.match(text('#modalCard'), /Over LEO, about 30 ms round trip/);
+ ev("ACT.buySat({a:'ccs',b:'cur',bird:'sb53',g:10});ACT.launchBB({city:'cur'});closeModal();" + ready + ';' + infra);
+ assert.match(text('#panel'), /Landing here from orbit/);
+ assert.ok(!acts('#panel').includes('teleLeoRm'), 'no closing while a circuit starts there');
+ ev(`UI.sel={type:'link',id:${leo}.id};renderAll()`);
+ assert.match(text('#panel'), /round trip/);
+ assert.match(text('#panel'), /Bent pipe from 550 km up/);
+ ev("S.ev.sky=S.day+2;compute();renderAll()");
+ assert.match(text('#panel'), /Safe mode through a solar storm: back in 2 days/);
+ ev("UI.sel={type:'city',id:'cur'};UI.tab='cust';renderAll()");
+ for (const s of ['#panel', '#modalCard', '#toasts']) assert.doesNotMatch(text(s), /satellites\.|undefined|NaN/, s);
+ assert.deepEqual(errors, []);
+});
+
+test('MCP: the gateway and LEO circuits quote what the game then charges, and say no once your crust flies', () => {
+ const s = createSession(), T = (n, a = {}) => TOOLS.find((x) => x.name === n).run(s, a), ev = (x) => s.game.ev(x);
+ T('new_game', { city: 'ccs', preset: 'sandbox', seed: 7, name: 'Probe' });
+ ev('S.cash=1e9');
+ T('act', { action: 'teleBuild', args: { city: 'ccs' } });
+ const q = T('act', { action: 'teleLeo', args: { city: 'ccs' }, dryRun: true }).quote;
+ assert.equal(q.setup, ev('LEO_GW_COST'));
+ assert.equal(q.monthly, ev('LEO_GW_MO'));
+ assert.deepEqual(q.blocked, []);
+ let c0 = ev('S.cash');
+ T('act', { action: 'teleLeo', args: { city: 'ccs' } });
+ assert.equal(c0 - ev('S.cash'), q.setup);
+ assert.match(T('act', { action: 'teleLeo', args: { city: 'ccs' }, dryRun: true }).quote.blocked.join(' '), /already/);
+ const b = T('act', { action: 'buySat', args: { a: 'ccs', b: 'cur', bird: 'sb53', g: 10 }, dryRun: true }).quote;
+ assert.deepEqual(b.blocked, []);
+ c0 = ev('S.cash');
+ T('act', { action: 'buySat', args: { a: 'ccs', b: 'cur', bird: 'sb53', g: 10 } });
+ assert.equal(c0 - ev('S.cash'), b.setup, 'the quote is the bill');
+ assert.equal(b.monthly, ev("S.links.find(l=>l.bird==='sb53').mo"));
+ const id = ev("S.links.find(l=>l.bird==='sb53').id");
+ assert.deepEqual(T('act', { action: 'satSize', args: { id, g: 20 }, dryRun: true }).quote.blocked, []);
+ ev(pie);
+ assert.match(T('act', { action: 'satSize', args: { id, g: 20 }, dryRun: true }).quote.blocked.join(' '), /rival constellation/);
+ assert.deepEqual(T('act', { action: 'satSize', args: { id, g: 5 }, dryRun: true }).quote.blocked, [], 'shrinking is fine');
+ assert.deepEqual(s.errors(), []);
+});
diff --git a/tests/mcp-commands.test.js b/tests/mcp-commands.test.js
index 5015f0f..d3b0884 100644
--- a/tests/mcp-commands.test.js
+++ b/tests/mcp-commands.test.js
@@ -228,7 +228,7 @@ test('a dry run prices every command that has a price, and changes nothing', ()
opsHire: { id: ev('Object.keys(INTERNS)[0]') }, opsNewPop: { city: 'nyc' }, pniAll: { net: 'cog', tier: 1 }, seatBuy: { n: 2 }, layShip: { id: df }, seaRush: { id: df },
utilityKit: { city: 'fra' }, utilityCaches: { city: 'fra' }, acceptFix: { id: 'none' }, ptApply: { city: 'fra', k: 'medium' }, ptAll: { k: 'medium' }, teDeploy: { script: 'spill at 85%' }, upLinkX: {},
pieRd: { k: 'reuse' }, pieAnt: { id: 'none' }, ip4Buy: { len: 24 }, ip4Lease: { len: 22 }, ip6Go: { city: 'fra' },
- teleBuild: { city: 'fra' }, teleTrk: { city: 'fra' }, buySat: { a: 'fra', b: 'rek', bird: 'is37', g: 1 }, satSize: { id: wave, g: 2 },
+ teleBuild: { city: 'fra' }, teleTrk: { city: 'fra' }, teleLeo: { city: 'fra' }, buySat: { a: 'fra', b: 'rek', bird: 'is37', g: 1 }, satSize: { id: wave, g: 2 },
};
const missing = quoted.filter((n) => !sample[n] && T('schema', { section: 'commands' })[n].args.some((a) => a.required));
assert.deepEqual(missing, [], 'every priced command with arguments has a sample here');
diff --git a/tests/mp-sim-acts.test.js b/tests/mp-sim-acts.test.js
index e8f9dd1..73cc177 100644
--- a/tests/mp-sim-acts.test.js
+++ b/tests/mp-sim-acts.test.js
@@ -30,11 +30,11 @@ test('SEND is the agent\'s game commands without the puzzles, teCheck, traceRun
});
/* A rich network with something behind every two-click button: the big fixture, an intern, a sales head, a scrubbing
- center, a teleport, an own exchange. Its S also goes to the realm, so both sides start the same. */
+ center, a teleport with a LEO gateway, an own exchange. Its S also goes to the realm, so both sides start the same. */
function rich() {
const P = page({ save: bigScenic() });
P.ev(`S.lvl=Math.max(S.lvl,6);ACT.opsHire({id:'kevin'});closeModal();ACT.salesHire({id:'eng'});closeModal();
- ACT.buildScrub({city:'fra'});closeModal();ACT.teleBuild({city:'sea'});closeModal();UI.confirm=null;UI.sel=null;
+ ACT.buildScrub({city:'fra'});closeModal();ACT.teleBuild({city:'sea'});closeModal();ACT.teleLeo({city:'sea'});closeModal();UI.confirm=null;UI.sel=null;
S.day=Math.max(S.day,IP4_HOLD+30);S=migrate(JSON.parse(JSON.stringify(S)));compute();`);
// (Address blocks are held two years before they may be sold: these were bought long ago.)
return P;
@@ -72,7 +72,8 @@ test('two-click buttons: the first click arms SRV_ARM\'s key (or waits for ok),
const found = {};
for (const [a, args] of crawl(ev)) if (A.CONFIRM[a] && !found[a]) found[a] = args;
ev('UI.confirm=null;UI.sel=null;closeModal();');
- Object.assign(found, { rmScrub: { city: 'fra' }, teleRm: { city: 'sea' }, cancelVxc: found.cancelVxc || { id: 'nolink' }, dkOptOut: found.dkOptOut || { city: 'fra', n: 'Nobody' } }, found);
+ // (The gateway closes before its teleport, which would take it along.)
+ Object.assign(found, { rmScrub: { city: 'fra' }, teleLeoRm: { city: 'sea' }, teleRm: { city: 'sea' }, cancelVxc: found.cancelVxc || { id: 'nolink' }, dkOptOut: found.dkOptOut || { city: 'fra', n: 'Nobody' } }, found);
const missing = Object.keys(A.CONFIRM).filter((a) => !found[a] && a !== 'repayLoan');
assert.deepEqual(missing, [], 'a button for every two-click act');
const changed = {};
@@ -98,7 +99,7 @@ test('two-click buttons: the first click arms SRV_ARM\'s key (or waits for ok),
if (changed[a]) assert.equal(r.outcome, 'applied', a);
}
// The ones with a real target were really done.
- for (const a of ['cancelTransit', 'cancelIx', 'cancelPni', 'rmLink', 'rmSite', 'dropBiz', 'salesFire', 'opsFire', 'rmScrub', 'teleRm', 'connCancel']) if (found[a]) assert.equal(changed[a], true, `${a} did its thing`);
+ for (const a of ['cancelTransit', 'cancelIx', 'cancelPni', 'rmLink', 'rmSite', 'dropBiz', 'salesFire', 'opsFire', 'rmScrub', 'teleLeoRm', 'teleRm', 'connCancel']) if (found[a]) assert.equal(changed[a], true, `${a} did its thing`);
assert.deepEqual(P.errors, []);
});
const closeAll = (ev) => ev('closeModal();');