Pie in the Sky: a grand opening when a crust starts carrying traffic, so regular customers sign as the patchy ones fade

This commit is contained in:
Frederic Jung 2026-11-05 17:12:50 +01:00
parent 7001174d79
commit 95f3851557
No known key found for this signature in database
4 changed files with 32 additions and 3 deletions

View file

@ -23,7 +23,7 @@ All notable changes to this project are documented here. The project follows
- Pie Control's Launch tab now says how long each crust you are filling takes to fill at your current pace. When that is more than two years, it suggests another launch pad at your coastal POP nearest the equator, with a button to build it.
- Buoys, ships' mail and sensors that can live with gaps in the sky now pay a little before a crust carries anything: from 10% coverage, up to about $30M a month for the Shortcrust at 40%, as long as one pie dish works under it. Between 40% and 60% they make way for regular orbit customers, and the Traffic tab lists them.
- While your crusts are under 30% covered, the Dishes tab reminds you that pie dishes earn nothing until the sky fills up, so it pays to wait.
- The month a crust starts carrying traffic is its grand opening: for 30 days orbit customers call every day and up to four offers wait, so regular customers sign up while the gap-tolerant ones fade out.
- Your own subsea cables now land right on the city's dot, also in Fujairah, Dubai, Karachi, Barcelona, Osaka and other cities the map shifts slightly so they do not overlap (#305).
- Starting a new network no longer leaves the last one's "New POP!" and money pop-ups frozen all over the map until a reload.

View file

@ -131,7 +131,7 @@ function pieSanitize(s){s.pieV=int(s.pieV,0,1,0);pieEximFix(s);const p=s.pie,ob=
.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;}
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;if(c.open!==undefined)o.crusts[id].open=int(c.open,0,day,day);}
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)}));

View file

@ -27,5 +27,9 @@ function pieSpawn(t){const T=BIZ_T[t],min=T.opts[0],ok=pieCands(t).filter(c=>{if
const left=Math.min(pieRoom(t),pieServe(city,t).left-S.offers.reduce((a,o)=>a+(BIZ_T[o.type].orbit?o.bw:0),0)),opts=T.opts.filter(g=>g<=left),bw=opts.length?pick(opts):0;if(!bw)return;
const list=T.names.filter(n=>!S.usedNames.includes(n)),name=list.length?pick(list):pick(T.names);useName(name);
S.offers.push({id:uid(),city,city2:null,name,type:t,bw,rate:T.rate,reqs:[],exp:S.day+40});}
// Grand opening: the first PIE_OPEN_DAYS after a crust starts carrying traffic (crust.open, the day it first did), the phone
// rings every day and up to PIE_OPEN_OFFERS wait, so regular customers sign while the patchy-sky income fades (99-pie-patchy.js).
const PIE_OPEN_DAYS=30,PIE_OPEN_OFFERS=4;
function pieOpening(){const P=S.pie;let on=false;for(const id of pieHubs()){const c=P.crusts[id];if(!c)continue;if(c.open===undefined&&pieCap(id)>0)c.open=S.day;if(c.open!==undefined&&S.day-c.open<PIE_OPEN_DAYS)on=true;}return on;}
// Orbit has its own sales desk, so the ground's offers keep their odds: about one call every three days, two on the table at most.
PIE_ON.day.push(()=>{if(S.offers.filter(o=>BIZ_T[o.type].orbit).length>=PIE_OFFERS)return;const t=pieOfferTypes();if(t.length&&Math.random()<PIE_OFFER_RATE)pieSpawn(pick(t));});
PIE_ON.day.push(()=>{const op=pieOpening();if(S.offers.filter(o=>BIZ_T[o.type].orbit).length>=(op?PIE_OPEN_OFFERS:PIE_OFFERS))return;const t=pieOfferTypes();if(t.length&&(op||Math.random()<PIE_OFFER_RATE))pieSpawn(pick(t));});

View file

@ -167,3 +167,28 @@ test('a hasty player sees a small orbit income in the first year', { timeout: 12
ev('closeModal()');
assert.deepEqual(errors, []);
});
test('a crust that starts carrying traffic gets a grand opening: a call a day for 30 days, then the usual pace', () => {
const { ev, errors } = load({ seed: 5 });
company(ev);
dish(ev, 'sin');
ev('S.pie.dishes[0].ant=16'); // 320 Gbps: room for every size of orbit customer
cover(ev, 0.3);
ev('dayTick()');
assert.equal(ev("S.pie.crusts.short.open"), undefined, 'nothing opens while the crust carries nothing');
cover(ev, 0.7);
const open = (n) => ev(`(()=>{let k=0;for(let i=0;i<${n};i++){S.offers=S.offers.filter(o=>!BIZ_T[o.type].orbit);dayTick();k+=S.offers.filter(o=>BIZ_T[o.type].orbit).length;}return k;})()`);
const d0 = ev('S.day');
const first = open(10);
assert.ok([d0, d0 + 1].includes(ev("S.pie.crusts.short.open")), 'the opening day is kept (the day tick moves the date first)');
assert.ok(first >= 7, 'nearly every day of the opening brings a call (a type that fits nowhere spawns nothing): ' + first);
ev(`S.day=${d0}+40`);
const later = open(30);
assert.ok(later < 20, 'after the opening, about one call in three days: ' + later);
// The opening day survives a save, and garbage is dropped.
ev(`S.pie.crusts.short.open=${d0};S=migrate(JSON.parse(JSON.stringify(S)))`);
assert.equal(ev("S.pie.crusts.short.open"), d0);
ev("S.pie.crusts.short.open='soon';S=migrate(JSON.parse(JSON.stringify(S)))");
assert.equal(typeof ev("S.pie.crusts.short.open"), 'number');
assert.deepEqual(errors, []);
});