Intern: write the shift log as a reload keeps it, and drop opsTidy()

The day's log named every order that ran out of budget, and the week's tally
got an empty list for a job with no place (a rushed repair, a route server);
a reload keeps three places a kind and no empty lists, so opsTidy() trimmed
live state after every shift. The shift now writes it that way itself: the
broken orders are cut to three ([...X.broke].slice(0,3)), and W.wh[k] is made
only for a job that names a place. tests/canonical-state.test.js passes
without opsTidy() (a year of the big network with everything on, checked
every day), so it is gone.
This commit is contained in:
jvanvik 2026-11-09 22:50:48 +01:00
parent 286ae48207
commit 02b6c24d7b
3 changed files with 25 additions and 7 deletions

View file

@ -114,7 +114,7 @@ function* dayPost(d){
// the sales desk signs and declines deals, when the player lets it (39-sales-auto.js), then the intern's shift sees them
yield* slAutoRun(d);
if(opsHired())yield DAY_REST;
yield* opsRun(d);opsTidy();
yield* opsRun(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');}
@ -130,10 +130,6 @@ function* dayPost(d){
{const c=cal(d);if(c.m===0&&c.d===1&&[2,3,5].includes(c.y))track('game_year_'+c.y,true);}
if(d%10===0)save();
}
// The shift's notes as a reload keeps them (opsSanitize): at most three places a job in the day's log (the broken links
// were all listed), and no empty list in the week's tally. So live state is what a reload makes of it (server-sim 5.4).
function opsTidy(){const O=S.ops;if(!O)return;for(const e of O.log||[])for(const r of e.r||[])if(Array.isArray(r[2])&&r[2].length>3)r[2]=r[2].slice(0,3);
for(const w of [O.wk,O.rep])if(w&&w.wh)for(const k of Object.keys(w.wh))if(Array.isArray(w.wh[k])&&!w.wh[k].length)delete w.wh[k];}
function spawnOffer(){
const mine=spMine(Object.keys(S.pops).filter(bizCity)),lv=lvl();
const types=['dia','dia','game','host'];if(mine.length>=2)types.push('l2vpn','l2vpn');if(S.day>60)types.push('scrub');