IPv4 address space: scarce, bought, leased, leased out; IPv6 is free (#150)
A rule (ip4), on in On-call and BGP at 3 a.m., off in the gentler presets, sandbox and puzzles; scenarios only when they opt in. You start with a /21 from the registry, sized so the early game never notices (a gameplay-rules F1 test plays six start cities for 50 days). Business customers need a block by kind and size; broadband homes take what is left and the rest go behind CGNAT, which costs a box per home and annoys some customers. An offer that does not fit cannot be signed and says why, and a customer that cannot grow at renewal stays its size. The bank's Address space section buys and sells blocks on a transfer market with a gentle trend, leases blocks in, and leases spare blocks out for monthly income, in real CIDR sizes (/24 to /16), at most 256 blocks (what a save keeps). Old saves get what they already use, plus room, so nothing changes on load. The dashboard's AS box now lists the blocks you announce.
This commit is contained in:
parent
2cd6b71198
commit
eac0604300
34 changed files with 957 additions and 32 deletions
|
|
@ -58,14 +58,16 @@ function clRenew(b,rate){b.rate=Math.max(0,Math.round(rate));b.mk=mkt();delete b
|
|||
function clGone(b,why){S.biz=S.biz.filter(x=>x!==b);clNote('lost',why);}
|
||||
const clWhere=b=>bCities(b).map(c=>CITY[c].name).join(' ⇄ ');
|
||||
|
||||
// Growing: the next size up their type sells, or twice the bandwidth past the top one. Fiber grows by renewing.
|
||||
function clGrow(b){const T=BIZ_T[b.type];if(T.fiber)return false;const up=(T.opts||[]).find(x=>x>b.bw);b.bw=up||b.bw*2;return true;}
|
||||
// Growing: the next size up their type sells, or twice the bandwidth past the top one. Fiber grows by renewing. Not
|
||||
// when the bigger IPv4 block it needs is not free (#150): out.v4 lists them for the day's news.
|
||||
function clGrow(b,out){const T=BIZ_T[b.type];if(T.fiber)return false;const bw=(T.opts||[]).find(x=>x>b.bw)||b.bw*2;
|
||||
if(!ip4GrowOk(b,bw)){if(out)out.v4.push([b,bw]);return false;}b.bw=bw;return true;}
|
||||
// Leaving, or one of the not-your-fault turns that keeps them. Returns what the log says.
|
||||
function clLeave(b,d,out){const T=BIZ_T[b.type],v={name:esc(b.name),city:esc(clWhere(b))};
|
||||
if(b.mood<50){clGone(b,'sad');out.lost.push(tr('lifecycle.left_unhappy',v));return;}
|
||||
const C=S.cl;if(d-C.odd>=CL_ODD_GAP&&clR(b,'odd')<0.25){C.odd=d;clGone(b,'odd');out.lost.push(tr('lifecycle.left_odd',{...v,why:tr(clPick(CL_ODD,b,'oddline'))}));return;}
|
||||
const ks=Object.keys(CL_WHY).filter(k=>CL_WHY[k].ok(b.type)),k=clPick(ks,b,'why');
|
||||
if(k==='acq'&&clR(b,'acqbig')<0.3&&clGrow(b)){clRenew(b,clFair(b));clNote('grew');out.ok.push(tr('lifecycle.acquired_stays_bigger',{...v,bw:fmtG(b.bw)}));return;}
|
||||
if(k==='acq'&&clR(b,'acqbig')<0.3&&clGrow(b,out)){clRenew(b,clFair(b));clNote('grew');out.ok.push(tr('lifecycle.acquired_stays_bigger',{...v,bw:fmtG(b.bw)}));return;}
|
||||
if(k==='moved'){const reg=CITY[b.city].reg,to=Object.keys(S.pops).filter(c=>c!==b.city&&CITY[c].reg===reg&&bizCity(c)).sort();
|
||||
const c2=to.length&&clR(b,'stay')<0.5?clPick(to,b,'to'):null;
|
||||
if(c2){const from=CITY[b.city].name;b.city=c2;clRenew(b,clFair(b));clNote('ren');out.ok.push(tr('lifecycle.moved_stays',{name:v.name,from:esc(from),to:esc(CITY[c2].name)}));return;}}
|
||||
|
|
@ -75,7 +77,7 @@ function clLeave(b,d,out){const T=BIZ_T[b.type],v={name:esc(b.name),city:esc(clW
|
|||
/* A day of contracts, after the moods. 30 days before a term ends a customer with competitors around may ask for a
|
||||
discount (at most three open at a time); at the end, the rest renew, grow or leave. An unanswered haggle renews at
|
||||
the asked price. */
|
||||
function clDay(d){if(!S.cl)S.cl={odd:-1e9,mo:[]};const out={ren:0,grew:0,ok:[],lost:[],hag:[]};let open=S.biz.reduce((a,b)=>a+(b.hag?1:0),0);
|
||||
function clDay(d){if(!S.cl)S.cl={odd:-1e9,mo:[]};const out={ren:0,grew:0,ok:[],lost:[],hag:[],v4:[]};let open=S.biz.reduce((a,b)=>a+(b.hag?1:0),0);
|
||||
const pat=rule('moods')==='patient'?0.5:1;
|
||||
for(const b of S.biz.slice()){if(!b.te||!clOn(b))continue;
|
||||
if(b.hag){if(d>=b.hag.until){clRenew(b,b.hag.rate);clNote('ren');out.ren++;}continue;}
|
||||
|
|
@ -86,7 +88,7 @@ function clDay(d){if(!S.cl)S.cl={odd:-1e9,mo:[]};const out={ren:0,grew:0,ok:[],l
|
|||
continue;}
|
||||
const cf=Math.min(1,clComp(b)/6),u=(100-b.mood)/100,leave=(0.04+0.08*cf+0.35*u*u)*pat*salesLeaveMul(b);
|
||||
if(clR(b,'leave')<leave){clLeave(b,d,out);continue;}
|
||||
const g=clR(b,'grow');if((b.mood>=80&&g<0.3)||(b.mood>=60&&g<0.12)){if(clGrow(b)){clRenew(b,clFair(b));clNote('grew');out.grew++;out.ok.push(tr('lifecycle.renewed_and_grew',{name:esc(b.name),city:esc(clWhere(b)),bw:fmtG(b.bw)}));continue;}}
|
||||
const g=clR(b,'grow');if((b.mood>=80&&g<0.3)||(b.mood>=60&&g<0.12)){if(clGrow(b,out)){clRenew(b,clFair(b));clNote('grew');out.grew++;out.ok.push(tr('lifecycle.renewed_and_grew',{name:esc(b.name),city:esc(clWhere(b)),bw:fmtG(b.bw)}));continue;}}
|
||||
clRenew(b,clFair(b));clNote('ren');out.ren++;}
|
||||
clNews(out);clReferral(d);}
|
||||
// What the day says: haggles one by one (they want an answer), the rest in a few lines so a big network is not a wall of toasts.
|
||||
|
|
@ -94,7 +96,7 @@ function clNews(out){
|
|||
for(const b of out.hag){const was=bizMo(b),now=BIZ_T[b.type].fiber?b.hag.rate:b.bw*b.hag.rate;
|
||||
toast(tr('lifecycle.haggle',{name:esc(b.name),city:esc(clWhere(b)),price:fmt$(now),p:pct(1-now/Math.max(1,was)),n:b.hag.until-S.day}),'',[{l:tr('common.deals'),act:'leftTab',args:{t:'deals'}}],{a:'cust',v:b.id});}
|
||||
const few=(list,kind)=>{for(const t of list.slice(0,3))toast(t,kind);if(list.length>3)toast(trn('lifecycle.n_more',list.length-3),kind);};
|
||||
few(out.ok,'good');few(out.lost,'');
|
||||
few(out.ok,'good');ip4News(out.v4);few(out.lost,'');
|
||||
if(out.ren)toast(trn('lifecycle.n_renewed',out.ren,{p:mktTxt()}),'');}
|
||||
const mktTxt=()=>{const m=mkt();return Math.abs(m-1)<0.005?tr('lifecycle.market_as_start'):m<1?tr('lifecycle.market_below',{p:pct(1-m)}):tr('lifecycle.market_above',{p:pct(m-1)});};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue