diff --git a/CHANGELOG.md b/CHANGELOG.md index b870d88..e224b82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- Hardware now gets dearer over the years, and shortages come and go: routers, optics and new fiber and cable builds cost about 4% more each year after your first six months, up to 30% more in the end, while what you already own keeps its price. Now and then a laser shortage, a chip shortage or a run on cable ships makes one of them 30 to 50% dearer for a month or two. Stock spare optics in calm times, or lock in a year of today's prices with your vendor from the NOC tab. - PNIs with the big networks are quicker again: most arrive in about a month, and only about one order in seven gets stuck in provisioning for 6 to 12 months. - Now and then a carrier is sold out of a wave size on a route for a while, and bigger waves sell out more often. The link window shows which sizes are sold out and for how long; a smaller wave or another route usually still works, and nothing sells out in your first 90 days. - You can now start in Sydney, on hard mode. Australia is a long way from everywhere: transit costs three times the usual price and any wave touching the country costs far more than in Asia, though IX ports are cheaper than in Europe. Homes pay well for broadband, but the Nearly Broadband Network keeps 45% of every bill, and business customers pay more per gigabit but buy less of it. diff --git a/package.json b/package.json index 60f60a9..8d360ea 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "git+https://github.com/fjaeckel/seriesoftubes.git" }, "scripts": { - "test": "node --test --test-concurrency=1 tests/game.test.js tests/build.test.js tests/persist.test.js tests/services.test.js tests/peering.test.js tests/inbox.test.js tests/latency.test.js tests/issues.test.js tests/regions.test.js tests/modes.test.js tests/levels.test.js tests/speed.test.js tests/i18n.test.js tests/routing-reference.test.js tests/perf.test.js tests/sea-routing.test.js tests/subsea-upgrade-timing.test.js", + "test": "node --test --test-concurrency=1 tests/game.test.js tests/build.test.js tests/persist.test.js tests/services.test.js tests/peering.test.js tests/inbox.test.js tests/latency.test.js tests/supply.test.js tests/issues.test.js tests/regions.test.js tests/modes.test.js tests/levels.test.js tests/speed.test.js tests/i18n.test.js tests/routing-reference.test.js tests/perf.test.js tests/sea-routing.test.js tests/subsea-upgrade-timing.test.js", "build": "bash scripts/build.sh", "i18n:check": "node scripts/i18n-check.js", "serve": "npm run build && npx --yes serve@14.2.4 _site", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index ead66dd..30dbf74 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -2911,4 +2911,23 @@ "The upgrade is planned for Q3. Which year, the email does not say.":"La mise à niveau est prévue pour le T3. De quelle année, l’e-mail ne le dit pas.", "No {wave} capacity on this route right now.
{why} Try a smaller wave, another route, or ask again in {n} days.":"Plus de capacité {wave} sur cette route pour l’instant.
{why} Essayez une onde plus petite, une autre route, ou redemandez dans {n} jours.", "sold out for {n} days":"épuisé pour {n} jours", +"Laser shortage!
The factory that makes the lasers for half the world’s optics flooded. Optics cost 50% more for {n} days. Spares on your shelf just became the best investment you ever made.":"Pénurie de lasers !
L’usine qui fabrique les lasers de la moitié des optiques du monde a été inondée. Les optiques coûtent 50 % de plus pendant {n} jours. Les pièces de rechange sur votre étagère viennent de devenir le meilleur investissement de votre vie.", +"Chip shortage!
Every router vendor is waiting for the same chips. New routers and router upgrades cost 40% more for {n} days. Lead time: “yes”.":"Pénurie de puces !
Tous les fabricants de routeurs attendent les mêmes puces. Les routeurs neufs et les mises à niveau coûtent 40 % de plus pendant {n} jours. Délai de livraison : « oui ».", +"New fiber and cable builds":"Nouvelles fibres et nouveaux câbles", +"Every cable ship is booked.
Hyperscalers have hired every cable ship and trenching crew on the planet. New fiber and cable builds cost 30% more for {n} days.":"Tous les câbliers sont réservés.
Les hyperscalers ont loué chaque câblier et chaque équipe de tranchée de la planète. Les nouvelles fibres et les nouveaux câbles coûtent 30 % de plus pendant {n} jours.", +"Your price lock covers you until {date}.":"Votre blocage des prix vous couvre jusqu’au {date}.", +"Supply chain":"Chaîne d’approvisionnement", +"Hardware prices":"Prix du matériel", +"+{p} since you started":"+{p} depuis vos débuts", +"as when you started":"comme à vos débuts", +"Shortage":"Pénurie", +"{what} +{p} · {n} days left":"{what} +{p} · encore {n} jours", +"Price lock":"Blocage des prix", +"until {date}, at +{p}":"jusqu’au {date}, à +{p}", +"Routers, optics and new builds at today’s prices for a year, shortages included. Tariffs are the government’s, not your vendor’s.":"Routeurs, optiques et nouvelles constructions aux prix d’aujourd’hui pendant un an, pénuries comprises. Les droits de douane sont ceux du gouvernement, pas de votre fournisseur.", +"Lock prices for a year {cost}":"Bloquer les prix pour un an {cost}", +"Prices locked until {date}.
Your vendor’s account manager is delighted. He gets a bonus for this.":"Prix bloqués jusqu’au {date}.
L’account manager de votre fournisseur est ravi. Il touche une prime pour ça.", +"Stock a spare {optic} {price}":"Stocker un {optic} de rechange {price}", +"Spares bought now are already paid for when the next shortage hits.":"Les pièces achetées maintenant sont déjà payées quand la prochaine pénurie arrive.", +"Routers, optics and new builds get dearer over the years, about 4% a year after the first six months, and now and then a shortage makes one of them a lot dearer for a month or two. What you already own keeps its price. Spares on the shelf and a yearly price lock from the NOC tab soften the blow.":"Routeurs, optiques et nouvelles constructions coûtent plus cher avec les années, environ 4 % par an après les six premiers mois, et de temps en temps une pénurie rend l’un d’eux bien plus cher pendant un mois ou deux. Ce que vous possédez déjà garde son prix. Des pièces de rechange sur l’étagère et un blocage annuel des prix depuis l’onglet NOC amortissent le choc.", }; diff --git a/site/i18n/it.js b/site/i18n/it.js index fbef8e9..d8707a4 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2911,4 +2911,23 @@ "The upgrade is planned for Q3. Which year, the email does not say.":"L’aggiornamento è previsto per il Q3. Di quale anno, l’email non lo dice.", "No {wave} capacity on this route right now.
{why} Try a smaller wave, another route, or ask again in {n} days.":"Nessuna capacità {wave} su questa tratta al momento.
{why} Prova un’onda più piccola, un’altra tratta, o chiedi di nuovo tra {n} giorni.", "sold out for {n} days":"esaurito per {n} giorni", +"Laser shortage!
The factory that makes the lasers for half the world’s optics flooded. Optics cost 50% more for {n} days. Spares on your shelf just became the best investment you ever made.":"Carenza di laser!
La fabbrica che produce i laser di metà delle ottiche del mondo si è allagata. Le ottiche costano il 50% in più per {n} giorni. Le scorte sul tuo scaffale sono appena diventate il miglior investimento della tua vita.", +"Chip shortage!
Every router vendor is waiting for the same chips. New routers and router upgrades cost 40% more for {n} days. Lead time: “yes”.":"Carenza di chip!
Tutti i produttori di router aspettano gli stessi chip. Router nuovi e upgrade costano il 40% in più per {n} giorni. Tempi di consegna: “sì”.", +"New fiber and cable builds":"Nuove fibre e nuovi cavi", +"Every cable ship is booked.
Hyperscalers have hired every cable ship and trenching crew on the planet. New fiber and cable builds cost 30% more for {n} days.":"Tutte le navi posacavi sono prenotate.
Gli hyperscaler hanno noleggiato ogni nave posacavi e ogni squadra di scavo del pianeta. Nuove fibre e nuovi cavi costano il 30% in più per {n} giorni.", +"Your price lock covers you until {date}.":"Il tuo blocco dei prezzi ti copre fino al {date}.", +"Supply chain":"Catena di fornitura", +"Hardware prices":"Prezzi dell’hardware", +"+{p} since you started":"+{p} da quando hai iniziato", +"as when you started":"come quando hai iniziato", +"Shortage":"Carenza", +"{what} +{p} · {n} days left":"{what} +{p} · {n} giorni rimasti", +"Price lock":"Blocco dei prezzi", +"until {date}, at +{p}":"fino al {date}, a +{p}", +"Routers, optics and new builds at today’s prices for a year, shortages included. Tariffs are the government’s, not your vendor’s.":"Router, ottiche e nuove costruzioni ai prezzi di oggi per un anno, carenze comprese. I dazi sono del governo, non del tuo fornitore.", +"Lock prices for a year {cost}":"Blocca i prezzi per un anno {cost}", +"Prices locked until {date}.
Your vendor’s account manager is delighted. He gets a bonus for this.":"Prezzi bloccati fino al {date}.
L’account manager del tuo fornitore è felicissimo. Ci prende un bonus.", +"Stock a spare {optic} {price}":"Metti da parte un {optic} di scorta {price}", +"Spares bought now are already paid for when the next shortage hits.":"Le scorte comprate adesso sono già pagate quando arriva la prossima carenza.", +"Routers, optics and new builds get dearer over the years, about 4% a year after the first six months, and now and then a shortage makes one of them a lot dearer for a month or two. What you already own keeps its price. Spares on the shelf and a yearly price lock from the NOC tab soften the blow.":"Router, ottiche e nuove costruzioni rincarano con gli anni, circa il 4% all’anno dopo i primi sei mesi, e ogni tanto una carenza ne fa rincarare uno parecchio per un mese o due. Quello che possiedi già mantiene il suo prezzo. Le scorte sullo scaffale e un blocco annuale dei prezzi dalla scheda NOC attutiscono il colpo.", }; diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 68287bf..d29ce8b 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -2911,4 +2911,23 @@ "The upgrade is planned for Q3. Which year, the email does not say.":"A atualização está prevista para o Q3. De que ano, o e-mail não diz.", "No {wave} capacity on this route right now.
{why} Try a smaller wave, another route, or ask again in {n} days.":"Sem capacidade de {wave} nesta rota agora.
{why} Tente uma onda menor, outra rota, ou pergunte de novo em {n} dias.", "sold out for {n} days":"esgotado por {n} dias", +"Laser shortage!
The factory that makes the lasers for half the world’s optics flooded. Optics cost 50% more for {n} days. Spares on your shelf just became the best investment you ever made.":"Falta de lasers!
A fábrica que faz os lasers de metade das ópticas do mundo inundou. Ópticas custam 50% a mais por {n} dias. Os sobressalentes na sua prateleira acabaram de virar o melhor investimento da sua vida.", +"Chip shortage!
Every router vendor is waiting for the same chips. New routers and router upgrades cost 40% more for {n} days. Lead time: “yes”.":"Falta de chips!
Todo fabricante de roteador está esperando os mesmos chips. Roteadores novos e upgrades custam 40% a mais por {n} dias. Prazo de entrega: “sim”.", +"New fiber and cable builds":"Novas fibras e novos cabos", +"Every cable ship is booked.
Hyperscalers have hired every cable ship and trenching crew on the planet. New fiber and cable builds cost 30% more for {n} days.":"Todos os navios lançadores de cabo estão reservados.
Os hyperscalers contrataram todos os navios e todas as equipes de escavação do planeta. Novas fibras e novos cabos custam 30% a mais por {n} dias.", +"Your price lock covers you until {date}.":"Seu congelamento de preços te cobre até {date}.", +"Supply chain":"Cadeia de suprimentos", +"Hardware prices":"Preços de hardware", +"+{p} since you started":"+{p} desde o começo", +"as when you started":"como no começo", +"Shortage":"Falta", +"{what} +{p} · {n} days left":"{what} +{p} · faltam {n} dias", +"Price lock":"Congelamento de preços", +"until {date}, at +{p}":"até {date}, a +{p}", +"Routers, optics and new builds at today’s prices for a year, shortages included. Tariffs are the government’s, not your vendor’s.":"Roteadores, ópticas e novas obras aos preços de hoje por um ano, faltas incluídas. As tarifas são do governo, não do seu fornecedor.", +"Lock prices for a year {cost}":"Congelar preços por um ano {cost}", +"Prices locked until {date}.
Your vendor’s account manager is delighted. He gets a bonus for this.":"Preços congelados até {date}.
O gerente de contas do seu fornecedor está radiante. Ele ganha um bônus por isso.", +"Stock a spare {optic} {price}":"Guardar um {optic} sobressalente {price}", +"Spares bought now are already paid for when the next shortage hits.":"Sobressalentes comprados agora já estão pagos quando vier a próxima falta.", +"Routers, optics and new builds get dearer over the years, about 4% a year after the first six months, and now and then a shortage makes one of them a lot dearer for a month or two. What you already own keeps its price. Spares on the shelf and a yearly price lock from the NOC tab soften the blow.":"Roteadores, ópticas e novas obras ficam mais caros com os anos, cerca de 4% ao ano depois dos primeiros seis meses, e de vez em quando uma falta deixa um deles bem mais caro por um ou dois meses. O que você já tem mantém o preço. Sobressalentes na prateleira e um congelamento anual de preços na aba NOC amortecem o golpe.", }; diff --git a/site/index.html b/site/index.html index bc16839..b5d50c1 100644 --- a/site/index.html +++ b/site/index.html @@ -671,9 +671,31 @@ const RG=[ const SLOW_BOOT=[tr('is oinking through the self-test of every PacketOinker on every line card'),tr('is running fsck on a compact flash card older than your interns'),tr('found a newer firmware on the USB stick someone left in it, and is installing it'),tr('is counting to 2 million routes. Out loud. One at a time'),tr('is waiting for the line cards to agree on who is the primary'),tr('booted, panicked about a missing fan tray, and started again'),tr('is "synchronising the routing engines". Nobody knows what that means')]; function slowBoot(c){const p=S.pops[c];if(!p)return false;const g=p.rgen||0;return hstr(c+'|boot|'+g+'|'+S.asn)%100Math.round(ROUTER_COST+RG[g].cost*0.8); +/* ---------- Supply chain: hardware gets dearer over the years, with shortages that come and go ---------- + Transit keeps getting cheaper (it really does), but routers, optics and new builds drift the other way: free for + the first six months, then +4% a year, capped at +30%. Only new purchases pay it; what you own costs what it cost. + Now and then a shortage hits one kind of hardware for a month or two. Spares on the shelf and a yearly price lock + with your vendor are the ways around it. */ +const HW_YR=0.04,HW_CAP=1.3,HW_FREE=180,HW_LOCK_DAYS=365; +const HW_SHOCK={opt:{mul:1.5,n:N_('Optics'),msg:N_('Laser shortage!
The factory that makes the lasers for half the world’s optics flooded. Optics cost 50% more for {n} days. Spares on your shelf just became the best investment you ever made.')}, + rt:{mul:1.4,n:N_('Routers'),msg:N_('Chip shortage!
Every router vendor is waiting for the same chips. New routers and router upgrades cost 40% more for {n} days. Lead time: “yes”.')}, + build:{mul:1.3,n:N_('New fiber and cable builds'),msg:N_('Every cable ship is booked.
Hyperscalers have hired every cable ship and trenching crew on the planet. New fiber and cable builds cost 30% more for {n} days.')}}; +const hwTrend=d=>Math.min(HW_CAP,1+HW_YR*Math.max(0,(d-HW_FREE)/365)); +const hwShock=()=>{const s=S&&S.hw&&S.hw.shock;return s&&s.until>S.day?s:null;},hwLock=()=>{const l=S&&S.hw&&S.hw.lock;return l&&l.until>S.day?l:null;}; +function hwMul(k){if(!S)return 1;const l=hwLock();if(l)return l.mul;const s=hwShock();return hwTrend(S.day)*(s&&s.k===k?s.mul:1);} +// A lock costs a little more for a bigger network, and twice as much in the middle of a shortage. +const hwLockCost=()=>Math.round((80000+30000*Object.keys(S.pops).length)*(hwShock()?2:1)/1000)*1000; +function hwShockStart(){const k=pick(Object.keys(HW_SHOCK)),n=45+Math.floor(Math.random()*31);S.hw=S.hw||{};S.hw.shock={k,until:S.day+n,mul:HW_SHOCK[k].mul}; + toast(tr(HW_SHOCK[k].msg,{n})+(hwLock()?'
'+tr('Your price lock covers you until {date}.',{date:dateStr(hwLock().until)}):''),hwLock()?'':'bad');sfx('alert');} +function hwCard(){if(!S||(S.day<=HW_FREE&&!hwShock()&&!hwLock()))return '';const t=hwTrend(S.day),s=hwShock(),l=hwLock(); + return `
📦 ${tr('Supply chain')}
+
${tr('Hardware prices')}${t>1.005?tr('+{p} since you started',{p:pct(t-1)}):tr('as when you started')}
+ ${s?`
${tr('Shortage')}${tr('{what} +{p} · {n} days left',{what:tr(HW_SHOCK[s.k].n),p:pct(s.mul-1),n:s.until-S.day})}
`:''} + ${l?`
${tr('Price lock')}${tr('until {date}, at +{p}',{date:dateStr(l.until),p:pct(l.mul-1)})}
` + :`

${tr('Routers, optics and new builds at today’s prices for a year, shortages included. Tariffs are the government’s, not your vendor’s.')}

${btn(tr('Lock prices for a year {cost}',{cost:fmt$(hwLockCost())}),'hwLock',{},'sm',S.cash`}
`;} +const routerCost=g=>Math.round((ROUTER_COST+RG[g].cost*0.8)*hwMul('rt')); // Old routers go on eBuy when you swap models or remove one (#82), like spare optics (#45). Chassis age faster. -const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCost=(c,g)=>{const p=S.pops[c],rt=p.routers||1;return Math.max(0,RG[g].cost*rt-tradeIn(p.rgen||0,rt));}; +const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCost=(c,g)=>{const p=S.pops[c],rt=p.routers||1;return Math.max(0,Math.round(RG[g].cost*rt*hwMul('rt'))-tradeIn(p.rgen||0,rt));}; const RMAX=6; // The plain, badge-less model of each class is the default upgrade path; the others are side-grades. const mainRG=k=>RG.findIndex(r=>r.cls===k&&!r.badge); @@ -720,7 +742,7 @@ const OPT={ tp32:{n:'Sienna WaveMagic 3.2T',g:3200,cost:130000,reach:1500,modes:[[3200,1500],[1600,4000],[1200,5500],[800,7000],[400,12000]],rg:4,lvl:8,sys:'roadm',blurb:tr('Twice the WaveMagic. Full speed only on shorter spans, and a cooling fan you can hear from the car park.')}, }; const dfLeaseMo=km=>Math.round(400+km*1.0); -const dfBuildCost=km=>Math.round(25000+km*120); +const dfBuildCost=km=>Math.round((25000+km*120)*hwMul('build')); const dfBuildDays=km=>Math.round(120+km*0.25); const ampCount=km=>Math.max(0,Math.floor(km/AMP_EVERY)); const fmtCap=g=>g>=1000?(+(g/1000).toFixed(1))+'T':g+'G'; @@ -1767,7 +1789,7 @@ function scenarioModal(){const wk=weekly(),h=scnHof();let best=null;try{best=JSO function newGame(name,home){ S={v:1,name,asn:200000+Math.floor(_rand()*15000),home,day:0,cash:START_CASH, ltv:2,t1v:2,auV:1,seen:NETS.map(n=>n.id),spares:{},pops:{[home]:{day:0,bb:null,boost:0,down:0,routers:1,gen:false}},links:[],nni:[],transit:[],ixp:{},rs:{},peers:{},pni:[],caches:[],biz:[],offers:[],myIx:{}, - done:{},inc:[],ev:{},priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0,inbox:{items:[],down:{},tiny:{},rep:0,bot:false,log:[],seq:0}}; + done:{},inc:[],ev:{},priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0,inbox:{items:[],down:{},tiny:{},rep:0,bot:false,log:[],seq:0},hw:{}}; } /* ================= HELPERS ================= */ @@ -2470,6 +2492,10 @@ function sanitize(s){ s.pni=s.pni.filter(x=>x&&isCity(x.city)&&isNet(x.net)).map(x=>(x.lacp=degO(x.lacp),x.site=['a','b','ab'].includes(x.site)?x.site:'a',x.id=sid(x.id),x.tier=tier(x.tier),x.n=lag(x.n),x.sacrif=!!x.sacrif,x)); // PNIs on order (#…): delivery day, a pending augment, and 1G for the one network that sells it for(const x of s.pni){if(x.ready!==undefined)x.ready=num(x.ready,0);if(x.g1)x.g1=x.tier===0&&x.net==='dtk'?true:undefined;else delete x.g1;if(x.up){const u=x.up;x.up=u&&typeof u==='object'?{tier:tier(u.tier),n:lag(u.n),ready:num(u.ready,0),g1:!!u.g1&&x.net==='dtk'&&tier(u.tier)===0}:undefined;if(!x.up)delete x.up;}} + // Supply chain: a shortage and a price lock, both optional. + {const H=s.hw&&typeof s.hw==='object'&&!Array.isArray(s.hw)?s.hw:{},o={};const sh=H.shock,lk=H.lock; + if(sh&&typeof sh==='object'&&own(HW_SHOCK,sh.k))o.shock={k:sh.k,until:num(sh.until,0),mul:clamp(num(sh.mul,1),1,2)}; + if(lk&&typeof lk==='object')o.lock={until:num(lk.until,0),mul:clamp(num(lk.mul,1),1,HW_CAP)};s.hw=o;} {const I=s.inbox&&typeof s.inbox==='object'&&!Array.isArray(s.inbox)?s.inbox:{},o=v=>v&&typeof v==='object'&&!Array.isArray(v)?v:{},str=(v,n)=>String(v==null?'':v).slice(0,n); const items=(Array.isArray(I.items)?I.items:[]).filter(x=>x&&typeof x==='object'&&(x.k==='req'||x.k==='mp')&&typeof x.ix==='string'&&isIx(x.ix)&&(x.net===undefined||isNet(x.net))&&(x.net!==undefined||typeof x.nm==='string')).slice(0,INBOX_MAX).map(x=>({id:int(x.id,0,1e9,0),k:x.k,ix:x.ix,net:x.net,nm:x.net?undefined:str(x.nm,40),asn:x.net?undefined:int(x.asn,1,4294967294,64512),day:num(x.day,0),stale:!!x.stale,yrs:int(x.yrs,1,30,1),say:int(x.say,0,REQ_SAY.length-1,0),bump:x.bump?1:undefined,key:x.k==='mp'?str(x.key,80):undefined,lim:x.k==='mp'?int(x.lim,1,1e7,100):undefined,got:x.k==='mp'?int(x.got,1,1e7,100):undefined,leak:x.k==='mp'?!!x.leak:undefined})); const down={};for(const [k,v] of Object.entries(o(I.down)))if(typeof k==='string'&&k.length<80)down[k]=num(v,0); @@ -2934,6 +2960,7 @@ function purgeInc(){S.inc=S.inc.filter(i=>{const T=i.type;if(LINKCUT_TR.includes function fireEvent(){ const opts=['viral','price','grant']; if(S.day>50)opts.push('sanction','tariff','hijack','landban','shutdown','redsea','baltic'); + if(S.day>HW_FREE&&!hwShock())opts.push('hwshock'); if(S.day>90&&S.links.filter(l=>l.kind==='wave'&&!l.sub).length>=3)opts.push('ctrlplane'); if(Object.keys(S.pops).some(ruCity))opts.push('runet','runet'); if(S.pops.doh&&Object.keys(S.pops).some(c=>CITY[c].gcc||CITY[c].uae)&&!(S.ev.gulf>S.day))opts.push('gulf'); @@ -2959,6 +2986,7 @@ function fireEvent(){ toast(tr('Faceplant rerouted Korea via Hong Kong.
Seoul users get a fifth less of it for 20 days, however you connect.'),'bad');sfx('alert');return;} if(e==='mega'){const c=pick(Object.keys(S.pops).filter(x=>CITY[x].saudi)),bw=pick([800,1600,3200]),start=S.day+15;S.offers.push({id:uid(),city:c,city2:null,name:tr('A futuristic city that is not built yet, demo day in {city}',{city:CITY[c].name}),type:'event',bw,rate:0,reqs:[],start,dur:4,fee:bw*4*90,exp:start-2});toast(tr('A gigaproject wants a demo.
{bw} for four days in {city}, to show off a city that is still mostly renderings. Check the Deals tab.',{bw:fmtG(bw),city:CITY[c].name}),'goal');} if(e==='sanction'){S.ev.sanction=S.day+60;toast(tr('Sanctions!
The Republic of Paperworkistan sanctioned your router vendor’s favorite screw supplier. Spare parts are slow: router crashes take twice as long to fix for 60 days.'),'bad');sfx('alert');return;} + if(e==='hwshock'){hwShockStart();return;} if(e==='tariff'){S.ev.tariff=S.day+90;toast(tr('Trade war on optics
Two governments slapped tariffs on each other’s lasers. Optics cost 40% more for 90 days.'),'bad');sfx('alert');return;} if(e==='hijack'){const nh=NETS.map(n=>n.id).filter(()=>Math.random()<0.6),old=S.ev.rpki&&S.ev.rpki.until>S.day?S.ev.rpki:null;S.ev.rpki=old?{until:Math.max(old.until,S.day+1),nets:[...new Set(old.nets.concat(nh))]}:{until:S.day+1,nets:nh};addInc({type:'hijack',ref:'rpki',until:S.day+1,msg:tr('A state-owned ISP “accidentally” announced your prefixes for 18 minutes. Their apology press release was suspiciously well written. Many networks are still routing your traffic into the void.'),cost:1500,fix:tr('Call everyone you know')});toast(tr('BGP hijack
Someone else is announcing your prefixes. Reach is down until it is cleaned up.'),'bad');sfx('alert');return;} if(e==='landban'){const lc=[...new Set(CABLE_PAIRS.flatMap(c=>[c.a,c.b]))];const c=pick(lc);S.ev.landban={city:c,until:S.day+45};toast(tr('Landing permit dispute in {city}
Two ministries both claim the beach. No new subsea links can land there for 45 days.',{city:CITY[c].name}),'bad');return;} @@ -3431,6 +3459,8 @@ const ACT={ if(d>0&&!spend(REGEN_COST+Math.round((l.ch||[]).reduce((a,c)=>a+optCost(c),0)*REGEN_CH)))return;l.regen=n;toast(d>0?tr('Regen site {n} is up.
Optical spans on {a}–{b} are now {km} km.',{n,a:CITY[l.a].name,b:CITY[l.b].name,km:spanKm(l).toLocaleString()}):tr('Regen site removed.'),'good');sfx('build');after();}, addCh:({id,o})=>{const l=S.links.find(x=>x.id===id),O=OPT[o];if(!l||!O||l.kind!=='df')return;const why=chWhy(l,o);if(why){toast(tr("Can't add {optic}.
{why}",{optic:O.n,why:esc(why)}),'bad');sfx('err');return;}if(!portGate(l.a,1)||!portGate(l.b,1))return;const sp=spareN(o)>0;if(!spend(chCost(l,o)))return;if(sp)S.spares[o]--;(l.ch=l.ch||[]).push(o);floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,`+${O.n}`,'#FF4F9A');after();}, rmCh:({id,o})=>{const l=S.links.find(x=>x.id===id);if(!l||!OPT[o])return;const i=(l.ch||[]).lastIndexOf(o);if(i<0)return;l.ch.splice(i,1);S.spares=S.spares||{};S.spares[o]=(S.spares[o]||0)+1;floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,tr('{optic} to spares',{optic:OPT[o].n}),'#7B61FF');after();}, + hwLock:()=>{if(hwLock())return;const c=hwLockCost();if(!spend(c))return;S.hw=S.hw||{};S.hw.lock={until:S.day+HW_LOCK_DAYS,mul:hwTrend(S.day)};toast(tr('Prices locked until {date}.
Your vendor’s account manager is delighted. He gets a bonus for this.',{date:dateStr(S.hw.lock.until)}),'good');after();}, + buySpare:({o})=>{if(!OPT[o]||OPT[o].lvl>lvl()||spareN(o)>=64)return;if(!spend(optCost(o)))return;S.spares=S.spares||{};S.spares[o]=(S.spares[o]||0)+1;sfx('build');after();}, sellSpare:({o})=>{if(!OPT[o]||spareN(o)<1)return;S.spares[o]--;const v=spareValue(o);S.cash+=v;toast(tr('Sold a spare {optic} on eBuy.
{price} back, which is {p} of what it cost new.',{optic:OPT[o].n,price:fmt$(v),p:pct(SPARE_RESALE)}),'good');sfx('coin');after();}, addPair:({id})=>{const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='df'||!l.own||!isRdm(l.sys)||l.ready>S.day)return;const n=Math.max(1,l.pairs|0);if(n>=pairsMax(l))return;if((l.ch||[]).length+soldSlots(l)Fill this pair first.
Light all {max} channels before you light another fiber pair.',{max:chMax(l)}),'bad');sfx('err');return;}if(!spend(pairCost(l)))return;l.pairs=n+1;toast(tr('Fiber pair {n} is lit: {a}–{b}.
Another ROADMaster 9000 and a fresh chain of amplifiers. Room for {m} more channels.',{n:n+1,a:CITY[l.a].name,b:CITY[l.b].name,m:DF_SYS[l.sys].max}),'good');sfx('build');after();}, upSys:({id})=>{const l=S.links.find(x=>x.id===id),to=l&&sysNext(l);if(!to||DF_SYS[to].lvl>lvl())return;if(!spend(sysUpCost(l)))return;l.sys=to;if(l.ready<=S.day){l.eqDown=S.day+1;toast(tr('Line system swap
All channels are dark for a day while the ROADMs go in.'),'bad');}after();}, @@ -3486,7 +3516,7 @@ function dfAllowed(a,b){if(isSub(a,b))return !!subDfCable(a,b);return cnCity(a)= for free (only the regen sites' transponders are new), or you sell it on eBuy for part of the price. */ const SPARE_RESALE=0.4,spareN=o=>(S&&S.spares&&S.spares[o])|0,spareValue=o=>Math.round(optCost(o)*SPARE_RESALE); function chCost(l,o){const r=REGEN_CH*(l.regen|0);return Math.round(optCost(o)*(spareN(o)>0?r:1+r));} -function optCost(o){return Math.round(OPT[o].cost*(S&&S.ev&&S.ev.tariff>S.day?1.4:1));} +function optCost(o){return Math.round(OPT[o].cost*hwMul('opt')*(S&&S.ev&&S.ev.tariff>S.day?1.4:1));} // Line systems upgrade in place: Rainbow → ROADMaster → C+L. Every lit pair gets the new gear. const sysNext=l=>l.sys==='lite'?'roadm':l.sys==='roadm'?'cl':null,sysUpCost=l=>{const t=sysNext(l);return t?DF_SYS[t].cost*(t==='cl'&&l.own?Math.max(1,l.pairs|0):1):0;}; function pairBtn(l){if(!l.own||!isRdm(l.sys)||l.ready>S.day)return '';const n=Math.max(1,l.pairs|0);if(n>=pairsMax(l))return `${tr('{n} fiber pairs lit, the trench is full',{n})}`; @@ -3670,6 +3700,7 @@ function renderLeft(){checkLayer(); :`
Auto-TE${lvl()<3?tr('Unlocks at customer level 3'):tr('Not installed')}

${tr('Traffic takes the shortest path, even when it is full. A traffic-engineering controller spills the overflow onto the next-best paths with room.')}

${btn(tr('Install Auto-TE {cost} + {mo}/mo',{cost:fmt$(TE_COST),mo:fmt$(TE_MO)}),'buyTE',{},'pink sm',lvl()<3||S.cash`; const hot=S.links.filter(l=>!linkDown(l)&&capOf(l)>0&&(R.load[l.id]||0)/capOf(l)>=0.85).sort((a,b)=>(R.load[b.id]/capOf(b))-(R.load[a.id]/capOf(a))); if(hot.length){h+=`

${tr('Congested links')}

${S.te&&S.te.on?'':'

'+tr('Raise a full link’s metric so traffic prefers another path, upgrade it, or install Auto-TE.')+'

'}`+hot.map(l=>`
${CITY[l.a].name} ⇄ ${CITY[l.b].name}
${capName(l)} · ${tr('{p} full',{p:pct((R.load[l.id]||0)/capOf(l))})}
${btn(tr('Inspect'),'selLink',{id:l.id},'pink sm')}
`).join('');} + h+=hwCard(); const slow=Object.keys(S.pops).filter(latSlow).sort((a,b)=>R.latF[a]-R.latF[b]); if(slow.length)h+=`

🐢 ${tr('Slow cities')}

${tr('Their users go out through transit far away. Past 50 ms round trip, broadband and internet services count as bad service.')}

`+slow.map(c=>{const f=R.latFar[c];return `
${CITY[c].name} → ${CITY[f.to].name}
${tr('{p} of its traffic · {ms} ms round trip · service {sf}',{p:pct(Math.min(1,f.share)),ms:Math.round(f.ms),sf:pct(R.latF[c])})}
${btn(tr('Inspect'),'focusCity',{city:c},'ghost sm')}
`;}).join(''); const hotR=hotPorts(); @@ -3916,7 +3947,8 @@ function dfPanel(l){ for(const k of Object.keys(OPT)){const O=OPT[k],n=(l.ch||[]).filter(x=>x===k).length,why=chWhy(l,k); const md=optMode(k,l),cc=chCost(l,k),sp=spareN(k); h+=`
${O.n} ${optModes(k,l).map(([g,r])=>tr('{g} to {km} km',{g:fmtG(g),km:r.toLocaleString()})).join(' · ')}
${esc(O.blurb)}${n?` · ${tr('{n} lit',{n})}`:''}${sp?` · ${trn('{n} spare on the shelf','{n} spares on the shelf',sp)}`:''}
${md&&!md.full?`
⚠️ ${tr('Runs at {g} per channel on this route (long-haul mode).',{g:fmtG(md.g)})} ${!l.sub&®enNeed(k,l)>(l.regen|0)?trn('{n} regen site would bring it back to {g}.','{n} regen sites would bring it back to {g}.',regenNeed(k,l),{g:fmtG(O.g)}):''}
`:''}${why?`
${esc(why)}
`:''}
${n?btn('−','rmCh',{id:l.id,o:k},'ghost sm'):''}${btn(sp?`+ ${cc?tr('spare + {price}',{price:fmt$(cc)}):tr('spare')}`:`+ ${fmt$(cc)}`,'addCh',{id:l.id,o:k},'sm',!!why||S.cash`;} - {const st=Object.keys(OPT).filter(k=>spareN(k)>0);h+=`

${tr('Unplugged optics go on the spares shelf and are used first next time.')}

`;if(st.length)h+=`

${tr('Spares shelf')}

`+st.map(k=>`
${spareN(k)} × ${OPT[k].n}
${btn(tr('Sell one {price}',{price:fmt$(spareValue(k))}),'sellSpare',{o:k},'ghost sm')}
`).join('');} + {const st=Object.keys(OPT).filter(k=>spareN(k)>0);h+=`

${tr('Unplugged optics go on the spares shelf and are used first next time.')}

`; + {const used=[...new Set(l.ch||[])].filter(k=>OPT[k]&&OPT[k].lvl<=lvl());if(used.length)h+=`
${used.map(k=>btn(tr('Stock a spare {optic} {price}',{optic:OPT[k].n,price:fmt$(optCost(k))}),'buySpare',{o:k},'ghost sm',S.cash=64)).join('')}

${tr('Spares bought now are already paid for when the next shortage hits.')}

`;}if(st.length)h+=`

${tr('Spares shelf')}

`+st.map(k=>`
${spareN(k)} × ${OPT[k].n}
${btn(tr('Sell one {price}',{price:fmt$(spareValue(k))}),'sellSpare',{o:k},'ghost sm')}
`).join('');} const rg=l.regen|0,rgAdd=REGEN_COST+Math.round((l.ch||[]).reduce((a,c)=>a+optCost(c),0)*REGEN_CH); h+=`

${tr('Line system')}

${esc(sysD.n)}${tr('{n} amplifiers',{n:amps})}
${tr('Regen sites')}${rg?tr('{n} · optical spans of {km} km',{n:rg,km:spanKm(l).toLocaleString()}):tr('none')}

${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.')}

`:`
${rg{price}',{price:fmt$(rgAdd)}),'regen',{id:l.id,d:1},'sm',S.cash`}

${esc(sysD.blurb)}

${(()=>{const t=sysNext(l);if(!t)return '';const T=DF_SYS[t],c=sysUpCost(l);return T.lvl>lvl()?btn(tr('{sys} level {n}',{sys:T.n,n:T.lvl}),'upSys',{id:l.id},'sm',true):btn(tr('Upgrade to {sys} {price}',{sys:T.n,price:fmt$(c)}),'upSys',{id:l.id},'sm',S.cash{price}/mo',{price:fmt$(Math.round(150+(l.ch||[]).length*80))}),'spares',{id:l.id},l.spares?'green sm':'sm')}

${tr('Spare optics and amplifier cards on the shelf turn multi-day hardware failures into one-day swaps.')}

`; @@ -4355,6 +4387,7 @@ function showHelp(){
${tr('IX (Internet Exchange)')}
${tr('A shared switch in a city. One port, many free peering sessions. The route server peers you with every open member at once.')}
PNI
${tr('Private network interconnect: a cable straight to one network in the same building. For big traffic.')}
${tr('PNI lead times')}
${tr('A cross-connect with a small network takes a few weeks. With the big content networks, Tier 1s and big eyeball networks, a new PNI or an augment usually takes about a month, but one order in seven slips to 6 to 12 months. The content networks and Tier 1s start at 100G. Doitsche Telekomm still sells 1G.')}
+
${tr('Supply chain')}
${tr('Routers, optics and new builds get dearer over the years, about 4% a year after the first six months, and now and then a shortage makes one of them a lot dearer for a month or two. What you already own keeps its price. Spares on the shelf and a yearly price lock from the NOC tab soften the blow.')}
${tr('Backhaul latency')}
${tr('Users feel the round trip to wherever their traffic leaves your network for transit. Up to 20 ms (about 1,500 km) is fine; past 50 ms broadband and internet services count as bad service, which costs revenue and customers. Traffic over your own peering, PNIs and caches is not penalised.')}
${tr('Peering inbox')}
${tr('Every IX port brings peering requests and max-prefix alerts, in the Networks tab. A session that blows past its limit is down until you look: raise the limit for growth, keep it down for a leak. Ignore your mail and selective networks get pickier.')}
${tr('Embedded cache')}
${tr('A CDN\'s server in your rack. Serves most of that CDN\'s traffic locally, for the price of power.')}
@@ -4397,7 +4430,7 @@ const OWNCAB_SHIPS=['MV Cable Guy','Spool of Thought','Wet Willy','Reel Deal','S 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)=>seaRoutes(a,b)[0]?.km||Infinity; -const ownCabCost=km=>2*OWNCAB_LAND+km*OWNCAB_KM+DF_SYS.roadm.cost; +const ownCabCost=km=>Math.round((2*OWNCAB_LAND+km*OWNCAB_KM+DF_SYS.roadm.cost)*hwMul('build')); const ownCabMo=km=>Math.round(km*OWNCAB_OM)+ampCount(km)*AMP_MO; const ownCabDays=km=>Math.round(300+km*0.05); // Marine routing uses the same coastline as the map, in geographic coordinates. diff --git a/tests/supply.test.js b/tests/supply.test.js new file mode 100644 index 0000000..7e2219a --- /dev/null +++ b/tests/supply.test.js @@ -0,0 +1,73 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +function setup(ev) { + ev("ACT.start({});S.cash=1e9;S.lvl=6;S.nextFail=S.nextEvent=1e9;for(const g of GOALS)S.done[g.id]=0;compute()"); +} + +test('hardware gets dearer over the years, gently, and only for new purchases', () => { + const { ev, errors } = load(); + setup(ev); + const o = ev('Object.keys(OPT)[0]'); + const at = d => JSON.parse(ev(`S.day=${d};JSON.stringify([optCost('${o}'),routerCost(1),dfBuildCost(500),ownCabCost(5000)])`)); + const d0 = at(0); + assert.deepEqual(at(180), d0, 'nothing changes in the first six months'); + const y1 = at(180 + 365); + assert.ok(y1.every((v, i) => Math.abs(v / d0[i] - 1.04) < 0.01), `+4% a year (${y1} vs ${d0})`); + const late = at(180 + 365 * 30); + assert.ok(late.every((v, i) => Math.abs(v / d0[i] - 1.3) < 0.01), 'capped at +30%'); + // what you already own costs what it cost: monthly bills do not move + ev("S.day=0;ACT.buyTransit({city:'fra',net:'cog',tier:1});compute()"); + const mo = ev('R.costMo'); + ev('S.day=180+365*5;compute()'); + assert.equal(ev('R.costMo'), mo); + assert.deepEqual(errors, []); +}); + +test('shortages hit one kind of hardware for a month or two; spares and a price lock soften them', () => { + const { ev, errors } = load(); + setup(ev); + const o = ev('Object.keys(OPT)[0]'); + ev('S.day=200'); + const calm = JSON.parse(ev(`JSON.stringify([optCost('${o}'),routerCost(1),dfBuildCost(500)])`)); + // a spare bought in calm times is already paid for + ev(`ACT.buySpare({o:'${o}'})`); + assert.equal(ev(`spareN('${o}')`), 1); + ev("Math.random=()=>0;hwShockStart()"); + assert.equal(ev('S.hw.shock.k'), 'opt'); + const n = ev('S.hw.shock.until-S.day'); + assert.ok(n >= 45 && n <= 75, `a month or two (${n} days)`); + assert.equal(ev(`optCost('${o}')`), Math.round(ev(`OPT['${o}'].cost*hwTrend(S.day)*1.5`))); + assert.equal(ev('routerCost(1)'), calm[1], 'only optics'); + assert.match(ev("document.getElementById('toasts').textContent"), /Laser shortage/); + // the NOC shows it, and a lock costs double during a shortage + ev("UI.sel=null;UI.left='noc';UI.leftOpen=true;renderLeft()"); + assert.match(ev("document.getElementById('left').textContent"), /Supply chain[\s\S]*Optics \+50%/); + const dear = ev('hwLockCost()'); + ev('S.hw.shock.until=S.day'); + assert.equal(ev('hwLockCost()') * 2, dear); + // a lock keeps today's prices for a year, whatever happens + const cash = ev('S.cash'); + ev('ACT.hwLock()'); + assert.equal(cash - ev('S.cash'), ev('hwLockCost()')); + ev("S.day+=100;Math.random=()=>0.4;hwShockStart()"); + assert.equal(ev('S.hw.shock.k'), 'rt'); + assert.equal(ev('routerCost(1)'), calm[1], 'locked through a chip shortage'); + assert.equal(ev("S.day+=300;dfBuildCost(500)"), Math.round((25000 + 500 * 120) * ev('hwTrend(S.day)')), 'and then it runs out'); + // events: only after six months, and never two shortages at once + ev("S.day=100;S.hw={}"); + assert.equal(ev("(()=>{const o=[];if(S.day>HW_FREE&&!hwShock())o.push(1);return o.length})()"), 0); + assert.deepEqual(errors, []); +}); + +test('saves: shortages and locks survive, garbage is repaired', () => { + const { ev, errors } = load(); + setup(ev); + ev("S.hw={shock:{k:'opt',until:'90',mul:9},lock:{until:400,mul:'x'}};window.__a=JSON.parse(JSON.stringify(S));sanitize(__a)"); + assert.deepEqual(JSON.parse(ev('JSON.stringify(__a.hw)')), { shock: { k: 'opt', until: 90, mul: 2 }, lock: { until: 400, mul: 1 } }); + ev("S.hw={shock:{k:'nope'}};window.__b=JSON.parse(JSON.stringify(S));sanitize(__b);window.__c=JSON.parse(JSON.stringify(S));delete __c.hw;sanitize(__c)"); + assert.equal(ev('JSON.stringify(__b.hw)'), '{}'); + assert.equal(ev('JSON.stringify(__c.hw)'), '{}', 'old saves get an empty supply chain'); + assert.deepEqual(errors, []); +});