Deals belong to Sales: the intern sticks to the network, the sales desk signs deals for you, orbit ones too
The NOC intern loses the sales order. Saves that had it load cleanly: sanitize drops the order, its log lines and its weekly tally, and an intern who was running it hands its switch and minimum to the sales desk (S.slAuto). With someone at the sales desk, the player can let them sign offers once a game day and decline the ones under a minimum (39-sales-auto.js), each in their own style: the engineer and the CEO sign after the #185 routing trial (one a day, a misfit waits a week), the shark signs every offer whose POPs are up, promises and commission included, and the CEO's declines are a handshake away. Orbit offers need room on their landing dish instead of a trial. Nobody at the desk (the default; the CEO is a choice, not a given): every deal is signed by hand. The sales desk runs before the intern's shift, so a deal signed today is in the loads the intern works from. The sheet shows the switch, the minimum and this week's and last week's tally; the NOC gets one notice a week. Orbit offers go through the desk too (99-pie-sales.js): they carry o.by, so commission, renewal haggles and each one's mark at renewal apply. The engineer only offers where the landing dish has 1.5x room on a well-served POP, and those customers renew like the nerds (0.5x leave). The shark rings airlines, cruise lines and the Mars mission first, at the biggest size that fits and 25% more, and half of them get a full-sky promise (REQS.skyfull: a crust at 90%) before there is one; they grumble down to 40 happiness and never cancel over the promise alone. The CEO plays every other golf game with the Founder: the biggest orbit deal that fits, Mars first, at 30% off; jitters cut his orbit prices by 0.4x the jitters and from 0.6 the Founder skips golf. Without a salesperson orbit offers are drawn exactly as before (the O7 balance save has nobody at the desk: payback unchanged, 7.0 years on seed 7, 7.5 on seed 11). Also: the scenario reference plays 'sales' as the CEO signing for you; the route fuzz leaves out the state and buttons of a standing order only main still has; the intern's on/off dials (paid peering, keep a spare) show their translated value in the shipped page instead of the raw label.
This commit is contained in:
parent
2243280aff
commit
9a5522bbb1
28 changed files with 613 additions and 184 deletions
|
|
@ -43,8 +43,9 @@ function salesShape(n0){const p=slP();if(!p)return;for(let i=S.offers.length-1;i
|
|||
// A promise nobody checked: a requirement this deal can have, that the network does not meet today.
|
||||
function salesPromise(o){const T=BIZ_T[o.type],pool=Object.keys(REQS).filter(k=>!(o.reqs||[]).includes(k)&&!REQS[k].only&&(!REQS[k].l2||T.l2)&&(!REQS[k].ip||!T.l2)&&reqCan(k,o)).sort();
|
||||
const no=pool.filter(k=>{try{return !REQS[k].ok(o);}catch(e){return false;}});return no.length?no[Math.floor(slR('promise|'+slKey(o))*no.length)]:null;}
|
||||
// Their mark at renewal: how much likelier the customers they signed are to leave.
|
||||
function salesLeaveMul(b){if(b.by==='eng')return SALES_NERDS.includes(b.type)?0.5:0.75;if(b.by==='shark')return 1.5;if(b.by==='ceo')return 1.25;return 1;}
|
||||
// Their mark at renewal: how much likelier the customers they signed are to leave. The engineer's orbit customers, sold
|
||||
// only where a dish had room to spare, stay like the nerds do.
|
||||
function salesLeaveMul(b){if(b.by==='eng')return SALES_NERDS.includes(b.type)||BIZ_T[b.type].orbit?0.5:0.75;if(b.by==='shark')return 1.5;if(b.by==='ceo')return 1.25;return 1;}
|
||||
// Haggles with whoever is at the desk now: how deep the discount they ask, and how often meeting halfway works.
|
||||
const salesAsk=()=>slP()==='eng'?0.72:0.8;
|
||||
const salesMeet=()=>({shark:0.9,eng:0.5,ceo:0.55})[slP()]||0.65;
|
||||
|
|
@ -61,8 +62,9 @@ function salesDay(d){const L=S.sales;if(!L)return;
|
|||
if(p==='ceo'){if(!(L.golf>=d))L.golf=d+50+Math.floor(slR('golf|'+d)*30);else if(d===L.golf){salesGolf(d);L.golf=d+50+Math.floor(slR('golf|'+d)*30);}
|
||||
if(!(L.say>=d))L.say=d+20+Math.floor(slR('say|'+d)*15);else if(d===L.say){toast(tr('sales.ceo_says',{say:tr(SALES_SAY[Math.floor(slR('sayl|'+d)*SALES_SAY.length)])}),'');L.say=d+20+Math.floor(slR('say|'+d)*15);}}}
|
||||
// The golf course: the biggest internet customer this network can take, in its biggest city, at 30% off, signed on the spot.
|
||||
// With a rocket company, every other game is with the Founder, and in orbit (pieGolf, 99-pie-sales.js).
|
||||
const SALES_GOLF=['metav','cgame','gpu','stream','isp','edu','host','dia'];
|
||||
function salesGolf(d){const mine=Object.keys(S.pops).filter(c=>popUp(c)&&bizCity(c));if(!mine.length)return;
|
||||
function salesGolf(d){if(pieGolf(d))return;const mine=Object.keys(S.pops).filter(c=>popUp(c)&&bizCity(c));if(!mine.length)return;
|
||||
const t=SALES_GOLF.find(x=>(BIZ_T[x].lv||1)<=lvl());if(!t)return;const T=BIZ_T[t],city=mine.sort((a,b)=>CITY[b].P-CITY[a].P||(a<b?-1:1))[0];
|
||||
const list=(T.names||BIZ_N).filter(n=>!S.usedNames.includes(n));const name=list.length?list[Math.floor(slR('golfn|'+d)*list.length)]:(T.names||BIZ_N)[0];useName(name);
|
||||
const o={id:uid(),city,city2:null,name,type:t,bw:T.opts[T.opts.length-1],rate:Math.round((CITY[city].au?T.rate*AU_ARPU:T.rate)*mkt()*0.7),reqs:[],exp:d+40};
|
||||
|
|
@ -74,4 +76,4 @@ function salesOverride(o){if(slP()!=='ceo'||!o||!bHas(o)||BIZ_T[o.type].event||s
|
|||
// Saves: who is at the desk, the VP on the way, the CEO's calendar; who brought each offer and signed each customer.
|
||||
function salesFix(s){const L=s.sales&&typeof s.sales==='object'&&!Array.isArray(s.sales)?s.sales:{},n=v=>Number.isInteger(v)&&v>=0&&v<1e7?v:null;
|
||||
s.sales={p:own(SALES,L.p)?L.p:null,hired:n(L.hired)||0,vp:L.p==='ceo'?n(L.vp):null,golf:n(L.golf),say:n(L.say)};
|
||||
for(const x of [...s.biz,...s.offers])if(x.by!==undefined&&!own(SALES,x.by))delete x.by;}
|
||||
for(const x of [...s.biz,...s.offers])if(x.by!==undefined&&!own(SALES,x.by))delete x.by;slAutoFix(s);}
|
||||
|
|
|
|||
41
src/game/60-features/39-sales-auto.js
Normal file
41
src/game/60-features/39-sales-auto.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/* ---------- The sales desk signs deals for you ----------
|
||||
Deals belong to Sales, not to the NOC intern. With someone at the desk, the player can let them sign offers once a
|
||||
game day (S.slAuto.on) and decline the ones that pay less than a minimum (S.slAuto.min). How they sign is who they are:
|
||||
- the engineer signs only what the network can serve: #185's trial (autoOffer, a full routing pass), at most
|
||||
SL_TRIALS a day, and an offer that did not fit waits SL_RETRY days;
|
||||
- the shark signs every offer whose POPs are up the moment it lands, promises and all: no trial, an unkept promise is
|
||||
the customer's problem. The commission is paid as on any shark deal, so only while the cash covers it;
|
||||
- the CEO signs like the engineer, and a decline is a handshake away (salesOverride: about one in three he signs anyway).
|
||||
Orbit offers need no routing pass: the dish they land on (pieServe) must have room, except for the shark.
|
||||
Nobody at the desk, nothing automatic: every deal is signed by hand. No random numbers are drawn here. */
|
||||
const SL_MINS=[0,2000,5000,10000,25000,50000],SL_TRIALS=1,SL_RETRY=7;
|
||||
const slAutoNew=()=>({on:false,min:0,wk:null,rep:null});
|
||||
// Is the desk signing or declining anything today?
|
||||
const slAutoOn=()=>!!(S&&S.slAuto&&slP()&&(S.slAuto.on||S.slAuto.min));
|
||||
// A week's tally: {w: week, p: who was at the desk, n: signed, rev: what they pay a month, x: declined, y: of those, signed anyway}.
|
||||
function slWkOk(x){if(!x||typeof x!=='object'||Array.isArray(x)||!own(SALES,x.p))return null;const n=v=>int(v,0,1e6,0);return {w:n(x.w),p:x.p,n:n(x.n),rev:int(x.rev,0,1e10,0),x:n(x.x),y:n(x.y)};}
|
||||
const slWkAny=x=>!!x&&(x.n>0||x.x>0);
|
||||
function slAutoFix(s){const a=s.slAuto&&typeof s.slAuto==='object'&&!Array.isArray(s.slAuto)?s.slAuto:{};
|
||||
s.slAuto={on:a.on===true,min:SL_MINS.includes(a.min)?a.min:0,wk:slWkOk(a.wk),rep:slWkOk(a.rep)};}
|
||||
// An old save whose intern ran the sales order: the same switch and minimum, now at the sales desk (they run once someone is there).
|
||||
function slAutoFrom(s,on,p){if(!on||(s.slAuto&&typeof s.slAuto==='object'))return;s.slAuto={on:p.acc!==false,min:SL_MINS.includes(p.min)?p.min:0,wk:null,rep:null};}
|
||||
// "This week Dave signed 3 customers (+$41k/mo), declined 17 tiny offers."
|
||||
function slWeekLine(x,last){const parts=[];if(x.n)parts.push(trn('sales.w_signed',x.n,{rev:opsMo$(x.rev)}));if(x.x)parts.push(trn('sales.w_declined',x.x));if(x.y)parts.push(trn('sales.w_anyway',x.y));
|
||||
const v={name:tr(SALES[x.p].s),list:parts.join(', ')};return last?tr('sales.w_last',v):tr('sales.w_now',v);}
|
||||
// An orbit offer fits where its dish has room for it; used: what this shift already signed on each dish.
|
||||
function slSkyOk(o,used){const L=pieServe(o.city,o.type);if(!L)return null;const k=L.cr+'|'+L.k;return slP()==='shark'||L.left-(used.get(k)||0)>=o.bw?k:null;}
|
||||
function slAutoDay(d){if(!slAutoOn())return;const A=S.slAuto,p=slP(),w=Math.floor(d/7);
|
||||
// A new week: last week's tally becomes the report, and the one notice of the week.
|
||||
if(!A.wk||A.wk.w!==w){if(slWkAny(A.wk)&&A.wk.w<w){A.rep=A.wk;logNote(`<b>${esc(tr('sales.desk'))}</b> ${esc(slWeekLine(A.rep,true))}`,A.rep.rev>0?'good':'',[],{a:'tab',v:'deals'});}A.wk={w,p,n:0,rev:0,x:0,y:0};}
|
||||
const W=A.wk,used=new Map();W.p=p;let tries=0,dirty=false;
|
||||
const tried=UI.slTried&&UI.slTried.s===S?UI.slTried.m:(UI.slTried={s:S,m:new Map()}).m;
|
||||
const won=o=>{if(S.offers.includes(o))return false;W.n++;W.rev+=Math.round(bizMo(o));dirty=true;return true;};
|
||||
opsQuiet(()=>{for(const o of S.offers.slice()){if(!S.offers.includes(o))continue;const T=BIZ_T[o.type];if(!T||!(o.exp>d))continue;const v=T.event?(o.fee||0):bizMo(o);
|
||||
if(A.min&&v<A.min){const b0=S.biz.length;ACT.decline({id:o.id});W.x++;if(S.biz.length>b0){W.y++;W.rev+=Math.round(bizMo(o));dirty=true;}continue;}
|
||||
if(!A.on)continue;
|
||||
if(T.orbit){const k=slSkyOk(o,used);if(!k||(p==='shark'&&S.cash<bizMo(o)))continue;ACT.accept({id:o.id});if(won(o))used.set(k,(used.get(k)||0)+o.bw);continue;}
|
||||
if(!bCities(o).every(popUp))continue;
|
||||
if(p==='shark'){if(S.cash<bizMo(o)||(T.event&&!(o.start>d)))continue;ACT.accept({id:o.id});won(o);continue;}
|
||||
// Each trial is a full routing pass: at most SL_TRIALS a day, and an offer that did not fit waits a week.
|
||||
if(!reqOk(o)||tries>=SL_TRIALS||tried.get(o.id)>d-SL_RETRY)continue;tries++;ACT.accept({id:o.id,auto:true});if(!won(o))tried.set(o.id,d);}});
|
||||
if(dirty)compute();}
|
||||
|
|
@ -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,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:{},
|
||||
ltv:2,t1v:4,auV:1,calV:1,pieV:1,pie:null,ops:opsNew(),slAuto:slAutoNew(),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}};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* The sales engine of #185: would this offer work if signed now? The intern's sales order runs it once a day.
|
||||
/* The sales engine of #185: would this offer work if signed now? The sales desk runs it once a day (39-sales-auto.js).
|
||||
It trials the new demand on a copy of the game, so a failed trial leaves the live game untouched. */
|
||||
function offerCustomer(o){return {id:o.id,city:o.city,city2:o.city2||null,reqs:o.reqs||[],latMax:o.latMax||null,route:BIZ_T[o.type].scenic?'scenic':BIZ_T[o.type].lat?'fast':'normal',name:o.name,type:o.type,bw:o.bw,rate:o.rate,mood:100,since:S.day,sites:o.sites||null,start:o.start,dur:o.dur,fee:o.fee,link:o.link,slots:o.slots||0,what:o.what,prov:o.prov,due:BIZ_T[o.type].cap?S.day+o.win:undefined};}
|
||||
function autoOffer(o){if(!o||!own(BIZ_T,o.type)||!(o.exp>S.day)||!(o.bw>0)||o.rate<0||!bCities(o).length||!bCities(o).every(popUp)||!reqOk(o))return null;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ const INTERNS={
|
|||
kevin:{i:'🌙',n:N_('ops.kevin_from_the_night_shift'),s:N_('ops.kevin'),d:N_('ops.kevin_d')},
|
||||
tracy:{i:'🧭',n:N_('ops.tracy_route'),s:N_('ops.tracy'),d:N_('ops.tracy_d')},
|
||||
};
|
||||
// Deals are not the intern's: the sales desk signs them (39-sales-auto.js).
|
||||
// The orders, in the order the panel shows them. pop: can be switched off per POP. cap: default monthly budget, of setup
|
||||
// fees, or (mo) of the running costs the order adds, for caches, which are free to rack but cost rent every month.
|
||||
const OPS=[
|
||||
|
|
@ -16,19 +17,18 @@ const OPS=[
|
|||
{k:'routers',i:'🧠',pop:1,cap:250000,t:N_('ops.o_routers'),d:N_('ops.o_routers_d'),p:{at:{d:80,v:[60,70,80,90],l:N_('ops.p_at'),f:v=>v+'%'},how:{d:'auto',v:['auto','add','swap'],l:N_('ops.p_how'),f:v=>tr({auto:N_('ops.how_auto'),add:N_('ops.how_add'),swap:N_('ops.how_swap')}[v])}}},
|
||||
{k:'caches',i:'📦',pop:1,cap:5000,mo:1,t:N_('ops.o_caches'),d:N_('ops.o_caches_d'),p:{g:{d:5,v:[1,5,10,25,50],l:N_('ops.p_g'),f:v=>fmtG(v)}}},
|
||||
{k:'ix',i:'🔀',t:N_('ops.o_ix'),d:N_('ops.o_ix_d'),p:{}},
|
||||
{k:'pni',i:'🤝',pop:1,cap:50000,t:N_('ops.o_pni'),d:N_('ops.o_pni_d'),p:{g:{d:25,v:[5,10,25,50,100],l:N_('ops.p_g'),f:v=>fmtG(v)},tier:{d:0,v:[0,1,2],l:N_('ops.p_tier'),f:v=>tr('ops.at_least_port',{port:PORT[v].n})},paid:{d:false,v:[false,true],l:N_('ops.p_paid'),f:v=>tr(v?'common.on':'common.off')}}},
|
||||
{k:'sales',i:'💼',t:N_('ops.o_sales'),d:N_('ops.o_sales_d'),p:{acc:{d:true,v:[true,false],l:N_('ops.p_acc'),f:v=>tr(v?'common.on':'common.off')},min:{d:0,v:[0,2000,5000,10000,25000,50000],l:N_('ops.p_min'),f:v=>v?tr('common.price_mo',{price:fmt$(v)}):tr('ops.never')}}},
|
||||
{k:'pni',i:'🤝',pop:1,cap:50000,t:N_('ops.o_pni'),d:N_('ops.o_pni_d'),p:{g:{d:25,v:[5,10,25,50,100],l:N_('ops.p_g'),f:v=>fmtG(v)},tier:{d:0,v:[0,1,2],l:N_('ops.p_tier'),f:v=>tr('ops.at_least_port',{port:PORT[v].n})},paid:{d:false,v:[false,true],l:N_('ops.p_paid'),f:v=>v?tr('common.on'):tr('common.off')}}},
|
||||
{k:'repair',i:'🔧',cap:50000,t:N_('ops.o_repair'),d:N_('ops.o_repair_d'),p:{}},
|
||||
{k:'optics',i:'🌈',cap:250000,t:N_('ops.o_optics'),d:N_('ops.o_optics_d'),p:{at:{d:70,v:[50,60,70,80,90],l:N_('ops.p_at'),f:v=>v+'%'},pick:{d:'cheap',v:['cheap','big'],l:N_('ops.p_pick'),f:v=>tr({cheap:N_('ops.pick_cheap'),big:N_('ops.pick_big')}[v])}}},
|
||||
{k:'decom',i:'🧹',t:N_('ops.o_decom'),d:N_('ops.o_decom_d'),p:{keep:{d:true,v:[true,false],l:N_('ops.p_keep'),f:v=>tr(v?'common.on':'common.off')}}},
|
||||
{k:'decom',i:'🧹',t:N_('ops.o_decom'),d:N_('ops.o_decom_d'),p:{keep:{d:true,v:[true,false],l:N_('ops.p_keep'),f:v=>v?tr('common.on'):tr('common.off')}}},
|
||||
];
|
||||
const OPSK=Object.fromEntries(OPS.map(o=>[o.k,o])),OPS_POP=OPS.filter(o=>o.pop).map(o=>o.k);
|
||||
const OPS_TPL=['bb','transit','ix','kit'];
|
||||
// What the shift log can say. One line per day: "{name} did this, that and the other."
|
||||
const OPS_SAY={transit:N_('ops.l_transit'),ports:N_('ops.l_ports'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),sales:N_('ops.l_sales'),decline:N_('ops.l_decline'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke'),snag:N_('ops.l_snag')};
|
||||
const OPS_SAY={transit:N_('ops.l_transit'),ports:N_('ops.l_ports'),routers:N_('ops.l_routers'),caches:N_('ops.l_caches'),rs:N_('ops.l_rs'),peer:N_('ops.l_peer'),pni:N_('ops.l_pni'),repair:N_('ops.l_repair'),optics:N_('ops.l_optics'),decom:N_('ops.l_decom'),broke:N_('ops.l_broke'),snag:N_('ops.l_snag')};
|
||||
// Fat fingers: rare, visible, harmless. Only the LAG one costs anything, and only a little.
|
||||
const OPS_FF=[N_('ops.ff_desc'),N_('ops.ff_hostname'),N_('ops.ff_typo'),N_('ops.ff_lag'),N_('ops.ff_ping')];
|
||||
const OPS_TRIALS=1,OPS_FF_RATE={oncall:1/150,bgp:1/60};
|
||||
const OPS_FF_RATE={oncall:1/150,bgp:1/60};
|
||||
function opsNew(){return {intern:null,hired:0,on:Object.fromEntries(OPS.map(o=>[o.k,false])),p:{},cap:{},spent:Object.fromEntries(OPS.filter(o=>o.cap).map(o=>[o.k,0])),addMo:{},mon:0,skip:{},log:[],wk:null,rep:null,floor:50000,tpl:{bb:true,transit:true,ix:true,kit:true}};}
|
||||
const opsO=()=>S.ops||(S.ops=opsNew());
|
||||
const opsHired=()=>!!(S&&S.ops&&S.ops.intern&&own(INTERNS,S.ops.intern));
|
||||
|
|
@ -40,8 +40,9 @@ function opsCap(k){const c=S.ops.cap[k];return opsCaps(k).includes(c)?c:OPSK[k].
|
|||
const opsHere=(k,c)=>!(S.ops.skip[c]||[]).includes(k);
|
||||
const opsPops=k=>Object.keys(S.pops).filter(c=>opsHere(k,c));
|
||||
// Saves are untrusted: rebuild ops from known orders, params, cities and log shapes. Runs after the POPs are repaired,
|
||||
// so exceptions only survive for POPs that still exist. Old saves get no intern,
|
||||
// and the two #185 toggles (auto-accept, auto-pay repairs) become the sales and repair orders.
|
||||
// so exceptions only survive for POPs that still exist. Old saves get no intern, and the #185 auto-repair toggle becomes
|
||||
// the repair order. A sales order the intern was running moves to the sales desk (slAutoFrom); #185's auto-accept never
|
||||
// ran without an intern, so it goes.
|
||||
function opsSanitize(s){const o=s.ops&&typeof s.ops==='object'&&!Array.isArray(s.ops)?s.ops:{},n=opsNew(),ob=x=>x&&typeof x==='object'&&!Array.isArray(x)?x:{};
|
||||
n.intern=typeof o.intern==='string'&&own(INTERNS,o.intern)?o.intern:null;n.hired=int(o.hired,0,1e7,0);n.mon=int(o.mon,0,1e6,0);
|
||||
n.floor=OPS_FLOORS.includes(o.floor)?o.floor:n.floor;
|
||||
|
|
@ -54,28 +55,32 @@ function opsSanitize(s){const o=s.ops&&typeof s.ops==='object'&&!Array.isArray(s
|
|||
{const sk=ob(o.skip);for(const c of Object.keys(sk))if(isCity(c)&&own(s.pops,c)&&Array.isArray(sk[c])){const ks=[...new Set(sk[c].filter(k=>OPS_POP.includes(k)))];if(ks.length)n.skip[c]=ks;}}
|
||||
if(Array.isArray(o.log))n.log=o.log.map(opsLogOk).filter(Boolean).slice(0,OPS_LOG);
|
||||
n.wk=opsWkOk(o.wk);n.rep=opsWkOk(o.rep);
|
||||
if(s.autoSales===true)n.on.sales=true;if(s.autoRepair===true)n.on.repair=true;delete s.autoSales;delete s.autoRepair;
|
||||
slAutoFrom(s,on.sales===true&&!!n.intern,ob(p.sales));if(s.autoRepair===true)n.on.repair=true;delete s.autoSales;delete s.autoRepair;
|
||||
s.ops=n;}
|
||||
// A log entry: {d, i: intern, r: [[kind, n, [where…]]], f: fat-finger index, c: its city, up: paid up front, mo: running costs added}.
|
||||
const opsWhereOk=w=>typeof w==='string'&&w.length<=48&&/^[a-z0-9~|]+( [+\w.×→⇧]+)?$/i.test(w)&&w.split(' ')[0].split('|').every(x=>isIx(x)||own(OPSK,x)||isNet(x));
|
||||
function opsLogOk(e){if(!e||typeof e!=='object'||!own(INTERNS,e.i))return null;const r=Array.isArray(e.r)?e.r.filter(x=>Array.isArray(x)&&own(OPS_SAY,x[0])&&Array.isArray(x[2])).map(x=>[x[0],int(x[1],1,1e6,1),x[2].filter(opsWhereOk).slice(0,3)]).slice(0,16):[];
|
||||
function opsLogOk(e){if(!e||typeof e!=='object'||!own(INTERNS,e.i))return null;const r0=Array.isArray(e.r)?e.r:[],r=r0.filter(x=>Array.isArray(x)&&own(OPS_SAY,x[0])&&Array.isArray(x[2])).map(x=>[x[0],int(x[1],1,1e6,1),x[2].filter(opsWhereOk).slice(0,3)]).slice(0,16);
|
||||
const f=Number.isInteger(e.f)&&OPS_FF[e.f]?e.f:undefined,up=int(e.up,0,1e12,0),mo=int(e.mo,-1e9,1e9,0);
|
||||
// A day that only signed or declined deals (the retired sales order) has nothing left to say.
|
||||
if(r0.length&&!r.length&&f===undefined&&!up&&!mo)return null;
|
||||
return {d:int(e.d,0,1e7,0),i:e.i,r,...(f!==undefined&&isCity(e.c)?{f,c:e.c}:{}),...(up?{up}:{}),...(mo?{mo}:{})};}
|
||||
// A week's tally, for the shift report and the one NOC notice a week: {w: week, i: intern, n: {kind: count}, wh: {kind: [where…]}, up, mo, rev, ff}.
|
||||
// A week's tally, for the shift report and the one NOC notice a week: {w: week, i: intern, n: {kind: count}, wh: {kind: [where…]}, up, mo, ff}.
|
||||
function opsWkOk(x){if(!x||typeof x!=='object'||Array.isArray(x)||!own(INTERNS,x.i))return null;const n={},wh={},xn=x.n&&typeof x.n==='object'?x.n:{},xw=x.wh&&typeof x.wh==='object'?x.wh:{};
|
||||
for(const k of Object.keys(OPS_SAY)){if(own(xn,k)){const v=int(xn[k],0,1e6,0);if(v)n[k]=v;}if(own(xw,k)&&Array.isArray(xw[k])){const w=xw[k].filter(opsWhereOk).slice(0,3);if(w.length)wh[k]=w;}}
|
||||
return {w:int(x.w,0,1e6,0),i:x.i,n,wh,up:int(x.up,0,1e12,0),mo:int(x.mo,-1e9,1e9,0),rev:int(x.rev,0,1e9,0),ff:int(x.ff,0,7,0)};}
|
||||
const opsWkNew=w=>({w,i:S.ops.intern,n:{},wh:{},up:0,mo:0,rev:0,ff:0});
|
||||
// A tally of only the retired sales order says nothing any more.
|
||||
const ff=int(x.ff,0,7,0);if(Object.keys(xn).length&&!Object.keys(n).length&&!ff)return null;
|
||||
return {w:int(x.w,0,1e6,0),i:x.i,n,wh,up:int(x.up,0,1e12,0),mo:int(x.mo,-1e9,1e9,0),ff};}
|
||||
const opsWkNew=w=>({w,i:S.ops.intern,n:{},wh:{},up:0,mo:0,ff:0});
|
||||
const opsWkAny=x=>!!x&&(Object.keys(x.n).length>0||x.ff>0);
|
||||
// "Kevin's week: signed 3 customers (+$41k/mo), topped up transit 2 times (Frankfurt +1×100G), declined 17 tiny offers. Week total: …"
|
||||
function opsWeekLine(x){const I=INTERNS[x.i],name=I?tr(I.s):'',ks=Object.keys(x.n).sort((a,b)=>(a==='sales'?-1:b==='sales'?1:0)||(a==='broke')-(b==='broke'));
|
||||
const parts=ks.map(k=>k==='sales'?trn('ops.w_sales',x.n[k],{rev:opsMo$(x.rev)}):trn(OPS_SAY[k],x.n[k],{where:(x.wh[k]||[]).map(w=>opsWhere(w,k)).join(', ')}));
|
||||
// "Kevin's week: topped up transit 2 times (Frankfurt +1×100G), rushed a repair. Week total: …"
|
||||
function opsWeekLine(x){const I=INTERNS[x.i],name=I?tr(I.s):'',ks=Object.keys(x.n).sort((a,b)=>(a==='broke')-(b==='broke'));
|
||||
const parts=ks.map(k=>trn(OPS_SAY[k],x.n[k],{where:(x.wh[k]||[]).map(w=>opsWhere(w,k)).join(', ')}));
|
||||
if(x.ff)parts.push(trn('ops.w_oops',x.ff));
|
||||
return tr('ops.w_line',{name,list:parts.join(', ')})+(x.up||x.mo?' '+tr('ops.w_money',{cost:fmt$(x.up),mo:opsMo$(x.mo)}):'');}
|
||||
// The intern's mood, from what the week has been like. No dice: the same day always reads the same.
|
||||
function opsMood(){const O=S.ops,x=O.wk&&O.wk.w===Math.floor(S.day/7)?O.wk:null,n=x?x.n:{},jobs=Object.keys(n).filter(k=>k!=='broke'&&k!=='decline').reduce((a,k)=>a+n[k],0);
|
||||
const k=S.day-O.hired<7?'new':x&&x.ff?'oops':n.snag?'snag':S.inc.some(i=>i.until>S.day&&i.type!=='ddos')?'outage':n.sales?'sales':n.broke?'broke':jobs>=5?'busy':S.day%2?'quiet':O.intern;
|
||||
return tr({new:N_('ops.mood_new'),oops:N_('ops.mood_oops'),snag:N_('ops.mood_snag'),outage:N_('ops.mood_outage'),sales:N_('ops.mood_sales'),broke:N_('ops.mood_broke'),busy:N_('ops.mood_busy'),quiet:N_('ops.mood_quiet'),
|
||||
function opsMood(){const O=S.ops,x=O.wk&&O.wk.w===Math.floor(S.day/7)?O.wk:null,n=x?x.n:{},jobs=Object.keys(n).filter(k=>k!=='broke').reduce((a,k)=>a+n[k],0);
|
||||
const k=S.day-O.hired<7?'new':x&&x.ff?'oops':n.snag?'snag':S.inc.some(i=>i.until>S.day&&i.type!=='ddos')?'outage':n.broke?'broke':jobs>=5?'busy':S.day%2?'quiet':O.intern;
|
||||
return tr({new:N_('ops.mood_new'),oops:N_('ops.mood_oops'),snag:N_('ops.mood_snag'),outage:N_('ops.mood_outage'),broke:N_('ops.mood_broke'),busy:N_('ops.mood_busy'),quiet:N_('ops.mood_quiet'),
|
||||
annie:N_('ops.mood_annie'),kevin:N_('ops.mood_kevin'),tracy:N_('ops.mood_tracy')}[k],{name:opsName()});}
|
||||
// "fra +1×100G", "fra|ams", "ams~3", "transit" (an order, for the budget line) or "ggl" (a network).
|
||||
// Peering is always at an exchange, and a city's first exchange has the city's id ("lon" is LYNX): name the exchange (#228).
|
||||
|
|
@ -99,9 +104,9 @@ function opsQuiet(fn){const a=after,t=toast,s=sfx,f=floater,sel=UI.sel,cf=UI.con
|
|||
try{return fn();}finally{after=a;toast=t;sfx=s;floater=f;UI.confirm=cf;UI.tab=tab;UI.sel=sel&&(sel.type!=='link'||S.links.some(l=>l.id===sel.id))&&(sel.type!=='city'||isCity(sel.id))?sel:null;}}
|
||||
// One shift's bookkeeping: what got done, and whether a job had to wait for next month's budget.
|
||||
// dirty: a job changed the network, so R (loads, routing) is out of date until the next compute().
|
||||
// up/mo/rev: what this shift paid up front, added to the monthly bill, and signed in monthly revenue.
|
||||
// up/mo: what this shift paid up front and added to the monthly bill.
|
||||
function opsShift(){const r=new Map(),broke=new Set();
|
||||
return {r,broke,dirty:false,up:0,mo:0,rev:0,did(k,w){if(k!=='decline')this.dirty=true;const x=r.get(k)||{n:0,w:[]};x.n++;if(w&&x.w.length<3&&!x.w.includes(w))x.w.push(w);r.set(k,x);},
|
||||
return {r,broke,dirty:false,up:0,mo:0,did(k,w){this.dirty=true;const x=r.get(k)||{n:0,w:[]};x.n++;if(w&&x.w.length<3&&!x.w.includes(w))x.w.push(w);r.set(k,x);},
|
||||
// A job that costs nothing up front still has to pass the cash floor if it adds to the monthly bill.
|
||||
// quiet: only asking, so a no is not logged as the budget running out.
|
||||
can(k,cost,mo=0,quiet){const O=S.ops,cap=opsCap(k);if(cost<=0&&!(mo>0))return true;
|
||||
|
|
@ -122,12 +127,6 @@ const opsProv=c=>{const pv=opsP('transit','prov'),n=isNet(pv)?NET[pv]:null;retur
|
|||
// The orders. Each takes the shift and does its jobs through the player's own actions.
|
||||
const OPS_RUN={
|
||||
repair(X){purgeInc();for(const i of S.inc.slice())if(i.type!=='ddos'&&i.until>S.day&&i.cost>0&&!(i.slow&&i.rushed)&&X.can('repair',i.cost)&&X.pay('repair',()=>ACT.fixInc({id:i.id})))X.did('repair');},
|
||||
sales(X){const min=opsP('sales','min'),acc=opsP('sales','acc');let tries=0;
|
||||
for(const o of S.offers.slice()){const T=BIZ_T[o.type];if(!T)continue;const v=T.event?(o.fee||0):bizMo(o);
|
||||
if(min&&v<min){S.offers=S.offers.filter(x=>x!==o);X.did('decline');continue;}
|
||||
// Each trial is a full routing pass: at most one a shift, and an offer that did not fit waits a week.
|
||||
if(acc&&o.exp>S.day&&bCities(o).every(popUp)&&reqOk(o)&&tries<OPS_TRIALS&&!(UI.opsTried&&UI.opsTried.s===S&&UI.opsTried.m.get(o.id)>S.day-7)){tries++;ACT.accept({id:o.id,auto:true});
|
||||
if(!S.offers.includes(o)){X.did('sales');X.rev+=bizMo(o);}else{if(!UI.opsTried||UI.opsTried.s!==S)UI.opsTried={s:S,m:new Map()};UI.opsTried.m.set(o.id,S.day);}}}},
|
||||
routers(X){const at=opsP('routers','at')/100,how=opsP('routers','how');
|
||||
for(const c of opsPops('routers')){const p=S.pops[c];if(p.rupDay===S.day)continue;
|
||||
const ld=Math.max((R.nodeLoad[c]||0)/(R.nodeCap[c]||nodeCap(c)||1),portsUsed(c)/Math.max(1,portsMax(c)));if(ld<at)continue;
|
||||
|
|
@ -222,11 +221,11 @@ const OPS_RUN={
|
|||
function opsDecomSafe(l){const bz=S.biz.filter(b=>(b.reqs||[]).some(k=>k==='diverse'||k==='sharks'||k==='lat')&&b.city2);if(!bz.length)return true;
|
||||
const chk=b=>(b.reqs||[]).every(k=>k==='diverse'?diversePaths(b.city,b.city2):k==='sharks'?terrestrialPath(b.city,b.city2):k==='lat'?bestLat(b.city,b.city2)<=b.latMax:true);
|
||||
const was=bz.filter(chk),all=S.links;S.links=all.filter(x=>x!==l);try{return was.every(chk);}finally{S.links=all;}}
|
||||
const OPS_ORDER=['repair','sales','routers','transit','ports','optics','caches','ix','pni','decom'];
|
||||
const OPS_ORDER=['repair','routers','transit','ports','optics','caches','ix','pni','decom'];
|
||||
// The shift: once per game day from dayTick, after outages and events have had their turn.
|
||||
function opsDay(d){if(!opsHired())return;const O=S.ops,m=monthIdx(d);if(m!==O.mon){O.mon=m;for(const k in O.spent)O.spent[k]=0;O.addMo={};}
|
||||
// A new week: last week's tally becomes the shift report, and the one NOC notice of the week.
|
||||
const w=Math.floor(d/7);if(!O.wk||O.wk.w!==w){if(opsWkAny(O.wk)&&O.wk.w<w){O.rep=O.wk;logNote(`<b>${esc(tr('ops.shift_report',{name:opsName()}))}</b> ${esc(opsWeekLine(O.rep))}`,O.rep.rev>0?'good':'',[],{a:'ops'});}O.wk=opsWkNew(w);}
|
||||
const w=Math.floor(d/7);if(!O.wk||O.wk.w!==w){if(opsWkAny(O.wk)&&O.wk.w<w){O.rep=O.wk;logNote(`<b>${esc(tr('ops.shift_report',{name:opsName()}))}</b> ${esc(opsWeekLine(O.rep))}`,'',[],{a:'ops'});}O.wk=opsWkNew(w);}
|
||||
const X=opsShift();
|
||||
// One order that trips over something (an odd save, a bug) is paused and noted; payday, goals and the save still happen.
|
||||
opsQuiet(()=>{for(const k of OPS_ORDER)if(O.on[k])try{OPS_RUN[k](X);}catch(err){O.on[k]=false;X.dirty=true;X.did('snag',k);console.error('[tubes] standing order failed',k,err);}});
|
||||
|
|
@ -236,12 +235,12 @@ function opsDay(d){if(!opsHired())return;const O=S.ops,m=monthIdx(d);if(m!==O.mo
|
|||
if(f===3){const t=O.on.transit&&opsHere('transit',c)&&!scnRule('noTransit')&&S.transit.find(t=>t.city===c&&(t.n||1)<LAG_MAX&&portOk(c,t.tier)&&PORT[t.tier].setup<=Math.min(20000,S.cash*0.05));if(!t||!opsQuiet(()=>X.pay('transit',()=>ACT.lagT({id:t.id,d:1}))))f=0;else X.dirty=true;}
|
||||
e.f=f;e.c=c;toast(esc(opsFFLine(e)),'',[{l:tr('ops.ops'),act:'opsOpen',args:{}}]);}
|
||||
if(X.up)e.up=Math.round(X.up);if(Math.round(X.mo))e.mo=Math.round(X.mo);
|
||||
// Declining an offer or stopping at a budget changes nothing a route depends on: no recompute for those.
|
||||
// Stopping at a budget changes nothing a route depends on: no recompute for that.
|
||||
if(X.dirty)compute();
|
||||
if(e.r.length||e.f!==undefined){O.log.unshift(e);O.log.length=Math.min(O.log.length,OPS_LOG);}
|
||||
// The day's detail stays in the Ops sheet; the NOC gets one notice a week (above).
|
||||
const W=O.wk;for(const [k,n,ws] of e.r){W.n[k]=(W.n[k]||0)+n;const a=W.wh[k]||(W.wh[k]=[]);for(const x of ws)if(a.length<3&&!a.includes(x))a.push(x);}
|
||||
W.up+=e.up||0;W.mo+=e.mo||0;W.rev+=Math.round(X.rev);if(e.f!==undefined)W.ff=Math.min(7,W.ff+1);}
|
||||
W.up+=e.up||0;W.mo+=e.mo||0;if(e.f!==undefined)W.ff=Math.min(7,W.ff+1);}
|
||||
// New POP from the template: price the whole bundle first, then click through it in one go.
|
||||
function opsTplQuote(c){if(!S||S.pops[c]||!cityOn(c)||(cnCity(c)&&!cnOk()))return null;const T=S.ops.tpl,parts=[];let cost=popCost(c),net=null,ix=null,kit=null;
|
||||
if(T.bb){cost+=bbCost(c);parts.push(tr('ops.tpl_bb'));}
|
||||
|
|
|
|||
|
|
@ -22,14 +22,15 @@ function pieOfferTypes(){if(!pieOn()||!R||!R.pie||!R.pie.hubs.length||!pieDishes
|
|||
// Cities a terminal could sit in: cruise ships call at the coast, airlines at big airports, homes anywhere.
|
||||
function pieCands(t){if(t==='boat')return CITIES.filter(c=>c.beach||pieCoast(c.id));if(t==='flywifi')return CITIES.filter(c=>c.P>=250);return CITIES;}
|
||||
// The size fits the market left and the room on the dish it would land on (offers on the table count as taken).
|
||||
function pieSpawn(t){const T=BIZ_T[t],min=T.opts[0],ok=pieCands(t).filter(c=>{if(c.cn)return false;const L=pieServe(c.id,t);return !!L&&L.left>=min;});if(!ok.length)return;
|
||||
// Whoever runs sales has a say (99-pie-sales.js): the room they will sell, the size they ask for, how they dress it up.
|
||||
function pieSpawn(t){const T=BIZ_T[t],min=T.opts[0],ok=pieCands(t).filter(c=>{if(c.cn)return false;const L=pieServe(c.id,t);return !!L&&pieSlRoom(L)>=min;});if(!ok.length)return;
|
||||
const far=ok.filter(c=>!S.pops[c.id]&&c.P<=60),city=(far.length&&Math.random()<PIE_REMOTE?pick(far):pick(ok)).id;
|
||||
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 left=Math.min(pieRoom(t),pieSlRoom(pieServe(city,t))-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?pieSlSize(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});}
|
||||
const o={id:uid(),city,city2:null,name,type:t,bw,rate:T.rate,reqs:[],exp:S.day+40};pieSlShape(o);S.offers.push(o);}
|
||||
// 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(()=>{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*pieOfferMul()))pieSpawn(pick(t));});
|
||||
// Orbit offers come on top of the ground's, so the ground's offers keep their odds: about one call every three days, two on the table at most.
|
||||
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*pieOfferMul()))pieSpawn(pick(pieSlTypes(t)));});
|
||||
|
|
|
|||
36
src/game/60-features/99-pie-sales.js
Normal file
36
src/game/60-features/99-pie-sales.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ---------- Pie in the Sky: the sales desk sells orbit too (38-sales-desk.js, 99-pie-orbit-customers.js) ----------
|
||||
Orbit offers go through whoever runs sales, as ground offers do: they carry o.by (so the shark's commission, the
|
||||
renewal haggles and each one's mark at renewal apply), plus what each of them does with a sky to sell:
|
||||
- the engineer only offers a deal where the dish it lands on has room to spare (PIE_ENG_ROOM times the deal) and its
|
||||
POP is well served (PIE_ENG_SF), and their orbit customers renew like the nerds do (salesLeaveMul);
|
||||
- the shark calls airlines and cruise lines first, asks for the biggest size that fits at a quarter more, and promises
|
||||
half of them a full sky (REQS.skyfull) before the crust is there: those customers grumble until it is, but never
|
||||
cancel over the promise alone (they stop at PIE_GRUMBLE happiness);
|
||||
- the CEO plays some of his golf with the Founder (one game in two while a rocket company exists): the biggest orbit
|
||||
deal that fits, the Mars mission first, at 30% off and with a promise nobody checked. A jumpy market costs him:
|
||||
his orbit prices drop by PIE_CEO_JIT times the jitters, and from PIE_CEO_SKIP the Founder does not show up.
|
||||
Rolls are hashes of the deal (slR), never Math.random: without a salesperson orbit offers are drawn exactly as before. */
|
||||
const PIE_ENG_ROOM=1.5,PIE_ENG_SF=0.98,PIE_SHARK=1.25,PIE_SHARK_OVER=0.5,PIE_PROMISE=0.9,PIE_GRUMBLE=40,PIE_GOLF_SKY=0.5,PIE_CEO_JIT=0.4,PIE_CEO_SKIP=0.6;
|
||||
// What the salesperson can sell on a landing (pieServe()'s answer): the engineer keeps headroom on healthy dishes only.
|
||||
function pieSlRoom(L){if(slP()!=='eng')return L.left;const d=pieDishes()[L.k];return d&&!R.pie.isl.includes(d.city)&&sfOf(R,d.city)>=PIE_ENG_SF?L.left/PIE_ENG_ROOM:0;}
|
||||
// Which kinds get a call: the shark rings airlines and cruise lines first.
|
||||
function pieSlTypes(t){if(slP()!=='shark')return t;const big=t.filter(x=>x==='flywifi'||x==='boat'||x==='marsorb');return big.length?big:t;}
|
||||
// The size: the shark asks for the biggest that fits, everyone else as the customer asks (pick, as before).
|
||||
const pieSlSize=opts=>slP()==='shark'?opts[opts.length-1]:pick(opts);
|
||||
// A new orbit offer, dressed by whoever is at the desk.
|
||||
function pieSlShape(o){const p=slP();if(!p)return;o.by=p;
|
||||
if(p==='shark'){o.rate=Math.round(o.rate*PIE_SHARK);if(!REQS.skyfull.ok()&&slR('skyover|'+slKey(o))<PIE_SHARK_OVER)o.reqs=['skyfull'];}
|
||||
if(p==='ceo'){const j=pieJit();if(j>0)o.rate=Math.round(o.rate*(1-PIE_CEO_JIT*j));}}
|
||||
const pieJit=()=>(S.pie&&S.pie.founder&&S.pie.founder.jit)||0;
|
||||
// The CEO's golf with the Founder (salesGolf, on a golf day): true when this game was in orbit, deal or no deal.
|
||||
function pieGolf(d){if(!pieOn()||!S.pie||!S.pie.co||slR('golfsky|'+d)>=PIE_GOLF_SKY)return false;
|
||||
const ts=pieOfferTypes();if(!ts.length)return false;
|
||||
if(pieJit()>=PIE_CEO_SKIP){toast(tr('sales.ceo_golf_skip'),'');return true;}
|
||||
for(const t of ['marsorb','boat','flywifi','pizza']){if(!ts.includes(t))continue;const T=BIZ_T[t];
|
||||
const cs=pieCands(t).filter(c=>!c.cn).map(c=>[c,pieServe(c.id,t)]).filter(([,L])=>L&&L.left>=T.opts[0]).sort((a,b)=>b[0].P-a[0].P||(a[0].id<b[0].id?-1:1));if(!cs.length)continue;
|
||||
const [c,L]=cs[0],bw=T.opts.filter(g=>g<=Math.min(pieRoom(t),L.left)).pop();if(!bw)continue;
|
||||
const list=T.names.filter(n=>!S.usedNames.includes(n)),name=list.length?list[Math.floor(slR('golfskyn|'+d)*list.length)]:T.names[0];useName(name);
|
||||
const off=1-0.7*(1-PIE_CEO_JIT*pieJit()),o={id:uid(),city:c.id,city2:null,name,type:t,bw,rate:Math.round(T.rate*(1-off)),reqs:REQS.skyfull.ok()?[]:['skyfull'],exp:d+40};
|
||||
const b=offerCustomer(o);b.by='ceo';S.biz.push(clSign(b));
|
||||
toast(tr('sales.ceo_golf_sky',{name:esc(name),city:esc(c.name),bw:fmtG(bw),price:fmt$(bw*o.rate),p:pct(off)})+(o.reqs.length?' '+tr('sales.ceo_promised',{req:esc(REQS.skyfull.l())}):''),'goal',[{l:tr('common.show_me'),act:'custGo',args:{id:b.id}}]);sfx('coin');return true;}
|
||||
return false;}
|
||||
|
|
@ -15,6 +15,8 @@ const REQS={
|
|||
china:{l:tr('requirements.needs_low_loss_reach_into_china'),bonus:.3,ip:true,ok:()=>S.transit.some(premOn)||S.links.some(l=>l.premium)||S.pni.some(p=>NET[p.net].cn&&pniOn(p))},
|
||||
scrubbed:{l:tr('requirements.will_only_sign_with_a_network'),bonus:.15,ok:()=>hasScrub()},
|
||||
scrubnear:{l:tr('requirements.wants_a_scrubbing_center_on_its'),bonus:.15,ip:true,ok:b=>S.scrubs.some(x=>CITY[x.city].reg===CITY[b.city].reg)},
|
||||
// The shark's orbit promise (99-pie-sales.js): a full sky, a crust at least PIE_PROMISE in orbit. Never on an ordinary offer.
|
||||
skyfull:{only:true,bonus:0,l:()=>tr('requirements.promised_a_full_sky',{p:pct(PIE_PROMISE)}),ok:()=>pieHubs().some(id=>pieCov(id)>=PIE_PROMISE)},
|
||||
puns:{l:tr('requirements.their_ceo_hates_puns_please_do'),bonus:.05,ok:()=>true},
|
||||
};
|
||||
function terrestrialPath(a,b){const ls=S.links.filter(l=>!linkDown(l)&&!l.sub);const adj={};for(const l of ls){(adj[l.a]=adj[l.a]||[]).push(l.b);(adj[l.b]=adj[l.b]||[]).push(l.a);}const seen=new Set([a]),q=[a];while(q.length){const u=q.shift();if(u===b)return true;for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return false;}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ function dayPost(d){
|
|||
if(sf>=0.95&&reachOk&&scrubOk&&divOk)b.mood=Math.min(100,b.mood+2);
|
||||
else if(S.day-(b.since||0)<15){}
|
||||
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;
|
||||
// An orbit customer served in full but promised more (the shark's full sky) grumbles, and never cancels over it.
|
||||
if(BIZ_T[b.type].orbit&&sf>=0.95&&reachOk)b.mood=Math.max(b.mood,Math.min(b.pm,PIE_GRUMBLE));
|
||||
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');}
|
||||
|
|
@ -82,6 +84,8 @@ function dayPost(d){
|
|||
if(cm&&d>45&&scnRule('anchors')){const n=S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l)&&anchorProne(l)).length;if(n&&Math.random()<Math.min(5,+S.scn.rules.anchors||1)*n/365){dirty=true;fireFailure('cut');}}
|
||||
if(cm&&d>=S.nextEvent){dirty=true;fireEvent();S.nextEvent=d+Math.round((45+Math.floor(Math.random()*45))/cm);}
|
||||
if(dirty)compute();
|
||||
// the sales desk signs and declines deals, when the player lets it (39-sales-auto.js), then the intern's shift sees them
|
||||
slAutoDay(d);
|
||||
opsDay(d);
|
||||
if(S.pie){pieDay(d);pieTier();}
|
||||
// payday floaters
|
||||
|
|
|
|||
|
|
@ -8,5 +8,8 @@ Object.assign(ACT,{
|
|||
salesFire:()=>{const p=slP();if(!p||p==='ceo')return;if(UI.confirm!=='salesFire'){UI.confirm='salesFire';salesModal();return;}UI.confirm=null;const nm=slCap();S.sales.p=null;
|
||||
toast(tr('sales.fired',{name:esc(nm)}),'');after();salesModal();},
|
||||
// The CEO cannot be fired. A board meeting (and its catering) can get you a VP of Sales, who takes over a month later.
|
||||
// Signing for you (39-sales-auto.js): on or off, and the minimum under which offers are declined.
|
||||
salesAuto:()=>{if(!slP())return;const A=S.slAuto||(S.slAuto=slAutoNew());A.on=!A.on;sfx('click');after();salesModal();},
|
||||
salesMin:()=>{if(!slP())return;const A=S.slAuto||(S.slAuto=slAutoNew());A.min=opsCycle(SL_MINS,A.min);sfx('click');after();salesModal();},
|
||||
salesVp:()=>{if(slP()!=='ceo'||S.sales.vp)return;if(!spend(SALES_VP))return;S.sales.vp=S.day+SALES_VP_DAYS;toast(tr('sales.vp_asked',{n:SALES_VP_DAYS}),'');after();salesModal();},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// The sales desk in Deals, and its sheet: the three kinds of salesperson, who is at the desk, and what they cost.
|
||||
function salesCard(){if(!S||!rule('clock'))return '';const p=slP(),L=S.sales||{};
|
||||
return `<div class="ops-card"><div class="nm">${p?`${SALES[p].i} ${esc(tr('sales.at_desk',{name:slCap()}))}`:`💼 ${tr('sales.desk')}`}</div>
|
||||
<div class="meta">${p?(L.vp?tr('sales.vp_coming',{n:Math.max(0,L.vp-S.day)}):tr(SALES[p].d)):salesCanHire()?tr('sales.pitch'):tr('sales.locked',{lv:SALES_LV})}</div>
|
||||
<div class="meta">${p?(L.vp?tr('sales.vp_coming',{n:Math.max(0,L.vp-S.day)}):slCardLine()||tr(SALES[p].d)):salesCanHire()?tr('sales.pitch'):tr('sales.locked',{lv:SALES_LV})}</div>
|
||||
<div class="btns">${btn(p?tr('sales.desk'):tr('sales.hire_sales'),'salesOpen',{},p?'sm':'pink sm',!p&&!salesCanHire())}</div></div>`;}
|
||||
function salesModal(){if(!S)return;const p=slP(),L=S.sales||{};
|
||||
let h=`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('common.deals')}</div><h2 style="font-size:26px">${tr('sales.desk')}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>`;
|
||||
|
|
@ -12,6 +12,19 @@ function salesModal(){if(!S)return;const p=slP(),L=S.sales||{};
|
|||
:btn(UI.confirm==='salesFire'?tr('ops.really_fire'):tr('ops.fire'),'salesFire',{},'ghost sm'))
|
||||
:p?'':btn(id==='ceo'?tr('sales.let_ceo'):tr('ops.hire_mo',{price:fmt$(P.mo)}),'salesHire',{id},'pink sm',!salesCanHire()||!rule('clock')||S.cash<P.mo);
|
||||
return `<div class="ops-o${here?' on':''}"><div class="ops-h"><span class="ops-i" aria-hidden="true">${P.i}</span><div class="grow"><div class="nm">${tr(P.n)}</div>
|
||||
<div class="meta">${tr(P.d)}</div>${here&&id!=='ceo'?`<div class="meta">${tr('ops.salary',{price:fmt$(P.mo),d:dateStr(L.hired||0)})}</div>`:''}${act?`<div class="btns">${act}</div>`:''}</div></div></div>`;}).join('');
|
||||
<div class="meta">${tr(P.d)}</div>${pieOn()?`<div class="meta">🥧 ${tr(SL_SKY[id])}</div>`:''}${here&&id!=='ceo'?`<div class="meta">${tr('ops.salary',{price:fmt$(P.mo),d:dateStr(L.hired||0)})}</div>`:''}${act?`<div class="btns">${act}</div>`:''}</div></div></div>`;}).join('');
|
||||
if(p&&p!=='ceo')h+=`<p class="note">${tr('sales.one_at_a_time')}</p>`;
|
||||
h+=p?slAutoHtml(p):rule('clock')?`<p class="note">${tr('sales.by_hand')}</p>`:'';
|
||||
openModal(h,'ops');}
|
||||
// What each of them does in orbit, shown once there is a rocket company to sell for (99-pie-sales.js).
|
||||
const SL_SKY={eng:N_('sales.eng_sky'),shark:N_('sales.shark_sky'),ceo:N_('sales.ceo_sky')};
|
||||
const SL_AUTO={eng:N_('sales.auto_eng'),shark:N_('sales.auto_shark'),ceo:N_('sales.auto_ceo')};
|
||||
// Signing for you (39-sales-auto.js): the switch, the minimum, and this week's and last week's tally.
|
||||
function slAutoHtml(p){const A=S.slAuto||slAutoNew(),w=Math.floor(S.day/7),cur=A.wk&&A.wk.w===w&&slWkAny(A.wk)?A.wk:null,rep=A.rep&&A.rep.w===w-1?A.rep:null;
|
||||
const row=(x,last)=>`<div class="ops-rep">${esc(slWeekLine(x,last))}</div>`;
|
||||
return `<section class="sl-auto"><h3>${tr('sales.auto')}</h3><p class="meta">${tr(SL_AUTO[p],{name:esc(slCap())})}</p>
|
||||
<div class="ops-p"><button class="b sm ${A.on?'green':'ghost'}" data-act="salesAuto" data-args='{}' aria-pressed="${A.on}">${tr('sales.p_sign')}: <b>${A.on?tr('common.on'):tr('common.off')}</b></button>
|
||||
${btn(`${tr('sales.decline_below')}: <b>${A.min?tr('common.price_mo',{price:fmt$(A.min)}):tr('sales.never')}</b>`,'salesMin',{},'ghost sm')}</div>
|
||||
${rep?row(rep,true):''}${cur?row(cur,false):''}</section>`;}
|
||||
// On the card in Deals: this week's tally, once there is one.
|
||||
function slCardLine(){if(!slAutoOn())return '';const A=S.slAuto,x=A.wk&&A.wk.w===Math.floor(S.day/7)&&slWkAny(A.wk)?A.wk:null;return x?esc(slWeekLine(x,false)):'';}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue