diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ba3a18..851ed08 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,11 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
+- Your own subsea cable can no longer be longer than any optic can light (#88). New York to Sydney now says so before you pay, instead of after the ship comes home. Calling off a cable while it is still being laid returns most of the price of the part not laid yet, and an unusable cable from an older save goes back for a full refund.
+- Your own IX can now live in either building of a two-site metro, or in both with a second switch, so a dark building no longer takes your exchange down (#36). The LAG buttons that did nothing on your own IX are gone.
+- Upgrading the only router in a POP that has nothing plugged in yet no longer opens a maintenance window or a NOC warning (#105).
+- Declining a loan offer clears the bank badge right away, even while the game is paused (#104).
+- Picking a subsea route from a city without a cable landing, like Oslo, now names the nearest landing station instead of saying its cables reach "nowhere" (#50).
## [1.29.0] — 2026-10-26
- Big networks lag a lot less: on a network with a hundred POPs and a thousand peering ports, the NOC dashboard opens six times faster, the side panels three times faster, and each game day takes about a third less time. The map needs about a third fewer drawing steps per frame, and open panels only update what changed, which keeps them smooth and lets the traffic bars glide to their new values. The connection and customer lists in the NOC dashboard show 100 rows at a time, with a button for more. While the game is paused or animations are off, the map is only redrawn when something on it changes, which saves a lot of battery on phones. On a phone, the map also rests while the NOC dashboard fills the screen, so scrolling it stays smooth.
diff --git a/site/i18n/it.js b/site/i18n/it.js
index cec41b6..507a4ca 100644
--- a/site/i18n/it.js
+++ b/site/i18n/it.js
@@ -1901,7 +1901,6 @@
"Subsea":"Sottomarino",
"Terrestrial":"Terrestre",
"No subsea cable lands in both {a} and {b}. Cables from {a} reach {list}. Hop through one of those.":"Nessun cavo sottomarino approda sia a {a} che a {b}. I cavi da {a} raggiungono: {list}. Fai tappa in una di queste.",
-"nowhere":"nessuna città",
"The landing permit dispute in {city} blocks new subsea links for {n} more days.":"La disputa sui permessi di approdo a {city} blocca i nuovi link sottomarini per altri {n} giorni.",
"Waves are leased at a flat monthly rate. Bigger and longer costs more, and subsea is 1.8×. First month is due now.":"Le wave si affittano a canone mensile fisso. Più grandi e più lunghe costano di più, e il sottomarino costa 1,8×. Il primo mese si paga subito.",
"Includes a new POP in {city} ({price}{extra}).":"Include un nuovo POP a {city} ({price}{extra}).",
@@ -2535,4 +2534,12 @@
"A path from Cape Town to Cairo, POPs in Lagos and Nairobi, and 150 Gbps served":"Un percorso da Città del Capo al Cairo, POP a Lagos e Nairobi, e 150 Gbps serviti",
"This route crosses a border in Africa: 2× the price. Every country wants its own permits, its own carrier and its own cut.":"Questa rotta attraversa un confine in Africa: 2× il prezzo. Ogni paese vuole i suoi permessi, il suo carrier e la sua fetta.",
"A path from Cape Town to Cairo":"Un percorso da Città del Capo al Cairo",
+"Both a second switch, +{price}/mo":"Entrambi un secondo switch, +{price}/mese",
+"{name} is called off.
The cable factory takes back the glass nobody needs: {price} back.":"{name} è annullato.
La fabbrica di cavi si riprende il vetro che non serve a nessuno: {price} indietro.",
+"Your cable":"Il tuo cavo",
+"New router in {city}
Swapped before anything was plugged in: zero downtime, zero angry customers.":"Nuovo router a {city}
Sostituito prima che ci fosse collegato qualcosa: zero downtime, zero clienti arrabbiati.",
+"{ix} switch":"Switch di {ix}",
+"Giving it up now returns {price}.":"Rinunciarci adesso ti restituisce {price}.",
+"No subsea cable lands in {city}. The nearest landing station is {near}: run fiber there first, then take a cable from it.":"Nessun cavo sottomarino approda a {city}. La stazione di approdo più vicina è {near}: porta prima la fibra fin lì, poi prendi un cavo da lì.",
+"{km} km is more than any optic can light, even on the best subsea gear ({max} km at most). Real cables stop at an island or a landing station on the way: lay two shorter ones.":"{km} km sono più di quanto qualsiasi ottica possa illuminare, anche con il miglior equipaggiamento sottomarino (al massimo {max} km). I cavi veri fanno tappa su un’isola o in una stazione di approdo lungo la strada: posane due più corti.",
};
diff --git a/site/i18n/pt.js b/site/i18n/pt.js
index f2bb835..a5b7582 100644
--- a/site/i18n/pt.js
+++ b/site/i18n/pt.js
@@ -1900,7 +1900,6 @@
"Subsea":"Subsea",
"Terrestrial":"Terrestre",
"No subsea cable lands in both {a} and {b}. Cables from {a} reach {list}. Hop through one of those.":"Nenhum cabo submarino desembarca em {a} e {b} ao mesmo tempo. Os cabos de {a} chegam a {list}. Faça um hop por um deles.",
-"nowhere":"lugar nenhum",
"The landing permit dispute in {city} blocks new subsea links for {n} more days.":"A disputa de licença de desembarque em {city} bloqueia novos links subsea por mais {n} dias.",
"Waves are leased at a flat monthly rate. Bigger and longer costs more, and subsea is 1.8×. First month is due now.":"Waves são alugadas a uma mensalidade fixa. Maior e mais longa custa mais, e subsea é 1,8×. O primeiro mês vence agora.",
"Includes a new POP in {city} ({price}{extra}).":"Inclui um novo POP em {city} ({price}{extra}).",
@@ -2535,4 +2534,12 @@
"A path from Cape Town to Cairo, POPs in Lagos and Nairobi, and 150 Gbps served":"Um caminho da Cidade do Cabo ao Cairo, POPs em Lagos e Nairóbi, e 150 Gbps atendidos",
"This route crosses a border in Africa: 2× the price. Every country wants its own permits, its own carrier and its own cut.":"Esta rota cruza uma fronteira na África: 2× o preço. Cada país quer suas próprias licenças, sua própria operadora e sua parte.",
"A path from Cape Town to Cairo":"Um caminho da Cidade do Cabo ao Cairo",
+"Both a second switch, +{price}/mo":"Ambos um segundo switch, +{price}/mês",
+"{name} is called off.
The cable factory takes back the glass nobody needs: {price} back.":"{name} foi cancelado.
A fábrica de cabos pega de volta o vidro que ninguém precisa: {price} de volta.",
+"Your cable":"Seu cabo",
+"New router in {city}
Swapped before anything was plugged in: zero downtime, zero angry customers.":"Roteador novo em {city}
Trocado antes de qualquer coisa estar conectada: zero downtime, zero clientes bravos.",
+"{ix} switch":"Switch do {ix}",
+"Giving it up now returns {price}.":"Desistir agora devolve {price}.",
+"No subsea cable lands in {city}. The nearest landing station is {near}: run fiber there first, then take a cable from it.":"Nenhum cabo submarino chega a {city}. A estação de chegada mais próxima é {near}: leve fibra até lá primeiro e depois pegue um cabo de lá.",
+"{km} km is more than any optic can light, even on the best subsea gear ({max} km at most). Real cables stop at an island or a landing station on the way: lay two shorter ones.":"{km} km é mais do que qualquer óptica consegue iluminar, mesmo com o melhor equipamento submarino ({max} km no máximo). Cabos de verdade param numa ilha ou numa estação de chegada no caminho: lance dois mais curtos.",
};
diff --git a/site/index.html b/site/index.html
index 9fc415c..23aade0 100644
--- a/site/index.html
+++ b/site/index.html
@@ -673,6 +673,8 @@ function portsUsed(c){let u=0;
function portsMax(c,g,rt){const p=S.pops[c];if(!p)return 0;return RG[g===undefined?(p.rgen||0):g].ports*(rt||p.routers||1);}
function portGate(c,add){if(!S.pops[c]||add<=0)return true;const u=portsUsed(c),m=portsMax(c);if(u+add<=m+1e-9)return true;
toast(tr('No free router ports in {city}.
{u} of {m} in use. Add a router, or swap to a model with more ports (Infra tab).',{city:esc(CITY[c].name),u:fmtPorts(u),m}),'bad');sfx('err');return false;}
+// Nothing depends on this POP yet: no broadband, nothing plugged in, no customer. Work here bothers nobody (#105).
+const popIdle=c=>{const p=S.pops[c];return !!p&&!p.bb&&portsUsed(c)===0&&!S.biz.some(b=>b.city===c||b.city2===c||(b.sites||[]).includes(c));};
const fmtPorts=u=>Number.isInteger(u)?String(u):u.toFixed(2).replace(/0+$/,'');
function modelFits(c,g){const G=RG[g],p=S.pops[c];if(!p)return '';
if(S.links.some(l=>(l.a===c||l.b===c)&&l.kind==='wave'&&l.tier>G.maxLT))return tr('A wave here is faster than {pn}.',{pn:G.pn});
@@ -727,6 +729,7 @@ const spanKm=l=>Math.ceil(l.km/((l.regen|0)+1));
~70 km, no regens (#66, #68). Optics reach about half as far again as on land, and the same physics caps
every wave on a cable, leased or your own: transatlantic gets 1.6T, transpacific 800G. */
const SUB_REACH=1.5,reachOn=(r,sub)=>sub?Math.round(r*SUB_REACH):r;
+const SUB_MAXKM=()=>Math.max(...Object.values(OPT).flatMap(O=>(O.modes||[[O.g,O.reach]]).map(m=>reachOn(m[1],true))));
function optMode(o,l){const O=OPT[o],km=spanKm(l);for(const [g,r] of O.modes||[[O.g,O.reach]])if(km<=reachOn(r,l.sub))return {g,reach:reachOn(r,l.sub),full:g===O.g};return null;}
// The fastest single carrier any optic can run over this much subsea cable.
const subCarrier=km=>Math.max(0,...Object.values(OPT).map(O=>{const m=(O.modes||[[O.g,O.reach]]).find(([,r])=>km<=reachOn(r,true));return m?m[0]:0;}));
@@ -1650,7 +1653,7 @@ function ixMembers(c){if(XIXM[c])return XIXM[c].members.slice();if(S.myIx[c])ret
const LAG_MAX=8;
function lagCap(g,n){n=n||1;return g*n*(n>1?0.95:1);}
function lagName(tier,n){return (n||1)>1?`${n}×${PORT[tier].n} LAG`:tr('{port} port',{port:PORT[tier].n});}
-function ixCap(c){return ixLagF(c)*(S.myIx[c]?myFab(c).g*(S.pops[c]&&(siteDown(c,'a'))?0:1):liveCap(PORT[S.ixp[c]].g,ixCity(c),(S.ixSite||{})[c],(S.ixn||{})[c])*(isRemote(c)?REMOTE_CAP:1));}
+function ixCap(c){return ixLagF(c)*(S.myIx[c]?myFab(c).g*(myIxLive(c)?1:0):liveCap(PORT[S.ixp[c]].g,ixCity(c),(S.ixSite||{})[c],(S.ixn||{})[c])*(isRemote(c)?REMOTE_CAP:1));}
function ixSessions(c){
const s=new Set(); if(S.ixp[c]===undefined)return s;
for(const id of ixMembers(c)){const n=NET[id];
@@ -1870,7 +1873,7 @@ function compute(){
const ex={k:'t',net:t.net,prem:!!t.premium&&t.city==='hkg',pref:t.pref||'normal',lab:labOf(N_('{net} transit'),'net',NET[t.net].name),id:t.id,city:t.city,cap:cap*(1-pf),used:0,rank:3,ok:n=>!(depeer&&t.net==='cog'&&n==='ggl')&&n!==leak};
E.push(ex);if(pf)E.push({...ex,cap:cap*pf,prep:true});}
// `nets`: every network ok() can say yes to, so it need not be asked about the other hundred.
- for(const c in S.ixp){const ct=ixCity(c);if(!(popUp(ct)||remote.includes(ct))||(S.ev.ixdown&&S.ev.ixdown[c]>day)||!liveN(ct,(S.ixSite||{})[c],(S.ixn||{})[c]))continue;const set=ixSessions(c);R2.sessions+=set.size;
+ for(const c in S.ixp){const ct=ixCity(c);if(!(popUp(ct)||remote.includes(ct))||(S.ev.ixdown&&S.ev.ixdown[c]>day)||!(S.myIx[c]?myIxLive(c):liveN(ct,(S.ixSite||{})[c],(S.ixn||{})[c])))continue;const set=ixSessions(c);R2.sessions+=set.size;
E.push({k:'ix',pref:(S.ixPref&&S.ixPref[c])||'normal',lab:labOf(N_('{ix} peering'),'ix',ixName(c)),id:c,city:ct,cap:ixCap(c),used:0,rank:2,ok:n=>set.has(n),nets:set});}
for(const p of S.pni){if(!popUp(p.city)||!liveN(p.city,p.site,p.n))continue;R2.sessions++;E.push({k:'p',pnc:!!NET[p.net].cn,pref:p.pref||'normal',lab:labOf(N_('PNI with {net}'),'net',NET[p.net].name),id:p.id,city:p.city,cap:liveCap(PORT[p.tier].g,p.city,p.site,p.n)*lagF(p)*(p.sacrif?0.5:1),used:0,rank:1,ok:n=>n===p.net||!!(NET[n].up&&NET[n].up.includes(p.net)),nets:PNI_NETS[p.net]});}
for(const c of S.caches){if(!popUp(c.city)||siteDown(c.city,c.site==='b'?'b':'a'))continue;E.push({k:'c',pref:'normal',lab:labOf(N_('{name} cache'),'name',NET[c.net].cache.name),id:c.id,city:c.city,cap:CACHE_CAP,used:0,rank:0,ok:n=>n===c.net,nets:[c.net]});}
@@ -2089,7 +2092,7 @@ function nniUsed(c,prov){return S.links.filter(l=>l.kind==='vxc'&&l.prov===prov&
// Monthly price of one connection; compute() sums these, the connections overview lists them.
function transitMo(t,q){const n=t.n||1;return Math.max(q,PORT[t.tier].g*n*0.2)*NET[t.net].price*(t.premium&&t.city==='hkg'?NET[t.net].premium:1)*S.priceMul*regionMult(t.city)+PORT[t.tier].tmo*n+(t.clean?cleanMo(t):0);}
function pniMo(p,use){return PORT[p.tier].pni*(p.n||1)+(NET[p.net].pol==='paid'&&!paidFree(NET[p.net])?NET[p.net].paidFee:0)+(NET[p.net].perG?Math.round(NET[p.net].perG*use):0);}
-function ixMo(c){return S.myIx[c]?myFab(c).mo:ixPortMo(c,S.ixp[c])*((S.ixn||{})[c]||1)+dkAddonMo(c);}
+function ixMo(c){return S.myIx[c]?Math.round(myFab(c).mo*((S.ixSite||{})[c]==='ab'?1.5:1)):ixPortMo(c,S.ixp[c])*((S.ixn||{})[c]||1)+dkAddonMo(c);}
function nniPort(c,prov){return (S.nni||[]).find(x=>x.city===c&&x.prov===prov);}
function repayCost(l,B){return B.equity?Math.round(l.amount*3):Math.round(Math.max(l.bal,B.crypto&&l.got?l.got:0)*1.02);}
const own=(o,k)=>Object.prototype.hasOwnProperty.call(o,k);
@@ -2286,9 +2289,11 @@ function siteDown(c,s){const p=S.pops[c];if(!p||!p.site2)return false;if(S.inc.s
// Ports can live in site A, site B, or be split across both ('ab'): a LAG with members in each
// building, so one dark building only takes out its half.
function liveN(c,site,n){n=n||1;const p=S.pops[c];if(!p||!p.site2)return n;if(site==='ab'){const a=Math.ceil(n/2),b=n-a;return (siteDown(c,'a')?0:a)+(siteDown(c,'b')?0:b);}return siteDown(c,site==='b'?'b':'a')?0:n;}
+// Your own IX is a switch, not a port: it lives in building A or B, or in both with a second switch (#36).
+const myIxLive=c=>{const ct=ixCity(c),st=(S.ixSite||{})[c]||'a';return st==='ab'?!(siteDown(ct,'a')&&siteDown(ct,'b')):!siteDown(ct,st);};
const liveCap=(g,c,site,n)=>{const k=liveN(c,site,n);return k?lagCap(g,k):0;};
const onSite=(site,s)=>(site||'a')===s||site==='ab';
-function siteCtl(k,id,c,cur){const p=S.pops[c];if(!p||!p.site2)return '';cur=cur||'a';const n=k==='t'?(S.transit.find(x=>x.id===id)||{}).n:k==='p'?(S.pni.find(x=>x.id===id)||{}).n:(S.ixn||{})[id];return `
${(p.rgen||0)>0?tr('Prices include {p} back for the old routers on eBuy.',{p:fmt$(tradeIn(p.rgen||0,rt))})+' ':''}${p.rupDay===S.day?tr('New routers went in today. The next swap can wait until tomorrow.')+' ':''}${rt>1?tr('Rolling upgrade: one router at a time, no downtime.'):tr('With one router, the upgrade needs a maintenance window: this POP goes dark for a day.')}
`:''}${rt>=2?tr('A crash here only costs one router’s capacity for a few days.'):tr('One router is a single point of failure.')}
-${tr('Two buildings joined by your own metro ring. A power cut or cleaner in one leaves the other running at half capacity. Uplinks only work while their site is up, unless you split them: choose Both on a port to put LAG members in each building.')}
${row('a')}${row('b')}${up('b').length&&up('a').length?'':`${tr('Everything is in one building. Move some uplinks to the other site from the Transit and Peering tabs.')}
`}${tr('Right now {city} is one building. A power cut, an A/C failure or a cleaner with a vacuum takes the whole city dark, and a second router does not help with that. A second data center across town, joined by your own metro ring, keeps half the POP up.',{city:esc(CITY[c].name)})}
${tr('A regen site turns the light back into bits halfway and sends it on fresh, so optics only have to reach the next site. Each needs a regen card for every lit channel. {price}/mo per site for the hut.',{price:fmt$(REGEN_MO)})}
${l.sub&&l.own?`${tr('No regen sites in the middle of the ocean: long cables run their optics in long-haul mode.')}
`:`${esc(sysD.blurb)}
${tr('Spare optics and amplifier cards on the shelf turn multi-day hardware failures into one-day swaps.')}
`; {const sib=pairLinks(l.a,l.b).filter(x=>x!==l&&x.kind!=='vxc');h+=`${sib.length?tr('Other links between these cities:'):tr('This is the only link between these cities. Add a parallel one, or a path through another city.')}
${sib.map(x=>`${tr('Giving it up now returns {price}.',{price:fmt$(cabBack(l))})}
`:''}${tr('No subsea cable lands in both {a} and {b}. Cables from {a} reach {list}. Hop through one of those.',{a:CITY[a].name,b:CITY[b].name,list:fr.join(', ')||tr('nowhere')})}
${S.won&&!ownCabWhy(a,b)?ownCabTeaser(a,b):''}`);return;} + if(sub&&!cablesOk(a,b).length){const fr=[...new Set(CABLE_PAIRS.filter(c=>c.a===a||c.b===a).map(c=>CITY[c.a===a?c.b:c.a].name))],dry=[a,b].find(c=>!landing(c));openModal(head+`${dry?tr('No subsea cable lands in {city}. The nearest landing station is {near}: run fiber there first, then take a cable from it.',{city:CITY[dry].name,near:CITY[nearLanding(dry)].name}):tr('No subsea cable lands in both {a} and {b}. Cables from {a} reach {list}. Hop through one of those.',{a:CITY[a].name,b:CITY[b].name,list:fr.join(', ')})}
${S.won&&!ownCabWhy(a,b)?ownCabTeaser(a,b):''}`);return;} if(isSub(a,b)&&S.ev.landban&&S.ev.landban.until>S.day&&[a,b].includes(S.ev.landban.city)){openModal(head+`${tr('The landing permit dispute in {city} blocks new subsea links for {n} more days.',{city:CITY[S.ev.landban.city].name,n:S.ev.landban.until-S.day})}
`);return;} if(uaePair(a,b)||andesPair(a,b)||rainPair(a,b)||borderPair(a,b))route+=`${landWhy(a,b)}
`; route+=`📈 ${esc(marketNote(a,b,sub))}
`; @@ -3860,13 +3867,19 @@ const OWNCAB_LAND=3000000,OWNCAB_KM=6000,OWNCAB_OM=25,OWNCAB_ROUTE=1.15; const OWNCAB_NAMES=['Big Wet Tube','Davy Jones’ Backhaul','Kraken-1','Mariana Trench Coat','The Wet Ethernet','Sea-ya Later','Deep Pockets Express','Salty Sausage','Poseidon’s Patch Cable','Neptune Neutrality','Moby Disk','Fibre Nemo','The Long Wet Thing','Bermuda Triangle Routing','Seabed & Breakfast','Atlantis Backhaul']; const OWNCAB_SHIPS=['MV Cable Guy','Spool of Thought','Wet Willy','Reel Deal','Splice Girl','Knot Today','Seas the Day','HMS Unplugged']; const landing=c=>CABLE_PAIRS.some(p=>p.a===c||p.b===c); +const nearLanding=c=>CITIES.filter(x=>x.id!==c&&landing(x.id)).sort((x,y)=>kmBetween(c,x.id)-kmBetween(c,y.id))[0].id; const ownCabKm=(a,b)=>Math.round(kmBetween(a,b)*OWNCAB_ROUTE); const ownCabCost=km=>2*OWNCAB_LAND+km*OWNCAB_KM+DF_SYS.roadm.cost; const ownCabMo=km=>Math.round(km*OWNCAB_OM)+ampCount(km)*AMP_MO; const ownCabDays=km=>Math.round(300+km*0.05); // Some pairs share a landmass and still have cables between them (Marseille–Singapore, Cairo–Palermo) (#67). const seaCab=(a,b)=>isSub(a,b)||(landing(a)&&landing(b)&&cablesFor(a,b).length>0); +// What you get back for giving up your own subsea cable (#88): a cable no optic can light goes back in full, +// one still being laid returns most of the part not laid yet, a working one is yours for good. +const cabBack=l=>{if(!l||l.kind!=='df'||!l.own||!l.sub)return 0;const c=ownCabCost(l.km);if(!subCarrier(l.km))return c; + if(l.ready>S.day){const tot=Math.max(1,l.ready-(l.day||0));return Math.round(c*0.75*Math.min(1,(l.ready-S.day)/tot));}return 0;}; function ownCabWhy(a,b){if(!seaCab(a,b))return tr('This route is on land. Build your own fiber instead.'); + {const km=ownCabKm(a,b);if(!subCarrier(km))return tr('{km} km is more than any optic can light, even on the best subsea gear ({max} km at most). Real cables stop at an island or a landing station on the way: lay two shorter ones.',{km:km.toLocaleString(),max:Math.round(SUB_MAXKM()).toLocaleString()});} if(!S.won)return tr('Laying your own subsea cable is a Tier 1 thing. Go transit-free first.'); for(const c of [a,b])if(!landing(c))return tr('{city} has no cable landing station.',{city:CITY[c].name}); if(cnCity(a)||cnCity(b))return tr('Nobody gives a foreign network a landing licence in mainland China.'); diff --git a/tests/issues.test.js b/tests/issues.test.js index bdc84a8..8ec90d9 100644 --- a/tests/issues.test.js +++ b/tests/issues.test.js @@ -1024,3 +1024,87 @@ test('fiber between nearby cities bends gently instead of looping around the nei assert.ok(worst < 0.3, `worst bend is ${worst.toFixed(2)}× its length`); assert.deepEqual(errors, []); }); + +test('#105 swapping the only router in an empty POP needs no maintenance window', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e9;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.buildPop({city:'ams'})"); + assert.equal(ev("popIdle('ams')"), true); + const inc0 = ev('S.inc.length'), n0 = ev('S.stats.incidents'); + ev("ACT.upRouter({city:'ams',g:1})"); + assert.equal(ev('S.pops.ams.rgen'), 1, 'upgraded'); + assert.equal(ev('S.inc.length'), inc0, 'no NOC warning'); + assert.equal(ev('S.stats.incidents'), n0, 'not counted as an incident'); + assert.ok(!(ev('S.pops.ams.down') > ev('S.day')), 'no downtime'); + // once something depends on it, the window is back + ev("ACT.launchBB({city:'ams'});S.day++"); + assert.equal(ev("popIdle('ams')"), false); + ev("ACT.upRouter({city:'ams',g:2})"); + assert.equal(ev("S.inc.filter(i=>i.type==='maint'&&i.ref==='ams').length"), 1); + assert.ok(ev('S.pops.ams.down') > ev('S.day')); + assert.deepEqual(errors, []); +}); + +test('#104 declining a loan offer clears the bank badge while paused', () => { + const { ev, errors } = load(); + ev("ACT.start({});UI.speed=0;S.loanOffers=[];spawnLoanOffer(false);renderHUD()"); + assert.equal(ev("$('hBank').hidden"), false); + ev("ACT.declineLoan({id:S.loanOffers[0].id})"); + assert.equal(ev("$('hBank').hidden"), true, 'badge gone without a new day'); + assert.equal(ev("JSON.parse(localStorage.getItem('sot-save-v1')).loanOffers.length"), 0, 'saved right away'); + assert.deepEqual(errors, []); +}); + +test('#88 no subsea cable longer than any optic can light, and a refund for calling one off', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e10;S.lvl=13;S.won=true;for(const g of GOALS)S.done[g.id]=0"); + assert.match(ev("ownCabWhy('nyc','syd')"), /more than any optic can light/); + assert.equal(ev("ownCabWhy('lax','syd')"), '', 'Los Angeles to Sydney still works'); + assert.ok(ev("subCarrier(ownCabKm('lax','syd'))") > 0); + // half-way through laying it: most of the unlaid part comes back + ev("S.day=100;S.links.push({id:'oc',a:'lax',b:'syd',kind:'df',own:true,sub:true,sys:'roadm',ch:[],km:ownCabKm('lax','syd'),cname:'Kraken-1',mo:1,trench:'own:oc',cut:0,day:0,ready:200,pairs:1})"); + const want = ev("Math.round(ownCabCost(ownCabKm('lax','syd'))*0.75*0.5)"); + assert.equal(ev("cabBack(S.links.find(l=>l.id==='oc'))"), want); + const c0 = ev('S.cash'); + ev("ACT.rmLink({id:'oc'});ACT.rmLink({id:'oc'})"); + assert.equal(ev("S.links.some(l=>l.id==='oc')"), false); + assert.equal(ev('S.cash') - c0, want); + // a finished cable that works is yours for good; one nothing can light (old saves) goes back in full + assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:ownCabKm('lax','syd'),ready:0})"), 0); + assert.equal(ev("cabBack({kind:'df',own:true,sub:true,km:18387,ready:0})"), ev('ownCabCost(18387)')); + assert.deepEqual(errors, []); +}); + +test('#50 a city without a cable landing points to the nearest one', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e9;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.buildPop({city:'osl'});UI.pending=null;openLinkModal('osl','nyc')"); + const t = ev("$('modalCard').textContent"); + assert.match(t, /No subsea cable lands in Oslo\. The nearest landing station is Stavanger/); + assert.doesNotMatch(t, /nowhere/); + assert.deepEqual(errors, []); +}); + +test('#36 your own IX moves between buildings, or runs a switch in both', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e9;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.buildPop({city:'beg'});ACT.launchBB({city:'beg'});ACT.foundIx({city:'beg'});ACT.addSite({city:'beg'});compute()"); + assert.ok(ev("!!S.myIx.beg")); + const mo = ev("ixMo('beg')"), cap = ev("ixCap('beg')"); + assert.ok(cap > 0); + // no LAG for a switch you own + ev("UI.sel={type:'city',id:'beg'};UI.tab='peer';renderPanel()"); + assert.equal(ev("!!document.querySelector('#panel [data-act=lagIx]')"), false, 'no LAG button'); + // move it to B: a dark A no longer matters + ev("ACT.siteSet({k:'ix',id:'beg',s:'b'})"); + assert.equal(ev("S.ixSite.beg"), 'b'); + ev("addInc({type:'site',ref:'beg',site:'a',until:S.day+3,msg:'x',cost:0});compute()"); + assert.equal(ev("ixCap('beg')"), cap, 'B is up'); + // both buildings: a second switch for half the fabric's fee, survives either one going dark + ev("ACT.siteSet({k:'ix',id:'beg',s:'ab'})"); + assert.equal(ev("S.ixSite.beg"), 'ab'); + assert.equal(ev("ixMo('beg')"), Math.round(mo * 1.5)); + assert.equal(ev("(S.ixn||{}).beg||1"), 1, 'no LAG member bought'); + ev("S.inc=[];addInc({type:'site',ref:'beg',site:'b',until:S.day+3,msg:'x',cost:0});compute()"); + assert.equal(ev("ixCap('beg')"), cap); + ev("addInc({type:'site',ref:'beg',site:'a',until:S.day+3,msg:'x',cost:0});compute()"); + assert.equal(ev("ixCap('beg')"), 0, 'both dark'); + assert.deepEqual(errors, []); +});