Charters: a popup at the start, and a third one, the Cable broker (#300)
A new Normal game now asks what it is building before anything else, in a popup that holds the clock and cannot be closed without an answer; the tutorial waits for it. A save still in its first month that never picked is asked on load. Sandbox, puzzles and scenarios never ask. The Cable broker builds and lights glass from day one at the prices everyone pays at the top level: dark fiber, every line system and optic, digging without the pioneer markup, own subsea cables and their upgrades, eight pairs, and every router those optics need. Everything else unlocks by level as before. Its offers lean to carriers buying waves and pairs, capacity conferences are open to it at any level, and carriers call about three times a year with a capacity deal. It runs its own ten-goal ladder and wins Glass Baron (own cables on five continents, $1M a month of capacity sales), with a badge; Tier 1 stays its own win. Classic and boutique networks may lay their own subsea cable from customer level 9 as well as after Tier 1. Rule M6 (gameplay-rules): a charter changes what you set out to do, never what things cost. Closes #300.
This commit is contained in:
parent
f303f29f22
commit
934a83588a
40 changed files with 535 additions and 97 deletions
|
|
@ -54,4 +54,5 @@ function beginGame(nm,city,o={}){if(needPitch()&&!UI.pitched){UI.pendGame=[nm,ci
|
|||
UI.lastSpeed=rule('clock')?0.5:0;setSpeed(UI.lastSpeed);UI.resumeSpeed=null;
|
||||
track('game_new');UI.started=true;closeModal();compute();cam.x=CITY[city].x;cam.y=CITY[city].y;cam.z=innerWidth<760?1.1:1.4;selectCity(city);
|
||||
toast(S.scn?`<b>${esc(S.scn.name)}</b><br>${o.scn.goal?esc(o.scn.goal)+'.':tr('common.serve_as_much_traffic_as_you')} ${tr('scenarios.you_have_n_days',{n:S.scn.days})}`:S.mode==='sandbox'?(chaosMul()?tr('scenarios.sandbox_mode_a_billion_dollars_chaos',{chaos:CHAOS[rule('chaos')].n}):tr('scenarios.sandbox_mode_a_billion_dollars_every')):tr('scenarios.welcome_name_the_ripe_ncc_assigned',{name:esc(nm),asn:S.asn,city:CITY[city].name}),'goal');
|
||||
renderAll();save();if(!S.scn&&S.mode!=='sandbox'&&S.mode!=='puzzle')tutorialStart();}
|
||||
// A Normal game asks for its charter first; the tutorial starts once it is signed.
|
||||
renderAll();save();if(!S.scn&&S.mode!=='sandbox'&&S.mode!=='puzzle'){if(charterDue()){UI.tutLater=true;charterAsk();}else tutorialStart();}}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ function confTick(d){S.confReg=S.confReg||{};
|
|||
capDealTick(d);}
|
||||
function confSection(){const up=upcomingConfs(75).slice(0,3),cb=S.conf&&S.conf.until>S.day?S.conf:null;if(!up.length&&!cb)return '';
|
||||
return `<h3 style="font-size:15px;margin:10px 0 4px">${tr('common.conferences')}</h3>${cb?`<div class="inc" style="background:#EAF7EE"><div class="nm">${tr('conferences.name_glow_n_days_left',{name:esc(cb.name),n:cb.until-S.day})}</div><div class="meta">${tr('conferences.selective_networks_in_region_need',{region:esc(REG[cb.reg])})}${cb.sp?' '+tr('conferences.as_a_sponsor_you_also_get',{region:esc(REG[cb.reg])}):''}</div></div>`:''}${up.map(confRow).join('')}`;}
|
||||
function confRow(cf){const reg=S.confReg&&S.confReg[cf.key],open=cf.day>S.day,sp=confSp(cf),cost=confCost(cf),lk=cf.cap&&lvl()<CAP_LV;
|
||||
function confRow(cf){const reg=S.confReg&&S.confReg[cf.key],open=cf.day>S.day,sp=confSp(cf),cost=confCost(cf),lk=cf.cap&&glassLvl()<CAP_LV;
|
||||
const tags=(reg==='sp'?'<span class="tag st on">'+tr('conferences.sponsor')+'</span>':reg?'<span class="tag st on">'+tr('common.registered')+'</span>':open?'':'<span class="tag st">'+tr('common.registration_closed')+'</span>');
|
||||
const btns=!open||reg==='sp'?'':(reg?'':lk?btn(tr('sites_and_service.level_n',{n:CAP_LV}),'confGo',{key:cf.key},'sm',true):btn(tr('conferences.attend_cost',{cost:fmt$(cost)}),'confGo',{key:cf.key},'sm',S.cash<cost))+(sp?btn(tr('conferences.sponsor_cost',{cost:fmt$(CONF_SP-(reg?CONF_COST:0))}),'confSponsor',{key:cf.key},'pink sm',S.cash<CONF_SP-(reg?CONF_COST:0)):'');
|
||||
return `<div class="row"><div class="grow"><div class="nm">${esc(cf.n)} · ${esc(CITY[cf.c].name)}</div><div class="meta">${cf.day===S.day?tr('common.today'):tr('conferences.in_n_days',{n:cf.day-S.day})} · ${esc(REG[CITY[cf.c].reg])}${cf.cap?' · '+tr('conferences.capacity_conference_carriers_buy_in'):sp&&open&®!=='sp'?' · '+tr('conferences.sponsorships_available'):''}</div></div>${tags}${btns?`<div class="btns">${btns}</div>`:''}</div>`;}
|
||||
|
|
|
|||
|
|
@ -34,15 +34,15 @@ const DEMO_MUL=1.6,DEMO_DAYS=14;
|
|||
function demoItem(k,id){return k==='rg'?RG[+id]||null:k==='sys'?(own(DF_SYS,id)?DF_SYS[id]:null):k==='opt'?(own(OPT,id)?OPT[id]:null):null;}
|
||||
const demoAt=(k,id)=>{const d=S&&S.demo&&S.demo[k+':'+id];return d===undefined?null:d;};
|
||||
const demoCan=L=>!gatesOpen()&&L===lvl()+1;
|
||||
function techOk(k,id,L){if(L<=lvl())return true;const d=demoAt(k,id);return demoCan(L)&&d!==null&&d<=S.day;}
|
||||
const techMul=L=>L>lvl()?DEMO_MUL:1;
|
||||
function techOk(k,id,L){if(L<=(k==='rg'?(rgGlass(+id)?LEVELS.length:lvl()):k==='sys'||k==='opt'?glassLvl():lvl()))return true;const d=demoAt(k,id);return demoCan(L)&&d!==null&&d<=S.day;}
|
||||
const techMul=L=>L>glassLvl()?DEMO_MUL:1;
|
||||
function demoBtn(k,id,L,lock,cls){const d=demoAt(k,id);if(!demoCan(L))return btn(lock,'demoAsk',{k,id},cls,true);
|
||||
if(d!==null&&d>S.day)return btn(tr('specialist.demo_unit_ships_in_n_days',{n:d-S.day}),'demoAsk',{k,id},cls,true);
|
||||
return btn(tr('specialist.ask_for_a_demo_unit_p_n',{p:Math.round((DEMO_MUL-1)*100),n:leadDays(DEMO_DAYS)}),'demoAsk',{k,id},cls);}
|
||||
const sysCost=k=>Math.round(DF_SYS[k].cost*techMul(DF_SYS[k].lvl));
|
||||
// Digging your own fiber before level 3: the pioneer pays for the permits nobody has asked for yet.
|
||||
const PIONEER=1.6;
|
||||
const digMul=()=>lvl()>=3?1:PIONEER,digCost=km=>Math.round(dfBuildCost(km)*digMul());
|
||||
const digMul=()=>glassLvl()>=3?1:PIONEER,digCost=km=>Math.round(dfBuildCost(km)*digMul());
|
||||
|
||||
/* A seat on a consortium cable (#173): pay your share of the build, wait for the ship, and own fiber pairs on it,
|
||||
lit with your own optics like your own cable. Capacity conferences offer them, and now and then a consortium calls. */
|
||||
|
|
@ -64,11 +64,18 @@ function seatSection(){const o=S.seatOff;if(!o||o.exp<=S.day)return '';const pop
|
|||
<div class="btns">${SEAT_N.map(n=>{const c=seatCost(o.km,n)+pop;return btn(`${trn('specialist.n_fiber_pairs',n)} <small>${fmt$(c)} · ${tr('common.price_mo',{price:fmt$(seatMo(o.km,n))})}</small>`,'seatBuy',{n},'sm',S.cash<c);}).join('')}${btn(tr('common.decline'),'seatNo',{},'ghost sm')}</div></div>`;}
|
||||
function seatPanel(l){if(!l.seat)return '';return `<div class="kv"><span>${tr('specialist.consortium_seat')}</span><b>${esc(l.cname||'')} · ${trn('specialist.n_fiber_pairs',Math.max(1,l.pairs|0))}</b></div><p class="note">${tr('specialist.the_consortium_runs_the_cable_your')}</p>`;}
|
||||
|
||||
/* Charters: what the network sets out to be, picked once at the start of a Normal game. Global backbone is the game as
|
||||
it always was; the Low-latency boutique sells speed to traders and has its own win, Speed of Light. */
|
||||
const CHARTERS={global:{i:'🌐',n:N_('specialist.global_backbone'),d:N_('specialist.the_classic_game_grow_everywhere_and')},boutique:{i:'⚡',n:N_('specialist.low_latency_boutique'),d:N_('specialist.trading_firms_and_other_latency_customers')}};
|
||||
/* Charters: what the network sets out to be, picked once when a Normal game starts, in a popup that waits for an
|
||||
answer. Global backbone is the game as it always was; the Low-latency boutique sells speed to traders and has its own
|
||||
win, Speed of Light; the Cable broker (#300) lays and lights glass on land and under the sea from day one, at the
|
||||
usual prices, sells it, and has its own goals and win, Glass Baron (37-cable-broker.js). */
|
||||
const CHARTERS={global:{i:'🌐',n:N_('specialist.global_backbone'),d:N_('specialist.the_classic_game_grow_everywhere_and')},boutique:{i:'⚡',n:N_('specialist.low_latency_boutique'),d:N_('specialist.trading_firms_and_other_latency_customers')},broker:{i:'🚢',n:N_('specialist.cable_broker'),d:N_('specialist.cable_broker_desc')}};
|
||||
const CHARTER_DAYS=30,LAT_PAY=1.4,SOL_ROUTES=3,SOL_CUST=2;
|
||||
const charter=()=>S&&!S.scn&&S.mode==='normal'&&S.charter==='boutique'?'boutique':'global';
|
||||
const charter=()=>S&&!S.scn&&S.mode==='normal'&&(S.charter==='boutique'||S.charter==='broker')?S.charter:'global';
|
||||
const broker=()=>charter()==='broker';
|
||||
// The level glass is judged at: fiber, line systems, optics, pairs and subsea gear. A broker has all of it from day one.
|
||||
const glassLvl=()=>broker()?LEVELS.length:lvl();
|
||||
// The router class the fastest optics need: a broker may buy every router up to it, so all its optics can be lit.
|
||||
const RG_GLASS=Math.max(...Object.values(OPT).map(o=>o.rg)),rgGlass=g=>broker()&&!!RG[g]&&RG[g].cls<=RG_GLASS,rgOpen=g=>!!RG[g]&&(RG[g].lvl<=lvl()||rgGlass(g));
|
||||
const latPay=()=>charter()==='boutique'?LAT_PAY:1;
|
||||
// The fastest a leased wave or fiber gets between two cities: overland, or the quickest cable on the route.
|
||||
function leasedLat(a,b){let best=isSub(a,b)?Infinity:kmBetween(a,b)*1.25/200;for(const c of cablesFor(a,b))best=Math.min(best,c.km*Math.min(CAB[c.cid].lat||1,1.25)/200);return best;}
|
||||
|
|
@ -78,19 +85,29 @@ function solRoutes(){const k=S.day+'|'+S.links.length+'|'+S.links.reduce((n,l)=>
|
|||
const f=FIN.filter(c=>S.pops[c]),v=[];if(S.links.some(ownGlass))for(let i=0;i<f.length;i++)for(let j=i+1;j<f.length;j++){const a=f[i],b=f[j],o=bestLat(a,b,ownGlass),l=leasedLat(a,b);if(isFinite(o)&&isFinite(l)&&o<l)v.push({a,b,o,l});}
|
||||
SOLC={s:S,k,v};return v;}
|
||||
const solCust=()=>S.biz.filter(b=>BIZ_T[b.type]&&BIZ_T[b.type].lat&&b.mood>=50&&reqOk(b)).length;
|
||||
// What each charter promises, as the picker and the agent's docs say it.
|
||||
const charterDesc=C=>tr(C.d,{p:Math.round((LAT_PAY-1)*100),r:SOL_ROUTES,c:SOL_CUST,n:BARON_CONT,m:fmt$(BARON_MO)});
|
||||
/* The picker: when a Normal game starts (and when a save that never picked loads), before anything else. It pauses the
|
||||
clock like any open window and cannot be closed without a choice; the tutorial waits for it. Seeded tests skip it unless
|
||||
they ask (window.__TUBES_CHARTER__), as they skip the tutorial: they sign a charter with ACT.charter when they need one. */
|
||||
const charterDue=()=>!!(S&&UI.started&&!S.lost&&!S.scn&&S.mode==='normal'&&!S.chartSet&&!pzOn());
|
||||
function charterPickHtml(){return `<div class="chpick"><div class="eyebrow">${esc(S.name)} · AS${S.asn}</div><h2 style="font-size:26px">${tr('specialist.what_are_you_building')}</h2><p class="tagline">${tr('specialist.your_charter_sets_your_goals')}</p><div class="chopts">`
|
||||
+Object.entries(CHARTERS).map(([k,C])=>`<button class="chopt" data-act="charter" data-args='${JSON.stringify({k})}'><span class="chi" aria-hidden="true">${C.i}</span><span class="cht"><b>${tr(C.n)}</b><span>${charterDesc(C)}</span></span></button>`).join('')+`</div></div>`;}
|
||||
function charterAsk(){if(!charterDue()||!$('modal').hidden||window.__TUBES_TEST__&&!window.__TUBES_CHARTER__)return;openModal(charterPickHtml(),'charter');}
|
||||
function charterCard(){if(S.scn||S.mode!=='normal')return '';
|
||||
if(!S.chartSet&&S.day<=CHARTER_DAYS)return `<div class="inc" style="background:#EEF0FF"><div class="nm">${tr('specialist.pick_a_charter')}</div><div class="meta">${tr('specialist.what_kind_of_network_are_you',{n:CHARTER_DAYS-S.day})}</div>${Object.entries(CHARTERS).map(([k,C])=>`<div class="row"><div class="grow"><div class="nm">${C.i} ${tr(C.n)}</div><div class="meta">${tr(C.d,{p:Math.round((LAT_PAY-1)*100),r:SOL_ROUTES,c:SOL_CUST})}</div></div>${btn(charter()===k?tr('specialist.keep_it'):tr('specialist.pick'),'charter',{k},k==='global'?'ghost sm':'pink sm')}</div>`).join('')}</div>`;
|
||||
if(broker())return baronCard();
|
||||
if(charter()!=='boutique')return '';
|
||||
if(S.solWon)return `<div class="inc" style="background:#EAF7EE"><div class="nm">⚡ ${tr('specialist.speed_of_light')}</div><div class="meta">${tr('specialist.won_on_date_your_own_glass',{date:dateStr(S.solWon)})}</div></div>`;
|
||||
const r=solRoutes();return `<div class="inc" style="background:#EEF0FF"><div class="nm">⚡ ${tr('specialist.speed_of_light')}</div><div class="meta">${tr('specialist.routes_r_of_n_beat_the',{r:Math.min(r.length,SOL_ROUTES),n:SOL_ROUTES,c:Math.min(solCust(),SOL_CUST),m:SOL_CUST})}</div>${r.slice(0,SOL_ROUTES).map(x=>`<div class="meta">✓ ${CITY[x.a].name} ⇄ ${CITY[x.b].name}: ${tr('common.ms_ms_one_way',{ms:x.o.toFixed(1)})} < ${x.l.toFixed(1)}</div>`).join('')}</div>`;}
|
||||
// Once a day: seats expire or call, and the boutique checks its win.
|
||||
function specDay(d){if(S.seatOff&&S.seatOff.exp<=d)S.seatOff=null;
|
||||
// Once a day: seats expire or call, the boutique checks its win and carriers call the broker.
|
||||
function specDay(d){if(broker())brokerDay(d);if(S.seatOff&&S.seatOff.exp<=d)S.seatOff=null;
|
||||
if(!S.seatOff&&!S.scn&&S.mode!=='puzzle'&&lvl()>=SEAT_LV&&hstr(S.asn+'|seatcall|'+d)%SEAT_ODDS===0)seatConf(null);
|
||||
if(charter()==='boutique'&&!S.solWon&&solRoutes().length>=SOL_ROUTES&&solCust()>=SOL_CUST){S.solWon=Math.max(1,d);track('win_sol');toast(`<b>⚡ ${tr('specialist.speed_of_light')}</b><br>${tr('specialist.your_own_glass_beats_every_leased')}`,'goal');sfx('coin');checkBadges();}}
|
||||
// Saves: the charter, demo orders, a seat on offer and the boutique's win. Old saves are Global backbone, picked.
|
||||
function specSanitize(s){s.charter=s.charter==='boutique'&&s.mode==='normal'&&!s.scn?'boutique':'global';s.chartSet=s.chartSet===false&&s.day<=CHARTER_DAYS?false:true;
|
||||
// Saves: the charter, demo orders, a seat on offer and the boutique's and the broker's wins. Old saves are Global
|
||||
// backbone, picked; one still in its first month that never picked is asked again.
|
||||
function specSanitize(s){s.charter=(s.charter==='boutique'||s.charter==='broker')&&s.mode==='normal'&&!s.scn?s.charter:'global';s.chartSet=s.chartSet===false&&s.day<=CHARTER_DAYS?false:true;
|
||||
const dm={};if(s.demo&&typeof s.demo==='object'&&!Array.isArray(s.demo))for(const key of Object.keys(s.demo).slice(0,64)){const [k,id]=key.split(':');if(demoItem(k,id)&&Number.isFinite(+s.demo[key]))dm[key]=Math.round(+s.demo[key]);}s.demo=dm;
|
||||
const o=s.seatOff;s.seatOff=o&&typeof o==='object'&&typeof o.name==='string'&&seatRoute(o.name)&&seatRoute(o.name)[0]===o.a&&seatRoute(o.name)[1]===o.b?{a:o.a,b:o.b,name:o.name,km:seatKm(o.a,o.b),exp:num(o.exp,0)}:null;
|
||||
s.solWon=Number.isFinite(+s.solWon)&&+s.solWon>0?Math.round(+s.solWon):0;
|
||||
s.solWon=Number.isFinite(+s.solWon)&&+s.solWon>0?Math.round(+s.solWon):0;s.baronWon=Number.isFinite(+s.baronWon)&&+s.baronWon>0?Math.round(+s.baronWon):0;
|
||||
for(const l of s.links)if(l.seat!==undefined){if(l.seat===true&&l.kind==='df'&&l.own&&l.sub)l.pairs=Math.max(1,Math.min(Math.max(...SEAT_N),l.pairs|0));else delete l.seat;}
|
||||
for(const b of [...s.biz,...s.offers])if(b.spot!==undefined){const x=b.spot;if(x&&typeof x==='object'&&own(SPOT_W,x.k))b.spot={k:x.k,n:num(x.n,0)};else delete b.spot;}}
|
||||
|
|
|
|||
34
src/game/60-features/37-cable-broker.js
Normal file
34
src/game/60-features/37-cable-broker.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ---------- The Cable broker (#300) ----------
|
||||
A charter for building glass and selling it. Dark fiber, every line system and optic, digging, own subsea cables,
|
||||
their upgrades and more pairs are open from day one at the usual prices (glassLvl, rgGlass in 36-specialist.js); the
|
||||
rest of the game unlocks by level as always. Carriers call for capacity, the goals are about glass (BROKER_GOALS), and
|
||||
the win is Glass Baron: your own cables land on five continents while carriers pay you $1M a month for capacity. */
|
||||
const BARON_CONT=5,BARON_MO=1000000,BROKER_CALL=120,BROKER_CALL_FROM=60;
|
||||
// Your own glass: fiber you dug and cables you laid, once ready. A leased IRU is someone else's; so is a consortium seat.
|
||||
const ownGlassL=l=>l.kind==='df'&&l.own&&!l.seat&&l.ready<=S.day;
|
||||
const glassKm=()=>S.links.reduce((a,l)=>a+(ownGlassL(l)?l.km:0),0);
|
||||
// The continents your own subsea cables land on.
|
||||
function cableConts(){const r=new Set();for(const l of S.links)if(ownGlassL(l)&&l.sub)for(const c of [l.a,l.b])r.add(CITY[c].reg);return r.size;}
|
||||
// Capacity other carriers buy from you: alien waves, fiber pairs and capacity deals (once delivered).
|
||||
const CAP_TYPES=['wwave','dfpair','pairs','capw','capsub','capfib'];
|
||||
const capSold=b=>CAP_TYPES.includes(b.type)&&!capPend(b);
|
||||
const capSalesMo=()=>S.biz.reduce((a,b)=>a+(capSold(b)?bizMo(b):0),0);
|
||||
// Lit capacity sold, in Gbps: waves (400G each) and subsea capacity. A dark pair is the buyer's to light.
|
||||
const capSoldG=()=>S.biz.reduce((a,b)=>a+(!capSold(b)?0:b.type==='wwave'?(b.slots||1)*400:b.type==='capw'||b.type==='capsub'?b.bw:0),0);
|
||||
// Two hops of your own glass through one city, each lit to at least g.
|
||||
function glassChain(g){const by={};for(const l of S.links)if(ownGlassL(l)&&dfCap(l)>=g)for(const [c,o] of [[l.a,l.b],[l.b,l.a]])(by[c]=by[c]||new Set()).add(o);
|
||||
return Object.values(by).some(s=>s.size>=2);}
|
||||
const baronOk=()=>cableConts()>=BARON_CONT&&capSalesMo()>=BARON_MO;
|
||||
// On the goals tab, under the charter: how far Glass Baron is.
|
||||
function baronCard(){if(S.baronWon)return `<div class="inc" style="background:#EAF7EE"><div class="nm">🌊 ${tr('broker.glass_baron')}</div><div class="meta">${tr('broker.won_on_date',{date:dateStr(S.baronWon)})}</div></div>`;
|
||||
return `<div class="inc" style="background:#E6F4FF"><div class="nm">🌊 ${tr('broker.glass_baron')}</div><div class="meta">${tr('broker.progress',{c:Math.min(cableConts(),BARON_CONT),n:BARON_CONT,mo:fmt$(capSalesMo()),m:fmt$(BARON_MO)})}</div></div>`;}
|
||||
function showBaronWin(){openModal(`<h1 style="font-family:var(--display);font-size:40px;margin:0">🌊 ${tr('broker.glass_baron')}</h1><p class="tagline">${tr('broker.win_text',{name:esc(S.name),asn:S.asn,days:S.day,n:BARON_CONT,mo:fmt$(capSalesMo())})}</p><div class="btns">${btn(tr('help.share_my_network'),'share',{},'pink')}${btn(tr('common.keep_playing'),'closeModal',{},'ghost')}</div>`);}
|
||||
/* Carriers call the broker now and then (about three times a year, from day 60) with a capacity deal on a route the
|
||||
capacity conferences trade: the same deals at the same terms, without the trip. Picked by a hash of the day, so a
|
||||
broker's other dice roll as they would. */
|
||||
function brokerDay(d){if(d<BROKER_CALL_FROM||S.scn||hstr(S.asn+'|capcall|'+d)%BROKER_CALL!==0)return;
|
||||
const pool=Object.values(CAP_ROUTES).flat().filter(r=>isCity(r[0])&&isCity(r[1])&&!S.offers.some(o=>o.city===r[0]&&o.city2===r[1]&&o.type===r[2]));if(!pool.length)return;
|
||||
const [a,b,t]=pool[hstr(S.asn+'|caproute|'+d)%pool.length],T=BIZ_T[t];
|
||||
const nm=()=>{const list=T.names.filter(n=>!S.usedNames.includes(n)),n=list.length?pick(list):pick(T.names);useName(n);return n;};
|
||||
const o=capOffer(a,b,t,nm);S.offers.push(o);
|
||||
toast(tr('broker.a_carrier_calls',{name:esc(o.name),what:capWhat(o),a:CITY[a].name,b:CITY[b].name}),'goal',[{l:tr('common.show_me'),act:'leftTab',args:{t:'deals'}}]);sfx('coin');}
|
||||
|
|
@ -133,7 +133,7 @@ const OPS_RUN={
|
|||
const ld=Math.max((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1),portsUsed(c)/Math.max(1,portsMax(c)));if(ld<at)continue;
|
||||
const rt=p.routers||1,g=p.rgen||0,nx=mainRG(RG[g].cls+1);
|
||||
// A swap with one router is a maintenance window: the intern only swaps where a second router carries the traffic.
|
||||
const swap=nx>=0&&RG[nx].lvl<=lvl()&&!modelFits(c,nx)&&(rt>1||popIdle(c)),add=rt<RMAX;
|
||||
const swap=nx>=0&&rgOpen(nx)&&!modelFits(c,nx)&&(rt>1||popIdle(c)),add=rt<RMAX;
|
||||
const doSwap=how==='swap'?swap:how==='add'?false:swap&&(rt>=4||!add);if(!doSwap&&(how==='swap'||!add))continue;
|
||||
const cost=doSwap?swapCost(c,nx):routerCost(g,rt);if(!X.can('routers',cost))continue;
|
||||
if(X.pay('routers',()=>doSwap?ACT.upRouter({city:c,g:nx}):ACT.addRouter({city:c})))X.did('routers',c+(doSwap?' ⇧'+RG[nx].pn:' +1'));}},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue