Satellite teleports: GEO and MEO circuits for islands and remote towns (#83)
The early and mid-game satellite option, before Pie in the Sky. Build a teleport at a POP that a satellite sees, then rent capacity from it to a remote POP: GEO (Intelsplat, Kacophony) needs no capex but costs a lot a month per Gbps, 1-10 Gbps at about 600 ms; MEO (O3bservant) needs tracking antennas at the teleport and gives multi-Gbps at about 130 ms where both ends are under its ring, at least 5 degrees up. Coverage follows each bird's footprint by ocean region. Latency feeds the latency model: users who ride a satellite notice, in proportion to the share. A circuit beside a cable goes on standby, whichever came first, and carries only what the cable cannot: the classic single-cable island backup. Satellites are not subsea links for covenants, scenario goals or subsidies (Pitcairn's UK grant needs a cable). Express fiber and the build standard leave satellite circuits alone.
This commit is contained in:
parent
8e1f2d66a5
commit
e1ae8e0164
46 changed files with 1176 additions and 55 deletions
60
src/game/93-ui/72-teleport-panels.js
Normal file
60
src/game/93-ui/72-teleport-panels.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
// Teleports and satellite circuits on screen (#83): a POP's section, the order sheet, a circuit's panel.
|
||||
const satLogo=P=>`<span class="logo" style="--c:${P.col}">${esc(P.n.slice(0,2).toUpperCase())}</span>`;
|
||||
// Round trip over bird id between a and b, in whole ms.
|
||||
const satRtt=(id,a,b)=>Math.round(2*satLat({bird:id,km:satKm(id,a,b)}));
|
||||
const satModalHead=(eye,title)=>`<div style="display:flex;align-items:center"><div><div class="eyebrow">🛰️ ${eye}</div><h2 style="font-size:24px">${title}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>`;
|
||||
// In a city's facts: its own users' traffic rides a satellite today (R.satU), and they count part of the service as bad (sfOf, R.latF).
|
||||
const satFact=c=>R&&R.latF&&R.latF[c]<1&&R.satU&&R.satU[c]>1e-3?`<span class="fact bad">🛰️ ${tr('satellites.users_ride_a_satellite')}</span>`:'';
|
||||
// The birds a dish at c sees, in words.
|
||||
const satInView=c=>{const ids=teleSees(c);return ids.length?tr('satellites.in_view_list',{list:ids.map(id=>`<b>${esc(SATS[id].n)}</b> (${tr(SATS[id].sea)})`).join(', ')}):tr('satellites.no_bird_sees_this_city');};
|
||||
// In a POP's Infra tab: its teleport (build it, what it sees, its circuits), and the teleports that can reach it.
|
||||
function teleHtml(c){if(pzOn())return '';const t=teleOf(c),from=satFrom(c),open=lvl()>=SAT_ORB.geo.lv;if(!t&&!open&&!from.length)return '';
|
||||
let h=`<section><h3>🛰️ ${tr('satellites.satellites')}</h3>`;
|
||||
if(t){const out=S.links.filter(l=>l.kind==='sat'&&l.a===c),cf=UI.confirm==='tele:'+c,meo=teleSees(c).some(id=>SATS[id].orb==='meo');
|
||||
h+=`<div class="kv"><span>${tr('satellites.teleport')}</span><b>${t>1?tr('satellites.geo_dishes_and_meo_tracking'):tr('satellites.geo_dishes')} · ${tr('common.price_mo',{price:fmt$(TPORT_MO+(t>1?TRK_MO:0))})}</b></div>
|
||||
<div class="meta">${satInView(c)}</div>`;
|
||||
for(const l of out){const u=capOf(l)?(R.load[l.id]||0)/capOf(l):0;
|
||||
h+=`<div class="row"><div class="grow"><div class="nm">→ ${CITY[l.b].name}${l.standby?' <span class="tag st">'+tr('common.standby')+'</span>':''}</div><div class="meta">${capName(l)} · ${esc(satName(l))}${l.ready>S.day?' · '+tr('city_panel.ready_in_n_d',{n:l.ready-S.day}):''} · ${tr('common.price_mo',{price:fmt$(l.mo)})}</div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div>${btn(tr('common.open'),'selLink',{id:l.id},'ghost sm')}</div>`;}
|
||||
h+=`<div class="btns">${btn(tr('satellites.rent_satellite_capacity'),'satOpen',{a:c},'pink sm')}${t===1&&lvl()>=SAT_ORB.meo.lv&&meo?btn(tr('satellites.add_tracking_antennas_cost_mo',{cost:fmt$(TRK_COST),mo:fmt$(TRK_MO)}),'teleTrk',{city:c},'sm',S.cash<TRK_COST):''}${out.length?'':btn(cf?tr('satellites.really_close_it'):tr('satellites.close_the_teleport'),'teleRm',{city:c},'ghost sm')}</div>
|
||||
${t===1&&lvl()<SAT_ORB.meo.lv&&meo?`<p class="note">${tr('satellites.meo_comes_at_level',{lv:SAT_ORB.meo.lv})}</p>`:''}`;}
|
||||
// Before the build: what its dishes would see and reach at your level, and no button to a teleport that reaches nothing.
|
||||
else if(open){const why=teleWhy(c),n=why?0:satTargets(c).filter(x=>satBirds(c,x).some(id=>lvl()>=SAT_ORB[SATS[id].orb].lv)).length;
|
||||
h+=`<p class="lead">${tr('satellites.a_teleport_is_a_satellite_gateway')}</p><div class="meta">${satInView(c)}${why?'':' '+trn('satellites.n_places_in_reach',n)}</div>${why&&teleSees(c).length?`<div class="why">${esc(why)}</div>`:''}
|
||||
<div class="btns">${btn(tr('satellites.build_a_teleport_cost_mo',{cost:fmt$(TPORT_COST),mo:fmt$(TPORT_MO)}),'teleBuild',{city:c},'sm',S.cash<TPORT_COST||!!why)}</div>`;}
|
||||
if(from.length)h+=satReach(c,from);
|
||||
return h+`</section>`;}
|
||||
// Teleports that reach city c: a button each, to the order sheet.
|
||||
const satReach=(c,from)=>`<p class="note">${tr('satellites.reachable_from_your_teleports',{city:CITY[c].name})}</p><div class="btns">${from.slice(0,4).map(a=>btn(tr('fiber_modals.from_city',{city:CITY[a].name}),'satOpen',{a,b:c},'ghost sm')).join('')}</div>`;
|
||||
// A city without a POP of yours, that a teleport of yours reaches: a POP and a circuit in one go.
|
||||
function satNoPop(c){if(pzOn()||S.pops[c])return '';const from=satFrom(c);if(!from.length)return '';
|
||||
return `<section><h3>🛰️ ${tr('satellites.by_satellite')}</h3><p class="lead">${tr('satellites.no_cable_needed_a_pop_here',{city:CITY[c].name})}</p>${satReach(c,from)}</section>`;}
|
||||
// The order sheet: from teleport a to b. With one end missing it lists the choices first.
|
||||
function satModal(a,b){a=isCity(a)?a:null;b=isCity(b)?b:null;
|
||||
if(!a&&b){const fr=satFrom(b);if(fr.length===1)a=fr[0];
|
||||
else{openModal(satModalHead(tr('satellites.satellite_capacity'),tr('fiber_modals.to_city',{city:CITY[b].name}))+(fr.length?fr.map(x=>`<div class="row"><div class="grow"><div class="nm">${CITY[x].name}</div><div class="meta">${tr('satellites.teleport')} · ${trn('satellites.n_birds_see_both',satBirds(x,b).length)}</div></div>${btn(tr('satellites.choose'),'satOpen',{a:x,b},'sm')}</div>`).join(''):`<p class="empty">${tr('satellites.no_teleport_reaches_city',{city:CITY[b].name})}</p>`));return;}}
|
||||
if(!a||!teleOf(a))return;
|
||||
if(!b){const ts=satTargets(a),mine=ts.filter(x=>S.pops[x]),more=ts.filter(x=>!S.pops[x]).slice(0,12);
|
||||
const row=x=>`<div class="row"><div class="grow"><div class="nm">${CITY[x].name}</div><div class="meta">${S.pops[x]?tr('common.your_pop'):tr('satellites.new_pop_cost',{cost:fmt$(newPopCost(x))})} · ${kmBetween(a,x).toLocaleString()} km · ${trn('satellites.n_birds_see_both',satBirds(a,x).length)}</div></div>${btn(tr('satellites.choose'),'satOpen',{a,b:x},'sm')}</div>`;
|
||||
openModal(satModalHead(tr('satellites.satellite_capacity'),tr('fiber_modals.from_city',{city:CITY[a].name}))+`<p class="lead" style="margin-top:8px">${tr('satellites.who_a_satellite_serves')}</p>`
|
||||
+(mine.length?`<h4 class="sub4">${tr('satellites.your_pops_in_view')}</h4>`+mine.map(row).join(''):'')+(more.length?`<h4 class="sub4">${tr('satellites.more_islands_and_towns')}</h4>`+more.map(row).join(''):'')+(ts.length?'':`<p class="empty">${tr('satellites.nothing_in_view_from_here')}</p>`));return;}
|
||||
const pop=S.pops[b]?0:newPopCost(b),sib=pairLinks(a,b).some(l=>l.kind!=='sat'),birds=satBirds(a,b);
|
||||
const rows=birds.map(id=>{const B=SATS[id],O=SAT_ORB[B.orb],P=SAT_PROV[B.p],why=satWhy(a,b,id);
|
||||
return `<div class="row">${satLogo(P)}<div class="grow"><div class="nm">${esc(B.n)} <span class="tag">${O.n}</span></div><div class="meta">${esc(P.n)} · ${tr(B.sea)} · ${tr('satellites.ms_round_trip',{ms:satRtt(id,a,b)})} · ${trn('satellites.up_in_n_days',leadDays(O.days))}</div><div class="meta">${esc(P.blurb)}</div>${why?`<div class="why">${esc(why)}</div>`:''}
|
||||
<div class="btns">${O.g.map(g=>btn(`${fmtCap(g)} <small>${tr('common.price_mo',{price:fmt$(satMo(id,g))})}</small>`,'buySat',{a,b,bird:id,g},'sm',!!why||S.cash<satMo(id,g)+pop)).join('')}</div></div></div>`;}).join('');
|
||||
openModal(satModalHead(tr('satellites.satellite_capacity'),`${CITY[a].name} → ${CITY[b].name}`)+`<p class="lead" style="margin-top:8px">${tr('satellites.users_notice_geo_meo')}</p>`
|
||||
+(pop?`<p class="note">${tr('satellites.no_pop_there_yet',{city:CITY[b].name,cost:fmt$(pop)})}</p>`:'')+(sib?`<p class="note">${tr('satellites.it_waits_on_standby')}</p>`:'')
|
||||
+(rows||`<p class="empty">${tr('satellites.no_bird_sees_both',{a:CITY[a].name,b:CITY[b].name})}</p>`));}
|
||||
// A circuit's panel: what it carries, its latency and rent, a size up or down, standby and the metric, cancel.
|
||||
function satPanel(l){const B=SATS[l.bird],O=SAT_ORB[B.orb],P=SAT_PROV[B.p],load=R.load[l.id]||0,cap=capOf(l),u=cap?load/cap:0,ms=satLat(l);
|
||||
let h=`<div class="ph"><div><div class="eyebrow">🛰️ ${esc(B.n)} · ${O.n} · ${esc(P.n)}</div><h2>${CITY[l.a].name} ⇄ ${CITY[l.b].name}</h2></div><button class="x" data-act="closePanel" aria-label="${tr('common.close')}">×</button></div><div class="scroll">`;
|
||||
if(l.ready>S.day){const tot=Math.max(1,l.ready-l.day),done=clamp((S.day-l.day)/tot,0,1);
|
||||
h+=`<section><h3>${tr('satellites.being_commissioned')}</h3><div class="kv"><span>${tr('satellites.pointing_dishes_and_testing')}</span><b>${tr('common.n_days_left',{n:l.ready-S.day})}</b></div><div class="bar me"><i style="width:${done*100}%"></i></div></section>`;}
|
||||
h+=`<section><h3>${tr('common.capacity')}</h3><div class="kv"><span>${capName(l)}${l.standby?' · '+tr('common.standby'):''}</span><b>${fmtG(load)} / ${fmtG(cap)}</b></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div>
|
||||
<div class="kv"><span>${tr('common.latency')}</span><b>${tr('satellites.ms_one_way_rtt',{ms:Math.round(ms),rtt:Math.round(2*ms)})}</b></div>
|
||||
<div class="kv"><span>${tr('satellites.radio_path')}</span><b>${l.km.toLocaleString()} km</b></div>
|
||||
<div class="kv"><span>${tr('satellites.rent')}</span><b>${tr('common.price_mo',{price:fmt$(l.mo)})}</b></div>
|
||||
<p class="note">${B.orb==='geo'?tr('satellites.geo_users_notice',{p:pct(O.loss)}):tr('satellites.meo_users_notice',{p:pct(O.loss)})} ${esc(P.blurb)}</p>
|
||||
<div class="btns">${O.g.filter(g=>g!==l.g).map(g=>btn(`${g>l.g?tr('satellites.grow_to',{cap:fmtCap(g)}):tr('satellites.shrink_to',{cap:fmtCap(g)})} <small>${tr('common.price_mo',{price:fmt$(satMo(l.bird,g))})}</small>`,'satSize',{id:l.id,g},'sm',g>l.g&&S.cash<satMo(l.bird,g))).join('')}</div></section>
|
||||
${trafficSection(l)}${metricSection(l)}
|
||||
<section>${btn(UI.confirm===l.id?tr('common.really_cancel'):tr('common.cancel_circuit'),'rmLink',{id:l.id},'ghost sm')}</section></div>`;
|
||||
return h;}
|
||||
Loading…
Add table
Add a link
Reference in a new issue