Merge remote-tracking branch 'origin/main' into keyboard-shortcuts
This commit is contained in:
commit
c5c5aac970
14 changed files with 92 additions and 2 deletions
|
|
@ -78,4 +78,9 @@ const layOwn=l=>l.kind==='df'&&l.own&&l.sub;
|
|||
const layName=(l,k=0)=>{let h=0;for(const ch of String(l.id))h=(h*31+ch.charCodeAt(0))>>>0;return LAY_SHIPS[(h+k)%LAY_SHIPS.length];};
|
||||
function layQuote(l){if(!layOwn(l)||l.ship2||S.day>=layStart(l)||l.ready<=S.day+1)return null;const save=Math.floor(layDays(l)/2);if(save<1)return null;return {save,cost:SHIP_MOB+save*LAY_DAY};}
|
||||
// How much of the cable is on the seabed, 0 to 1.
|
||||
/* Money hurries the survey, the permits and the factory (#258), 30 days a step, but only so far: the cable still has to
|
||||
be made, about two months plus a day for every 80 km of it, before the ships can sail and lay it. */
|
||||
const PREP_STEP=30,prepMin=l=>leadDays(Math.round(60+(l.km||0)*0.012)),prepCost=l=>Math.round((500000+(l.km||0)*60)*hwMul('build')),
|
||||
prepFloor=l=>Math.max(S.day+1,(l.day||0)+prepMin(l))+layLen(l),
|
||||
prepSteps=l=>layOwn(l)&&l.ready>S.day&&S.day<layStart(l)?Math.max(0,Math.ceil((l.ready-prepFloor(l))/PREP_STEP)):0;
|
||||
const layDone=(l,T)=>clamp((T-layStart(l))/layLen(l),0,1);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ Object.assign(ACT,{
|
|||
upSys:({id})=>{const l=S.links.find(x=>x.id===id),to=l&&sysNext(l);if(!to||!techOk('sys',to,DF_SYS[to].lvl))return;if(!spend(sysUpCost(l)))return;l.sys=to;if(l.ready<=S.day){l.eqDown=S.day+1;toast(tr('fiber_and_hardware.line_system_swap_all_channels_are'),'bad');}after();},
|
||||
spares:({id})=>{const l=S.links.find(x=>x.id===id);if(!l)return;l.spares=!l.spares;sfx('click');after();},
|
||||
// Your own subsea cable: book a second lay ship before laying starts; it lays from the other end (50-cable-ships.js).
|
||||
seaRush:({id,all})=>{const l=S.links.find(x=>x.id===id);if(!l)return;const k=prepSteps(l);if(!k)return;const n=all?k:1;if(!spend(n*prepCost(l)))return;const ready=Math.max(prepFloor(l),l.ready-PREP_STEP*n),saved=l.ready-ready;setCableReady(l,ready);toast(trn('cable_ships.the_factory_runs_a_night_shift',saved,{n:saved}),'good');sfx('build');after();},
|
||||
layShip:({id})=>{const l=S.links.find(x=>x.id===id);const q=l&&layQuote(l);if(!q||!spend(q.cost))return;l.ship2=1;setCableReady(l,l.ready-q.save);
|
||||
toast(trn('cable_ships.second_lay_ship_booked',q.save,{ship:esc(layName(l,1)),n:q.save}),'good');sfx('coin');after();},
|
||||
crews:({id,all})=>{const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='df'||!l.own||l.sub||l.ready<=S.day+1)return;const n=all?crewSteps(l):1,c=n*crewCost(l);if(!spend(c))return;const ready=Math.max(S.day+1,l.ready-30*n),saved=l.ready-ready;setCableReady(l,ready);toast(trn('fiber_and_hardware.more_crews_on_site_construction_is',saved,{n:saved}),'good');after();},
|
||||
|
|
|
|||
|
|
@ -105,6 +105,9 @@ const shipNote=i=>{const t=i&&shipStatus(i);return t?`<p class="note">🚢 ${esc
|
|||
function layPanel(l){const d=S.day,st=layStart(l),q=layQuote(l),km=Math.round(layDone(l,d)*l.km),two=l.ship2?tr('cable_ships.ship_and_ship',{a:layName(l),b:layName(l,1)}):layName(l);
|
||||
let h=d<st?`<div class="kv"><span>${tr('cable_ships.survey_permits_and_the_cable_factory')}</span><b>${trn('cable_ships.laying_starts_in_n_days',st-d)}</b></div>`
|
||||
:`<div class="kv"><span>${tr('cable_ships.ships_lay_the_cable',{ships:esc(two)})}</span><b>${tr('cable_ships.km_of_km',{km:km.toLocaleString(),of:Math.round(l.km).toLocaleString()})}</b></div>`;
|
||||
const k=prepSteps(l),pc=prepCost(l),fast=Math.min(k*PREP_STEP,l.ready-prepFloor(l));
|
||||
if(k)h+=`<div class="btns">${btn(tr('cable_ships.hurry_the_permits_and_the',{n:Math.min(PREP_STEP,fast),price:fmt$(pc)}),'seaRush',{id:l.id},'sm',S.cash<pc)}${k>1?btn(tr('cable_ships.as_fast_as_money_goes',{n:fast,price:fmt$(k*pc)}),'seaRush',{id:l.id,all:1},'sm',S.cash<k*pc):''}</div>`;
|
||||
if(d<st)h+=`<p class="note">${tr('cable_ships.money_only_goes_so_far',{n:prepMin(l)})}</p>`;
|
||||
if(q)h+=`<div class="btns">${btn(tr('cable_ships.book_a_second_lay_ship',{price:fmt$(q.cost),n:q.save}),'layShip',{id:l.id},'sm',S.cash<q.cost)}</div><p class="note">${tr('link_panels.only_a_few_dozen_cable_ships')}</p>`;
|
||||
else if(!l.ship2&&d<st)h+=`<p class="note">${tr('link_panels.only_a_few_dozen_cable_ships')}</p>`;
|
||||
return h;}
|
||||
|
|
|
|||
|
|
@ -422,13 +422,16 @@
|
|||
"businesses.your_network_diagram_is_a_photo":"Your network diagram is a photo of a whiteboard.",
|
||||
"businesses.your_noc_has_a_chat_channel":"Your NOC has a chat channel called #its-always-the-fiber, and it is always the fiber.",
|
||||
"businesses.your_routing_table_needs_its_own":"Your routing table needs its own routing table.",
|
||||
"cable_ships.as_fast_as_money_goes":"As fast as money goes <small>{price} · −{n} days</small>",
|
||||
"cable_ships.at_anchor_off_home":"at anchor off {home}, ready to sail within a day.",
|
||||
"cable_ships.book_a_second_lay_ship":"Book a second lay ship <small>{price} · −{n} days</small>",
|
||||
"cable_ships.charter_ship":"Charter {ship}",
|
||||
"cable_ships.every_club_ship_is_out":"Every {club} ship is out on a job. The cut waits for the first one back, or a private charter.",
|
||||
"cable_ships.hurry_the_permits_and_the":"Hurry the permits and the factory <small>{price} · −{n} days</small>",
|
||||
"cable_ships.km_of_km":"{km} of {of} km",
|
||||
"cable_ships.lay_ship_tap":"<b>{ship}</b><br>Laying your cable from {a} to {b}: {km} of {of} km on the seabed.",
|
||||
"cable_ships.laying_starts_in_n_days":{"one":"Laying starts in {n} day","other":"Laying starts in {n} days"},
|
||||
"cable_ships.money_only_goes_so_far":"Lawyers and overtime only go so far: the cable still has to be made. For this one that is {n} days from the order at the soonest, then the ships sail.",
|
||||
"cable_ships.private_at_anchor":"at anchor off {home}, for charter to anyone who pays.",
|
||||
"cable_ships.private_operator":"Private operator",
|
||||
"cable_ships.sailing_home_to_home":{"one":"sailing home to {home}, free again in {n} day.","other":"sailing home to {home}, free again in {n} days."},
|
||||
|
|
@ -440,6 +443,7 @@
|
|||
"cable_ships.ship_waits_for_a_permit":"{ship} is on site, waiting {n}d for a repair permit. Cable back in about {m}d.",
|
||||
"cable_ships.ships_lay_the_cable":"{ships} at sea, laying",
|
||||
"cable_ships.survey_permits_and_the_cable_factory":"Survey, permits and the cable factory",
|
||||
"cable_ships.the_factory_runs_a_night_shift":{"one":"The permit lawyers found a stamp and the factory runs a night shift: laying starts {n} day sooner.","other":"The permit lawyers found a stamp and the factory runs a night shift: laying starts {n} days sooner."},
|
||||
"cables.a_bet_on_a_tiny_island":"A bet on a tiny island in the middle of the Pacific.",
|
||||
"cables.a_buffet_of_landings_down_norway":"A buffet of landings down the Norwegian coast, from the oil fields to Oslo.",
|
||||
"cables.a_friendly_cable_with_french_manners":"A friendly cable with French manners.",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue