From 823e4188befe7e105df7edbb1599403c92f2d805 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Tue, 3 Nov 2026 10:35:16 +0000 Subject: [PATCH] Pay to hurry the permits and factory of your own subsea cable (closes #258) Before laying starts, seaRush buys 30 days a step (or all of them at once) at $500k plus $60 a km, with the market's build prices. The floor is the factory: 60 days plus a day per ~80 km from the order (prepMin, through leadDays), then the lay ships still need their time at sea, which a second ship still halves. 6,000 km: from 600 days of prep to 132 for about $13M. --- CHANGELOG.md | 1 + scripts/lib/mcp-commands.js | 3 ++ site/i18n/de.js | 4 ++ site/i18n/es.js | 4 ++ site/i18n/fr.js | 4 ++ site/i18n/it.js | 4 ++ site/i18n/pt.js | 4 ++ src/game/85-incidents/50-cable-ships.js | 5 ++ src/game/90-actions/87-fiber-and-hardware.js | 1 + src/game/93-ui/70-link-panels.js | 3 ++ src/i18n/en.js | 4 ++ tests/mcp-commands.test.js | 2 +- tests/sea-rush.test.js | 51 ++++++++++++++++++++ 13 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 tests/sea-rush.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 31034ad..d7bca0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- You can pay to hurry the survey, permits and factory of your own subsea cable, 30 days at a time (#258). Money only goes so far: the cable still has to be made, about two months plus a day for every 80 km, before the lay ships sail. - Three new cities in northern Australia: Port Hedland, Townsville and Alice Springs (#255). Port Hedland lands a new cable up the coast to Darwin and a branch of Darwin's cable out to Singapore; Alice Springs has no sea at all. In the wet season, November to April, fiber cuts in the tropical north, Darwin included, take twice as long to reach. - Traceroute no longer shows an "embedded cache in your rack" hop on paths that leave over transit, an exchange or a PNI. Only traffic that really ends at one of your cache boxes shows it now. diff --git a/scripts/lib/mcp-commands.js b/scripts/lib/mcp-commands.js index e21df6e..6a5d8e1 100644 --- a/scripts/lib/mcp-commands.js +++ b/scripts/lib/mcp-commands.js @@ -432,6 +432,9 @@ const API_CMD={ metricSet:{args:[['id','entityId'],['v','string']],dom:['metIn'],watch:['pairMet'], bind:a=>{$('metIn').value=String(a.v);}, doc:'Write the custom metric\'s number for the link\'s city pair, in the mode metricMode set. Select the link first (view.selLink), so the panel is showing the input.'}, + seaRush:{args:[['id','entityId'],['all','boolean',false]],watch:['links.#id'], + quote:a=>{const l=S.links.find(x=>x.id===a.id);if(!l)return {};const k=prepSteps(l),n=a.all?k:Math.min(1,k);return {setup:n*prepCost(l),days:Math.min(n*PREP_STEP,Math.max(0,l.ready-prepFloor(l)))};}, + doc:'Hurry the survey, permits and factory of your own subsea cable before laying starts: 30 days sooner per step (all: as fast as money goes), never sooner than the factory can make the cable.'}, layShip:{args:[['id','entityId']],watch:['links.#id'], quote:a=>{const l=S.links.find(x=>x.id===a.id),q=l&&layQuote(l);return q?{setup:q.cost}:{};}, doc:'Book a second lay ship on your own cable before laying starts: it lays from the other end and halves that part of the build.'}, diff --git a/site/i18n/de.js b/site/i18n/de.js index de60b3e..f9d2595 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -423,13 +423,16 @@ "businesses.your_network_diagram_is_a_photo":"Dein Netzplan ist ein Foto von einem Whiteboard.", "businesses.your_noc_has_a_chat_channel":"Dein NOC hat einen Chat-Kanal namens #its-always-the-fiber, und es ist immer die Glasfaser.", "businesses.your_routing_table_needs_its_own":"Deine Routing-Tabelle braucht eine eigene Routing-Tabelle.", +"cable_ships.as_fast_as_money_goes":"So schnell, wie Geld es kann {price} · −{n} Tage", "cable_ships.at_anchor_off_home":"liegt vor {home} vor Anker, binnen eines Tages auslaufbereit.", "cable_ships.book_a_second_lay_ship":"Zweites Verlegeschiff buchen {price} · −{n} Tage", "cable_ships.charter_ship":"{ship} chartern", "cable_ships.every_club_ship_is_out":"Jedes Schiff des {club} ist im Einsatz. Der Schnitt wartet auf das erste, das zurückkommt, oder auf eine private Charter.", +"cable_ships.hurry_the_permits_and_the":"Genehmigungen und Fabrik antreiben {price} · −{n} Tage", "cable_ships.km_of_km":"{km} von {of} km", "cable_ships.lay_ship_tap":"{ship}
Verlegt dein Kabel von {a} nach {b}: {km} von {of} km liegen am Meeresgrund.", "cable_ships.laying_starts_in_n_days":{"one":"Verlegung beginnt in {n} Tag","other":"Verlegung beginnt in {n} Tagen"}, +"cable_ships.money_only_goes_so_far":"Anwälte und Überstunden helfen nur bis zu einem Punkt: Das Kabel muss trotzdem gebaut werden. Bei diesem frühestens {n} Tage nach der Bestellung, dann laufen die Schiffe aus.", "cable_ships.private_at_anchor":"liegt vor {home} vor Anker, zu chartern für alle, die zahlen.", "cable_ships.private_operator":"Privater Betreiber", "cable_ships.sailing_home_to_home":{"one":"auf dem Heimweg nach {home}, in {n} Tag wieder frei.","other":"auf dem Heimweg nach {home}, in {n} Tagen wieder frei."}, @@ -441,6 +444,7 @@ "cable_ships.ship_waits_for_a_permit":"{ship} ist vor Ort und wartet {n} T. auf eine Reparaturgenehmigung. Kabel in etwa {m} T. wieder da.", "cable_ships.ships_lay_the_cable":"{ships} auf See, beim Verlegen", "cable_ships.survey_permits_and_the_cable_factory":"Vermessung, Genehmigungen und die Kabelfabrik", +"cable_ships.the_factory_runs_a_night_shift":{"one":"Die Genehmigungsanwälte haben einen Stempel gefunden und die Fabrik fährt eine Nachtschicht: Das Verlegen beginnt {n} Tag früher.","other":"Die Genehmigungsanwälte haben einen Stempel gefunden und die Fabrik fährt eine Nachtschicht: Das Verlegen beginnt {n} Tage früher."}, "cables.a_bet_on_a_tiny_island":"Eine Wette auf eine winzige Insel mitten im Pazifik.", "cables.a_buffet_of_landings_down_norway":"Ein Buffet aus Anlandungen entlang der norwegischen Küste, von den Ölfeldern bis Oslo.", "cables.a_friendly_cable_with_french_manners":"Ein freundliches Kabel mit französischen Manieren.", diff --git a/site/i18n/es.js b/site/i18n/es.js index 22393f8..193a39f 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -421,13 +421,16 @@ "businesses.your_network_diagram_is_a_photo":"Tu diagrama de red es una foto de una pizarra.", "businesses.your_noc_has_a_chat_channel":"Tu NOC tiene un canal de chat llamado #siempre-es-la-fibra, y siempre es la fibra.", "businesses.your_routing_table_needs_its_own":"Tu tabla de rutas necesita su propia tabla de rutas.", +"cable_ships.as_fast_as_money_goes":"Tan rápido como el dinero permita {price} · −{n} días", "cable_ships.at_anchor_off_home":"fondeado frente a {home}, listo para zarpar en un día.", "cable_ships.book_a_second_lay_ship":"Reservar un segundo buque tendedor {price} · −{n} días", "cable_ships.charter_ship":"Fletar {ship}", "cable_ships.every_club_ship_is_out":"Todos los buques del {club} están en un trabajo. El corte espera al primero que vuelva, o a un flete privado.", +"cable_ships.hurry_the_permits_and_the":"Acelerar permisos y fábrica {price} · −{n} días", "cable_ships.km_of_km":"{km} de {of} km", "cable_ships.lay_ship_tap":"{ship}
Tiende tu cable de {a} a {b}: {km} de {of} km en el fondo del mar.", "cable_ships.laying_starts_in_n_days":{"one":"El tendido empieza en {n} día","other":"El tendido empieza en {n} días"}, +"cable_ships.money_only_goes_so_far":"Los abogados y las horas extra tienen un límite: el cable hay que fabricarlo igual. Para este son al menos {n} días desde el pedido, y luego zarpan los barcos.", "cable_ships.private_at_anchor":"fondeado frente a {home}, en flete para quien pague.", "cable_ships.private_operator":"Operador privado", "cable_ships.sailing_home_to_home":{"one":"volviendo a {home}, libre de nuevo en {n} día.","other":"volviendo a {home}, libre de nuevo en {n} días."}, @@ -439,6 +442,7 @@ "cable_ships.ship_waits_for_a_permit":"{ship} está en el sitio y espera {n} d un permiso de reparación. El cable vuelve en unos {m} d.", "cable_ships.ships_lay_the_cable":"{ships} en el mar, tendiendo", "cable_ships.survey_permits_and_the_cable_factory":"Estudio, permisos y la fábrica de cable", +"cable_ships.the_factory_runs_a_night_shift":{"one":"Los abogados de permisos encontraron un sello y la fábrica hace turno de noche: el tendido empieza {n} día antes.","other":"Los abogados de permisos encontraron un sello y la fábrica hace turno de noche: el tendido empieza {n} días antes."}, "cables.a_bet_on_a_tiny_island":"Una apuesta por una isla diminuta en medio del Pacífico.", "cables.a_buffet_of_landings_down_norway":"Un bufé de aterrizajes por la costa noruega, de los campos petrolíferos a Oslo.", "cables.a_friendly_cable_with_french_manners":"Un cable simpático con modales franceses.", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index 4266251..4950bfc 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -421,13 +421,16 @@ "businesses.your_network_diagram_is_a_photo":"Ton schéma réseau est une photo de tableau blanc.", "businesses.your_noc_has_a_chat_channel":"Ton NOC a un canal de chat nommé #c-est-toujours-la-fibre, et c’est toujours la fibre.", "businesses.your_routing_table_needs_its_own":"Ta table de routage a besoin de sa propre table de routage.", +"cable_ships.as_fast_as_money_goes":"Aussi vite que l'argent le permet {price} · −{n} jours", "cable_ships.at_anchor_off_home":"au mouillage devant {home}, prêt à appareiller en un jour.", "cable_ships.book_a_second_lay_ship":"Réserver un second navire câblier {price} · −{n} jours", "cable_ships.charter_ship":"Affréter {ship}", "cable_ships.every_club_ship_is_out":"Tous les navires du {club} sont en mission. La coupure attend le premier qui rentre, ou un affrètement privé.", +"cable_ships.hurry_the_permits_and_the":"Presser les permis et l'usine {price} · −{n} jours", "cable_ships.km_of_km":"{km} sur {of} km", "cable_ships.lay_ship_tap":"{ship}
Pose ton câble de {a} à {b} : {km} sur {of} km sur le fond.", "cable_ships.laying_starts_in_n_days":{"one":"La pose commence dans {n} jour","other":"La pose commence dans {n} jours"}, +"cable_ships.money_only_goes_so_far":"Les avocats et les heures sup' ont leurs limites : le câble doit quand même être fabriqué. Pour celui-ci, au plus tôt {n} jours après la commande, puis les navires appareillent.", "cable_ships.private_at_anchor":"au mouillage devant {home}, à affréter pour qui paie.", "cable_ships.private_operator":"Opérateur privé", "cable_ships.sailing_home_to_home":{"one":"rentre à {home}, libre dans {n} jour.","other":"rentre à {home}, libre dans {n} jours."}, @@ -439,6 +442,7 @@ "cable_ships.ship_waits_for_a_permit":"{ship} est sur place et attend {n} j un permis de réparation. Câble rétabli dans environ {m} j.", "cable_ships.ships_lay_the_cable":"{ships} en mer, en pose", "cable_ships.survey_permits_and_the_cable_factory":"Relevés, permis et usine de câble", +"cable_ships.the_factory_runs_a_night_shift":{"one":"Les avocats des permis ont trouvé un tampon et l'usine tourne de nuit : la pose commence {n} jour plus tôt.","other":"Les avocats des permis ont trouvé un tampon et l'usine tourne de nuit : la pose commence {n} jours plus tôt."}, "cables.a_bet_on_a_tiny_island":"Un pari sur une minuscule île au milieu du Pacifique.", "cables.a_buffet_of_landings_down_norway":"Un buffet d’atterrissements le long de la côte norvégienne, des champs pétroliers jusqu’à Oslo.", "cables.a_friendly_cable_with_french_manners":"Un câble sympathique aux manières bien françaises.", diff --git a/site/i18n/it.js b/site/i18n/it.js index d6a25d0..e495fad 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -421,13 +421,16 @@ "businesses.your_network_diagram_is_a_photo":"Il tuo schema di rete è la foto di una lavagna.", "businesses.your_noc_has_a_chat_channel":"Il tuo NOC ha un canale chat chiamato #è-sempre-la-fibra, ed è sempre la fibra.", "businesses.your_routing_table_needs_its_own":"La tua tabella di routing ha bisogno di una tabella di routing tutta sua.", +"cable_ships.as_fast_as_money_goes":"Più veloce che i soldi permettono {price} · −{n} giorni", "cable_ships.at_anchor_off_home":"alla fonda davanti a {home}, pronta a salpare entro un giorno.", "cable_ships.book_a_second_lay_ship":"Prenota una seconda nave posacavi {price} · −{n} giorni", "cable_ships.charter_ship":"Noleggia {ship}", "cable_ships.every_club_ship_is_out":"Tutte le navi del {club} sono in missione. Il taglio aspetta la prima che rientra, o un noleggio privato.", +"cable_ships.hurry_the_permits_and_the":"Accelera permessi e fabbrica {price} · −{n} giorni", "cable_ships.km_of_km":"{km} di {of} km", "cable_ships.lay_ship_tap":"{ship}
Posa il tuo cavo da {a} a {b}: {km} di {of} km sul fondale.", "cable_ships.laying_starts_in_n_days":{"one":"La posa inizia tra {n} giorno","other":"La posa inizia tra {n} giorni"}, +"cable_ships.money_only_goes_so_far":"Avvocati e straordinari arrivano fino a un certo punto: il cavo va comunque fabbricato. Per questo servono almeno {n} giorni dall'ordine, poi salpano le navi.", "cable_ships.private_at_anchor":"alla fonda davanti a {home}, a noleggio per chi paga.", "cable_ships.private_operator":"Operatore privato", "cable_ships.sailing_home_to_home":{"one":"rientra a {home}, di nuovo libera tra {n} giorno.","other":"rientra a {home}, di nuovo libera tra {n} giorni."}, @@ -439,6 +442,7 @@ "cable_ships.ship_waits_for_a_permit":"{ship} è sul posto e aspetta {n} g un permesso di riparazione. Cavo di nuovo su tra circa {m} g.", "cable_ships.ships_lay_the_cable":"{ships} in mare, in posa", "cable_ships.survey_permits_and_the_cable_factory":"Rilievi, permessi e fabbrica del cavo", +"cable_ships.the_factory_runs_a_night_shift":{"one":"Gli avvocati dei permessi hanno trovato un timbro e la fabbrica fa il turno di notte: la posa inizia {n} giorno prima.","other":"Gli avvocati dei permessi hanno trovato un timbro e la fabbrica fa il turno di notte: la posa inizia {n} giorni prima."}, "cables.a_bet_on_a_tiny_island":"Una scommessa su un’isoletta in mezzo al Pacifico.", "cables.a_buffet_of_landings_down_norway":"Un buffet di approdi lungo la costa norvegese, dai giacimenti di petrolio fino a Oslo.", "cables.a_friendly_cable_with_french_manners":"Un cavo amichevole con le buone maniere francesi.", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 855dfcc..446141b 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -421,13 +421,16 @@ "businesses.your_network_diagram_is_a_photo":"Seu diagrama de rede é uma foto de um quadro branco.", "businesses.your_noc_has_a_chat_channel":"Seu NOC tem um canal de chat chamado #é-sempre-a-fibra, e é sempre a fibra.", "businesses.your_routing_table_needs_its_own":"Sua tabela de roteamento precisa de uma tabela de roteamento própria.", +"cable_ships.as_fast_as_money_goes":"O mais rápido que o dinheiro permite {price} · −{n} dias", "cable_ships.at_anchor_off_home":"fundeado diante de {home}, pronto para zarpar em um dia.", "cable_ships.book_a_second_lay_ship":"Reservar um segundo navio lançador {price} · −{n} dias", "cable_ships.charter_ship":"Fretar {ship}", "cable_ships.every_club_ship_is_out":"Todos os navios do {club} estão em serviço. O corte espera o primeiro que voltar, ou um frete privado.", +"cable_ships.hurry_the_permits_and_the":"Apressar licenças e fábrica {price} · −{n} dias", "cable_ships.km_of_km":"{km} de {of} km", "cable_ships.lay_ship_tap":"{ship}
Lançando seu cabo de {a} a {b}: {km} de {of} km no fundo do mar.", "cable_ships.laying_starts_in_n_days":{"one":"O lançamento começa em {n} dia","other":"O lançamento começa em {n} dias"}, +"cable_ships.money_only_goes_so_far":"Advogados e horas extras têm limite: o cabo ainda precisa ser fabricado. Para este, pelo menos {n} dias desde o pedido, e depois os navios zarpam.", "cable_ships.private_at_anchor":"fundeado diante de {home}, para frete a quem pagar.", "cable_ships.private_operator":"Operador privado", "cable_ships.sailing_home_to_home":{"one":"voltando para {home}, livre de novo em {n} dia.","other":"voltando para {home}, livre de novo em {n} dias."}, @@ -439,6 +442,7 @@ "cable_ships.ship_waits_for_a_permit":"{ship} está no local e espera {n} d por uma licença de reparo. Cabo de volta em cerca de {m} d.", "cable_ships.ships_lay_the_cable":"{ships} no mar, lançando", "cable_ships.survey_permits_and_the_cable_factory":"Levantamento, licenças e a fábrica de cabo", +"cable_ships.the_factory_runs_a_night_shift":{"one":"Os advogados de licenças acharam um carimbo e a fábrica faz turno da noite: o lançamento começa {n} dia antes.","other":"Os advogados de licenças acharam um carimbo e a fábrica faz turno da noite: o lançamento começa {n} dias antes."}, "cables.a_bet_on_a_tiny_island":"Uma aposta numa ilhota no meio do Pacífico.", "cables.a_buffet_of_landings_down_norway":"Um rodízio de pontos de chegada pela costa norueguesa, dos campos de petróleo até Oslo.", "cables.a_friendly_cable_with_french_manners":"Um cabo simpático com bons modos franceses.", diff --git a/src/game/85-incidents/50-cable-ships.js b/src/game/85-incidents/50-cable-ships.js index a09e9e5..02febde 100644 --- a/src/game/85-incidents/50-cable-ships.js +++ b/src/game/85-incidents/50-cable-ships.js @@ -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.dayclamp((T-layStart(l))/layLen(l),0,1); diff --git a/src/game/90-actions/87-fiber-and-hardware.js b/src/game/90-actions/87-fiber-and-hardware.js index 9befa30..c7fd8e2 100644 --- a/src/game/90-actions/87-fiber-and-hardware.js +++ b/src/game/90-actions/87-fiber-and-hardware.js @@ -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();}, diff --git a/src/game/93-ui/70-link-panels.js b/src/game/93-ui/70-link-panels.js index c64aa1d..dcd5491 100644 --- a/src/game/93-ui/70-link-panels.js +++ b/src/game/93-ui/70-link-panels.js @@ -105,6 +105,9 @@ const shipNote=i=>{const t=i&&shipStatus(i);return t?`

🚢 ${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${tr('cable_ships.survey_permits_and_the_cable_factory')}${trn('cable_ships.laying_starts_in_n_days',st-d)}` :`

${tr('cable_ships.ships_lay_the_cable',{ships:esc(two)})}${tr('cable_ships.km_of_km',{km:km.toLocaleString(),of:Math.round(l.km).toLocaleString()})}
`; + const k=prepSteps(l),pc=prepCost(l),fast=Math.min(k*PREP_STEP,l.ready-prepFloor(l)); + if(k)h+=`
${btn(tr('cable_ships.hurry_the_permits_and_the',{n:Math.min(PREP_STEP,fast),price:fmt$(pc)}),'seaRush',{id:l.id},'sm',S.cash1?btn(tr('cable_ships.as_fast_as_money_goes',{n:fast,price:fmt$(k*pc)}),'seaRush',{id:l.id,all:1},'sm',S.cash`; + if(d${tr('cable_ships.money_only_goes_so_far',{n:prepMin(l)})}

`; if(q)h+=`
${btn(tr('cable_ships.book_a_second_lay_ship',{price:fmt$(q.cost),n:q.save}),'layShip',{id:l.id},'sm',S.cash

${tr('link_panels.only_a_few_dozen_cable_ships')}

`; else if(!l.ship2&&d${tr('link_panels.only_a_few_dozen_cable_ships')}

`; return h;} diff --git a/src/i18n/en.js b/src/i18n/en.js index 53e9910..b554937 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -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 {price} · −{n} days", "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 {price} · −{n} days", "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 {price} · −{n} days", "cable_ships.km_of_km":"{km} of {of} km", "cable_ships.lay_ship_tap":"{ship}
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.", diff --git a/tests/mcp-commands.test.js b/tests/mcp-commands.test.js index 566da68..5c336ce 100644 --- a/tests/mcp-commands.test.js +++ b/tests/mcp-commands.test.js @@ -225,7 +225,7 @@ test('a dry run prices every command that has a price, and changes nothing', () crews: { id: df }, addCh: { id: df, o: 'zr4' }, addPair: { id: df }, upSys: { id: df }, regen: { id: df, d: 1 }, buySpare: { o: 'zr4' }, sellSpare: { o: 'zr4' }, setChCount: { id: df, o: 'zr4', n: 2 }, repayLoan: { id: 'none' }, buildScrub: { city: 'ams', tier: 1 }, scrubUp: { city: 'fra', tier: 1 }, fixInc: { id: 'none' }, confGo: { key: T('catalog', { name: 'conferences' })[0].key }, confSponsor: { key: T('catalog', { name: 'conferences' })[0].key }, - opsHire: { id: ev('Object.keys(INTERNS)[0]') }, opsNewPop: { city: 'nyc' }, pniAll: { net: 'cog', tier: 1 }, seatBuy: { n: 2 }, layShip: { id: df }, + opsHire: { id: ev('Object.keys(INTERNS)[0]') }, opsNewPop: { city: 'nyc' }, pniAll: { net: 'cog', tier: 1 }, seatBuy: { n: 2 }, layShip: { id: df }, seaRush: { id: df }, utilityKit: { city: 'fra' }, utilityCaches: { city: 'fra' }, teDeploy: { script: 'spill at 85%' }, upLinkX: {}, }; const missing = quoted.filter((n) => !sample[n] && T('schema', { section: 'commands' })[n].args.some((a) => a.required)); diff --git a/tests/sea-rush.test.js b/tests/sea-rush.test.js new file mode 100644 index 0000000..77f8afe --- /dev/null +++ b/tests/sea-rush.test.js @@ -0,0 +1,51 @@ +// #258: money hurries the survey, permits and factory of your own subsea cable, 30 days a step, but never below what the +// factory needs to make the cable (two months plus a day per 80 km); the lay ships still sail after that. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +const start = "ACT.start({});S.cash=1e9;S.lvl=13;S.day=200;S.nextFail=S.nextEvent=1e8;for(const g of GOALS)S.done[g.id]=0;"; +const own = (km, ready) => `S.links=[{id:'own',a:'lag',b:'bde',kind:'df',own:true,sub:true,sys:'roadm',km:${km},ch:[],day:200,ready:${ready},cut:0,mo:1}];`; + +test('#258 paying hurries the permits and the factory, 30 days a step, down to what the factory needs', () => { + const { ev, dom, errors } = load(); + ev(start + own(6000, 800)); + // 6000 km: 60 + 72 days to make it, then 40 days at sea. + assert.equal(ev('prepMin(S.links[0])'), 132); + assert.equal(ev('prepFloor(S.links[0])'), 200 + 132 + 40); + assert.equal(ev('prepSteps(S.links[0])'), 15); + ev("UI.sel={type:'link',id:'own'};renderPanel()"); + const panel = () => dom.window.document.querySelector('#panelBody').textContent; + assert.match(panel(), /Hurry the permits and the factory/); + assert.match(panel(), /As fast as money goes/); + assert.match(panel(), /132 days from the order at the soonest/); + const step = ev('prepCost(S.links[0])'), cash = ev('S.cash'); + ev("ACT.seaRush({id:'own'})"); + assert.equal(ev('S.links[0].ready'), 770, 'one step: 30 days sooner'); + assert.equal(cash - ev('S.cash'), step); + ev("ACT.seaRush({id:'own',all:1})"); + assert.equal(ev('S.links[0].ready'), 372, 'all the way: the factory floor, then the ships'); + assert.equal(cash - ev('S.cash'), 15 * step); + assert.equal(ev('layStart(S.links[0])'), 332); + assert.equal(ev('prepSteps(S.links[0])'), 0, 'no faster than that'); + ev("ACT.seaRush({id:'own'})"); + assert.equal(cash - ev('S.cash'), 15 * step, 'and nothing more is charged'); + // The second lay ship still halves the time at sea on top. + ev("ACT.layShip({id:'own'})"); + assert.equal(ev('S.links[0].ready'), 352); + assert.deepEqual(errors, []); +}); + +test('#258 a short cable is quick; once the ships sail, money buys no more paperwork', () => { + const { ev, errors } = load(); + ev(start + own(800, 600)); + assert.equal(ev('prepMin(S.links[0])'), 70, 'a short hop: a couple of months'); + ev("ACT.seaRush({id:'own',all:1})"); + assert.equal(ev('S.links[0].ready'), 200 + 70 + 6); + ev(start + own(6000, 800) + 'S.day=770'); + assert.equal(ev('prepSteps(S.links[0])'), 0, 'laying has started'); + const cash = ev('S.cash'); + ev("ACT.seaRush({id:'own'})"); + assert.equal(ev('S.cash'), cash); + assert.deepEqual(errors, []); +});