A link starts at one of your POPs, for typed orders too
The map only drags a link from a POP, but buildLink, orderDf and orderCable read both ends from UI.pending, which the agent API fills from its arguments. An agent could sign a dark fiber IRU from a city with no POP (Aracaju got three of them). The three orders now refuse that with a toast, and their dry-run quotes report it as blocked. Three tests ordered from a city with no POP (ACT.start ignores city, so the only POP was Frankfurt); they now open the POP they assumed.
This commit is contained in:
parent
ac5ce7fa05
commit
3fd44908af
15 changed files with 77 additions and 9 deletions
|
|
@ -8,6 +8,7 @@ All notable changes to this project are documented here. The project follows
|
||||||
|
|
||||||
- The map zooms in twice as far, for crowded regions like New England or around Washington.
|
- The map zooms in twice as far, for crowded regions like New England or around Washington.
|
||||||
- Cable ships at anchor sit a little further out from their port, and a tap on a city picks the city even with a ship close by.
|
- Cable ships at anchor sit a little further out from their port, and a tap on a city picks the city even with a ship close by.
|
||||||
|
- Agents playing through the Agent API can no longer start a link in a city where you have no POP, just as on the map. Before, an agent could sign a dark fiber IRU, lease a wave or lay a cable from such a city; now it is told why, and so is its dry run.
|
||||||
|
|
||||||
## [2.8.0] — 2026-11-04
|
## [2.8.0] — 2026-11-04
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
"action_helpers.too_far_even_at_its_slowest":"Zu weit, selbst in der langsamsten Einstellung: Ein optischer Abschnitt ist hier {span} km lang, die Reichweite beträgt {max} km. Füge einen Regenerator-Standort hinzu (Line System).",
|
"action_helpers.too_far_even_at_its_slowest":"Zu weit, selbst in der langsamsten Einstellung: Ein optischer Abschnitt ist hier {span} km lang, die Reichweite beträgt {max} km. Füge einen Regenerator-Standort hinzu (Line System).",
|
||||||
"action_helpers.unlocks_at_customer_level_n":"Wird ab Kundenlevel {n} freigeschaltet.",
|
"action_helpers.unlocks_at_customer_level_n":"Wird ab Kundenlevel {n} freigeschaltet.",
|
||||||
"action_helpers.upgrades_cannot_stretch_this_optic":"Dieser Kanal reicht auf diesem Kabel {max} km weit; die Strecke ist {span} km lang. Unterwasser-Terminals und optisches Engineering verlängern diese Optik nicht. Diese reichen so weit: {optics}.",
|
"action_helpers.upgrades_cannot_stretch_this_optic":"Dieser Kanal reicht auf diesem Kabel {max} km weit; die Strecke ist {span} km lang. Unterwasser-Terminals und optisches Engineering verlängern diese Optik nicht. Diese reichen so weit: {optics}.",
|
||||||
|
"action_helpers.you_have_no_pop_in_city":"<b>Du hast keinen POP in {city}.</b><br>Ein Link beginnt an einem deiner POPs und eröffnet am anderen Ende einen POP, wenn dort keiner ist.",
|
||||||
"actions.your_router_can_t_take_a":"<b>Dein Router kann keinen {port}-Port aufnehmen.</b><br>Rüste ihn im Tab Infra auf.",
|
"actions.your_router_can_t_take_a":"<b>Dein Router kann keinen {port}-Port aufnehmen.</b><br>Rüste ihn im Tab Infra auf.",
|
||||||
"architect.anchor":"🐒 Platsch!",
|
"architect.anchor":"🐒 Platsch!",
|
||||||
"architect.architect_runs":"Architekt-Runs",
|
"architect.architect_runs":"Architekt-Runs",
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"action_helpers.too_far_even_at_its_slowest":"Demasiado lejos incluso en su ajuste más lento: aquí un tramo óptico mide {span} km y el alcance es de {max} km. Añade un sitio regenerador (Sistema de línea).",
|
"action_helpers.too_far_even_at_its_slowest":"Demasiado lejos incluso en su ajuste más lento: aquí un tramo óptico mide {span} km y el alcance es de {max} km. Añade un sitio regenerador (Sistema de línea).",
|
||||||
"action_helpers.unlocks_at_customer_level_n":"Se desbloquea en el nivel de cliente {n}.",
|
"action_helpers.unlocks_at_customer_level_n":"Se desbloquea en el nivel de cliente {n}.",
|
||||||
"action_helpers.upgrades_cannot_stretch_this_optic":"Este canal llega a {max} km en este cable; la ruta mide {span} km. Las terminales submarinas y la ingeniería óptica no alargan esta óptica. Estas sí llegan: {optics}.",
|
"action_helpers.upgrades_cannot_stretch_this_optic":"Este canal llega a {max} km en este cable; la ruta mide {span} km. Las terminales submarinas y la ingeniería óptica no alargan esta óptica. Estas sí llegan: {optics}.",
|
||||||
|
"action_helpers.you_have_no_pop_in_city":"<b>No tienes ningún POP en {city}.</b><br>Un enlace empieza en uno de tus POP y abre un POP en el otro extremo si hace falta.",
|
||||||
"actions.your_router_can_t_take_a":"<b>Tu router no admite un puerto de {port}.</b><br>Mejóralo en la pestaña Infra.",
|
"actions.your_router_can_t_take_a":"<b>Tu router no admite un puerto de {port}.</b><br>Mejóralo en la pestaña Infra.",
|
||||||
"architect.anchor":"🐒 ¡Chof!",
|
"architect.anchor":"🐒 ¡Chof!",
|
||||||
"architect.architect_runs":"Partidas de arquitecto",
|
"architect.architect_runs":"Partidas de arquitecto",
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"action_helpers.too_far_even_at_its_slowest":"Trop loin, même au débit le plus lent : ici une portée optique fait {span} km et l’optique va jusqu’à {max} km. Ajoute un site de régénération (Système de ligne).",
|
"action_helpers.too_far_even_at_its_slowest":"Trop loin, même au débit le plus lent : ici une portée optique fait {span} km et l’optique va jusqu’à {max} km. Ajoute un site de régénération (Système de ligne).",
|
||||||
"action_helpers.unlocks_at_customer_level_n":"Se débloque au niveau client {n}.",
|
"action_helpers.unlocks_at_customer_level_n":"Se débloque au niveau client {n}.",
|
||||||
"action_helpers.upgrades_cannot_stretch_this_optic":"Ce canal porte à {max} km sur ce câble ; le tracé fait {span} km. Les terminaux sous-marins et l’ingénierie optique n’allongent pas cette optique. Celles-ci y arrivent : {optics}.",
|
"action_helpers.upgrades_cannot_stretch_this_optic":"Ce canal porte à {max} km sur ce câble ; le tracé fait {span} km. Les terminaux sous-marins et l’ingénierie optique n’allongent pas cette optique. Celles-ci y arrivent : {optics}.",
|
||||||
|
"action_helpers.you_have_no_pop_in_city":"<b>Tu n’as pas de POP à {city}.</b><br>Un lien part d’un de tes POP, et ouvre un POP à l’autre bout s’il en faut un.",
|
||||||
"actions.your_router_can_t_take_a":"<b>Ton routeur ne supporte pas de port {port}.</b><br>Mets-le à niveau dans l’onglet Infra.",
|
"actions.your_router_can_t_take_a":"<b>Ton routeur ne supporte pas de port {port}.</b><br>Mets-le à niveau dans l’onglet Infra.",
|
||||||
"architect.anchor":"🐒 Plouf !",
|
"architect.anchor":"🐒 Plouf !",
|
||||||
"architect.architect_runs":"Parties d’architecte",
|
"architect.architect_runs":"Parties d’architecte",
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"action_helpers.too_far_even_at_its_slowest":"Troppo lontano anche alla velocità più bassa: qui una tratta ottica è di {span} km e l’ottica arriva a {max} km. Aggiungi un sito di rigenerazione (Sistema di linea).",
|
"action_helpers.too_far_even_at_its_slowest":"Troppo lontano anche alla velocità più bassa: qui una tratta ottica è di {span} km e l’ottica arriva a {max} km. Aggiungi un sito di rigenerazione (Sistema di linea).",
|
||||||
"action_helpers.unlocks_at_customer_level_n":"Si sblocca al livello cliente {n}.",
|
"action_helpers.unlocks_at_customer_level_n":"Si sblocca al livello cliente {n}.",
|
||||||
"action_helpers.upgrades_cannot_stretch_this_optic":"Questo canale raggiunge {max} km su questo cavo; il percorso è di {span} km. Terminali sottomarini e ingegneria ottica non allungano quest’ottica. Ci arrivano: {optics}.",
|
"action_helpers.upgrades_cannot_stretch_this_optic":"Questo canale raggiunge {max} km su questo cavo; il percorso è di {span} km. Terminali sottomarini e ingegneria ottica non allungano quest’ottica. Ci arrivano: {optics}.",
|
||||||
|
"action_helpers.you_have_no_pop_in_city":"<b>Non hai nessun POP a {city}.</b><br>Un link parte da uno dei tuoi POP e, se serve, apre un POP all’altro capo.",
|
||||||
"actions.your_router_can_t_take_a":"<b>Il tuo router non regge una porta {port}.</b><br>Aggiornalo nella scheda Infra.",
|
"actions.your_router_can_t_take_a":"<b>Il tuo router non regge una porta {port}.</b><br>Aggiornalo nella scheda Infra.",
|
||||||
"architect.anchor":"🐒 Splash!",
|
"architect.anchor":"🐒 Splash!",
|
||||||
"architect.architect_runs":"Partite da architetto",
|
"architect.architect_runs":"Partite da architetto",
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"action_helpers.too_far_even_at_its_slowest":"Longe demais até na configuração mais lenta: um span óptico aqui tem {span} km e ela alcança {max} km. Adicione um site de regeneração (Line system).",
|
"action_helpers.too_far_even_at_its_slowest":"Longe demais até na configuração mais lenta: um span óptico aqui tem {span} km e ela alcança {max} km. Adicione um site de regeneração (Line system).",
|
||||||
"action_helpers.unlocks_at_customer_level_n":"Desbloqueia no nível de cliente {n}.",
|
"action_helpers.unlocks_at_customer_level_n":"Desbloqueia no nível de cliente {n}.",
|
||||||
"action_helpers.upgrades_cannot_stretch_this_optic":"Este canal alcança {max} km neste cabo; a rota tem {span} km. Terminais submarinos e engenharia óptica não esticam esta óptica. Estas chegam lá: {optics}.",
|
"action_helpers.upgrades_cannot_stretch_this_optic":"Este canal alcança {max} km neste cabo; a rota tem {span} km. Terminais submarinos e engenharia óptica não esticam esta óptica. Estas chegam lá: {optics}.",
|
||||||
|
"action_helpers.you_have_no_pop_in_city":"<b>Você não tem POP em {city}.</b><br>Um link começa em um dos seus POPs e abre um POP na outra ponta, se precisar.",
|
||||||
"actions.your_router_can_t_take_a":"<b>Seu router não aguenta uma porta {port}.</b><br>Faça upgrade na aba Infra.",
|
"actions.your_router_can_t_take_a":"<b>Seu router não aguenta uma porta {port}.</b><br>Faça upgrade na aba Infra.",
|
||||||
"architect.anchor":"🐒 Tchibum!",
|
"architect.anchor":"🐒 Tchibum!",
|
||||||
"architect.architect_runs":"Partidas de arquiteto",
|
"architect.architect_runs":"Partidas de arquiteto",
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ const API_CMD={
|
||||||
bind:a=>{UI.pending={a:a.a,b:a.b};UI.route=a.route||'';UI.via=a.cable||'';UI.cnPrem=!!a.premiumCrossing;},
|
bind:a=>{UI.pending={a:a.a,b:a.b};UI.route=a.route||'';UI.via=a.cable||'';UI.cnPrem=!!a.premiumCrossing;},
|
||||||
pass:a=>({tier:a.tier}),
|
pass:a=>({tier:a.tier}),
|
||||||
quote:a=>{const A=a.a,B=a.b,tier=a.tier;
|
quote:a=>{const A=a.a,B=a.b,tier=a.tier;
|
||||||
|
if(!S.pops[A])return {blocked:[linkFromWhy(A)]};
|
||||||
if(!waveOk(A,B,tier))return {blocked:[tr('links.a_wave_wave_needs_need_at',{wave:LT[tier].n,need:waveNeed(tier)})]};
|
if(!waveOk(A,B,tier))return {blocked:[tr('links.a_wave_wave_needs_need_at',{wave:LT[tier].n,need:waveNeed(tier)})]};
|
||||||
const sib=pairLinks(A,B).filter(l=>l.kind!=='vxc'),jn=sib.length?routeJoin(A,B):null,border=cnCity(A)!==cnCity(B);
|
const sib=pairLinks(A,B).filter(l=>l.kind!=='vxc'),jn=sib.length?routeJoin(A,B):null,border=cnCity(A)!==cnCity(B);
|
||||||
const mult=(sib.length&&!(jn&&jn.k===(landTrenches(A,B)[0]||{}).k)?DIVERSE:1)*(border?3*((a.premiumCrossing&&(A==='hkg'||B==='hkg'))?1.6:1):1);
|
const mult=(sib.length&&!(jn&&jn.k===(landTrenches(A,B)[0]||{}).k)?DIVERSE:1)*(border?3*((a.premiumCrossing&&(A==='hkg'||B==='hkg'))?1.6:1):1);
|
||||||
|
|
@ -115,7 +116,7 @@ const API_CMD={
|
||||||
if(so)blocked.push(tr('links.no_wave_capacity_on_this_route',{wave:LT[tier].n,why:tr(so.why),n:Math.max(1,so.until-S.day)}));
|
if(so)blocked.push(tr('links.no_wave_capacity_on_this_route',{wave:LT[tier].n,why:tr(so.why),n:Math.max(1,so.until-S.day)}));
|
||||||
const w=subWaveWhy(tier,wr.km,wr.sub);if(w)blocked.push(tr('links.no_wave_waves_on_this_cable',{wave:LT[tier].n,why:w}));
|
const w=subWaveWhy(tier,wr.km,wr.sub);if(w)blocked.push(tr('links.no_wave_waves_on_this_cable',{wave:LT[tier].n,why:w}));
|
||||||
return {setup:Math.round(waveMo(wr.km,wr.sub,tier)*wr.wm)+(S.pops[B]?0:popCost(B)),monthly:Math.round(waveMo(wr.km,wr.sub,tier)*wr.wm),blocked};},
|
return {setup:Math.round(waveMo(wr.km,wr.sub,tier)*wr.wm)+(S.pops[B]?0:popCost(B)),monthly:Math.round(waveMo(wr.km,wr.sub,tier)*wr.wm),blocked};},
|
||||||
doc:'Lease a wave between two cities; opens a POP in b if there is none. A second wave on a pair costs 1.4x unless it joins an existing trench; cross-border into mainland China costs 3x. premiumCrossing applies only via Hong Kong.'},
|
doc:'Lease a wave from one of your POPs (a) to any city; opens a POP in b if there is none. A second wave on a pair costs 1.4x unless it joins an existing trench; cross-border into mainland China costs 3x. premiumCrossing applies only via Hong Kong.'},
|
||||||
upLink:{args:[['id','entityId'],['tier','linkTier']],watch:['links.#id'],
|
upLink:{args:[['id','entityId'],['tier','linkTier']],watch:['links.#id'],
|
||||||
quote:a=>{const l=S.links.find(x=>x.id===a.id);if(!l)return {};
|
quote:a=>{const l=S.links.find(x=>x.id===a.id);if(!l)return {};
|
||||||
const blocked=[waveOk(l.a,l.b,a.tier)?'':tr('links.a_wave_wave_needs_need_at',{wave:LT[a.tier].n,need:waveNeed(a.tier)})];
|
const blocked=[waveOk(l.a,l.b,a.tier)?'':tr('links.a_wave_wave_needs_need_at',{wave:LT[a.tier].n,need:waveNeed(a.tier)})];
|
||||||
|
|
@ -155,6 +156,7 @@ const API_CMD={
|
||||||
quote:a=>{const A=a.a,B=a.b,sc=isSub(A,B)?subDfCable(A,B):null,km=sc?sc.km:kmBetween(A,B);
|
quote:a=>{const A=a.a,B=a.b,sc=isSub(A,B)?subDfCable(A,B):null,km=sc?sc.km:kmBetween(A,B);
|
||||||
const building=a.source==='build'&&lvl()>=3&&!sc,sys=DF_SYS[a.system]&&DF_SYS[a.system].lvl<=lvl()?a.system:'lite';
|
const building=a.source==='build'&&lvl()>=3&&!sc,sys=DF_SYS[a.system]&&DF_SYS[a.system].lvl<=lvl()?a.system:'lite';
|
||||||
const amps=ampCount(km),blocked=[];
|
const amps=ampCount(km),blocked=[];
|
||||||
|
if(!S.pops[A])blocked.push(linkFromWhy(A));
|
||||||
if(isSub(A,B)&&!sc)blocked.push(tr('fiber_modals.nobody_sells_dark_fiber_on_a'));
|
if(isSub(A,B)&&!sc)blocked.push(tr('fiber_modals.nobody_sells_dark_fiber_on_a'));
|
||||||
else if(uaePair(A,B))blocked.push(tr('fiber_modals.no_dark_fiber_inside_the_uae'));
|
else if(uaePair(A,B))blocked.push(tr('fiber_modals.no_dark_fiber_inside_the_uae'));
|
||||||
else if(landX(A,B)&&cnCity(A)===cnCity(B))blocked.push(tr('fiber_modals.nobody_sells_one_fiber_pair_across'));
|
else if(landX(A,B)&&cnCity(A)===cnCity(B))blocked.push(tr('fiber_modals.nobody_sells_one_fiber_pair_across'));
|
||||||
|
|
@ -162,11 +164,11 @@ const API_CMD={
|
||||||
if(lvl()<2)blocked.push(tr('fiber_modals.dark_fiber_unlocks_at_customer_level'));
|
if(lvl()<2)blocked.push(tr('fiber_modals.dark_fiber_unlocks_at_customer_level'));
|
||||||
return {setup:(building?dfBuildCost(km):0)+DF_SYS[sys].cost+amps*AMP_COST+(S.pops[B]?0:popCost(B)),
|
return {setup:(building?dfBuildCost(km):0)+DF_SYS[sys].cost+amps*AMP_COST+(S.pops[B]?0:popCost(B)),
|
||||||
monthly:(building?Math.round(km*0.15):dfLeaseMo(km))+amps*AMP_MO,days:building?dfBuildDays(km):30,blocked};},
|
monthly:(building?Math.round(km*0.15):dfLeaseMo(km))+amps*AMP_MO,days:building?dfBuildDays(km):30,blocked};},
|
||||||
doc:'Get dark fiber: lease an IRU, dig your own (level 3+), or take a pair on a subsea cable. Then light it with a line system.'},
|
doc:'Get dark fiber from one of your POPs (a): lease an IRU, dig your own (level 3+), or take a pair on a subsea cable; opens a POP in b if there is none. Then light it with a line system.'},
|
||||||
orderCable:{args:[['a','cityId'],['b','cityId'],['design','designId',false],['terminal','boolean',false],['engineering','boolean',false]],
|
orderCable:{args:[['a','cityId'],['b','cityId'],['design','designId',false],['terminal','boolean',false],['engineering','boolean',false]],
|
||||||
bindsUI:['pending','seaDesign','seaterminal','seaengineering'],
|
bindsUI:['pending','seaDesign','seaterminal','seaengineering'],
|
||||||
bind:a=>{UI.pending={a:a.a,b:a.b};UI.seaDesign=a.design||'standard';UI.seaterminal=!!a.terminal;UI.seaengineering=!!a.engineering;},
|
bind:a=>{UI.pending={a:a.a,b:a.b};UI.seaDesign=a.design||'standard';UI.seaterminal=!!a.terminal;UI.seaengineering=!!a.engineering;},
|
||||||
quote:a=>{const why=ownCabWhy(a.a,a.b);if(why)return {blocked:[why]};
|
quote:a=>{const why=linkFromWhy(a.a)||ownCabWhy(a.a,a.b);if(why)return {blocked:[why]};
|
||||||
const design=own(SEA_DESIGNS,a.design)?a.design:'standard',up={terminal:!!a.terminal,engineering:!!a.engineering};
|
const design=own(SEA_DESIGNS,a.design)?a.design:'standard',up={terminal:!!a.terminal,engineering:!!a.engineering};
|
||||||
const q=seaQuote(a.a,a.b,design,up),lack=seaLack(q.km,up);
|
const q=seaQuote(a.a,a.b,design,up),lack=seaLack(q.km,up);
|
||||||
return {setup:q.cost+(S.pops[a.b]?0:popCost(a.b)),monthly:ownCabMo(q.km),days:q.days,
|
return {setup:q.cost+(S.pops[a.b]?0:popCost(a.b)),monthly:ownCabMo(q.km),days:q.days,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ Object.assign(ACT,{
|
||||||
foundIx:({city})=>{if(!S.pops[city]||S.myIx[city]||CITY[city].ix||CITY[city].cn)return;if(!spend(MYIX_COST))return;const nm=(S.name.split(' ')[0]||'My').replace(/[^A-Za-z0-9]/g,'').slice(0,10)+'-IX '+CITY[city].name;
|
foundIx:({city})=>{if(!S.pops[city]||S.myIx[city]||CITY[city].ix||CITY[city].cn)return;if(!spend(MYIX_COST))return;const nm=(S.name.split(' ')[0]||'My').replace(/[^A-Za-z0-9]/g,'').slice(0,10)+'-IX '+CITY[city].name;
|
||||||
S.myIx[city]={name:nm,members:[],next:S.day+4};S.ixp[city]=2;toast(tr('links.you_founded_ix_networks_will_join',{ix:esc(nm)}),'goal');after();},
|
S.myIx[city]={name:nm,members:[],next:S.day+4};S.ixp[city]=2;toast(tr('links.you_founded_ix_networks_will_join',{ix:esc(nm)}),'goal');after();},
|
||||||
buildLink:({tier})=>{tier=+tier;const p=UI.pending;if(!p)return;const {a,b}=p;const km=kmBetween(a,b),sub=isSub(a,b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'),jn=sib.length?routeJoin(a,b):null,same=!!jn,border=cnCity(a)!==cnCity(b),mult=(sib.length&&!(jn&&jn.k===(landTrenches(a,b)[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1);
|
buildLink:({tier})=>{tier=+tier;const p=UI.pending;if(!p)return;const {a,b}=p;const km=kmBetween(a,b),sub=isSub(a,b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'),jn=sib.length?routeJoin(a,b):null,same=!!jn,border=cnCity(a)!==cnCity(b),mult=(sib.length&&!(jn&&jn.k===(landTrenches(a,b)[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1);
|
||||||
if((cnCity(a)||cnCity(b))&&!cnOk())return;
|
if(!linkFromOk(a)||((cnCity(a)||cnCity(b))&&!cnOk()))return;
|
||||||
if(!waveOk(a,b,tier)){toast(tr('links.a_wave_wave_needs_need_at',{wave:LT[tier].n,need:esc(waveNeed(tier))}),'bad');sfx('err');return;}
|
if(!waveOk(a,b,tier)){toast(tr('links.a_wave_wave_needs_need_at',{wave:LT[tier].n,need:esc(waveNeed(tier))}),'bad');sfx('err');return;}
|
||||||
const wr=waveRoute(a,b,mult,border);if(!wr){toast(tr('links.no_cable_available_for_that_route'),'bad');sfx('err');return;}
|
const wr=waveRoute(a,b,mult,border);if(!wr){toast(tr('links.no_cable_available_for_that_route'),'bad');sfx('err');return;}
|
||||||
{const so=soldOut(a,b,tier,wr.cab);if(so){toast(tr('links.no_wave_capacity_on_this_route',{wave:LT[tier].n,why:tr(so.why),n:Math.max(1,so.until-S.day)}),'bad');sfx('err');return;}}{const w=subWaveWhy(tier,wr.km,wr.sub);if(w){toast(tr('links.no_wave_waves_on_this_cable',{wave:LT[tier].n,why:esc(w)}),'bad');sfx('err');return;}}const base=Math.round(waveMo(wr.km,wr.sub,tier)*wr.wm),cost=base+(S.pops[b]?0:popCost(b));
|
{const so=soldOut(a,b,tier,wr.cab);if(so){toast(tr('links.no_wave_capacity_on_this_route',{wave:LT[tier].n,why:tr(so.why),n:Math.max(1,so.until-S.day)}),'bad');sfx('err');return;}}{const w=subWaveWhy(tier,wr.km,wr.sub);if(w){toast(tr('links.no_wave_waves_on_this_cable',{wave:LT[tier].n,why:esc(w)}),'bad');sfx('err');return;}}const base=Math.round(waveMo(wr.km,wr.sub,tier)*wr.wm),cost=base+(S.pops[b]?0:popCost(b));
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,14 @@ Object.assign(ACT,{
|
||||||
ownCab:()=>{UI.lmode='df';UI.dfSrc='cable';UI.seaDesign='standard';UI.seaterminal=UI.seaengineering=false;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
ownCab:()=>{UI.lmode='df';UI.dfSrc='cable';UI.seaDesign='standard';UI.seaterminal=UI.seaengineering=false;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
||||||
dfSrc:({v})=>{UI.dfSrc=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
dfSrc:({v})=>{UI.dfSrc=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
||||||
dfSys:({v})=>{UI.dfSys=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
dfSys:({v})=>{UI.dfSys=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
|
||||||
orderCable:()=>{const p=UI.pending;if(!p)return;const {a,b}=p;if(ownCabWhy(a,b))return;const design=own(SEA_DESIGNS,UI.seaDesign)?UI.seaDesign:'standard',up=seaUps(seaQuote(a,b,design).km),q=seaQuote(a,b,design,up),km=q.km,cost=q.cost+(S.pops[b]?0:popCost(b));if(seaLack(km,up).length||!spend(cost))return;
|
orderCable:()=>{const p=UI.pending;if(!p)return;const {a,b}=p;if(ownCabWhy(a,b)||!linkFromOk(a))return;const design=own(SEA_DESIGNS,UI.seaDesign)?UI.seaDesign:'standard',up=seaUps(seaQuote(a,b,design).km),q=seaQuote(a,b,design,up),km=q.km,cost=q.cost+(S.pops[b]?0:popCost(b));if(seaLack(km,up).length||!spend(cost))return;
|
||||||
if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(b);}
|
if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(b);}
|
||||||
const used=new Set(S.links.map(l=>l.cname).filter(Boolean)),cname=OWNCAB_NAMES.find(n=>!used.has(n))||`${pick(OWNCAB_NAMES)} ${used.size+1}`,id=uid(),ship=layName({id}),days=q.days;
|
const used=new Set(S.links.map(l=>l.cname).filter(Boolean)),cname=OWNCAB_NAMES.find(n=>!used.has(n))||`${pick(OWNCAB_NAMES)} ${used.size+1}`,id=uid(),ship=layName({id}),days=q.days;
|
||||||
S.links.push({id,a,b,kind:'df',own:true,sub:true,seaDesign:design,seaPath:q.pts.map(p=>p.slice()),sys:'roadm',ch:[],km,cable:null,cname,mo:Math.round(km*OWNCAB_OM),trench:'own:'+id,cut:0,day:S.day,ready:S.day+days,spares:false,pairs:1});
|
S.links.push({id,a,b,kind:'df',own:true,sub:true,seaDesign:design,seaPath:q.pts.map(p=>p.slice()),sys:'roadm',ch:[],km,cable:null,cname,mo:Math.round(km*OWNCAB_OM),trench:'own:'+id,cut:0,day:S.day,ready:S.day+days,spares:false,pairs:1});
|
||||||
const laid=S.links[S.links.length-1];laid.paid=q.cost;for(const k of Object.keys(SUB_UPGRADES))if(up[k])laid['sub'+k]=laid.ready;UI.seaDesign='standard';UI.seaterminal=UI.seaengineering=false;
|
const laid=S.links[S.links.length-1];laid.paid=q.cost;for(const k of Object.keys(SUB_UPGRADES))if(up[k])laid['sub'+k]=laid.ready;UI.seaDesign='standard';UI.seaterminal=UI.seaengineering=false;
|
||||||
S.stats.ownCab=(S.stats.ownCab||0)+1;UI.dfSrc='lease';closeModal();UI.sel={type:'link',id};
|
S.stats.ownCab=(S.stats.ownCab||0)+1;UI.dfSrc='lease';closeModal();UI.sel={type:'link',id};
|
||||||
toast(tr('fiber_and_hardware.the_ship_sets_sail_name_your',{ship,name:cname,km:km.toLocaleString(),a:CITY[a].name,b:CITY[b].name,n:days}),'goal');sfx('build');after();},
|
toast(tr('fiber_and_hardware.the_ship_sets_sail_name_your',{ship,name:cname,km:km.toLocaleString(),a:CITY[a].name,b:CITY[b].name,n:days}),'goal');sfx('build');after();},
|
||||||
orderDf:()=>{const p=UI.pending;if(!p)return;const {a,b}=p;if(!dfAllowed(a,b))return;const sc=isSub(a,b)?subDfCable(a,b):null,km=sc?sc.km:kmBetween(a,b);
|
orderDf:()=>{const p=UI.pending;if(!p)return;const {a,b}=p;if(!dfAllowed(a,b)||!linkFromOk(a))return;const sc=isSub(a,b)?subDfCable(a,b):null,km=sc?sc.km:kmBetween(a,b);
|
||||||
const own=UI.dfSrc==='build'&&!sc,sys=DF_SYS[UI.dfSys]&&techOk('sys',UI.dfSys,DF_SYS[UI.dfSys].lvl)?UI.dfSys:'lite';if(lvl()<2)return;
|
const own=UI.dfSrc==='build'&&!sc,sys=DF_SYS[UI.dfSys]&&techOk('sys',UI.dfSys,DF_SYS[UI.dfSys].lvl)?UI.dfSys:'lite';if(lvl()<2)return;
|
||||||
const up=(own?digCost(km):0)+sysCost(sys)+ampCount(km)*AMP_COST+(S.pops[b]?0:popCost(b));if(!spend(up))return;
|
const up=(own?digCost(km):0)+sysCost(sys)+ampCount(km)*AMP_COST+(S.pops[b]?0:popCost(b));if(!spend(up))return;
|
||||||
if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(b);}
|
if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(b);}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ function prunePairMet(){const m=S.pairMet;if(!m)return;const k=new Set(S.links.m
|
||||||
// Short, busy subsea routes (London–Amsterdam, London–Paris) sell dark fiber pairs too.
|
// Short, busy subsea routes (London–Amsterdam, London–Paris) sell dark fiber pairs too.
|
||||||
function subDfCable(a,b){return cablesOk(a,b).filter(c=>CAB[c.cid].df).sort((x,y)=>x.km-y.km)[0]||null;}
|
function subDfCable(a,b){return cablesOk(a,b).filter(c=>CAB[c.cid].df).sort((x,y)=>x.km-y.km)[0]||null;}
|
||||||
function dfAllowed(a,b){if(isSub(a,b))return !!subDfCable(a,b);return cnCity(a)===cnCity(b)&&!uaePair(a,b)&&!landX(a,b);}
|
function dfAllowed(a,b){if(isSub(a,b))return !!subDfCable(a,b);return cnCity(a)===cnCity(b)&&!uaePair(a,b)&&!landX(a,b);}
|
||||||
|
// A link starts at one of your POPs. The map only drags one from a POP, but a typed order (the agent API) names both ends.
|
||||||
|
function linkFromWhy(a){return S.pops[a]?'':tr('action_helpers.you_have_no_pop_in_city',{city:CITY[a].name});}
|
||||||
|
function linkFromOk(a){const w=linkFromWhy(a);if(w){toast(w,'bad');sfx('err');}return !w;}
|
||||||
/* Optics you unplug go on a spares shelf instead of in the bin (#45): the next channel of that type uses a spare
|
/* Optics you unplug go on a spares shelf instead of in the bin (#45): the next channel of that type uses a spare
|
||||||
for free (only the regen sites' transponders are new), or you sell it on eBuy for part of the price. */
|
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);
|
const SPARE_RESALE=0.4,spareN=o=>(S&&S.spares&&S.spares[o])|0,spareValue=o=>Math.round(optCost(o)*SPARE_RESALE);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
"action_helpers.too_far_even_at_its_slowest":"Too far even at its slowest setting: an optical span here is {span} km and it reaches {max} km. Add a regen site (Line system).",
|
"action_helpers.too_far_even_at_its_slowest":"Too far even at its slowest setting: an optical span here is {span} km and it reaches {max} km. Add a regen site (Line system).",
|
||||||
"action_helpers.unlocks_at_customer_level_n":"Unlocks at customer level {n}.",
|
"action_helpers.unlocks_at_customer_level_n":"Unlocks at customer level {n}.",
|
||||||
"action_helpers.upgrades_cannot_stretch_this_optic":"This channel reaches {max} km on this cable; the route is {span} km. Submarine terminals and optical engineering do not stretch this optic. These reach it: {optics}.",
|
"action_helpers.upgrades_cannot_stretch_this_optic":"This channel reaches {max} km on this cable; the route is {span} km. Submarine terminals and optical engineering do not stretch this optic. These reach it: {optics}.",
|
||||||
|
"action_helpers.you_have_no_pop_in_city":"<b>You have no POP in {city}.</b><br>A link starts at one of your POPs, and opens a POP at the far end if it needs one.",
|
||||||
"actions.your_router_can_t_take_a":"<b>Your router can't take a {port} port.</b><br>Upgrade it in the Infra tab.",
|
"actions.your_router_can_t_take_a":"<b>Your router can't take a {port} port.</b><br>Upgrade it in the Infra tab.",
|
||||||
"architect.anchor":"🐒 Splash!",
|
"architect.anchor":"🐒 Splash!",
|
||||||
"architect.architect_runs":"Architect runs",
|
"architect.architect_runs":"Architect runs",
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ const assert = require('node:assert/strict');
|
||||||
const { load } = require('./harness');
|
const { load } = require('./harness');
|
||||||
|
|
||||||
const horn = (ev) => ev("BADGES.find(b=>b.id==='horn').ok()");
|
const horn = (ev) => ev("BADGES.find(b=>b.id==='horn').ok()");
|
||||||
const start = (ev) => ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=5e9;S.lvl=4;S.won=true;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'bue'})");
|
const start = (ev) => ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=5e9;S.lvl=4;S.won=true;for(const g of GOALS)S.done[g.id]=0;ACT.buildPop({city:'bue'});ACT.launchBB({city:'bue'})");
|
||||||
|
|
||||||
test('#272 your own subsea cable from Buenos Aires to Santiago earns The Long Way Round', () => {
|
test('#272 your own subsea cable from Buenos Aires to Santiago earns The Long Way Round', () => {
|
||||||
const { ev, errors } = load();
|
const { ev, errors } = load();
|
||||||
|
|
|
||||||
|
|
@ -1285,7 +1285,7 @@ test('#51 a dark fiber shows what is rented out, and spare capacity can be liste
|
||||||
|
|
||||||
test('#126 you can zoom in far enough, and pick a short link between two close cities', () => {
|
test('#126 you can zoom in far enough, and pick a short link between two close cities', () => {
|
||||||
const { ev, errors } = load();
|
const { ev, errors } = load();
|
||||||
ev("ACT.start({city:'sao'});S.cash=1e9;for(const g of GOALS)S.done[g.id]=0;for(const c of ['cpq'])ACT.buildPop({city:c});UI.pending=null;UI.via=null;UI.lmode='wave';UI.route='main';openLinkModal('sao','cpq');ACT.buildLink({tier:1});closeModal()");
|
ev("ACT.start({city:'sao'});S.cash=1e9;for(const g of GOALS)S.done[g.id]=0;for(const c of ['sao','cpq'])ACT.buildPop({city:c});UI.pending=null;UI.via=null;UI.lmode='wave';UI.route='main';openLinkModal('sao','cpq');ACT.buildLink({tier:1});closeModal()");
|
||||||
assert.ok(ev('ZMAX') >= 16);
|
assert.ok(ev('ZMAX') >= 16);
|
||||||
const id = ev("S.links.find(l=>l.a==='sao'||l.b==='sao').id");
|
const id = ev("S.links.find(l=>l.a==='sao'||l.b==='sao').id");
|
||||||
// the middle of the drawn link, on screen, fully zoomed in on it
|
// the middle of the drawn link, on screen, fully zoomed in on it
|
||||||
|
|
|
||||||
56
tests/link-preconditions.test.js
Normal file
56
tests/link-preconditions.test.js
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
// Typed orders (the MCP act tool) name both ends of a link, where the map only drags one from a POP of yours.
|
||||||
|
// A link from a city with no POP is refused, with a toast that says why and a dry run that reports it as blocked.
|
||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const { createSession, TOOLS } = require('../scripts/lib/mcp-game');
|
||||||
|
|
||||||
|
function sandbox() {
|
||||||
|
const s = createSession(), T = (name, args = {}) => TOOLS.find((t) => t.name === name).run(s, args), ev = (x) => s.game.ev(x);
|
||||||
|
T('new_game', { city: 'sao', preset: 'sandbox', seed: 7, name: 'Probe' });
|
||||||
|
const act = (action, args, dryRun) => T('act', { action, args, dryRun });
|
||||||
|
return { s, ev, act, pops: () => JSON.parse(ev('JSON.stringify(Object.keys(S.pops).sort())')), links: () => ev('S.links.length') };
|
||||||
|
}
|
||||||
|
|
||||||
|
test('a dark fiber IRU, a wave or a cable from a city with no POP is refused, and its dry run says why', () => {
|
||||||
|
const { s, act, pops, links } = sandbox();
|
||||||
|
for (const [action, args, city] of [
|
||||||
|
['orderDf', { a: 'aju', b: 'rec', source: 'lease', system: 'roadm' }, 'Aracaju'],
|
||||||
|
['orderDf', { a: 'rio', b: 'sao', source: 'build', system: 'lite' }, 'Rio de Janeiro'],
|
||||||
|
['buildLink', { a: 'bsb', b: 'for', tier: 1 }, 'Brasília'],
|
||||||
|
['orderCable', { a: 'for', b: 'lis' }, 'Fortaleza'],
|
||||||
|
]) {
|
||||||
|
const why = new RegExp(`You have no POP in ${city}`);
|
||||||
|
const q = act(action, args, true);
|
||||||
|
assert.equal(q.outcome, 'quote', action);
|
||||||
|
assert.ok(q.quote.blocked.some((b) => why.test(b)), `${action} ${args.a}→${args.b}: ${JSON.stringify(q.quote.blocked)}`);
|
||||||
|
const r = act(action, args);
|
||||||
|
assert.equal(r.outcome, 'rejected', `${action} ${args.a}→${args.b}`);
|
||||||
|
assert.ok(r.toasts.some((t) => why.test(t)), JSON.stringify(r.toasts));
|
||||||
|
assert.equal(r.charged, 0);
|
||||||
|
assert.equal(r.cashChange, 0);
|
||||||
|
}
|
||||||
|
// nothing was built, and no POP opened at either end
|
||||||
|
assert.deepEqual(pops(), ['sao']);
|
||||||
|
assert.equal(links(), 0);
|
||||||
|
assert.deepEqual(s.errors(), []);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('from one of your POPs the same orders still go through and open a POP at the far end', () => {
|
||||||
|
const { s, act, pops, links } = sandbox();
|
||||||
|
for (const [action, args] of [
|
||||||
|
['orderDf', { a: 'sao', b: 'rio', source: 'lease', system: 'roadm' }],
|
||||||
|
['buildLink', { a: 'sao', b: 'bsb', tier: 1 }],
|
||||||
|
['orderCable', { a: 'rio', b: 'lis' }],
|
||||||
|
]) {
|
||||||
|
assert.deepEqual(act(action, args, true).quote.blocked, [], action);
|
||||||
|
assert.equal(act(action, args).outcome, 'applied', action);
|
||||||
|
}
|
||||||
|
assert.deepEqual(pops(), ['bsb', 'lis', 'rio', 'sao']);
|
||||||
|
assert.equal(links(), 3);
|
||||||
|
// the game's own click path is unchanged: the link window from a POP signs the IRU
|
||||||
|
const { ev } = sandbox();
|
||||||
|
ev("openLinkModal('sao','cwb');UI.lmode='df';UI.dfSrc='lease';UI.dfSys='lite';ACT.orderDf()");
|
||||||
|
assert.equal(ev("S.links.filter(l=>l.kind==='df'&&l.a==='sao'&&l.b==='cwb').length"), 1);
|
||||||
|
assert.ok(ev('!!S.pops.cwb'));
|
||||||
|
assert.deepEqual(s.errors(), []);
|
||||||
|
});
|
||||||
|
|
@ -54,7 +54,7 @@ test('packages included in the original order stay aligned with its accelerated
|
||||||
const { ev, dom } = load();
|
const { ev, dom } = load();
|
||||||
try {
|
try {
|
||||||
setup(ev);
|
setup(ev);
|
||||||
ev("S.won=true;UI.pending={a:'sin',b:'lax'};UI.seaterminal=UI.seaengineering=true;ACT.orderCable();S.links=[S.links.at(-1)]");
|
ev("S.won=true;ACT.buildPop({city:'sin'});UI.pending={a:'sin',b:'lax'};UI.seaterminal=UI.seaengineering=true;ACT.orderCable();S.links=[S.links.at(-1)]");
|
||||||
assert.equal(ev('S.links[0].subterminal'), ev('S.links[0].ready'));
|
assert.equal(ev('S.links[0].subterminal'), ev('S.links[0].ready'));
|
||||||
assert.equal(ev('S.links[0].subengineering'), ev('S.links[0].ready'));
|
assert.equal(ev('S.links[0].subengineering'), ev('S.links[0].ready'));
|
||||||
const ready = ev('S.links[0].ready');
|
const ready = ev('S.links[0].ready');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue