${tr("Drag from this router to any city on the map to lay a new link. Two paths to every POP means a backhoe can't take you offline.")}
`; if(!ls.length)h+=`${tr('No links yet.')}
`; for(const l of ls){const o=l.a===c?l.b:l.a,u=capOf(l)?(R.load[l.id]||0)/capOf(l):0,cut=linkDown(l); - h+=`${tr('Shut this POP down: its links, ports and caches go with it, and every customer that depends on it is let go, with an early-termination penalty.')}
${tr('Each channel is a pair of optics, one per end. ZR+ optics plug straight into your routers. Transponders sit on a shelf.')}
`; 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+=`${tr('Unplugged optics go on the spares shelf and are used first next time.')}
`;if(st.length)h+=`${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)})}
${esc(sysD.blurb)}
${tr('Spare optics and amplifier cards on the shelf turn multi-day hardware failures into one-day swaps.')}
`; +${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('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')})}
`);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))];openModal(head+`${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(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))route+=`${landWhy(a,b)}
`; route+=`📈 ${esc(marketNote(a,b,sub))}
`; @@ -3384,8 +3392,37 @@ function openLinkModal(a,b){ ${pop?`${tr('Includes a new POP in {city} ({price}{extra}).',{city:CITY[b].name,price:fmt$(popCost(b)),extra:ruCity(b)?', '+tr('government box included'):CITY[b].uae?', '+tr('free-zone license included'):CITY[b].saudi?', '+tr('local telecom licence included'):''})}
`:''}${route}${viaSeg(a,b)}${esc(why)}
`:''}`;} +function ownCabBody(a,b,pop){const why=ownCabWhy(a,b);if(why)return `${esc(why)}
${btn(tr('Back'),'dfSrc',{v:'lease'},'ghost sm')}`; + const km=ownCabKm(a,b),cost=ownCabCost(km),mo=ownCabMo(km),days=ownCabDays(km),w=Math.round(waveMo(km,true,4)*waveMarket(a,b,true).m),save=10*w-mo,pay=save>0?Math.ceil(cost/save):0; + return `${tr('Your very own subsea cable. A ship lays it across the seabed, you own every fiber pair in it, and nobody else’s waves share your glass. It costs a frankly rude amount of money and takes a long time.')}
+${tr('A leased 1.6T wave on this route costs {price}/mo.',{price:fmt$(w)})} ${pay?tr('Replace ten of them and the cable pays for itself in about {n} months.',{n:pay}):''} ${tr('Cuts still happen, anchors and sharks included, but the repair ship is yours to call.')}
+${tr('Nobody sells dark fiber on a subsea cable here. Subsea capacity comes as leased waves.')}
`; + if(isSub(a,b)&&UI.dfSrc==='cable')return ownCabBody(a,b,pop); + if(isSub(a,b)&&!subDfCable(a,b))return `${tr('Nobody sells dark fiber on a subsea cable here. Subsea capacity comes as leased waves.')}
`+ownCabTeaser(a,b); const sc=isSub(a,b)?subDfCable(a,b):null;if(sc)km=sc.km; if(uaePair(a,b))return `${tr('No dark fiber inside the UAE. Only the two licensed operators may run fiber here, and they only sell waves.')}
`; if(landX(a,b)&&cnCity(a)===cnCity(b))return `${tr('Nobody sells one fiber pair across a dozen borders. Between continents, overland capacity only comes as leased waves.')}
`; @@ -3395,7 +3432,7 @@ function dfModalBody(a,b,km,pop){ const up=(src==='build'?dfBuildCost(km):0)+DF_SYS[sys].cost+amps*AMP_COST+pop,mo=(src==='build'?Math.round(km*0.15):dfLeaseMo(km))+amps*AMP_MO; const w=Math.round(waveMo(km,false,4)); return `${tr('A fiber pair of your own. The glass is cheap, the gear is not: you buy a line system with an amplifier every {km} km, then optics for each channel. Your gear can fail, and you fix it.',{km:AMP_EVERY})}
-${tr("A fiber pair on {cable}, {km} km. It shares the cable with everyone else's waves, anchors included.",{cable:esc(CAB[sc.cid].name),km:sc.km.toLocaleString()})}
`:''} +${tr("A fiber pair on {cable}, {km} km. It shares the cable with everyone else's waves, anchors included.",{cable:esc(CAB[sc.cid].name),km:sc.km.toLocaleString()})}
`:''} ${src==='build'?`${tr('Your own trench: almost no rent, but permits and digging take forever, and delays happen.')}
`:''}${esc(DF_SYS[sys].blurb)} ${trn('Plus {n} in-line amplifier ({price} each, {mo}/mo for hut rent and power).','Plus {n} in-line amplifiers ({price} each, {mo}/mo for hut rent and power).',amps,{price:fmt$(AMP_COST),mo:fmt$(AMP_MO)})}
${km>OPT.tp16.reach?`${km.toLocaleString()} km is longer than any optic reaches at full speed. Transponders will run in long-haul mode (800G or 400G per channel), or add regen sites along the way to get full speed back.
`:''} diff --git a/tests/regions.test.js b/tests/regions.test.js index 981f830..43db174 100644 --- a/tests/regions.test.js +++ b/tests/regions.test.js @@ -399,3 +399,39 @@ test('#47 Cairo reaches Asia overland across the Sinai, priced like the Bosporus assert.equal(ev("isSub('cai','lon')"), true, 'the Channel is still the sea'); assert.deepEqual(errors, []); }); + +test('#22 Tier 1 networks can lay their own subsea cable', () => { + const { ev, dom, errors } = load(); + ev("ACT.start({});S.cash=2e8;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'});ACT.buildPop({city:'lon'});ACT.buildPop({city:'nyc'});compute()"); + const card = () => dom.window.document.getElementById('modalCard').textContent; + // not before Tier 1 + ev("UI.lmode='df';UI.via=null;openLinkModal('lon','nyc')"); + assert.match(card(), /Tier 1 only/); + assert.match(ev("ownCabWhy('lon','nyc')"), /Tier 1/); + ev('ACT.orderCable()'); + assert.equal(ev("S.links.filter(l=>l.own&&l.sub).length"), 0, 'refused before Tier 1'); + // as a Tier 1 + ev("S.won=true;ACT.ownCab()"); + assert.match(card(), /frankly rude amount of money/); + assert.match(card(), /pays for itself in about \d+ months/); + const c0 = ev('S.cash'), km = ev("ownCabKm('lon','nyc')"); + ev('ACT.orderCable()'); + const l = JSON.parse(ev("JSON.stringify(S.links.find(l=>l.own&&l.sub))")); + assert.ok(l, 'the cable is being laid'); + assert.equal(c0 - ev('S.cash'), ev(`ownCabCost(${km})`)); + assert.ok(l.ready - ev('S.day') > 300, 'it takes a long time'); + assert.equal(l.sys, 'roadm'); + assert.ok(l.cname && l.cname.length > 3, 'it gets a name'); + // finished: light it, fill a pair, light the next one; no mid-ocean regen + ev(`const L=S.links.find(x=>x.id==='${l.id}');S.day=L.ready;L.ch=Array(64).fill('tp16');compute()`); + ev(`ACT.regen({id:'${l.id}',d:1})`); + assert.equal(ev(`S.links.find(x=>x.id==='${l.id}').regen|0`), 0, 'no regen sites in the ocean'); + ev(`ACT.addPair({id:'${l.id}'})`); + assert.equal(ev(`S.links.find(x=>x.id==='${l.id}').pairs`), 2); + assert.equal(ev(`pairsMax(S.links.find(x=>x.id==='${l.id}'))`), 8, 'up to eight pairs in a subsea cable'); + // landing stations and China + const inland = ev("CITIES.find(c=>c.land==='eu'&&!landing(c.id)&&!cnCity(c.id)).id"); + assert.match(ev(`ownCabWhy('${inland}','nyc')`), /landing station/, 'both ends need a landing station'); + assert.match(ev("ownCabWhy('sha','sea')"), /China/); + assert.deepEqual(errors, []); +});