Pie in the Sky: rocket company foundation
Catalog (rockets, crusts, prices), state with newGame default and a full sanitize repair, the one-time unlock on the Tier 1 win (sandbox from day 0), company, factory, pads, R&D, launches, dishes, landing rights, the daily tick, the Founder feed, three badges, a plain Pie Control modal from the NOC tab, and hooks for routing, spats and the globe. Translated in every language.
This commit is contained in:
parent
d2c7294ed3
commit
7fb7be305d
17 changed files with 1019 additions and 4 deletions
77
src/game/10-catalog/70-pie.js
Normal file
77
src/game/10-catalog/70-pie.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* ---------- Pie in the Sky: the rocket-company endgame (docs/plans/pie-in-the-sky.md) ----------
|
||||
The catalog: rockets, crusts (orbital shells of pies), prices and the small helpers everything else asks.
|
||||
Hardware is list price x PIE_MUL x hwMul(); running costs, fees and landing rights are not inflated, like the rest
|
||||
of the game. The economy and the daily tick are in 60-features/99-pie-in-the-sky.js. */
|
||||
const PIE_MUL=1;
|
||||
const PIE_CO=250e6,PIE_CO_MO=5e6,PIE_FAC=1e9,PIE_FAC_MO=8e6,PIE_FAC_MONTH=120,PIE_STOCK_MAX=480,
|
||||
PIE_PIE=1e6,PIE_LAS=0.5e6,PIE_PAD=400e6,PIE_PAD_MO=2e6,PIE_PAD_MAX=6,PIE_EQ=0.15,
|
||||
PIE_REUSE=500e6,PIE_HEAVY=3e9,PIE_HEAVY_TESTS=3,PIE_BOOST=40e6,PIE_BOOST_MAX=20,PIE_BOOSTERS=6,PIE_INS=0.08,
|
||||
PIE_DISH=25e6,PIE_ANT=2e6,PIE_ANT_MAX=16,PIE_ANT_G=20,PIE_DISH_MO=3e5,PIE_DISH_MAX=200,
|
||||
PIE_LIC_MIN=10e6,PIE_LIC_MAX=200e6,PIE_LIC_DAYS=360,PIE_LEOIX=50e6,PIE_LEOIX_MO=1e6,PIE_PARTY=2e6,
|
||||
PIE_QUIET=90,PIE_PREP=7,PIE_Q_MAX=40,PIE_COHORTS=240,PIE_POSTS=20,PIE_BAKED=0.6,PIE_SPARE=1.1;
|
||||
// In generation order. fail: chance a launch is lost (x chaos); land: chance a reused booster does not come back.
|
||||
const ROCKETS={
|
||||
falcon:{n:N_('pie.rk_falcon_punch'),cost:60e6,pies:20,fail:0.05,gap:14},
|
||||
again:{n:N_('pie.rk_falcon_punch_again'),cost:30e6,pies:20,fail:0.04,land:0.06,gap:10,rd:'reuse'},
|
||||
heavy:{n:N_('pie.rk_starshipping_and_handling'),cost:100e6,pies:100,fail:0.08,gap:30,rd:'heavy'},
|
||||
};
|
||||
const PIE_RD={reuse:{n:N_('pie.rd_reuse'),cost:PIE_REUSE},heavy:{n:N_('pie.rd_heavy'),cost:PIE_HEAVY}};
|
||||
// alt km, full: pies for 100% coverage, inc: the orbit's inclination (a pad can launch to it from |lat| <= inc),
|
||||
// life in game days (a year is 360), g: Gbps the whole crust carries when full.
|
||||
const CRUSTS={
|
||||
short:{n:N_('pie.cr_shortcrust'),alt:550,full:1584,inc:53,life:1800,g:40000},
|
||||
frozen:{n:N_('pie.cr_frozen'),alt:560,full:520,inc:97.6,life:1800,g:10000,polar:true},
|
||||
upper:{n:N_('pie.cr_upper'),alt:1100,full:1200,inc:60,life:1800,g:24000},
|
||||
flaky:{n:N_('pie.cr_flaky'),alt:340,full:2500,inc:53,life:1080,g:60000,dense:true},
|
||||
};
|
||||
// Company names: the first is the default; saves keep the label, or the player's own text after a rename.
|
||||
const PIE_NAMES=[
|
||||
N_('pie.co_mid_life_crisis_aerospace'),
|
||||
N_('pie.co_hubris_heavy_industries'),
|
||||
N_('pie.co_spacexpensive'),
|
||||
N_('pie.co_thrust_issues'),
|
||||
N_('pie.co_payload_bearing'),
|
||||
N_('pie.co_compensation_dynamics'),
|
||||
N_('pie.co_escape_velocity_partners'),
|
||||
N_('pie.co_gravity_is_optional'),
|
||||
];
|
||||
// What the Founder posts. Saves keep the label and at most a number and a crust id.
|
||||
const FOUNDER_POSTS=[
|
||||
N_('pie.fp_baked'),
|
||||
N_('pie.fp_booster'),
|
||||
N_('pie.fp_dish'),
|
||||
N_('pie.fp_fail'),
|
||||
N_('pie.fp_found'),
|
||||
N_('pie.fp_launch'),
|
||||
N_('pie.fp_promise'),
|
||||
N_('pie.fp_rename'),
|
||||
N_('pie.fp_slip'),
|
||||
N_('pie.fp_test'),
|
||||
N_('pie.fp_tour'),
|
||||
];
|
||||
const PIE_LIC_STATES=['ok','refused','sus'];
|
||||
/* Hooks for the parts built later, so they live in their own files: push functions here.
|
||||
day: f(d) once a day; launch: f(L,ok) after every launch; fail: f(L) after a lost one.
|
||||
PIE_SPATS[id] = {fix:(o,s)=>o|null}: a geopolitical spat kept in S.pie.spat[id], repaired by sanitize. */
|
||||
const PIE_ON={day:[],launch:[],fail:[]},PIE_SPATS={};
|
||||
const piePrice=(v,k='build')=>Math.round(v*PIE_MUL*hwMul(k));
|
||||
// A pad goes on the coast: a beach city, or within 80 km of the drawn coastline (cached; cable hubs inland do not count).
|
||||
const PIE_COAST=new Map();
|
||||
function pieCoast(c){if(!isCity(c))return false;if(PIE_COAST.has(c))return PIE_COAST.get(c);const C=CITY[c],cl=Math.cos(C.lat*Math.PI/180);let m=1e9;
|
||||
if(!C.beach)for(const p of COAST_LL)for(const q of p){const dx=(q[0]-C.lon)*cl,dy=q[1]-C.lat,d=dx*dx+dy*dy;if(d<m)m=d;}
|
||||
const ok=!!C.beach||Math.sqrt(m)*111<=80;PIE_COAST.set(c,ok);return ok;}
|
||||
// Launching nearer the equator saves fuel: up to 15% off a launch, nothing above 45 degrees.
|
||||
const pieEq=c=>PIE_EQ*clamp((45-Math.abs(CITY[c].lat))/35,0,1);
|
||||
// Landing rights by market size: the eyeballs of every city in the country.
|
||||
const pieLicPrice=cc=>Math.round(clamp(PIE_LIC_MIN+CITIES.reduce((a,c)=>a+(c.cc===cc?c.P:0),0)*28000,PIE_LIC_MIN,PIE_LIC_MAX)/1e6)*1e6;
|
||||
// The feature is here: unlocked by becoming Tier 1 in a save of this version, or open gates (sandbox). Never in puzzles,
|
||||
// the Architect or scenarios.
|
||||
function pieOn(){return !!S&&!S.scn&&S.mode!=='puzzle'&&(!!S.pie||gatesOpen());}
|
||||
const pieT1=()=>!!S.won&&isTier1();
|
||||
// New things (company, factory, pads, R&D, launches, dishes) need you to be Tier 1 now, or a sandbox.
|
||||
function pieCanBuild(){return pieOn()&&(gatesOpen()||pieT1());}
|
||||
function pieLive(id){const c=S&&S.pie&&S.pie.crusts[id];if(!c)return 0;let n=0;for(const k of c.cohorts)if(S.day-k.day<CRUSTS[id].life)n+=k.n;return n;}
|
||||
function pieCov(id){return own(CRUSTS,id)?Math.min(1,pieLive(id)/CRUSTS[id].full):0;}
|
||||
// Under 60% a crust is half-baked: too many gaps to carry anything.
|
||||
function pieBaked(id){return pieCov(id)>=PIE_BAKED;}
|
||||
function pieUp(id){const P=S&&S.pie;return !!P&&!P.safe&&pieBaked(id)&&!(P.crusts[id].down>S.day);}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
function newGame(name,home){
|
||||
S={v:1,name,asn:200000+Math.floor(_rand()*15000),home,day:0,cash:START_CASH,
|
||||
ltv:2,t1v:4,auV:1,calV:1,ops:opsNew(),achP:{},seen:NETS.map(n=>n.id),spares:{},pops:{[home]:{day:0,bb:null,boost:0,down:0,routers:1,gen:false}},links:[],nni:[],transit:[],ixp:{},rs:{},peers:{},pni:[],caches:[],biz:[],offers:[],myIx:{},pairMet:{},
|
||||
ltv:2,t1v:4,auV:1,calV:1,pieV:1,pie:null,ops:opsNew(),achP:{},seen:NETS.map(n=>n.id),spares:{},pops:{[home]:{day:0,bb:null,boost:0,down:0,routers:1,gen:false}},links:[],nni:[],transit:[],ixp:{},rs:{},peers:{},pni:[],caches:[],biz:[],offers:[],myIx:{},pairMet:{},
|
||||
done:{},inc:[],fleet:{},ev:{ddosMore:[]},ddosStarts:[],priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',ddosAuto:{rtbh:false,scrub:true},capDeal:null,core:{lv:0,run:0},popStd:null,won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0,ppol:'open',pdesk:null,pdeskRep:null,hw:{},rules:makeRules('oncall'),charter:'global',chartSet:false,demo:{},seatOff:null,solWon:0,monkey:{next:null,on:0}};
|
||||
}
|
||||
|
||||
|
|
|
|||
127
src/game/60-features/99-pie-in-the-sky.js
Normal file
127
src/game/60-features/99-pie-in-the-sky.js
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/* ---------- Pie in the Sky: your own satellite constellation (docs/plans/pie-in-the-sky.md) ----------
|
||||
Unlocks once, on becoming Tier 1 in a save started on this version (S.pieV>=1), or from day 0 with open gates.
|
||||
Pies are counted in cohorts per crust, never one object per satellite. Saves without S.pie pay nothing:
|
||||
pieDay() returns at once, compute() adds one falsy check.
|
||||
|
||||
Hooks for the parts that come later (routing, incidents and spats, the globe):
|
||||
- pieDishes() -> [{id,city,cc,ant,g}]: dishes that work today (POP there, not down, landing rights held)
|
||||
- pieHubs() -> ['short',…]: crusts that are baked (>= 60%) and up (not in safe mode, not down)
|
||||
- pieLicOk(cc) -> true when landing rights in that country are held and in force
|
||||
- pieCov(id), pieBaked(id), pieUp(id), pieLive(id), pieLiveLas(id) (10-catalog/70-pie.js and below)
|
||||
- PIE_ON.day / .launch / .fail: arrays of f(d) / f(L,ok) / f(L), called by pieDay() and pieFly()
|
||||
- S.pie.spat[id] with PIE_SPATS[id]={fix(o,s),day?(o,d)}: a spat's state, repaired by pieSanitize(), ticked and
|
||||
dropped when o.until<=d by pieSpatDay(d)
|
||||
- S.pie.crusts[id].down: day a crust is out until (a solar storm); S.pie.dishes[i].down likewise (a backhoe)
|
||||
- pieGlobeData() -> {crusts:[{id,alt,inc,n,las}],dishes:[{city,lat,lon}],pads:[{city,lat,lon,next}],
|
||||
launches:[{id,rk,cr,n,day,pad}]}
|
||||
- pieFounder(k,{n,c}) -> a Founder post (k from FOUNDER_POSTS); pieCharge(v) bills a cost (book kept)
|
||||
- book.earned: revenue from orbit, for the customers that come with routing. */
|
||||
function pieBlank(day){const crusts={};for(const id in CRUSTS)crusts[id]={cohorts:[],queued:0};
|
||||
return {born:day,co:null,fac:false,stock:0,rd:{reuse:false,heavy:false,heavyTests:0},pads:[],crusts,dishes:[],lic:{},q:[],
|
||||
founder:{posts:[],promises:0,broken:0,due:[]},book:{spent:0,earned:0,wouldHave:0},spat:{},safe:false};}
|
||||
function pieInit(){if(!S.pie)S.pie=pieBlank(S.day);return S.pie;}
|
||||
// The unlock: only on the Tier 1 transition of a save of this version, and only in a normal game.
|
||||
function pieUnlock(){if(S.pie||!(S.pieV>=1)||S.mode!=='normal'||S.scn)return;pieInit();track('pie_unlock');
|
||||
toast(`<b>🥧 ${tr('pie.unlocked_title')}</b><br>${tr('pie.unlocked_body')}`,'goal',[{l:tr('pie.open_pie_control'),act:'pieOpen',args:{}}]);}
|
||||
// Sandbox: there from day 0, created on the first action.
|
||||
const pieGet=()=>pieOn()?S.pie||pieInit():null;
|
||||
const pieSand=()=>S.mode==='sandbox';
|
||||
const pieCoName=()=>{const n=S.pie&&S.pie.co&&S.pie.co.name;return !n?tr(PIE_NAMES[0]):PIE_NAMES.includes(n)?tr(n):n;};
|
||||
// What it costs: sandbox pays nothing real but keeps count of what it would have paid.
|
||||
function pieSpend(v){const P=S.pie;if(pieSand()){P.book.wouldHave+=v;sfx('build');return true;}if(!spend(v))return false;P.book.spent+=v;return true;}
|
||||
function pieCharge(v){const P=S.pie;if(!P||!(v>0))return;if(pieSand())P.book.wouldHave+=v;else{S.cash-=v;P.book.spent+=v;}}
|
||||
function pieMo(){const P=S.pie;if(!P||!P.co)return 0;return PIE_CO_MO+(P.fac?PIE_FAC_MO:0)+P.pads.length*PIE_PAD_MO+P.dishes.length*PIE_DISH_MO;}
|
||||
const pieLiveLas=id=>{const c=S.pie&&S.pie.crusts[id];let n=0;if(c)for(const k of c.cohorts)if(k.las&&S.day-k.day<CRUSTS[id].life)n+=k.n;return n;};
|
||||
const pieLicOk=cc=>{const l=S.pie&&S.pie.lic[cc];return !!l&&l.state==='ok'&&l.until>S.day;};
|
||||
function pieDishes(){const P=S&&S.pie;if(!P)return [];const o=[];for(const x of P.dishes){if(!S.pops[x.city]||x.down>S.day)continue;const cc=CITY[x.city].cc;if(pieLicOk(cc))o.push({id:x.id,city:x.city,cc,ant:x.ant,g:x.ant*PIE_ANT_G});}return o;}
|
||||
function pieHubs(){return S&&S.pie?Object.keys(CRUSTS).filter(pieUp):[];}
|
||||
function pieGlobeData(){const P=S&&S.pie;if(!P)return {crusts:[],dishes:[],pads:[],launches:[]};const ll=c=>({city:c,lat:CITY[c].lat,lon:CITY[c].lon});
|
||||
return {crusts:Object.keys(CRUSTS).map(id=>({id,alt:CRUSTS[id].alt,inc:CRUSTS[id].inc,n:pieLive(id),las:pieLiveLas(id)})),
|
||||
dishes:P.dishes.map(x=>ll(x.city)),pads:P.pads.map(p=>({...ll(p.city),next:p.next})),launches:P.q.map(L=>({id:L.id,rk:L.rk,cr:L.cr,n:L.n,day:L.day,pad:L.pad}))};}
|
||||
// Spats (geopolitics) register in PIE_SPATS and keep their state in S.pie.spat; this ticks and ends them.
|
||||
function pieSpatDay(d){const sp=S.pie.spat;for(const k of Object.keys(sp)){const o=sp[k],D=PIE_SPATS[k];if(!D||o.until<=d){delete sp[k];continue;}if(D.day)D.day(o,d);}}
|
||||
const pieYear=d=>1+Math.floor(d/360);
|
||||
function pieFounder(k,v={}){const F=S.pie.founder,p={d:S.day,k};if(v.n!==undefined)p.n=v.n;if(v.c)p.c=v.c;F.posts.unshift(p);if(F.posts.length>PIE_POSTS)F.posts.length=PIE_POSTS;}
|
||||
// Every promise slips by a year: made today, due in a year, broken then.
|
||||
function piePromise(){const F=S.pie.founder;F.promises++;const due=S.day+360;F.due.push(due);if(F.due.length>8)F.due.shift();pieFounder(N_('pie.fp_promise'),{n:pieYear(due)});}
|
||||
function pieFpText(p){const C=own(CRUSTS,p.c||'')?tr(CRUSTS[p.c].n):'',n=p.n||0;return tr(p.k,{co:pieCoName(),n,crust:C});}
|
||||
// Pads that can reach a crust: an orbit's inclination is at least the pad's latitude.
|
||||
const piePadOk=(c,cr)=>CRUSTS[cr].polar||Math.abs(CITY[c].lat)<=CRUSTS[cr].inc;
|
||||
const pieRkOk=rk=>{const R0=ROCKETS[rk];return !R0.rd||!!S.pie.rd[R0.rd];};
|
||||
const pieTests=()=>S.pie.rd.heavyTests+S.pie.q.filter(L=>L.test).length;
|
||||
// A quote for a launch: why not, or what it costs, when and from where. The panel and the action both use it.
|
||||
function pieQuote(rk,cr,o={}){const P=S.pie;if(!P||!own(ROCKETS,rk)||!own(CRUSTS,cr))return {why:tr('pie.why_pick')};const R0=ROCKETS[rk],C=CRUSTS[cr];
|
||||
if(!pieCanBuild())return {why:tr('pie.why_not_t1')};
|
||||
if(!P.co)return {why:tr('pie.why_no_company')};if(!P.fac)return {why:tr('pie.why_no_factory')};
|
||||
if(!pieRkOk(rk))return {why:tr('pie.why_no_rd',{rd:tr(PIE_RD[R0.rd].n)})};
|
||||
const pads=P.pads.filter(p=>piePadOk(p.city,cr));if(!P.pads.length)return {why:tr('pie.why_no_pad')};if(!pads.length)return {why:tr('pie.why_pad_lat',{inc:C.inc})};
|
||||
if(P.q.length>=PIE_Q_MAX)return {why:tr('pie.why_queue_full')};
|
||||
const test=rk==='heavy'&&pieTests()<PIE_HEAVY_TESTS,n=test?0:R0.pies;
|
||||
if(!test&&P.stock<n)return {why:tr('pie.why_stock',{n,have:Math.floor(P.stock)})};
|
||||
if(!test&&pieLive(cr)+P.crusts[cr].queued+n>C.full*PIE_SPARE)return {why:tr('pie.why_full')};
|
||||
const t0=S.day+leadDays(PIE_PREP),pad=pads.slice().sort((a,b)=>Math.max(t0,a.next)-Math.max(t0,b.next)||Math.abs(CITY[a.city].lat)-Math.abs(CITY[b.city].lat))[0];
|
||||
const rocket=piePrice(R0.cost)*(1-pieEq(pad.city)),boost=rk==='again'&&!pad.boosters.length?piePrice(PIE_BOOST):0,pies=n*piePrice(PIE_PIE+(o.las?PIE_LAS:0));
|
||||
const ins=o.ins&&!test?Math.round((rocket+pies)*PIE_INS):0;
|
||||
return {ok:true,test,n,pad:pad.city,day:Math.max(t0,pad.next),cost:Math.round(rocket+boost+pies+ins),insured:Math.round(rocket+pies),ins:!!ins};}
|
||||
// The cheapest a crust can be filled from nothing (one-off costs only): rule O7.
|
||||
function pieFullCost(cr){const C=CRUSTS[cr],base=PIE_CO+PIE_FAC+PIE_PAD,pies=C.full*PIE_PIE;
|
||||
return base+pies+Math.min(...Object.keys(ROCKETS).map(rk=>{const R0=ROCKETS[rk],n=Math.ceil(C.full/R0.pies);return (R0.rd?PIE_RD[R0.rd].cost:0)+(n+(rk==='heavy'?PIE_HEAVY_TESTS:0))*R0.cost;}));}
|
||||
function pieCohort(cr,n,las){const c=S.pie.crusts[cr],m=Math.floor(S.day/30),k=c.cohorts.find(x=>x.las===las&&Math.floor(x.day/30)===m);if(k)k.n+=n;else c.cohorts.push({n,day:S.day,las});
|
||||
if(c.cohorts.length>PIE_COHORTS)c.cohorts.splice(0,c.cohorts.length-PIE_COHORTS);}
|
||||
// A launch: every one costs a party; a test always ends in a fireball; the rest fail by the rocket's odds and the chaos rule,
|
||||
// never in the first 90 days after the unlock.
|
||||
function pieFly(L){const P=S.pie,R0=ROCKETS[L.rk],C=P.crusts[L.cr],pad=P.pads.find(p=>p.city===L.pad);C.queued=Math.max(0,C.queued-L.n);
|
||||
pieCharge(PIE_PARTY);S.stats.pieLaunch=(S.stats.pieLaunch||0)+1;
|
||||
const quiet=S.day-P.born<PIE_QUIET,cm=quiet?0:chaosMul();let b=null;
|
||||
if(L.rk==='again'&&pad){if(!pad.boosters.length){pad.boosters.push({id:uid(),flights:0});}b=pad.boosters.slice().sort((x,y)=>x.flights-y.flights)[0];}
|
||||
let ok;
|
||||
if(L.test){ok=false;P.rd.heavyTests=Math.min(PIE_HEAVY_TESTS,P.rd.heavyTests+1);pieFounder(N_('pie.fp_test'),{n:P.rd.heavyTests});
|
||||
toast(tr('pie.t_test',{n:P.rd.heavyTests,left:PIE_HEAVY_TESTS-P.rd.heavyTests}),'bad');}
|
||||
else{ok=!(cm>0&&Math.random()<R0.fail*cm);
|
||||
if(ok){pieCohort(L.cr,L.n,!!L.las);pieFounder(N_('pie.fp_launch'),{n:L.n,c:L.cr});toast(tr('pie.t_launch',{n:L.n,crust:tr(CRUSTS[L.cr].n),p:pct(pieCov(L.cr))}),'good');}
|
||||
else{S.stats.pieFail=(S.stats.pieFail||0)+1;if(L.ins)pieRefund(L.cost);pieFounder(N_('pie.fp_fail'));
|
||||
toast(tr('pie.t_fail',{n:L.n})+(L.ins?' '+tr('pie.t_insured',{amt:fmt$(L.cost)}):''),'bad');for(const f of PIE_ON.fail)f(L);}}
|
||||
if(b&&pad){if(ok&&!(cm>0&&Math.random()<(R0.land||0)*cm)){b.flights++;if(b.flights>=PIE_BOOST_MAX)pad.boosters=pad.boosters.filter(x=>x!==b);}
|
||||
else if(!L.test){pad.boosters=pad.boosters.filter(x=>x!==b);if(ok){pieFounder(N_('pie.fp_booster'));toast(tr('pie.t_booster'),'bad');}}}
|
||||
for(const f of PIE_ON.launch)f(L,ok);}
|
||||
function pieRefund(v){const P=S.pie;if(pieSand())P.book.wouldHave=Math.max(0,P.book.wouldHave-v);else{S.cash+=v;P.book.spent=Math.max(0,P.book.spent-v);}}
|
||||
function pieDay(d){const P=S.pie;if(!P)return;
|
||||
if(P.fac)P.stock=Math.min(PIE_STOCK_MAX,P.stock+PIE_FAC_MONTH/30);
|
||||
if(P.q.length){const due=P.q.filter(L=>L.day<=d);if(due.length){P.q=P.q.filter(L=>L.day>d);for(const L of due)pieFly(L);}}
|
||||
for(const id in CRUSTS){const c=P.crusts[id],life=CRUSTS[id].life;if(c.cohorts.length&&d-c.cohorts[0].day>=life)c.cohorts=c.cohorts.filter(k=>d-k.day<life);
|
||||
if(!c.bk&&pieBaked(id)){c.bk=1;pieFounder(N_('pie.fp_baked'),{c:id});toast(tr('pie.t_baked',{crust:tr(CRUSTS[id].n)}),'goal');piePromise();}}
|
||||
{const F=P.founder;if(F.due.length&&F.due[0]<=d){F.due.shift();F.broken++;pieFounder(N_('pie.fp_slip'),{n:pieYear(d+360)});}}
|
||||
// Running costs are billed with the rest each day (compute()); the book keeps the tally, and the sandbox its shame.
|
||||
{const mo=pieMo()/30;if(mo){if(pieSand())P.book.wouldHave+=mo;else P.book.spent+=mo;}}
|
||||
pieSpatDay(d);for(const f of PIE_ON.day)f(d);}
|
||||
// Badge: lost Tier 1 while a launch was still on the pad.
|
||||
function pieTier(){const P=S.pie,t1=pieT1();if(P.t1&&!t1&&P.q.length&&!S.stats.pieTour){S.stats.pieTour=1;pieFounder(N_('pie.fp_tour'));}P.t1=t1;}
|
||||
/* The save gate for S.pie: everything clamped, unknown crusts, rockets and cities dropped, pads and dishes only where a
|
||||
POP is. A save without pieV (older versions) never unlocks it; puzzles, scenarios and the Architect never have it. */
|
||||
function pieSanitize(s){s.pieV=int(s.pieV,0,1,0);const p=s.pie,ob=x=>x&&typeof x==='object'&&!Array.isArray(x);
|
||||
if(!ob(p)||(s.pieV<1&&s.mode!=='sandbox')||s.scn||s.mode==='puzzle'){s.pie=null;return;}
|
||||
const o=pieBlank(int(p.born,0,s.day,s.day)),day=s.day,n=(v,hi)=>int(v,0,hi,0),m=(v,hi)=>clamp(num(v,0),0,hi);
|
||||
if(ob(p.co)){const nm=p.co.name;o.co={name:typeof nm==='string'&&nm.trim()?(PIE_NAMES.includes(nm)?nm:nm.replace(/\s+/g,' ').trim().slice(0,40)):PIE_NAMES[0]};}
|
||||
o.fac=!!p.fac&&!!o.co;o.stock=o.fac?m(p.stock,PIE_STOCK_MAX):0;o.safe=!!p.safe;o.t1=!!p.t1;
|
||||
if(ob(p.rd)){o.rd.reuse=!!p.rd.reuse;o.rd.heavy=!!p.rd.heavy;o.rd.heavyTests=o.rd.heavy?n(p.rd.heavyTests,PIE_HEAVY_TESTS):0;}
|
||||
const seen=new Set();
|
||||
o.pads=(Array.isArray(p.pads)?p.pads:[]).filter(x=>ob(x)&&isCity(x.city)&&s.pops[x.city]&&pieCoast(x.city)&&!seen.has(x.city)&&seen.add(x.city)).slice(0,PIE_PAD_MAX)
|
||||
.map(x=>({city:x.city,next:int(x.next,0,day+3650,day),boosters:(Array.isArray(x.boosters)?x.boosters:[]).filter(ob).slice(0,PIE_BOOSTERS).map(b=>({id:sid0(b.id),flights:n(b.flights,PIE_BOOST_MAX-1)}))}));
|
||||
if(ob(p.crusts))for(const id in CRUSTS){const c=p.crusts[id];if(!ob(c))continue;const C=CRUSTS[id];
|
||||
o.crusts[id].cohorts=(Array.isArray(c.cohorts)?c.cohorts:[]).filter(k=>ob(k)&&num(k.n,0)>=1).map(k=>({n:n(k.n,C.full*2),day:int(k.day,0,day,day),las:!!k.las})).filter(k=>day-k.day<C.life).slice(-PIE_COHORTS);
|
||||
if(c.down!==undefined&&num(c.down,0)>day)o.crusts[id].down=int(c.down,day,day+365,day);if(c.bk)o.crusts[id].bk=1;}
|
||||
const ds=new Set();
|
||||
o.dishes=(Array.isArray(p.dishes)?p.dishes:[]).filter(x=>ob(x)&&isCity(x.city)&&s.pops[x.city]&&!ds.has(x.city)&&ds.add(x.city)).slice(0,PIE_DISH_MAX)
|
||||
.map(x=>({id:sid0(x.id),city:x.city,ant:int(x.ant,1,PIE_ANT_MAX,1),down:int(x.down,0,day+365,0)}));
|
||||
const ccs=new Set(CITIES.map(c=>c.cc));
|
||||
if(ob(p.lic))for(const cc of Object.keys(p.lic)){const l=p.lic[cc];if(!ccs.has(cc)||!ob(l))continue;o.lic[cc]={state:PIE_LIC_STATES.includes(l.state)?l.state:'ok',until:int(l.until,0,day+PIE_LIC_DAYS*10,0)};}
|
||||
o.q=(Array.isArray(p.q)?p.q:[]).filter(L=>ob(L)&&own(ROCKETS,L.rk)&&own(CRUSTS,L.cr)&&o.pads.some(x=>x.city===L.pad)&&(!ROCKETS[L.rk].rd||o.rd[ROCKETS[L.rk].rd])).slice(0,PIE_Q_MAX)
|
||||
.map(L=>{const t=L.rk==='heavy'&&!!L.test;return {id:sid0(L.id),rk:L.rk,cr:L.cr,pad:L.pad,n:t?0:n(L.n,ROCKETS[L.rk].pies),day:int(L.day,0,day+3650,day),cost:m(L.cost,1e10),ins:!!L.ins,las:!!L.las,test:t};});
|
||||
for(const L of o.q)o.crusts[L.cr].queued+=L.n;
|
||||
if(ob(p.founder)){const F=p.founder;o.founder.promises=n(F.promises,1e6);o.founder.broken=n(F.broken,o.founder.promises);
|
||||
o.founder.posts=(Array.isArray(F.posts)?F.posts:[]).filter(x=>ob(x)&&FOUNDER_POSTS.includes(x.k)).slice(0,PIE_POSTS).map(x=>{const q={d:int(x.d,0,day,day),k:x.k};if(x.n!==undefined)q.n=n(x.n,1e7);if(own(CRUSTS,x.c||''))q.c=x.c;return q;});
|
||||
o.founder.due=(Array.isArray(F.due)?F.due:[]).map(v=>int(v,0,day+720,day)).sort((a,b)=>a-b).slice(-8);}
|
||||
if(ob(p.book))for(const k of ['spent','earned','wouldHave'])o.book[k]=m(p.book[k],1e15);
|
||||
if(ob(p.spat))for(const k of Object.keys(p.spat)){const D=PIE_SPATS[k];if(!D||!ob(p.spat[k]))continue;const v=D.fix?D.fix(p.spat[k],s):null;if(v)o.spat[k]=v;}
|
||||
s.pie=o;}
|
||||
const sid0=v=>typeof v==='string'&&v&&v.length<=40?v:uid();
|
||||
|
|
@ -363,6 +363,7 @@ function computeMoney(R2){
|
|||
C.caches=cachesMo();
|
||||
C.loans=(S.loans||[]).reduce((a,l)=>a+(BANKS[l.bank].equity?0:l.model==='transit'?Math.round((C.transit||0)*(l.cut||0.3)):l.pay)+loanFees(l),0);
|
||||
C.extras=(S.cnLic&&S.cnLic.state==='ok'?CN_JV_MO:0)+scrubMo()+Object.keys(S.pops).filter(ruCity).length*RU_BOX_MO+Object.values(S.pops).filter(p=>p.site2).length*SITE2_MO+(S.te?TE_MO:0)+(S.ops&&S.ops.intern?INTERN_MO:0)+salesMo();
|
||||
if(S.pie&&S.mode!=='sandbox')C.pie=pieMo();
|
||||
V.eyeballs=0;V.business=0;V.ix=0;V.grant=grantOn(R2)?GRANT_MO:0;
|
||||
C.wholesale=0;C.levy=0;const lev=scnRule('levy');for(const c in S.pops){const sf=sfOf(R2,c)*(R2.bbF[c]??1),v=R2.cityEye[c]*sf*EYE_RATE*arpuOf(c);V.eyeballs+=v;if(CITY[c].au){if(lev)C.levy+=v*AU_LEVY;else C.wholesale+=v*AU_WHOLESALE;}}
|
||||
const ids=linkIds();for(const b of S.biz){if(capPend(b))continue;const sf=BIZ_T[b.type].fiber?(fiberOk(b,ids)?1:0):BIZ_T[b.type].l2?clamp((R2.l2[b.id]||0)/b.bw,0,1):sfOf(R2,b.city)*(R2.tgtF[b.id]??1);V.business+=b.bw*b.rate*Math.min(1,sf/0.95);}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ function sanitize(s){
|
|||
{const r=s.rules&&typeof s.rules==='object'&&!Array.isArray(s.rules)?s.rules:{};
|
||||
const m={mods:r.mods};s.rules=s.scn&&typeof s.scn==='object'?makeRules('oncall',m):s.mode==='sandbox'?makeRules('sandbox',{...m,chaos:r.chaos}):makeRules(NORMAL_PRESETS.includes(r.preset)?r.preset:'oncall',m);}
|
||||
specSanitize(s);
|
||||
pieSanitize(s);
|
||||
if(s.te){if(typeof s.te!=='object')s.te=null;else{s.te.on=!!s.te.on;s.te.script=typeof s.te.script==='string'?s.te.script.slice(0,4000):'';}}
|
||||
return s;}
|
||||
function migrate(s){sanitize(s);
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ function dayPost(d){
|
|||
if(cm&&d>=S.nextEvent){dirty=true;fireEvent();S.nextEvent=d+Math.round((45+Math.floor(Math.random()*45))/cm);}
|
||||
if(dirty)compute();
|
||||
opsDay(d);
|
||||
if(S.pie){pieDay(d);pieTier();}
|
||||
// payday floaters
|
||||
if(cal(d).d===1){for(const c in S.pops){let v=(R.cityEye[c]*sfOf(R,c)*EYE_RATE)+S.biz.filter(b=>b.city===c).reduce((a,b)=>a+b.bw*b.rate,0);v=v-R.cityEye[c]*sfOf(R,c)*EYE_RATE*(1-arpuOf(c));if(v>500)floater(CITY[c].x,CITY[c].y-30,'+'+fmt$(v),'#16A866');}sfx('coin');}
|
||||
checkGoals();
|
||||
|
|
|
|||
|
|
@ -79,6 +79,9 @@ const BADGES=[
|
|||
{id:'bleed',i:'🩸',t:tr('core.bleeding_edge'),d:tr('core.run_an_srv6_backbone'),r:'r',ok:()=>coreOn()&&S.core.run>=4},
|
||||
{id:'mono',i:'🏪',t:tr('core.single_vendor_shop'),d:tr('core.run_sr_mpls_or_srv6_on'),r:'e',ok:()=>coreOn()&&S.core.run>=3&&Object.keys(S.pops).length>=8&&!coreOut().length&&coreVendors().size===1},
|
||||
{id:'zoo',i:'🦓',t:tr('core.vendor_zoo'),d:tr('core.run_an_mpls_backbone_with_4'),r:'r',ok:()=>coreOn()&&S.core.run>=1&&coreVendors().size>=4},
|
||||
{id:'billion',i:'🔥',t:tr('pie.b_billion'),d:tr('pie.b_billion_d'),r:'e',ok:()=>!!S.pie&&S.pie.book.spent>=1e9},
|
||||
{id:'baked',i:'🥧',t:tr('pie.b_baked'),d:tr('pie.b_baked_d'),r:'l',ok:()=>!!S.pie&&Object.keys(CRUSTS).some(id=>pieCov(id)>=1)},
|
||||
{id:'tour',i:'🎙️',t:tr('pie.b_tour'),d:tr('pie.b_tour_d'),r:'r',ok:()=>!!(st().pieTour)},
|
||||
{id:'zero',i:'🕳️',t:tr('badges.zero_peers_given'),d:tr('badges.reach_tier_2_with_every_single'),r:'l',secret:true,ok:()=>isTier2()&&!Object.keys(S.peers).length&&!S.pni.length},
|
||||
];
|
||||
/* Badge variants by ruleset (2.0): On-call earns the standard badge, Change Freeze a frosted one and BGP at 3 a.m. a
|
||||
|
|
@ -115,6 +118,6 @@ function checkGoals(){checkBadges();
|
|||
if(ok){S.done[g.id]=S.day;if(g.r&&S.mode!=='sandbox'){S.cash+=g.r;}
|
||||
toast(`<b>${tr('badges.goal_complete_name',{name:esc(g.t)})}</b>${g.r?`<br>${tr('badges.reward_amt',{amt:fmt$(g.r)})}`:''}`,'goal',[],{a:'tab',v:'goals'});sfx('coin');
|
||||
// Glass Baron is the broker's win; S.won stays Tier 1, which a broker can still become.
|
||||
track('goal_'+g.id);if(g.baron){if(!S.baronWon){S.baronWon=S.day||1;track('win_baron');checkBadges();showBaronWin();}}else if(g.win&&!S.won){S.won=true;track('win_tier1');checkBadges();showWin();}}}
|
||||
track('goal_'+g.id);if(g.baron){if(!S.baronWon){S.baronWon=S.day||1;track('win_baron');checkBadges();showBaronWin();}}else if(g.win&&!S.won){S.won=true;track('win_tier1');pieUnlock();checkBadges();showWin();}}}
|
||||
}
|
||||
|
||||
|
|
|
|||
33
src/game/90-actions/97-pie.js
Normal file
33
src/game/90-actions/97-pie.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Pie in the Sky (60-features/99-pie-in-the-sky.js): every action checks pieCanBuild() for anything new.
|
||||
const pieRe=()=>{after();if(!$('modal').hidden&&$('modal').className==='pie')pieModal();};
|
||||
const pieNo=why=>{toast(why,'bad');sfx('err');pieRe();};
|
||||
Object.assign(ACT,{
|
||||
pieOpen:()=>{if(!S||pzOn()||!pieOn())return;UI.confirm=null;pieModal();},
|
||||
pieFound:()=>{const P=pieGet();if(!P||P.co)return;if(!pieCanBuild())return pieNo(tr('pie.why_not_t1'));if(!pieSpend(piePrice(PIE_CO)))return pieRe();
|
||||
P.co={name:PIE_NAMES[0]};P.born=Math.min(P.born,S.day);pieFounder(N_('pie.fp_found'));piePromise();track('pie_found');toast(tr('pie.t_found',{co:esc(pieCoName())}),'goal');pieRe();},
|
||||
pieFactory:()=>{const P=pieGet();if(!P||!P.co||P.fac)return;if(!pieCanBuild())return pieNo(tr('pie.why_not_t1'));if(!pieSpend(piePrice(PIE_FAC)))return pieRe();
|
||||
P.fac=true;toast(tr('pie.t_factory',{n:PIE_FAC_MONTH}),'good');pieRe();},
|
||||
piePad:({city})=>{const P=pieGet();if(!P||!P.co||!isCity(city))return;if(!pieCanBuild())return pieNo(tr('pie.why_not_t1'));
|
||||
if(!S.pops[city]||!pieCoast(city))return pieNo(tr('pie.why_pad_city'));if(P.pads.some(p=>p.city===city)||P.pads.length>=PIE_PAD_MAX)return;
|
||||
if(!pieSpend(piePrice(PIE_PAD)))return pieRe();P.pads.push({city,next:S.day,boosters:[]});toast(tr('pie.t_pad',{city:CITY[city].name,p:pct(pieEq(city))}),'good');pieRe();},
|
||||
pieRd:({k})=>{const P=pieGet();if(!P||!P.co||!own(PIE_RD,k)||P.rd[k])return;if(!pieCanBuild())return pieNo(tr('pie.why_not_t1'));if(!pieSpend(piePrice(PIE_RD[k].cost)))return pieRe();
|
||||
P.rd[k]=true;toast(tr('pie.t_rd',{rd:tr(PIE_RD[k].n)}),'good');if(k==='heavy')piePromise();pieRe();},
|
||||
pieLaunch:({rk,cr})=>{const P=pieGet();if(!P)return;const o={ins:!!UI.pieIns,las:!!UI.pieLas},q=pieQuote(rk,cr,o);if(!q.ok)return pieNo(q.why);if(!pieSpend(q.cost))return pieRe();
|
||||
const pad=P.pads.find(p=>p.city===q.pad);pad.next=q.day+leadDays(ROCKETS[rk].gap);if(rk==='again'&&!pad.boosters.length)pad.boosters.push({id:uid(),flights:0});
|
||||
P.stock=Math.max(0,P.stock-q.n);P.crusts[cr].queued+=q.n;P.q.push({id:uid(),rk,cr,pad:q.pad,n:q.n,day:q.day,cost:q.ins?q.insured:0,ins:q.ins,las:o.las&&!q.test,test:q.test});
|
||||
{const v={n:q.n,crust:tr(CRUSTS[cr].n),city:CITY[q.pad].name,d:dateStr(q.day)};toast(q.test?tr('pie.t_queued_test',v):tr('pie.t_queued',v),'good');}pieRe();},
|
||||
pieIns:()=>{UI.pieIns=!UI.pieIns;sfx('click');pieModal();},
|
||||
pieLas:()=>{UI.pieLas=!UI.pieLas;sfx('click');pieModal();},
|
||||
pieDish:({city})=>{const P=pieGet();if(!P||!P.co||!isCity(city))return;if(!pieCanBuild())return pieNo(tr('pie.why_not_t1'));if(!S.pops[city])return pieNo(tr('pie.why_dish_city'));
|
||||
if(P.dishes.some(x=>x.city===city)||P.dishes.length>=PIE_DISH_MAX)return;if(!pieSpend(piePrice(PIE_DISH+PIE_ANT)))return pieRe();
|
||||
P.dishes.push({id:uid(),city,ant:1,down:0});if(P.dishes.length===1)pieFounder(N_('pie.fp_dish'));toast(tr('pie.t_dish',{city:CITY[city].name}),'good');pieRe();},
|
||||
pieAnt:({id})=>{const P=pieGet();const x=P&&P.dishes.find(d=>d.id===id);if(!x||x.ant>=PIE_ANT_MAX)return;if(!pieCanBuild())return pieNo(tr('pie.why_not_t1'));if(!pieSpend(piePrice(PIE_ANT)))return pieRe();x.ant++;pieRe();},
|
||||
// Landing rights: bought for a year, renewed for another from whenever they run out.
|
||||
pieLic:({cc})=>{const P=pieGet();if(!P||!P.co||typeof cc!=='string'||!CITIES.some(c=>c.cc===cc))return;const l=P.lic[cc];if(l&&l.state!=='ok'&&l.until>S.day)return pieNo(tr('pie.why_lic_refused'));
|
||||
if(!pieSpend(pieLicPrice(cc)))return pieRe();P.lic[cc]={state:'ok',until:Math.max(S.day,l&&l.state==='ok'?l.until:0)+PIE_LIC_DAYS};toast(tr('pie.t_lic',{n:pieLicCountry(cc)}),'good');pieRe();},
|
||||
pieSafe:()=>{const P=pieGet();if(!P||!P.co)return;P.safe=!P.safe;sfx('click');pieRe();},
|
||||
pieName:()=>{const P=pieGet();if(!P||!P.co)return;const i=PIE_NAMES.indexOf(P.co.name);P.co.name=PIE_NAMES[(i+1)%PIE_NAMES.length];pieFounder(N_('pie.fp_rename'));pieRe();},
|
||||
pieRename:()=>{const P=pieGet(),el=$('pieNm');if(!P||!P.co||!el)return;const v=el.value.replace(/\s+/g,' ').trim().slice(0,40);if(!v)return;P.co.name=v;pieFounder(N_('pie.fp_rename'));pieRe();},
|
||||
pieTab:({t})=>{if(!['co','fly','dish','book'].includes(t))return;UI.pieTab=t;pieModal();},
|
||||
pieCity:({v})=>{if(!S||!S.pops[v])return;UI.pieCity=v;pieModal();},
|
||||
});
|
||||
|
|
@ -51,7 +51,7 @@ function renderLeft(){checkLayer();
|
|||
}else if(UI.left==='noc'){
|
||||
h+=`<div class="btns" style="margin-bottom:8px">${btn(tr('hud_and_panels.open_noc_dashboard'),'dash',{},'pink')}${btn(tr('common.connections'),'connOpen',{},'')}${btn(tr('common.traceroute'),'trace',{},'')}${btn(`⚙️ ${tr('routing.routing_and_ddos')}${S.te&&!coreTE()?'<span class="cnt red dot" aria-hidden="true"></span>':''}`,'routingOpen',{},'')}</div>`;
|
||||
h+=`<p class="lead">${tr('hud_and_panels.your_network_operations_center_every')}</p>`;
|
||||
h+=opsCard()+mkCard()+ddosPanel();
|
||||
h+=opsCard()+pieCard()+mkCard()+ddosPanel();
|
||||
// Incidents come first, the ones you can fix with one click at the top (#63): no scrolling past hot ports to replace an optic.
|
||||
for(const i of S.inc.filter(i=>i.type!=='ddos').sort((a,b)=>(b.cost?1:0)-(a.cost?1:0)||(b.impact||0)-(a.impact||0))){h+=`<div class="inc"><div class="nm">${incTitle(i.type)}</div><div class="meta">${esc(i.msg)}</div><div class="meta">${shipSea(i)?'🚢 '+esc(shipStatus(i)):trn('hud_and_panels.auto_fix_in_n_day',i.until-S.day)}${i.impact?` · ${tr('hud_and_panels.g_lost',{g:fmtG(i.impact)})}`:''}</div>${i.cost?`<div class="btns">${btn(`${esc(i.fix||tr('common.rush_repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red sm',S.cash<i.cost)}</div>`:''}</div>`;}
|
||||
h+=logSection();UI.logSeen=Date.now();
|
||||
|
|
|
|||
46
src/game/93-ui/85-pie-control.js
Normal file
46
src/game/93-ui/85-pie-control.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// Pie Control: a plain modal (a bottom sheet on phones) for the rocket company. Reached from the NOC tab (pieCard()).
|
||||
let PIE_CCN=null;
|
||||
function pieLicCountry(cc){try{PIE_CCN=PIE_CCN&&PIE_CCN.l===LANG?PIE_CCN:{l:LANG,d:new Intl.DisplayNames([LANG],{type:'region'})};return PIE_CCN.d.of(cc)||cc;}catch(e){return cc;}}
|
||||
function pieCard(){if(!pieOn())return '';const P=S.pie;
|
||||
return `<div class="ops-card pie-card"><div class="nm">🥧 ${tr('pie.pie_in_the_sky')}</div><div class="meta">${P&&P.co?esc(pieCoName())+' · '+tr('pie.card_live',{n:Object.keys(CRUSTS).reduce((a,id)=>a+pieLive(id),0),q:P.q.length}):tr('pie.card_pitch')}</div>
|
||||
<div class="btns">${btn(tr('pie.open_pie_control'),'pieOpen',{},P&&P.co?'sm':'pink sm')}</div></div>`;}
|
||||
const pieTag=(t,on)=>`<span class="tag ${on?'open':'selective'}">${t}</span>`;
|
||||
function pieModal(){if(!S||!pieOn())return;const P=S.pie||pieBlank(S.day),can=pieCanBuild(),T=['co','fly','dish','book'].includes(UI.pieTab)?UI.pieTab:'co';
|
||||
let h=`<div style="display:flex;align-items:center"><div class="grow"><div class="eyebrow">${tr('pie.pie_in_the_sky')}</div><h2 style="font-size:24px">${P.co?esc(pieCoName()):tr('pie.pie_control')}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>`;
|
||||
if(!can)h+=`<p class="why">${tr('pie.why_not_t1')}</p>`;
|
||||
if(pieSand())h+=`<p class="note">${tr('pie.sandbox_note',{amt:fmt$(P.book.wouldHave)})}</p>`;
|
||||
if(!P.co){h+=`<p class="lead">${tr('pie.found_pitch')}</p><div class="btns">${btn(tr('pie.found_price',{price:fmt$(piePrice(PIE_CO)),mo:fmt$(PIE_CO_MO)}),'pieFound',{},'pink',!can)}</div>`;openModal(h,'pie');return;}
|
||||
const tab=(k,l)=>`<button class="b sm ${T===k?'pink':'ghost'}" data-act="pieTab" data-args='{"t":"${k}"}' aria-pressed="${T===k}">${l}</button>`;
|
||||
h+=`<div class="seg" style="margin:6px 0 10px">${tab('co',tr('pie.tab_company'))}${tab('fly',tr('pie.tab_launch'))}${tab('dish',tr('pie.tab_dishes'))}${tab('book',tr('pie.tab_founder'))}</div>`;
|
||||
const cities=Object.keys(S.pops).sort((a,b)=>CITY[a].name.localeCompare(CITY[b].name)),c=S.pops[UI.pieCity]?UI.pieCity:cities[0];
|
||||
const sel=`<div class="trsel"><label>${tr('common.your_pop')}<select data-chg="pieCity">${cities.map(x=>`<option value="${x}"${x===c?' selected':''}>${esc(CITY[x].name)}</option>`).join('')}</select></label></div>`;
|
||||
if(T==='co'){
|
||||
h+=`<div class="kv"><span>${tr('pie.running_costs')}</span><b>${tr('common.price_mo',{price:fmt$(pieMo())})}</b></div>`;
|
||||
h+=`<div class="ops-o${P.fac?' on':''}"><div class="nm">🏭 ${tr('pie.factory')}</div><div class="meta">${P.fac?tr('pie.factory_stock',{n:Math.floor(P.stock),m:PIE_FAC_MONTH}):tr('pie.factory_pitch',{m:PIE_FAC_MONTH,mo:fmt$(PIE_FAC_MO)})}</div>${P.fac?'':`<div class="btns">${btn(tr('pie.build_price',{price:fmt$(piePrice(PIE_FAC))}),'pieFactory',{},'pink sm',!can)}</div>`}</div>`;
|
||||
h+=`<div class="ops-o"><div class="nm">🧪 ${tr('pie.rd')}</div>${Object.keys(PIE_RD).map(k=>`<div class="kv"><span>${tr(PIE_RD[k].n)}</span>${P.rd[k]?`<b>✓</b>`:btn(fmt$(piePrice(PIE_RD[k].cost)),'pieRd',{k},'ghost sm',!can)}</div>`).join('')}
|
||||
${P.rd.heavy?`<p class="meta">${tr('pie.heavy_tests',{n:P.rd.heavyTests,max:PIE_HEAVY_TESTS})}</p>`:''}</div>`;
|
||||
h+=`<div class="ops-o"><div class="nm">🚀 ${tr('pie.pads')}</div>${P.pads.map(p=>`<div class="kv"><span>${esc(CITY[p.city].name)} · −${pct(pieEq(p.city))}</span><b>${p.next>S.day?tr('pie.pad_busy',{d:dateStr(p.next)}):tr('pie.pad_free')}${p.boosters.length?' · '+trn('pie.n_boosters',p.boosters.length):''}</b></div>`).join('')||`<p class="meta">${tr('pie.no_pads')}</p>`}
|
||||
${sel}<div class="btns">${btn(tr('pie.build_pad_price',{city:esc(CITY[c].name),price:fmt$(piePrice(PIE_PAD))}),'piePad',{city:c},'ghost sm',!can||!pieCoast(c)||P.pads.some(p=>p.city===c)||P.pads.length>=PIE_PAD_MAX)}</div>${pieCoast(c)?'':`<p class="why">${tr('pie.why_pad_city')}</p>`}</div>`;
|
||||
h+=`<div class="ops-o"><div class="nm">🏷️ ${tr('pie.name')}</div><div class="btns">${btn(tr('pie.next_name'),'pieName',{},'ghost sm')}</div>
|
||||
<div class="network-name" style="margin-top:6px"><input class="t" id="pieNm" maxlength="40" value="${esc(pieCoName())}" autocomplete="off" aria-label="${esc(tr('pie.name'))}"></div><div class="btns">${btn(tr('slots.rename'),'pieRename',{},'ghost sm')}</div></div>`;
|
||||
h+=`<div class="btns">${btn(P.safe?tr('pie.safe_on'):tr('pie.safe_off'),'pieSafe',{},P.safe?'red sm':'ghost sm')}</div><p class="meta">${tr('pie.safe_note')}</p>`;
|
||||
}else if(T==='fly'){
|
||||
h+=Object.keys(CRUSTS).map(id=>{const C=CRUSTS[id],cv=pieCov(id);return `<div class="ops-o${pieUp(id)?' on':''}"><div class="nm">${tr(C.n)} ${pieTag(pieBaked(id)?tr('pie.baked'):tr('pie.half_baked'),pieBaked(id))}</div>
|
||||
<div class="meta">${tr('pie.crust_line',{alt:C.alt,n:pieLive(id),full:C.full,q:P.crusts[id].queued,p:pct(cv)})}</div><div class="bar ${cv>=PIE_BAKED?'':'warn'}"><i style="width:${Math.round(cv*100)}%"></i></div>
|
||||
<div class="ops-p">${Object.keys(ROCKETS).filter(pieRkOk).map(rk=>{const q=pieQuote(rk,id,{ins:!!UI.pieIns,las:!!UI.pieLas});return btn(`${tr(ROCKETS[rk].n)} <small>${q.ok?(q.test?tr('pie.test_flight')+' · ':'')+fmt$(q.cost):esc(q.why)}</small>`,'pieLaunch',{rk,cr:id},'ghost sm',!q.ok);}).join('')}</div></div>`;}).join('');
|
||||
h+=`<div class="ops-p">${btn(UI.pieIns?tr('pie.ins_on'):tr('pie.ins_off'),'pieIns',{},UI.pieIns?'green sm':'ghost sm')}${btn(UI.pieLas?tr('pie.las_on'):tr('pie.las_off'),'pieLas',{},UI.pieLas?'green sm':'ghost sm')}</div>`;
|
||||
h+=`<p class="meta">${tr('pie.stock_line',{n:Math.floor(P.stock)})}</p>`;
|
||||
if(P.q.length)h+=`<h3 style="font-size:15px;margin:10px 0 4px">${tr('pie.queue')}</h3>`+P.q.slice().sort((a,b)=>a.day-b.day).map(L=>`<div class="kv"><span>${esc(tr(ROCKETS[L.rk].n))} → ${esc(tr(CRUSTS[L.cr].n))}</span><b>${L.test?tr('pie.test_flight'):L.n} · ${esc(CITY[L.pad].name)} · ${dateStr(L.day)}</b></div>`).join('');
|
||||
}else if(T==='dish'){
|
||||
h+=`<p class="meta">${tr('pie.dish_note')}</p>`+P.dishes.map(x=>{const cc=CITY[x.city].cc,ok=pieLicOk(cc);return `<div class="kv"><span>📡 ${esc(CITY[x.city].name)} · ${trn('pie.n_antennas',x.ant)}${ok?'':' · '+tr('pie.no_rights')}</span>${btn(tr('pie.add_antenna',{price:fmt$(piePrice(PIE_ANT))}),'pieAnt',{id:x.id},'ghost sm',!can||x.ant>=PIE_ANT_MAX)}</div>`;}).join('');
|
||||
h+=sel+`<div class="btns">${btn(tr('pie.build_dish_price',{city:esc(CITY[c].name),price:fmt$(piePrice(PIE_DISH+PIE_ANT))}),'pieDish',{city:c},'ghost sm',!can||P.dishes.some(x=>x.city===c))}</div>`;
|
||||
const ccs=[...new Set([...P.dishes.map(x=>CITY[x.city].cc),CITY[c].cc,...Object.keys(P.lic)])];
|
||||
h+=`<h3 style="font-size:15px;margin:10px 0 4px">${tr('pie.landing_rights')}</h3>`+ccs.map(cc=>{const l=P.lic[cc],ok=pieLicOk(cc);
|
||||
return `<div class="kv"><span>${esc(pieLicCountry(cc))}${ok?' · '+tr('pie.lic_until',{d:dateStr(l.until)}):l&&l.state!=='ok'&&l.until>S.day?' · '+tr('pie.lic_refused'):''}</span>${btn((ok?tr('pie.renew'):tr('pie.buy'))+' '+fmt$(pieLicPrice(cc)),'pieLic',{cc},'ghost sm')}</div>`;}).join('');
|
||||
}else{
|
||||
const F=P.founder;h+=`<div class="kv"><span>${tr('pie.promises')}</span><b>${tr('pie.promises_line',{n:F.promises,b:F.broken})}</b></div>`;
|
||||
h+=`<div class="kv"><span>${tr('pie.spent')}</span><b>${fmt$(P.book.spent)}</b></div><div class="kv"><span>${tr('pie.earned')}</span><b>${fmt$(P.book.earned)}</b></div>`;
|
||||
if(pieSand())h+=`<div class="kv"><span>${tr('pie.would_have')}</span><b>${fmt$(P.book.wouldHave)}</b></div>`;
|
||||
h+=`<h3 style="font-size:15px;margin:10px 0 4px">${tr('pie.founder_feed')}</h3>`+(F.posts.length?F.posts.map(p=>`<div class="ops-rep"><div class="eyebrow">${esc(dateStr(p.d))}</div><div>${esc(pieFpText(p))}</div></div>`).join(''):`<p class="meta">${tr('pie.feed_empty')}</p>`);
|
||||
}
|
||||
openModal(h,'pie');}
|
||||
|
|
@ -9,7 +9,7 @@ function renderDash(){checkLayer();
|
|||
<div class="dgrid">${tile(tr('common.traffic_now'),fmtG(R.served),tr('dashboard.of_g_wanted',{g:fmtG(R.demand)}))}${tile(tr('common.peak'),fmtG(S.stats.peak))}${tile(tr('dashboard.delivered_30_days'),(up*100).toFixed(1)+'%',up>=0.999?tr('dashboard.five_nines_ish'):up>=0.99?tr('dashboard.two_nines_and_change'):tr('dashboard.customers_are_upset'))}${tile(tr('common.peering_ratio'),pct(R.peerShare||0),tr('dashboard.caches_pnis_and_ix'))}${tile(tr('dashboard.monthly_p_l'),`<span style="color:${net>=0?'var(--eye)':'var(--bad)'}">${net>=0?'+':''}${fmt$(net)}</span>`,tr('dashboard.in_in_out_out',{in:fmt$(R.revMo),out:fmt$(R.costMo)}))}${tile(tr('common.incidents'),S.stats.incidents,tr('dashboard.n_shrugged_off',{n:S.stats.survived}))}</div>
|
||||
<div class="dcols"><div class="panel2"><h3>${tr('dashboard.traffic_by_way_out')}</h3>${svgChart(rows,['c','p','ix','t','l2'],[{k:'dem',col:'#1E2640',dash:true}],v=>fmtCap(Math.round(v)),'traffic')}${chartLegend('traffic',k=>k==='dem'?'':' '+pct((R.egT[k]||0)/tot))}</div>
|
||||
<div class="panel2"><h3>${tr('dashboard.money_per_month')}</h3>${svgChart(rows,[],[{k:'rev',col:'#16A866'},{k:'cost',col:'#FF4D5E'}],v=>fmt$(v),'money')}${chartLegend('money')}
|
||||
<h3 style="margin-top:8px">${tr('dashboard.where_the_money_goes')}</h3>${Object.entries(R.cost).filter(([k,v])=>v>0).sort((a,b)=>b[1]-a[1]).map(([k,v])=>`<div class="kv"><span>${{pops:tr('dashboard.pops_and_routers'),links:tr('dashboard.waves_and_fiber'),transit:tr('common.transit'),ix:tr('common.ix_ports'),pni:tr('common.pnis'),caches:tr('common.cache_power'),nni:tr('common.fabric_ports'),optical:tr('dashboard.amp_huts_and_spares'),loans:tr('common.loan_repayments'),revshare:tr('dashboard.investor_revenue_share'),extras:tr('dashboard.licenses_and_scrubbing'),wholesale:tr('dashboard.nearly_broadband_network_wholesale'),levy:tr('dashboard.regional_broadband_levy')}[k]||k}</span><b>${tr('common.price_mo',{price:fmt$(v)})}</b></div>`).join('')}</div></div>`;
|
||||
<h3 style="margin-top:8px">${tr('dashboard.where_the_money_goes')}</h3>${Object.entries(R.cost).filter(([k,v])=>v>0).sort((a,b)=>b[1]-a[1]).map(([k,v])=>`<div class="kv"><span>${{pops:tr('dashboard.pops_and_routers'),links:tr('dashboard.waves_and_fiber'),transit:tr('common.transit'),ix:tr('common.ix_ports'),pni:tr('common.pnis'),caches:tr('common.cache_power'),nni:tr('common.fabric_ports'),optical:tr('dashboard.amp_huts_and_spares'),loans:tr('common.loan_repayments'),revshare:tr('dashboard.investor_revenue_share'),extras:tr('dashboard.licenses_and_scrubbing'),wholesale:tr('dashboard.nearly_broadband_network_wholesale'),levy:tr('dashboard.regional_broadband_levy'),pie:tr('pie.costs_row')}[k]||k}</span><b>${tr('common.price_mo',{price:fmt$(v)})}</b></div>`).join('')}</div></div>`;
|
||||
const tT=(R.egT.t||0)||1;
|
||||
const offMix=(UI.chartOff&&UI.chartOff.mix)||{},filt=Object.keys(offMix).length>0;
|
||||
// The legend above the table picks which ways in count; "lost" still looks at everything the network gets.
|
||||
|
|
|
|||
121
src/i18n/en.js
121
src/i18n/en.js
|
|
@ -3375,6 +3375,127 @@
|
|||
"peering_policy.their_policy_here_says_ix_peering":"Their policy here says \"IX peering by invitation only\". You were not invited.",
|
||||
"peering_policy.their_routers_in_this_city_are":"Their routers in this city are \"at capacity\". They are not.",
|
||||
"peering_policy.tried_a_remote_peer_once_it":"Tried a remote peer once. It flapped during a product launch. Never again.",
|
||||
"pie.add_antenna":"+ antenna {price}",
|
||||
"pie.b_baked":"Fully Baked",
|
||||
"pie.b_baked_d":"Fill a whole crust with pies",
|
||||
"pie.b_billion":"Burned a Billion",
|
||||
"pie.b_billion_d":"Spend a billion dollars on your rocket company",
|
||||
"pie.b_tour":"Listening Tour",
|
||||
"pie.b_tour_d":"Lose Tier 1 while a launch is still on the pad",
|
||||
"pie.baked":"Baked",
|
||||
"pie.build_dish_price":"Build a pie dish in {city} {price}",
|
||||
"pie.build_pad_price":"Build a launch pad in {city} {price}",
|
||||
"pie.build_price":"Build {price}",
|
||||
"pie.buy":"Buy",
|
||||
"pie.card_live":"{n} pies in orbit · {q} launches queued",
|
||||
"pie.card_pitch":"Found a rocket company and put your own internet in the sky. It costs a fortune.",
|
||||
"pie.co_compensation_dynamics":"Compensation Dynamics",
|
||||
"pie.co_escape_velocity_partners":"Escape Velocity Partners",
|
||||
"pie.co_gravity_is_optional":"Gravity Is Optional",
|
||||
"pie.co_hubris_heavy_industries":"Hubris Heavy Industries",
|
||||
"pie.co_mid_life_crisis_aerospace":"Mid-Life Crisis Aerospace",
|
||||
"pie.co_payload_bearing":"Payload Bearing",
|
||||
"pie.co_spacexpensive":"SpaceXpensive",
|
||||
"pie.co_thrust_issues":"Thrust Issues",
|
||||
"pie.costs_row":"Rocket company",
|
||||
"pie.cr_flaky":"Flaky Pastry (340 km)",
|
||||
"pie.cr_frozen":"Frozen Crust (polar)",
|
||||
"pie.cr_shortcrust":"Shortcrust (550 km)",
|
||||
"pie.cr_upper":"Upper Crust (1,100 km)",
|
||||
"pie.crust_line":"{alt} km · {n} of {full} pies · {q} on the way · {p} covered",
|
||||
"pie.dish_note":"A pie dish talks to the pies overhead. It needs a POP in its city and landing rights in its country.",
|
||||
"pie.earned":"Earned from orbit",
|
||||
"pie.factory":"Pie factory",
|
||||
"pie.factory_pitch":"Bakes {m} pies a month, for {mo} a month.",
|
||||
"pie.factory_stock":"{n} pies on the shelf · {m} a month",
|
||||
"pie.feed_empty":"The Founder has not posted yet. Give it a minute.",
|
||||
"pie.found_pitch":"Your own constellation: rockets, thousands of satellites (pies) in shells (crusts), and dishes on the ground. Nothing you have built so far costs this much.",
|
||||
"pie.found_price":"Found the company {price} · {mo}/mo",
|
||||
"pie.founder_feed":"The Founder posts",
|
||||
"pie.fp_baked":"{crust} is fully baked. Next stop: Mars. Probably next year.",
|
||||
"pie.fp_booster":"The booster tipped over on landing. It was a planned tip. We call it a rapid horizontal recovery.",
|
||||
"pie.fp_dish":"Our first pie dish is up. My mum says the signal is great.",
|
||||
"pie.fp_fail":"Today's launch was a huge success. The rocket is now in many places at once.",
|
||||
"pie.fp_found":"Founded {co}. Our mission: put pies in the sky so everyone gets a slice.",
|
||||
"pie.fp_launch":"{n} more pies in {crust}. Bold. Visionary. On schedule (this one).",
|
||||
"pie.fp_promise":"Promise: full coverage by year {n}. Write it down.",
|
||||
"pie.fp_rename":"We are {co} now. The old name was holding back the vision.",
|
||||
"pie.fp_slip":"Full coverage is now year {n}. It was always year {n}. Read the footnotes.",
|
||||
"pie.fp_test":"Test flight {n} ended in a fireball, exactly as we hoped. We learned so much.",
|
||||
"pie.fp_tour":"Stepping back from Tier 1 to go on a listening tour. Mostly I will be talking.",
|
||||
"pie.half_baked":"Half-baked",
|
||||
"pie.heavy_tests":"Test flights flown: {n} of {max}. The first ones always explode.",
|
||||
"pie.ins_off":"Insurance: off",
|
||||
"pie.ins_on":"Insurance: on (8%)",
|
||||
"pie.landing_rights":"Landing rights",
|
||||
"pie.las_off":"Lasers: off",
|
||||
"pie.las_on":"Lasers: on (+$0.5M a pie)",
|
||||
"pie.lic_refused":"refused for now",
|
||||
"pie.lic_until":"until {d}",
|
||||
"pie.n_antennas":{"one":"{n} antenna","other":"{n} antennas"},
|
||||
"pie.n_boosters":{"one":"{n} booster","other":"{n} boosters"},
|
||||
"pie.name":"Company name",
|
||||
"pie.next_name":"Try another name",
|
||||
"pie.no_pads":"No launch pads yet. A pad needs a POP in a city on the coast.",
|
||||
"pie.no_rights":"no landing rights",
|
||||
"pie.open_pie_control":"Pie Control",
|
||||
"pie.pad_busy":"busy until {d}",
|
||||
"pie.pad_free":"ready",
|
||||
"pie.pads":"Launch pads",
|
||||
"pie.pie_control":"Pie Control",
|
||||
"pie.pie_in_the_sky":"Pie in the Sky",
|
||||
"pie.promises":"Promises",
|
||||
"pie.promises_line":"{n} made · {b} broken",
|
||||
"pie.queue":"On the pad",
|
||||
"pie.rd":"Research",
|
||||
"pie.rd_heavy":"Starshipping & Handling (heavy rocket)",
|
||||
"pie.rd_reuse":"Reusable boosters",
|
||||
"pie.renew":"Renew",
|
||||
"pie.rk_falcon_punch":"Falcon Punch",
|
||||
"pie.rk_falcon_punch_again":"Falcon Punch Again",
|
||||
"pie.rk_starshipping_and_handling":"Starshipping & Handling",
|
||||
"pie.running_costs":"Running costs",
|
||||
"pie.safe_note":"Safe mode parks every pie: they carry nothing, but nothing breaks either.",
|
||||
"pie.safe_off":"Safe mode: off",
|
||||
"pie.safe_on":"Safe mode: on",
|
||||
"pie.sandbox_note":"Sandbox: nothing here costs real money. You would have spent {amt} so far.",
|
||||
"pie.spent":"Spent so far",
|
||||
"pie.stock_line":"{n} pies ready at the factory.",
|
||||
"pie.t_baked":"{crust} is baked: enough pies to carry traffic.",
|
||||
"pie.t_booster":"The booster did not come back. A new one costs money.",
|
||||
"pie.t_dish":"Pie dish built in {city}.",
|
||||
"pie.t_factory":"The pie factory is open: {n} pies a month.",
|
||||
"pie.t_fail":"Launch lost with {n} pies on board.",
|
||||
"pie.t_found":"{co} is founded. The Founder is already posting.",
|
||||
"pie.t_insured":"The insurance pays back {amt}.",
|
||||
"pie.t_launch":"{n} pies reached {crust}. It is {p} covered.",
|
||||
"pie.t_lic":"Landing rights in {n} for a year.",
|
||||
"pie.t_pad":"Launch pad built in {city}: {p} off every launch for being near the equator.",
|
||||
"pie.t_queued":"{n} pies for {crust} launch from {city} on {d}.",
|
||||
"pie.t_queued_test":"A test flight launches from {city} on {d}.",
|
||||
"pie.t_rd":"Research done: {rd}.",
|
||||
"pie.t_test":"Test flight {n} exploded, as test flights do. {left} to go.",
|
||||
"pie.tab_company":"Company",
|
||||
"pie.tab_dishes":"Dishes",
|
||||
"pie.tab_founder":"Founder",
|
||||
"pie.tab_launch":"Launch",
|
||||
"pie.test_flight":"test flight",
|
||||
"pie.unlocked_body":"You are a Tier 1. Now you can found a rocket company and bake your own internet in orbit. Find it in the NOC tab.",
|
||||
"pie.unlocked_title":"Pie in the Sky is unlocked",
|
||||
"pie.why_dish_city":"A pie dish needs a POP in its city.",
|
||||
"pie.why_full":"That crust is full.",
|
||||
"pie.why_lic_refused":"That country refuses landing rights for now.",
|
||||
"pie.why_no_company":"Found the company first.",
|
||||
"pie.why_no_factory":"Build the pie factory first.",
|
||||
"pie.why_no_pad":"Build a launch pad first.",
|
||||
"pie.why_no_rd":"Needs research: {rd}.",
|
||||
"pie.why_not_t1":"Only a Tier 1 builds new things up there. Everything you have keeps working.",
|
||||
"pie.why_pad_city":"A launch pad needs a POP in a city on the coast.",
|
||||
"pie.why_pad_lat":"None of your pads can reach that orbit: it needs a pad within {inc}° of the equator.",
|
||||
"pie.why_pick":"Pick a rocket and a crust.",
|
||||
"pie.why_queue_full":"The launch schedule is full.",
|
||||
"pie.why_stock":"Needs {n} pies; the factory has {have}.",
|
||||
"pie.would_have":"Would have cost",
|
||||
"pitcairn.uk_grant_mo":"UK grant {mo}/mo",
|
||||
"pitcairn.uk_grant_mo_once_islanders":"UK grant {mo}/mo once the islanders are online",
|
||||
"pni_all.additional_per_month":"Additional monthly cost",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue