Founding your own IX says why it can't

foundIx returned without a word in mainland China, where an exchange
already runs (incumbent or your own), and without a POP, while its dry
run quoted $80k with nothing blocked. foundIxWhy() gives the reason, most
lasting first (China reuses the panel's own text), for the toast and the
quote alike.

The route fuzz's direct moves called foundIx at every POP city. They now
offer it only where the city panel shows the button, as their comment
says, so a refusal that now logs a toast does not count as diverging
from main.
This commit is contained in:
Charlie Allom 2026-11-04 23:07:57 +10:00
parent 034a5de66e
commit 82f3833d8f
No known key found for this signature in database
12 changed files with 62 additions and 9 deletions

View file

@ -64,8 +64,8 @@ const API_CMD={
doc:'Leave an exchange; drops every peering session there. De-Kicks may answer with a retention offer.'},
rs:{args:[['city','ixId']],watch:['rs'],
doc:'Toggle the route-server session, which peers you with everyone on the server at once.'},
foundIx:{args:[['city','cityId']],watch:['myIx.#city'],quote:a=>({setup:MYIX_COST,monthly:MYIX_MO}),
doc:'Found your own exchange in a city with no IX. Networks join over the following days.'},
foundIx:{args:[['city','cityId']],watch:['myIx.#city'],quote:a=>({setup:MYIX_COST,monthly:MYIX_MO,blocked:[foundIxWhy(a.city)].filter(Boolean)}),
doc:'Found your own exchange in a city with no IX where you have a POP. Not in mainland China. Networks join over the following days.'},
myIxUp:{args:[['city','cityId']],watch:['myIx.#city'],
quote:a=>{const m=S.myIx[a.city];const f=m?(m.fab|0)+1:0,N=f<MYIX_FAB.length?MYIX_FAB[f]:null;return N?{setup:N.cost,monthly:N.mo}:{};},
doc:'Upgrade your own exchange\'s switch fabric. Each step has a level gate.'},

View file

@ -12,7 +12,7 @@ Object.assign(ACT,{
if(shipSea(i)){if(shipRush(i)){const s=SHIP[i.ship];toast(tr('cable_ships.ship_chartered',{ship:esc(s.n),home:esc(CITY[s.home].name),n:Math.max(1,i.until-S.day)}),'good');sfx('coin');after();}return;}if(i.slow&&i.rushed)return;if(!spend(i.cost))return;
if(i.slow&&i.until>S.day+1){i.rushed=true;i.cost=0;i.until=S.day+1;const p=S.pops[i.ref];if(p)p.down=Math.min(p.down,S.day+1);toast(tr('links.power_cycled_the_router_in_city',{city:esc(CITY[i.ref].name),chip:esc(RG[(p&&p.rgen)||0].chip)}),'good');after();return;}clearInc(i);toast(tr('links.fixed_what_resolved_early',{what:incTitle(i.type)}),'good');after();},
myIxUp:({city})=>{const m=S.myIx[city];if(!m)return;const f=(m.fab|0)+1,N=MYIX_FAB[f];if(!N)return;if(N.lvl>lvl()){toast(tr('links.a_fab_fabric_unlocks_at_customer',{fab:N.n,lv:N.lvl}),'bad');sfx('err');return;}if(!spend(N.cost))return;m.fab=f;toast(tr('links.ix_now_runs_a_fab_fabric',{ix:esc(m.name),fab:N.n,max:N.max}),'good');m.next=Math.min(m.next,S.day+3);after();},
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(!isCity(city))return;const why=foundIxWhy(city);if(why){toast(why,'bad');sfx('err');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();},
buildLink:({tier})=>{tier=+tier;const p=UI.pending;if(!p||noTalk(p.a,p.b))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(!linkFromOk(a)||((cnCity(a)||cnCity(b))&&!cnOk()))return;

View file

@ -15,6 +15,11 @@ function linkFromOk(a){const w=linkFromWhy(a);if(w){toast(w,'bad');sfx('err');}r
// A retired small city (off: true) takes no new POP; the nearest open city in its country stands in for it.
function popOffWhy(c){const C=CITY[c],near=CITIES.filter(o=>!o.off&&o.cc===C.cc).sort((x,y)=>kmBetween(c,x.id)-kmBetween(c,y.id))[0];
return tr('action_helpers.city_is_off_the_map_small',{city:C.name,near:near?near.name:''});}
// Why a city takes no exchange of your own. The reasons a POP would not fix come first.
function foundIxWhy(c){const C=CITY[c];if(C.cn)return tr('link_panels.running_an_exchange_in_mainland');
if(S.myIx[c])return tr('action_helpers.you_already_run_ix_in_city',{ix:esc(S.myIx[c].name),city:C.name});
if(C.ix)return tr('action_helpers.city_already_has_an_exchange_ix',{city:C.name,ix:esc(C.ix)});
return S.pops[c]?'':tr('action_helpers.you_have_no_pop_in_city_build',{city:C.name});}
/* 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. */
const SPARE_RESALE=0.4,spareN=o=>(S&&S.spares&&S.spares[o])|0,spareValue=o=>Math.round(optCost(o)*SPARE_RESALE);

View file

@ -2,6 +2,7 @@
// Inlined into the page at build. One entry per line, sorted by label; plurals are {"one":…,"other":…}.
// Add or change text with scripts/i18n-add.js, check with npm run i18n:check.
(window.I18N=window.I18N||{}).en={
"action_helpers.city_already_has_an_exchange_ix":"<b>{city} already has an exchange, {ix}.</b><br>Take a port on it instead of founding your own.",
"action_helpers.city_is_off_the_map_small":"<b>{city} is off the map.</b><br>Small cities this close to a bigger one are retired from new games. Build in {near} instead.",
"action_helpers.light_fiber_pair_n_price":"Light fiber pair {n} <small>{price}</small>",
"action_helpers.light_fiber_pair_n_price_mo":"Light fiber pair {n} <small>{price} + {mo}/mo</small>",
@ -14,7 +15,9 @@
"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.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_already_run_ix_in_city":"<b>You already run {ix} in {city}.</b>",
"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.",
"action_helpers.you_have_no_pop_in_city_build":"<b>You have no POP in {city}.</b><br>Build one there first, then found the exchange.",
"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.architect_runs":"Architect runs",