One calendar for a server session (the user's answer to Q1): a network that joins begins on the session's date, and one that joins after day 180, when the shared market starts to move, gets a head start (answered 2026-11-11). Dormant until the host (T3) passes a start day: in the plain build and in single-device play S.day0 is 0 and the game is as before. - S.day0, the calendar day a network began: 0 in newGame(), repaired in sanitize() (at most S.day), so old saves load. netAge() is the network's age; the first-days rules count it: the charter window (and specSanitize), the tutorial's five days, the DDoS grace and early size cap, route leaks, RPKI, the world's bad news, shortages and control-plane events, sold-out routes, the scrubbing customers, loan offers, the broker's first calls, the Speedrun and Blitz badges and the day counts in the win, lose and Glass Baron windows. The market, the calendar and world events stay on the session's date. - beginState() takes o.day for a session network in Normal mode (lateStart()): the day, the first outage and event, the home POP and the first IPv4 block are stamped with it, so the block cannot be sold on day one at the session's price. - The head start (60-features/81-late-joiners.js): starting cash topped up by the rise in hardware prices (START_CASH x (hwTrend - 1), to $1,000, at most $60k, with the market rule only) and the first 365 days of home broadband matched (R.rev.late: what homes pay after the Australian wholesale cut or levy; outside investors' share, inside revMo). A second welcome with a button to the bank, a Goals card, a bank section, a line in a city's broadband pitch and a toast when the year is over; every label in all six dictionaries. - The "since you started" lines (supply chain, bandwidth market, wave prices) measure from the network's own start. - Server-run engine: srvBegin takes begin.day (an integer from 0, else the begin fails), the fake engine begins there and keeps day0 in its saves, CLOCK.off leaves the shape checker and the contract test, and the fixtures' network begins on day 473 (written again with tests/lib/mp-sim-fixtures.js; a second run changes nothing). - Gameplay rule F11, the agent's day0 doc and status age, ARCHITECTURE and the plans (Q1's game side built, open question 1 answered). - tests/late-joiners.test.js; F11 in tests/gameplay-rules.test.js; a late begin in tests/mp-sim-engine.test.js; one calendar in tests/mp-sim-contract.test.js. Merged onto Starblink and Island Wi-Fi: revMo counts both the islands (V.wisp) and the match (V.late), the revenue share base keeps V.wisp and leaves V.late out; F11 sits before F12 in the gameplay rules and their test; the mp-sim fixtures were written again with tests/lib/mp-sim-fixtures.js (a second run changes nothing).
35 lines
4 KiB
JavaScript
35 lines
4 KiB
JavaScript
/* ---------- Supply chain: hardware gets dearer over the years, with shortages that come and go ----------
|
|
Transit keeps getting cheaper (it really does), but routers, optics and new builds drift the other way: free for
|
|
the first six months, then +4% a year, capped at +30%. Only new purchases pay it; what you own costs what it cost.
|
|
Now and then a shortage hits one kind of hardware for a month or two. Spares on the shelf and a yearly price lock
|
|
with your vendor are the ways around it. */
|
|
const HW_YR=0.04,HW_CAP=1.3,HW_FREE=180,HW_LOCK_DAYS=365;
|
|
const HW_SHOCK={opt:{mul:1.5,n:N_('common.optics'),msg:N_('supply_chain.laser_shortage_the_factory_that')},
|
|
rt:{mul:1.4,n:N_('common.routers'),msg:N_('supply_chain.chip_shortage_every_router_vendor_is')},
|
|
build:{mul:1.3,n:N_('supply_chain.new_fiber_and_cable_builds'),msg:N_('supply_chain.every_cable_ship_is_booked')}};
|
|
const hwTrend=d=>Math.min(HW_CAP,1+HW_YR*Math.max(0,(d-HW_FREE)/365));
|
|
const hwShock=()=>{const s=S&&S.hw&&S.hw.shock;return s&&s.until>S.day?s:null;},hwLock=()=>{const l=S&&S.hw&&S.hw.lock;return l&&l.until>S.day?l:null;};
|
|
function hwMul(k){if(!S||!rule('market'))return 1;const l=hwLock();if(l)return l.mul;const s=hwShock();return hwTrend(S.day)*(s&&s.k===k?s.mul:1);}
|
|
// A lock costs a little more for a bigger network, and twice as much in the middle of a shortage.
|
|
const hwLockCost=()=>Math.round((80000+30000*Object.keys(S.pops).length)*(hwShock()?2:1)/1000)*1000;
|
|
function hwShockStart(){const k=pick(Object.keys(HW_SHOCK)),n=45+Math.floor(Math.random()*31);S.hw=S.hw||{};S.hw.shock={k,until:S.day+n,mul:HW_SHOCK[k].mul};
|
|
toast(tr(HW_SHOCK[k].msg,{n})+(hwLock()?'<br>'+tr('supply_chain.your_price_lock_covers_you_until',{date:dateStr(hwLock().until)}):''),hwLock()?'':'bad');sfx('alert');}
|
|
function hwCard(){if(!S||!rule('market')||(S.day<=HW_FREE&&!hwShock()&&!hwLock()))return '';const t=hwTrend(S.day)/hwTrend(S.day0|0),s=hwShock(),l=hwLock();
|
|
return `<div class="ibx"><div class="nm">📦 ${tr('common.supply_chain')}</div>
|
|
<div class="kv"><span>${tr('common.hardware_prices')}</span><b>${t>1.005?tr('supply_chain.p_since_you_started',{p:pct(t-1)}):tr('supply_chain.as_when_you_started')}</b></div>
|
|
<div class="kv"><span>${tr('lifecycle.bandwidth_prices')}</span><b>${mktTxt()}</b></div>
|
|
${s?`<div class="kv"><span>${tr('common.shortage')}</span><b>${tr('supply_chain.what_p_n_days_left',{what:tr(HW_SHOCK[s.k].n),p:pct(s.mul-1),n:s.until-S.day})}</b></div>`:''}
|
|
${l?`<div class="kv"><span>${tr('common.price_lock')}</span><b>${tr('supply_chain.until_date_at_p',{date:dateStr(l.until),p:pct(l.mul-1)})}</b></div>`
|
|
:`<p class="meta">${tr('supply_chain.routers_optics_and_new_builds_at')}</p><div class="btns">${btn(tr('supply_chain.lock_prices_for_a_year_cost',{cost:fmt$(hwLockCost())}),'hwLock',{},'sm',S.cash<hwLockCost())}</div>`}</div>`;}
|
|
// Routers past the standard cage (#157) need a cage extension: pricier to install, and rent on top.
|
|
const RCAGE=6,CAGE_MUL=1.5,CAGE_MO=2000;
|
|
const routerCost=(g,rt)=>Math.round((ROUTER_COST+RG[g].cost*0.8)*((rt||1)>=RCAGE?CAGE_MUL:1)*hwMul('rt')*techMul(RG[g].lvl));
|
|
const routerMo=g=>ROUTER_MO+RG[g].mo,cageMo=rt=>Math.max(0,(rt||1)-RCAGE)*CAGE_MO;
|
|
// Old routers go on eBuy when you swap models or remove one (#82), like spare optics (#45). Chassis age faster.
|
|
// swapCostOf: the same price for a POP on model old with rt routers (the build standard plans a few steps ahead).
|
|
const ROUTER_RESALE=0.3,tradeIn=(g,n)=>Math.round(RG[g].cost*n*ROUTER_RESALE),swapCostOf=(g,old,rt)=>Math.max(0,Math.round(RG[g].cost*rt*hwMul('rt')*techMul(RG[g].lvl))-tradeIn(old,rt)),swapCost=(c,g)=>{const p=S.pops[c];return swapCostOf(g,p.rgen||0,p.routers||1);};
|
|
const RMAX=16;
|
|
// The plain, badge-less model of each class is the default upgrade path; the others are side-grades.
|
|
const mainRG=k=>RG.findIndex(r=>r.cls===k&&!r.badge);
|
|
// Ports and waves beyond 1.6T / 6.4T only show once a router that takes them is unlocked.
|
|
const portShown=i=>i<=4||RG.some((r,g)=>rgOpen(g)&&r.maxP>=i),waveShown=i=>i<=5||RG.some((r,g)=>rgOpen(g)&&r.maxLT>=i);
|