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
|
|
@ -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;},
|
||||
pass:a=>({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)})]};
|
||||
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);
|
||||
|
|
@ -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)}));
|
||||
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};},
|
||||
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'],
|
||||
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)})];
|
||||
|
|
@ -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);
|
||||
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=[];
|
||||
if(!S.pops[A])blocked.push(linkFromWhy(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(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'));
|
||||
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};},
|
||||
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]],
|
||||
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;},
|
||||
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 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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue