Pie in the Sky: dips in orbit hurt instead of emptying the sky

A crust carries a share of its traffic from 40% coverage, growing to all
of it at 60% (pieCarry/pieCap), instead of nothing until 60%. Pies wear out
over the last 30% of their life (pieAlive), deterministic, so a launch month
no longer deorbits on one day. Storms take 2-10% and food fights 5-10% of a
crust (PIE_HIT), down from up to 40% and 20%. Orbit customers lose at most
PIE_PATIENCE happiness a day without service, about a month to cancel.
This commit is contained in:
Frederic Jung 2026-11-04 09:40:50 +01:00
parent 48d2cedbee
commit d7d5d21372
No known key found for this signature in database
21 changed files with 135 additions and 51 deletions

View file

@ -8,7 +8,7 @@ const PIE_CO=250e6,PIE_CO_MO=5e6,PIE_FAC=1e9,PIE_FAC_MO=8e6,PIE_FAC_MONTH=120,PI
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;
PIE_QUIET=90,PIE_PREP=7,PIE_Q_MAX=40,PIE_COHORTS=240,PIE_POSTS=20,PIE_RAW=0.4,PIE_BAKED=0.6,PIE_SPARE=1.1,PIE_WEAR=0.3;
// 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},
@ -70,8 +70,15 @@ 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;}
// Pies wear out over the last PIE_WEAR of their life, a few every day, so a launch month never falls out of the sky at once:
// a cohort counts in full until then, then less every day, and nothing at its life's end (no dice, nothing saved).
function pieAlive(k,life){const left=life-(S.day-k.day),w=life*PIE_WEAR;return left>=w?k.n:left>0?k.n*left/w:0;}
function pieLive(id){const c=S&&S.pie&&S.pie.crusts[id];if(!c)return 0;let n=0;const life=CRUSTS[id].life;for(const k of c.cohorts)n+=pieAlive(k,life);return Math.round(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.
// A crust is baked from 60%. Under that it is half-baked: from 40% (PIE_RAW) it carries a share of its traffic that grows
// to all of it at 60% (pieCarry), under 40% nothing; too many gaps.
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);}
function pieCarry(id){return clamp((pieCov(id)-PIE_RAW)/(PIE_BAKED-PIE_RAW),0,1);}
function pieUp(id){const P=S&&S.pie;return !!P&&!P.safe&&pieCarry(id)>0&&!(P.crusts[id].down>S.day);}
// Gbps a crust carries today: its capacity at its coverage, times the share a half-baked one manages.
const pieCap=id=>CRUSTS[id].g*pieCov(id)*pieCarry(id);

View file

@ -5,9 +5,9 @@
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)
- pieHubs() -> ['short',…]: crusts that carry traffic (over 40%, all of it from 60%: pieCarry) 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)
- pieCov(id), pieBaked(id), pieCarry(id), pieCap(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),end?(o)}: a spat's state, repaired by pieSanitize(), ticked and
dropped when o.until<=d by pieSpatDay(d)
@ -31,7 +31,7 @@ const pieCoName=()=>{const n=S.pie&&S.pie.co&&S.pie.co.name;return !n?tr(PIE_NAM
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(pieLasCut(id))return 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 pieLiveLas=id=>{const c=S.pie&&S.pie.crusts[id];let n=0;if(pieLasCut(id))return 0;if(c)for(const k of c.cohorts)if(k.las)n+=pieAlive(k,CRUSTS[id].life);return Math.round(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*pieDishMul(x)});}return o;}
function pieHubs(){return S&&S.pie?Object.keys(CRUSTS).filter(pieUp):[];}
@ -98,7 +98,7 @@ 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();}}
if(!c.bk&&pieBaked(id)){c.bk=1;pieFounder(N_('pie.fp_baked'),{c:id});toast(tr('pie.t_baked_all',{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;}}

View file

@ -6,8 +6,11 @@
on offer, so orbit income cannot outgrow the sky (like F5). Remote towns (no POP of yours, few people) are the first
to call: Pitcairn, the Arctic, the outer islands. */
const PIE_SELL=0.25,PIE_REMOTE=0.6,PIE_OFFER_RATE=1/6,PIE_OFFERS=2;
// Gbps the sky can sell: each baked crust's capacity at its coverage.
function pieMarket(){if(!S.pie)return 0;let g=0;for(const id of pieHubs())g+=CRUSTS[id].g*pieCov(id)*PIE_SELL;return g;}
// Orbit customers know the sky has bad weeks: without service they lose at most PIE_PATIENCE happiness a day (the day tick),
// so they grumble, then fume, and cancel only after about a month of nothing, not in three days like a fiber customer.
const PIE_PATIENCE=4;
// Gbps the sky can sell: what each crust carries (pieCap(): a half-baked one, a share of it).
function pieMarket(){if(!S.pie)return 0;let g=0;for(const id of pieHubs())g+=pieCap(id)*PIE_SELL;return g;}
// Gbps signed and on offer, of one kind (t) or of all.
const pieSold=t=>{let g=0;for(const b of S.biz)if(BIZ_T[b.type].orbit&&(!t||b.type===t))g+=b.bw;for(const o of S.offers)if(BIZ_T[o.type].orbit&&(!t||o.type===t))g+=o.bw;return g;};
const pieRoom=t=>{const m=pieMarket(),sh=BIZ_T[t].share;return Math.min(m-pieSold(),sh?m*sh-pieSold(t):Infinity);};

View file

@ -3,12 +3,13 @@
routing graph, after the IGP shortest paths are known:
- a sky node per connected pie dish (a virtual city index past NC), joined to its POP by an uplink edge: the dish's
antennas (x rain, jamming… from pieDishes()) less what its terminals and backhaul use; latency one hop up, alt/c + 1 ms;
- with lasers (a crust >= 60% lasered), a space edge between every two sky nodes at least PIE_MIN_KM apart, priced
along the great circle at the shell's height at c in vacuum, capacity the crust's (g x coverage) left after terminals.
- with lasers (a crust over 40% lasered), a space edge between every two sky nodes at least PIE_MIN_KM apart, priced
along the great circle at the shell's height at c in vacuum, capacity the crust's (pieCap(): g x coverage, x the share a half-baked one carries) left after terminals.
Orbit edges have IGP weight Infinity: bulk IP traffic and scenic circuits never see them, only latency-routed
circuits (lat:true customers, route 'fast') do, and only where the sky is faster. Space edges under 3,000 km do not
exist, so orbit never beats fiber there (O4). A dish whose POP is not on the backbone's island is flagged (R.pie.isl)
and gets no sky node: it carries no transit (O3). A half-baked crust (< 60%) is not a hub and carries nothing (O2).
and gets no sky node: it carries no transit (O3). A crust carries nothing under 40% and is not a hub; from
there it carries a share that grows to all of its capacity at 60% (pieCarry(), O2).
Backhaul (O3): a cut-off dish lifts its own POP's traffic, all of it, to a landing dish on the backbone: one virtual
edge, POP to landing POP ('pie:bh:'+city, e.bh), through a crust covering both (bent pipe within PIE_BENT km, lasers
past that). Its capacity is booked after terminals and before sky circuits: min(the dish's room, the landing dish's room,
@ -25,7 +26,7 @@ const PIE_C=300,PIE_RE=6371,PIE_MIN_KM=3000,PIE_BENT=1000,PIE_HOP=1,PIE_FOOT=3,P
const pieKm=(a,b)=>{const A=CITY[a],B=CITY[b];return hav(A.lon,A.lat,B.lon,B.lat);};
// Does crust id cover city c? A shell reaches a few degrees past its inclination; a polar one reaches everywhere.
const pieCovers=(id,c)=>!!CRUSTS[id].polar||Math.abs(CITY[c].lat)<=CRUSTS[id].inc+PIE_FOOT;
const pieLased=id=>pieLiveLas(id)>=CRUSTS[id].full*PIE_BAKED;
const pieLased=id=>pieLiveLas(id)>CRUSTS[id].full*PIE_RAW;
// One way through space between two dishes km apart, at shell height alt: up, along the great circle, down.
const pieSkyMs=(km,alt)=>2*(alt/PIE_C+PIE_HOP)+km*(PIE_RE+alt)/PIE_RE/PIE_C;
// May a customer in country ca land on a dish in country dc? (spats)
@ -40,7 +41,7 @@ function pieLand(c,t,ds,hubs){const T=BIZ_T[t],cc=CITY[c].cc;let best=null,bk=In
return best;}
function pieGraph(adj,edges,COMP,pops,NE){const NC=CITIES.length,hubs=pieHubs(),ds=pieDishes();
const X={hubs,ds,term:{},gs:{},gsBw:{},cr:{},isl:[],l2o:{},l2p:{},up:[],ne:NE,adj,nc:NC,sk:[],bh:[],bhNo:[],res:{},main:-1};
for(const id of hubs)X.cr[id]=CRUSTS[id].g*pieCov(id);
for(const id of hubs)X.cr[id]=pieCap(id);
// The backbone: the island with the most POPs (ties: the home city's).
const cnt=new Map();for(const p of pops){const k=COMP[CIDX[p]];if(k>=0)cnt.set(k,(cnt.get(k)||0)+1);}
let main=-1,mn=0;const hk=S.home&&S.pops[S.home]?COMP[CIDX[S.home]]:-1;for(const [k,n] of cnt)if(n>mn||(n===mn&&k===hk)){main=k;mn=n;}X.main=main;
@ -123,8 +124,8 @@ function pieLoads(X,flows,used,term,bhG){const P=S.pie,cu={},crust=[],dish=[],lo
// Backhaul booked its capacity from X.cr; count what it carried instead.
const bx={};for(const e of X.bh){const id=e.bh.cr;bx[id]=(bx[id]||0)+Math.min(e.cap,e.ld||0)-e.cap;}
for(const f of flows)if(f.k==='c'&&f.g>0){let r=f.g;const e=X.l2p[f.id].w.path.find(x=>x.sky==='las');for(const id of e?e.cs:[]){const t=Math.min(r,Math.max(0,X.cr[id]-(cu[id]||0)));cu[id]=(cu[id]||0)+t;r-=t;}}
for(const id in CRUSTS){if(!(pieLive(id)>0))continue;const cv=pieCov(id),pot=CRUSTS[id].g*cv,hub=X.hubs.includes(id);
crust.push({id,cov:cv,pot,cap:hub?pot:0,used:hub?Math.min(pot,pot-X.cr[id]+(cu[id]||0)+(bx[id]||0)):0,las:hub&&pieLased(id),st:hub?'ok':!pieBaked(id)?'half':P.safe?'safe':'down'});}
for(const id in CRUSTS){if(!(pieLive(id)>0))continue;const cv=pieCov(id),hub=X.hubs.includes(id),pot=hub?pieCap(id):CRUSTS[id].g*cv;
crust.push({id,cov:cv,pot,cap:hub?pot:0,used:hub?Math.min(pot,pot-X.cr[id]+(cu[id]||0)+(bx[id]||0)):0,las:hub&&pieLased(id),st:hub?(pieBaked(id)?'ok':'part'):!(pieCarry(id)>0)?'half':P.safe?'safe':'down'});}
const ok=new Map(X.ds.map(d=>[d.city,d])),isl=new Set(X.isl),las=X.hubs.filter(pieLased),bh=new Set(X.bh.map(e=>e.a));
for(const x of P.dishes){const c=x.city,d=ok.get(c),tm=d?term[c]:0,u0=d?used[c]:0,cap=d?d.g:0,cc=CITY[c].cc,l=P.lic[cc];let st;
if(!S.pops[c])st='nopop';else if(x.down>S.day)st='down';else if(!d)st=l&&l.until>S.day&&l.state==='sus'?'spat':l&&l.until>S.day&&l.state==='refused'?'ref':'lic';

View file

@ -5,7 +5,9 @@
What an incident does is read back from S.inc, so nothing else has to be undone. A booster that tips over on the drone
ship is in pieFly(); the astronomers ask a question, so they live with the spats (65-pie-spats.js). */
const PIE_INC=['piedig','piefood','pielaser','pierain','piestorm'],PIE_TROPIC=23.5,PIE_ROOMBA=120e6,PIE_FOOD_MUL=0.25,PIE_INC_RATE=1/40,
PIE_DIG_FIX=300000,PIE_RAIN=0.3,PIE_ASTRO_N=200;
PIE_DIG_FIX=300000,PIE_RAIN=0.3,PIE_ASTRO_N=200,PIE_HIT=0.1;
// PIE_HIT: the most of a crust one incident may take (a storm 2 to 10% over its week, a food fight 5 to 10%), so a bad
// week hurts but never empties the sky.
FOUNDER_POSTS.push(N_('pie.fp_3am'),N_('pie.fp_astro'),N_('pie.fp_debris'),N_('pie.fp_spat'),N_('pie.fp_storm'));
// Chaos on, a company to annoy, and the 90 quiet days are over.
function pieChaos(){const P=S&&S.pie;return !!P&&!!P.co&&chaosMul()>0&&S.day-P.born>=PIE_QUIET;}
@ -21,11 +23,11 @@ function pieIncClear(i){if(i.type!=='piedig'||!S.pie)return;const x=S.pie.dishes
// sanitize(): orbit incidents point at a crust or a city, and go when the company does.
function pieIncFix(s){const ok=!!s.pie;s.inc=s.inc.filter(i=>{if(!PIE_INC.includes(i.type))return true;if(!ok)return false;
if(['piefood','pielaser','piestorm'].includes(i.type)?!own(CRUSTS,i.ref):!isCity(i.ref))return false;
i.start=int(i.start,0,s.day,s.day);i.until=int(i.until,0,s.day+400,s.day);if(i.type==='piestorm')i.f=clamp(num(i.f,0),0,0.4);return true;});}
i.start=int(i.start,0,s.day,s.day);i.until=int(i.until,0,s.day+400,s.day);if(i.type==='piestorm')i.f=clamp(num(i.f,0),0,PIE_HIT);return true;});}
// One day of a storm (its first is the day it starts; the day tick resolves it on its last).
function pieStormBite(i){if(!own(CRUSTS,i.ref))return;const n=Math.max(1,i.until-i.start),q=(1-Math.pow(1-i.f,1/n))*(S.pie.safe?0.25:1);i.lost=(i.lost|0)+pieLose(i.ref,q);}
// Pies lost from every cohort of a crust alike.
function pieLose(cr,q){const c=S.pie.crusts[cr];let lost=0;for(const k of c.cohorts){const x=Math.min(k.n,Math.round(k.n*q));k.n-=x;lost+=x;}c.cohorts=c.cohorts.filter(k=>k.n>=1);return lost;}
// Pies lost from every cohort of a crust alike (counted as they fly: a worn cohort loses its worn share).
function pieLose(cr,q){const c=S.pie.crusts[cr],life=CRUSTS[cr].life;let lost=0;for(const k of c.cohorts){const x=Math.min(k.n,Math.round(k.n*q));lost+=x?pieAlive(k,life)*x/k.n:0;k.n-=x;}c.cohorts=c.cohorts.filter(k=>k.n>=1);return Math.round(lost);}
function pieIncToast(i,press,acts=[]){toast(`<b>🛰️ ${pieIncTitle(i.type)}</b><br>${esc(i.msg)}<br><i>${esc(press)}</i>`,'bad',(i.cost?[{l:`${i.fix||tr('common.rush_repair')} ${fmt$(i.cost)}`,act:'fixInc',args:{id:i.id}}]:[]).concat(acts),incOpen(i));sfx('alert');}
const pieAdd=o=>{addInc(o);return S.inc[S.inc.length-1];};
function pieIncDay(d){
@ -48,10 +50,10 @@ function pieIncOpts(){const P=S.pie,o=[],live=id=>pieLive(id),dish=x=>!!S.pops[x
function pieIncFire(k){const P=S.pie;if(!P||!P.co)return false;const d=S.day;
if(!k){const o=pieIncOpts();let r=Math.random()*o.reduce((a,x)=>a+x[1],0);k=o[o.length-1][0];for(const x of o){r-=x[1];if(r<=0){k=x[0];break;}}}
const crs=f=>Object.keys(CRUSTS).filter(f);
if(k==='storm'){const c=crs(id=>pieLive(id)>0&&!pieIncOf('piestorm',id));if(!c.length)return false;const cr=pick(c),f=+(0.05+Math.random()*0.35).toFixed(3);
if(k==='storm'){const c=crs(id=>pieLive(id)>0&&!pieIncOf('piestorm',id));if(!c.length)return false;const cr=pick(c),f=+(PIE_HIT/5+Math.random()*PIE_HIT*4/5).toFixed(3);
const i=pieAdd({type:'piestorm',ref:cr,until:d+7,f,lost:0,cost:0,msg:tr('pie_inc.storm_msg',{crust:tr(CRUSTS[cr].n),p:pct(f)})});pieFounder(N_('pie.fp_storm'),{c:cr});pieStormBite(i);
pieIncToast(i,tr('pie_inc.storm_press'),P.safe?[]:[{l:tr('pie_inc.safe_now'),act:'pieSafe',args:{}}]);return true;}
if(k==='food'){const c=crs(id=>pieLive(id)>=100&&!pieIncOf('piefood',id));if(!c.length)return false;const cr=pick(c),n=pieLose(cr,0.1+Math.random()*0.1);
if(k==='food'){const c=crs(id=>pieLive(id)>=100&&!pieIncOf('piefood',id));if(!c.length)return false;const cr=pick(c),n=pieLose(cr,PIE_HIT/2+Math.random()*PIE_HIT/2);
const i=pieAdd({type:'piefood',ref:cr,until:d+360,cost:piePrice(PIE_ROOMBA),fix:tr('pie_inc.food_fix'),msg:tr('pie_inc.food_msg',{crust:tr(CRUSTS[cr].n),n,p:pct(PIE_FOOD_MUL)})});
pieFounder(N_('pie.fp_debris'),{c:cr});pieIncToast(i,tr('pie_inc.food_press'));compute();return true;}
if(k==='rain'){const c=P.dishes.filter(x=>S.pops[x.city]&&Math.abs(CITY[x.city].lat)<=PIE_TROPIC&&!pieIncOf('pierain',x.city));if(!c.length)return false;const x=pick(c);

View file

@ -51,7 +51,7 @@ function dayPost(d){
const ids=linkIds(),frr=(coreFrr()&&S.links.some(l=>l.cut)?.5:1)*(rule('moods')==='patient'?.5:1);const bhT=new Set(ddosAll().filter(a=>a.bh).map(a=>a.tgt));for(const b of S.biz.slice()){if(eventTick(b,d)||capPendTick(b,d))continue;b.pm=b.mood;if(bhT.has(b.id))continue;const sf=bizSf(b,ids),reachOk=BIZ_T[b.type].l2||BIZ_T[b.type].fiber||R.reach>0.99||scnRule('local'),scrubOk=b.type!=='scrub'||(hasScrub()&&!scrubFar(b.city)),divOk=reqOk(b);
if(sf>=0.95&&reachOk&&scrubOk&&divOk)b.mood=Math.min(100,b.mood+2);
else if(S.day-(b.since||0)<15){}
else{b.mood-=frr*(Math.max(0,0.95-sf)*45+(!reachOk?3:0)+(!scrubOk?4:0)+(!divOk?3:0));
else{const dm=frr*(Math.max(0,0.95-sf)*45+(!reachOk?3:0)+(!scrubOk?4:0)+(!divOk?3:0));b.mood-=BIZ_T[b.type].orbit?Math.min(dm,PIE_PATIENCE):dm;
if(b.mood<=0){S.biz=S.biz.filter(x=>x!==b);toast(tr('day_tick.name_cancelled_too_many_outages_and',{name:esc(b.name),city:CITY[b.city].name}),'bad');sfx('err');}
else if(b.mood<30&&!b.warned){b.warned=b.warn60=true;const why=bizWhy(b)[0],paused=pref('pauseFurious')&&autoPause();
toast(tr('day_tick.name_is_furious_fix_service_in',{name:esc(b.name),city:CITY[b.city].name})+(why?`<br><i>${esc(why)}</i>`:'')+(paused?`<br><b>${tr('common.game_paused')}</b>`:''),'bad',[{l:tr('common.show_me'),act:'custGo',args:{id:b.id}}].concat(paused?[resumeAct()]:[]));sfx('err');}

View file

@ -11,14 +11,14 @@ const pieBar=(u,cls)=>`<div class="bar ${cls}"><i style="width:${Math.round(clam
function pieDishWhy(d){const cc=CITY[d.city].cc,l=S.pie.lic[cc];return {nopop:tr('pie_traffic.d_nopop'),down:tr('pie_traffic.d_down'),lic:tr('pie_traffic.d_lic',{country:esc(pieLicCountry(cc))}),
ref:tr('pie_traffic.d_ref'),backhaul:tr('pie_traffic.d_backhaul'),spat:tr('pie_traffic.d_spat',{d:l?dateStr(l.until):''}),nocrust:tr('pie_traffic.d_nocrust'),isl:tr('pie_traffic.d_isl'),rain:tr('pie_traffic.d_rain'),
jam:tr('pie_traffic.d_jam'),nolas:tr('pie_traffic.d_nolas'),idle:tr('pie_traffic.d_idle')}[d.st]||'';}
function pieCrustWhy(c){return c.st==='half'?tr('pie_traffic.crust_half',{crust:tr(CRUSTS[c.id].n),p:pct(c.cov),min:pct(PIE_BAKED)}):c.st==='safe'?tr('pie_traffic.crust_safe'):c.st==='down'?tr('pie_traffic.crust_down'):'';}
function pieCrustWhy(c){return c.st==='half'?tr('pie_traffic.crust_half',{crust:tr(CRUSTS[c.id].n),p:pct(c.cov),min:pct(PIE_RAW)}):c.st==='part'?tr('pie_traffic.crust_part',{crust:tr(CRUSTS[c.id].n),p:pct(c.cov),c:pct(pieCarry(c.id)),min:pct(PIE_BAKED)}):c.st==='safe'?tr('pie_traffic.crust_safe'):c.st==='down'?tr('pie_traffic.crust_down'):'';}
// Why a cut-off POP gets no backhaul (R.pie.bh[].why from pieBhLand).
function pieBhWhy(w){return {nocrust:tr('pie_traffic.bh_nocrust'),noland:tr('pie_traffic.bh_noland'),nolas:tr('pie_traffic.bh_nolas',{km:PIE_BENT.toLocaleString()}),spat:tr('pie_traffic.bh_spat'),full:tr('pie_traffic.bh_full_none')}[w]||tr('pie_traffic.bh_noland');}
// The empty sky: every condition traffic needs, ticked or not, with a hint for the first thing to fix.
function pieChecks(Q){const P=S.pie,cr=Q.crust,best=cr.slice().sort((a,b)=>b.cov-a.cov)[0],ds=Q.dish,isl=ds.find(d=>d.st==='isl'),bh=Q.bh||[],no=bh.find(b=>!(b.cap>0));
const sold=S.biz.some(b=>BIZ_T[b.type].orbit||(BIZ_T[b.type].lat&&b.route==='fast'&&b.city2&&pieKm(b.city,b.city2)>=PIE_MIN_KM));
return [
{k:'baked',ok:Q.hubs.length>0,l:tr('pie_traffic.ck_baked',{min:pct(PIE_BAKED)}),h:!best?tr('pie_traffic.ck_baked_none'):pieCrustWhy(best)||tr('pie_traffic.ck_baked_none')},
{k:'baked',ok:Q.hubs.length>0,l:tr('pie_traffic.ck_baked',{min:pct(PIE_RAW)}),h:!best?tr('pie_traffic.ck_baked_none'):pieCrustWhy(best)||tr('pie_traffic.ck_baked_none')},
{k:'dish',ok:ds.some(d=>d.cap>0),l:tr('pie_traffic.ck_dish'),h:P.dishes.length?tr('pie_traffic.ck_dish_lic'):tr('pie_traffic.ck_dish_none')},
{k:'backbone',ok:ds.some(d=>d.cap>0&&!Q.isl.includes(d.city)),l:tr('pie_traffic.ck_backbone'),h:Q.isl.length?tr('pie_traffic.ck_backbone_bh',{city:pieCn(isl?isl.city:Q.isl[0])}):tr('pie_traffic.ck_backbone_none')},
...(Q.isl.length?[{k:'backhaul',ok:bh.some(b=>b.cap>0)&&!no,l:tr('pie_traffic.ck_backhaul'),h:no?tr('pie_traffic.ck_backhaul_h',{city:pieCn(no.city),why:pieBhWhy(no.why)}):''}]:[]),
@ -43,8 +43,8 @@ function pieTrafficHtml(){const Q=R&&R.pie;if(!Q||!Q.flows)return `<p class="met
let h=`<p class="pft-head">${trn('pie_traffic.headline',n,{g:fmtG(g),of:fmtG(pieMarket()),amt:fmt$(Q.rev)})}</p>`;
if(!(g>0)&&!(bg>0))h+=`<div class="ops-o pft-why"><div class="nm">${tr('pie_traffic.empty_title')}</div><ul class="pft-ck">${pieChecks(Q).map(c=>`<li class="${c.ok?'on':'off'}" data-k="${c.k}"><span aria-hidden="true">${c.ok?'✅':'⬜'}</span><span><b>${c.l}</b>${c.ok?'':`<small>${c.h}</small>`}</span></li>`).join('')}</ul></div>`;
h+=`<h3 class="pft-h">${tr('pie_traffic.crusts')}</h3>`+(Q.crust.length?Q.crust.map(c=>{const why=pieCrustWhy(c);
return `<div class="pft-cr"><div class="kv"><span>${tr(CRUSTS[c.id].n)} ${pieTag(c.st==='half'?tr('pie.half_baked'):tr('pie.baked'),c.st!=='half')}</span><b>${c.cap>0?tr('pie_traffic.used_of',{u:fmtG(c.used),cap:fmtG(c.cap)}):pct(c.cov)}</b></div>
${c.cap>0?pieBar(c.used/c.cap,pieLoadCls(c.used/c.cap)):pieBar(c.cov/PIE_BAKED,'warn')}${why?`<p class="meta">${why}</p>`:''}</div>`;}).join(''):`<p class="meta">${tr('pie_traffic.ck_baked_none')}</p>`);
return `<div class="pft-cr"><div class="kv"><span>${tr(CRUSTS[c.id].n)} ${pieTag(c.st==='half'||c.st==='part'?tr('pie.half_baked'):tr('pie.baked'),c.st!=='half'&&c.st!=='part')}</span><b>${c.cap>0?tr('pie_traffic.used_of',{u:fmtG(c.used),cap:fmtG(c.cap)}):pct(c.cov)}</b></div>
${c.cap>0?pieBar(c.used/c.cap,pieLoadCls(c.used/c.cap)):pieBar(c.cov/PIE_RAW,'warn')}${why?`<p class="meta">${why}</p>`:''}</div>`;}).join(''):`<p class="meta">${tr('pie_traffic.ck_baked_none')}</p>`);
if(bh.length)h+=`<h3 class="pft-h">${tr('pie_traffic.backhaul')}</h3><p class="meta">${tr('pie_traffic.bh_hint')}</p>`+bh.slice().sort((a,b)=>b.g-a.g).map(pieBhRow).join('');
if(fl.length){h+=`<h3 class="pft-h">${tr('pie_traffic.riding')}</h3><p class="meta">${tr('pie_traffic.tap_hint')}</p><div class="pft-list">${fl.slice(0,PIE_ROWS).map(f=>pieFlowRow(f,B)).join('')}</div>`;
if(fl.length>PIE_ROWS)h+=`<p class="meta">${trn('pie_traffic.n_more',fl.length-PIE_ROWS)}</p>`;}

View file

@ -3471,7 +3471,7 @@
"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_baked_all":"{crust} is baked: enough pies to carry all its 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.",
@ -3626,6 +3626,7 @@
"pie_traffic.ck_lasers_h":"Without lasers, traffic only reaches a dish within 1,000 km and nothing crosses space. Launch pies with lasers.",
"pie_traffic.crust_down":"Out of service for now (a solar storm).",
"pie_traffic.crust_half":"{crust} is {p} baked; it carries traffic from {min}.",
"pie_traffic.crust_part":"{crust} is {p} baked: half-baked, it carries {c} of its traffic, all of it from {min}.",
"pie_traffic.crust_safe":"Safe mode is on: it carries nothing until you turn it off.",
"pie_traffic.crusts":"Crusts",
"pie_traffic.d_backhaul":"backhauls its own town through orbit",