diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 14bb4b4..aedb380 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -2,7 +2,7 @@ blank_issues_enabled: false contact_links: - name: Chat with other players on Signal url: https://signal.group/#CjQKIJwvEt5fYt1pvw7J2pV664CyUyGJXmAJLV8ia3nUdAD7EhA_FzdxflEzkNmcvDHdVgLQ - about: Screenshots, chat and peering-policy flame wars. Bugs, ideas and anything meaningful still go here as issues. + about: Screenshots, chat and peering-policy flame wars. Bugs and ideas go here as issues, so they don't scroll away. - name: How the internet really works url: https://tkjaer.github.io/how-the-internet-works/ about: Curious how the real thing works? This interactive map explains it far better than any game. diff --git a/CHANGELOG.md b/CHANGELOG.md index 40263ab..bb5e9fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,18 @@ All notable changes to this project are documented here. The project follows - Order PNIs with one network or every network at all shared POPs from the NOC Traffic tab: choose a port size, review the total cost, and add missing connections or upgrade smaller ones in one go. +## [1.36.0] — 2026-10-28 + +- You can put a link on standby, so one of two links between the same cities sits idle as a backup (#122). It carries traffic only when the other links are full or down, so its capacity is never wasted, and the map draws it dashed while it waits. The routing metric still applies to every link between the two cities. +- Start anywhere: the new game screen lists the five suggested home cities as a compact stack, and the last entry lets you pick any city on the map that sells transit, grouped by continent. Below the big start button, How to play, Import a save and Settings are now the same size. +- Language is now a dropdown on the title screen and in Settings, with each language named in itself. On phones it opens the system picker. +- Every new network starts at ½ speed, so you can find your feet before the bills arrive (#186). Saved games still continue at the speed you left them. + +## [1.35.1] — 2026-10-28 + +- Subsea cables stay at sea: Pacific cables no longer draw a line across the whole world where the map wraps round (#183), and over 170 cable routes that cut across Africa, Arabia, India, Brazil and other coasts now follow the sea. Cables into inland cities like Paris, Dublin and Hong Kong come ashore at the nearest coast. +- Found a bug or have an idea? The menu and How to play now link straight to the forms on GitHub, where every report is tracked. The Signal group stays for chatting. + ## [1.35.0] — 2026-10-27 - Series of Tubes now speaks Spanish. The game follows your browser's language the first time, and you can switch to Spanish under Settings or on the title screen. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index fd5769d..1e0ed07 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -106,8 +106,10 @@ never freezes the game. ## compute(): the traffic model 1. Builds a graph from your live links: parallel links between the same two cities - merge into one edge with summed capacity. Link metrics set weights; Dijkstra gives - shortest paths from each POP. + merge into one edge with summed capacity. The routing metric belongs to the city pair + (`S.pairMet`) and sets the edge's weight; Dijkstra gives shortest paths from each POP. + Links on standby (`l.standby`) add their capacity to the edge, but when loads are + handed back to links the active ones fill first and standby links take the rest. 2. Builds the exit list `E`: embedded caches (rank 0), PNIs (1), IX ports (2), transit (3). Each exit has a capacity, the networks it can reach (`ok(net)`) and an egress preference (`high`, `normal`, `low` = backup only). diff --git a/package-lock.json b/package-lock.json index 507548d..b0b4c4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "seriesoftubes", - "version": "1.35.0", + "version": "1.36.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "seriesoftubes", - "version": "1.35.0", + "version": "1.36.0", "license": "MIT", "devDependencies": { "jsdom": "24.1.3", diff --git a/package.json b/package.json index 1d77c7b..e9dff8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "seriesoftubes", - "version": "1.35.0", + "version": "1.36.0", "description": "A cartoon browser game about building the internet.", "private": true, "license": "MIT", diff --git a/site/i18n/es.js b/site/i18n/es.js index 06a16dd..970e705 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -1249,6 +1249,7 @@ "common.spreadsheet_ipam":"IPAM en hoja de cálculo", "common.stage_six":"Fase seis", "common.standard":"Estándar", +"common.standby":"En espera", "common.start_a_new_network":"Empezar una red nueva", "common.start_building":"Empezar a construir", "common.start_construction":"Empezar la construcción", @@ -2092,6 +2093,7 @@ "link_modal.waves_on_the_same_route_share":"Las ondas de la misma ruta comparten su suerte: una retroexcavadora las corta todas.", "link_modal.you_already_have_n_link_here":{"one":"Ya tienes {n} enlace aquí ({list}). Los enlaces paralelos suman capacidad. ¿Cómo debe enrutarse este?","other":"Ya tienes {n} enlaces aquí ({list}). Los enlaces paralelos suman capacidad. ¿Cómo debe enrutarse este?"}, "link_panels.a_bigger_fabric_carries_more_traffic":"Una fabric mayor transporta más tráfico y tiene sitio para más miembros. Tu router de aquí aún tiene que aguantar el ritmo.", +"link_panels.a_link_on_standby_carries_traffic":"Un enlace en espera solo lleva tráfico cuando los demás enlaces entre estas ciudades están llenos o caídos.", "link_panels.a_regen_site_turns_the_light":"Un sitio regenerador convierte la luz de nuevo en bits a mitad de camino y la envía renovada, así que las ópticas solo tienen que llegar al siguiente sitio. Cada uno necesita una tarjeta regeneradora por cada canal iluminado. {price}/mes por sitio por la caseta.", "link_panels.abandon_the_fiber":"Abandonar la fibra", "link_panels.add_parallel_link":"Añadir enlace paralelo", @@ -2151,6 +2153,9 @@ "link_panels.not_present_in_any_of_your":"Aún no está presente en ninguna de tus ciudades", "link_panels.nothing_spare_to_sell_on_this":"Ahora mismo no queda nada que vender en esta fibra.", "link_panels.off_while_your_peering_policy_is":"Desactivado mientras tu política de peering sea {pol}", +"link_panels.on_standby_but_carrying_the_traffic":"En espera, pero lleva el tráfico: ningún enlace activo entre estas ciudades funciona.", +"link_panels.on_standby_idle_while_the_other":"En espera: inactivo mientras los demás enlaces entre estas ciudades tengan sitio.", +"link_panels.on_standby_taking_the_overflow":"En espera: lleva el desbordamiento, porque los demás enlaces entre estas ciudades están llenos.", "link_panels.open_peer_but_not_on_any":"Open peer, pero no en ningún IX donde tengas POP. Más cercano: {city}", "link_panels.open_peer_but_not_on_any_bfbb":"Open peer, pero no en ningún IX donde tengas POP", "link_panels.open_peer_join_the_route_server":"Open peer: únete al route server de {ix}", @@ -2168,6 +2173,7 @@ "link_panels.ports_at_p_of_the_usual":"Puertos al {p} % del precio habitual.", "link_panels.ports_up_to_port_are_free":"Los puertos hasta {port} son gratis.", "link_panels.price_n_days":"{price} · {n} días", +"link_panels.put_this_link_on_standby":"Poner este enlace en espera", "link_panels.ready_for_a_pni_in_city":"Listo para un PNI en {city}", "link_panels.ready_in_n_days":"Listo en {n} días", "link_panels.really_give_it_up":"¿Renunciar de verdad?", @@ -2190,6 +2196,7 @@ "link_panels.spares_kit_on":"Kit de repuestos activo ✓", "link_panels.stock_a_spare_optic_price":"Tener una {optic} de repuesto {price}", "link_panels.sys_level_n":"{sys} nivel {n}", +"link_panels.take_it_off_standby":"Sacarlo de la espera", "link_panels.there_s_no_ix_in_city":"Aún no hay IX en {city}. Funda uno: las redes se unen con el tiempo, te pagan por los puertos y hacen peering contigo gratis.", "link_panels.they_need_the_full_internet_your":"Necesitan todo internet. Tu alcance es del {pct}.", "link_panels.this_fiber_is_dark_add_optics":"Esta fibra está a oscuras. Añade ópticas abajo para transportar tráfico.", @@ -2349,8 +2356,11 @@ "mergers.net_charges_for_peering":"{net} cobra por el peering, así que cuenta con una cuota mensual.", "mergers.net_has_swallowed_old":"{net} se ha tragado a {old}.", "mergers.now_part_of_net":"Ahora forma parte de {net}: haz peering con ellos.", +"modal_and_names.found_a_bug_or_have_an":"¿Has encontrado un fallo o tienes una idea?", "modal_and_names.join_the_noc_chat":"Únete al chat del NOC", -"modal_and_names.our_signal_group_swap_screenshots":"Nuestro grupo de Signal: intercambia capturas, informa de fallos y discute sobre política de peering con otros jugadores. Menos retroexcavadoras que en la vida real.", +"modal_and_names.open":"Abrir →", +"modal_and_names.our_signal_group_screenshots_chat":"Nuestro grupo de Signal: intercambia capturas y discute sobre política de peering con otros jugadores. Menos retroexcavadoras que en la vida real.", +"modal_and_names.tell_us_on_github_a_short":"Cuéntanoslo en GitHub: un formulario corto para fallos, ideas, equilibrio y traducciones. Los leemos todos.", "modal_and_names.the_real_thing_by_thomas_kj":"Lo de verdad, de Thomas Kjær Aabo: un mapa interactivo con zoom de cómo viajan realmente tus paquetes, del Wi-Fi a la fibra submarina, hoy, en 2010 y en 1995. Este juego se lo inventa sobre la marcha. Ese lo hace bien.", "modal_and_names.the_real_thing_follow_a_packet":"Lo de verdad: sigue un paquete del Wi-Fi a la fibra submarina.", "modals.lay_your_own_subsea_cable":"Tender tu propio cable submarino…", @@ -3022,16 +3032,19 @@ "supply_chain.until_date_at_p":"hasta {date}, a +{p}", "supply_chain.what_p_n_days_left":"{what} +{p} · quedan {n} días", "supply_chain.your_price_lock_covers_you_until":"Tu precio fijo te cubre hasta {date}.", +"title.anywhere_else":"En otro lugar", "title.asia_hub_great_peering_far_from":"Hub de Asia. Gran peering, lejos de casa.", "title.back_to_my_network":"Volver a mi red", "title.big_hungry_market_few_providers":"Mercado enorme y hambriento, pocos proveedores.", "title.build_an_internet_lay_fiber_between":"Construye un internet. Tiende fibra entre ciudades, compra tránsito, haz peering en intercambios, firma con empresas y mantén contentos a los eyeballs mientras retroexcavadoras, tiburones y fugas de rutas hacen lo posible por detenerte.", "title.chat_on_signal":"Chatea en Signal", +"title.choose":"Elegir…", "title.continue_name_date":"Continuar {name} · {date}", "title.cookieless_stats_no_tracking":"Estadísticas sin cookies, sin rastreo", "title.crossroads_of_europe_de_kicks_ix":"La encrucijada de Europa. DE-KICKS IX, tránsito barato.", -"title.hard_mode_everything_overseas_costs":"Modo difícil. Todo lo de ultramar cuesta una fortuna, los locales pagan un dineral, sobre todo a la Nearly Broadband Network, y todo lo demás intenta matarte.", +"title.hard_mode_pricey_everything":"Modo difícil. Todo carísimo, y la fauna te quiere muerto.", "title.huge_eyeball_market_pricey":"Mercado enorme de eyeballs. Vecinos caros.", +"title.n_more_cities_with_transit":{"one":"{n} ciudad más con tránsito a la venta","other":"{n} ciudades más con tránsito a la venta"}, "title.name_your_network":"Ponle nombre a tu red", "title.new_in_series_of_tubes_v":"Novedades de Series of Tubes {v}", "title.pick_your_home_city":"Elige tu ciudad de origen", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index 882a336..d311828 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -1249,6 +1249,7 @@ "common.spreadsheet_ipam":"IPAM sur tableur", "common.stage_six":"Stade six", "common.standard":"Standard", +"common.standby":"En attente", "common.start_a_new_network":"Créer un nouveau réseau", "common.start_building":"Commencer à construire", "common.start_construction":"Lancer les travaux", @@ -2092,6 +2093,7 @@ "link_modal.waves_on_the_same_route_share":"Les longueurs d’onde d’un même parcours partagent son sort : une pelleteuse les coupe toutes.", "link_modal.you_already_have_n_link_here":{"one":"Tu as déjà {n} lien ici ({list}). Les liens parallèles ajoutent de la capacité. Par où faire passer celui-ci ?","other":"Tu as déjà {n} liens ici ({list}). Les liens parallèles ajoutent de la capacité. Par où faire passer celui-ci ?"}, "link_panels.a_bigger_fabric_carries_more_traffic":"Un fabric plus gros transporte plus de trafic et accueille plus de membres. Ton routeur ici doit quand même suivre.", +"link_panels.a_link_on_standby_carries_traffic":"Un lien en attente ne porte du trafic que lorsque les autres liens entre ces villes sont pleins ou coupés.", "link_panels.a_regen_site_turns_the_light":"Un site de régénération reconvertit la lumière en bits à mi-chemin et la renvoie toute fraîche, donc les optiques n’ont qu’à atteindre le site suivant. Chacun demande une carte de régénération par canal allumé. {price}/mois par site pour l’abri.", "link_panels.abandon_the_fiber":"Abandonner la fibre", "link_panels.add_parallel_link":"Ajouter un lien parallèle", @@ -2151,6 +2153,9 @@ "link_panels.not_present_in_any_of_your":"Pas encore présent dans tes villes", "link_panels.nothing_spare_to_sell_on_this":"Rien à vendre sur cette fibre pour l’instant.", "link_panels.off_while_your_peering_policy_is":"Désactivé tant que votre politique de peering est {pol}", +"link_panels.on_standby_but_carrying_the_traffic":"En attente, mais il porte le trafic : aucun lien actif entre ces villes ne fonctionne.", +"link_panels.on_standby_idle_while_the_other":"En attente : au repos tant que les autres liens entre ces villes ont de la place.", +"link_panels.on_standby_taking_the_overflow":"En attente : il prend le débordement, car les autres liens entre ces villes sont pleins.", "link_panels.open_peer_but_not_on_any":"Peer ouvert, mais sur aucun IX où tu as un POP. Le plus proche : {city}", "link_panels.open_peer_but_not_on_any_bfbb":"Peer ouvert, mais sur aucun IX où tu as un POP", "link_panels.open_peer_join_the_route_server":"Peer ouvert : rejoins le route server de {ix}", @@ -2168,6 +2173,7 @@ "link_panels.ports_at_p_of_the_usual":"Ports à {p} % du prix habituel.", "link_panels.ports_up_to_port_are_free":"Les ports jusqu’à {port} sont gratuits.", "link_panels.price_n_days":"{price} · {n} jours", +"link_panels.put_this_link_on_standby":"Mettre ce lien en attente", "link_panels.ready_for_a_pni_in_city":"Prêt pour un PNI à {city}", "link_panels.ready_in_n_days":"Prêt dans {n} jours", "link_panels.really_give_it_up":"Vraiment y renoncer ?", @@ -2190,6 +2196,7 @@ "link_panels.spares_kit_on":"Kit de rechange actif ✓", "link_panels.stock_a_spare_optic_price":"Stocker un {optic} de rechange {price}", "link_panels.sys_level_n":"{sys} niveau {n}", +"link_panels.take_it_off_standby":"Le sortir de l’attente", "link_panels.there_s_no_ix_in_city":"Pas encore d’IX à {city}. Fondes-en un : les réseaux te rejoignent peu à peu, te paient leurs ports et font du peering gratuit avec toi.", "link_panels.they_need_the_full_internet_your":"Ils veulent tout Internet. Ta couverture est de {pct}.", "link_panels.this_fiber_is_dark_add_optics":"Cette fibre est éteinte. Ajoute des optiques ci-dessous pour transporter du trafic.", @@ -2349,8 +2356,11 @@ "mergers.net_charges_for_peering":"{net} fait payer le peering : attends-toi à un coût mensuel.", "mergers.net_has_swallowed_old":"{net} a avalé {old}.", "mergers.now_part_of_net":"Fait désormais partie de {net} : fais du peering avec eux à la place.", +"modal_and_names.found_a_bug_or_have_an":"Un bug ou une idée ?", "modal_and_names.join_the_noc_chat":"Rejoins le chat du NOC", -"modal_and_names.our_signal_group_swap_screenshots":"Notre groupe Signal : échange des captures d’écran, signale des bugs et dispute-toi sur les politiques de peering avec d’autres joueurs. Moins de pelleteuses qu’en vrai.", +"modal_and_names.open":"Ouvrir →", +"modal_and_names.our_signal_group_screenshots_chat":"Notre groupe Signal : échange des captures d’écran et dispute-toi sur les politiques de peering avec d’autres joueurs. Moins de pelleteuses qu’en vrai.", +"modal_and_names.tell_us_on_github_a_short":"Dis-le-nous sur GitHub : un court formulaire pour les bugs, les idées, l’équilibrage et les traductions. On les lit tous.", "modal_and_names.the_real_thing_by_thomas_kj":"La version réelle, par Thomas Kjær Aabo : une carte interactive et zoomable du vrai trajet de tes paquets, du Wi-Fi à la fibre sous-marine, aujourd’hui, en 2010 et en 1995. Ce jeu invente au fur et à mesure. Celle-là, elle a tout bon.", "modal_and_names.the_real_thing_follow_a_packet":"La version réelle : suis un paquet du Wi-Fi à la fibre sous-marine.", "modals.lay_your_own_subsea_cable":"Pose ton propre câble sous-marin…", @@ -3022,16 +3032,19 @@ "supply_chain.until_date_at_p":"jusqu’au {date}, à +{p}", "supply_chain.what_p_n_days_left":"{what} +{p} · encore {n} jours", "supply_chain.your_price_lock_covers_you_until":"Votre blocage des prix vous couvre jusqu’au {date}.", +"title.anywhere_else":"Ailleurs", "title.asia_hub_great_peering_far_from":"Hub de l’Asie. Super peering, loin de chez soi.", "title.back_to_my_network":"Retour à mon réseau", "title.big_hungry_market_few_providers":"Gros marché affamé, peu d’opérateurs.", "title.build_an_internet_lay_fiber_between":"Construis un Internet. Pose de la fibre entre les villes, achète du transit, fais du peering aux IX, signe des entreprises et garde les eyeballs contents pendant que pelleteuses, requins et fuites de routes font tout pour t’arrêter.", "title.chat_on_signal":"Discuter sur Signal", +"title.choose":"Choisir…", "title.continue_name_date":"Continuer {name} · {date}", "title.cookieless_stats_no_tracking":"Stats sans cookies, sans pistage", "title.crossroads_of_europe_de_kicks_ix":"Carrefour de l’Europe. IX DE-KICKS, transit pas cher.", -"title.hard_mode_everything_overseas_costs":"Mode difficile. Tout ce qui part à l’étranger coûte une fortune, les gens d’ici paient le prix fort, surtout à la Nearly Broadband Network, et tout le reste essaie de te tuer.", +"title.hard_mode_pricey_everything":"Mode difficile. Tout coûte cher, et la faune veut ta peau.", "title.huge_eyeball_market_pricey":"Énorme marché d’eyeballs. Voisins chers.", +"title.n_more_cities_with_transit":{"one":"{n} autre ville où acheter du transit","other":"{n} autres villes où acheter du transit"}, "title.name_your_network":"Nomme ton réseau", "title.new_in_series_of_tubes_v":"Nouveautés de Series of Tubes {v}", "title.pick_your_home_city":"Choisis ta ville de départ", diff --git a/site/i18n/it.js b/site/i18n/it.js index 6ad0307..965cf19 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -1249,6 +1249,7 @@ "common.spreadsheet_ipam":"IPAM su foglio di calcolo", "common.stage_six":"Fase sei", "common.standard":"Standard", +"common.standby":"Standby", "common.start_a_new_network":"Crea una nuova rete", "common.start_building":"Inizia a costruire", "common.start_construction":"Avvia i lavori", @@ -2092,6 +2093,7 @@ "link_modal.waves_on_the_same_route_share":"Le wave sullo stesso percorso ne condividono la sorte: una ruspa le taglia tutte.", "link_modal.you_already_have_n_link_here":{"one":"Hai già {n} link qui ({list}). I link paralleli aggiungono capacità. Che percorso deve fare questo?","other":"Hai già {n} link qui ({list}). I link paralleli aggiungono capacità. Che percorso deve fare questo?"}, "link_panels.a_bigger_fabric_carries_more_traffic":"Un fabric più grande porta più traffico e ha posto per più membri. Il tuo router qui deve comunque starci dietro.", +"link_panels.a_link_on_standby_carries_traffic":"Un link in standby porta traffico solo quando gli altri link tra queste città sono pieni o giù.", "link_panels.a_regen_site_turns_the_light":"Un sito di rigenerazione riconverte la luce in bit a metà strada e la rimanda fresca, così le ottiche devono arrivare solo al sito successivo. Ognuno richiede una scheda di rigenerazione per ogni canale acceso. {price}/mese a sito per la casupola.", "link_panels.abandon_the_fiber":"Abbandona la fibra", "link_panels.add_parallel_link":"Aggiungi link parallelo", @@ -2151,6 +2153,9 @@ "link_panels.not_present_in_any_of_your":"Non è ancora presente in nessuna delle tue città", "link_panels.nothing_spare_to_sell_on_this":"Per ora non c’è niente da vendere su questa fibra.", "link_panels.off_while_your_peering_policy_is":"Spento finché la tua politica di peering è {pol}", +"link_panels.on_standby_but_carrying_the_traffic":"In standby, ma porta il traffico: nessun link attivo tra queste città funziona.", +"link_panels.on_standby_idle_while_the_other":"In standby: a riposo finché gli altri link tra queste città hanno spazio.", +"link_panels.on_standby_taking_the_overflow":"In standby: prende il traffico in eccesso, perché gli altri link tra queste città sono pieni.", "link_panels.open_peer_but_not_on_any":"Peer aperto, ma non su nessun IX dove hai un POP. Il più vicino: {city}", "link_panels.open_peer_but_not_on_any_bfbb":"Peer aperto, ma non su nessun IX dove hai un POP", "link_panels.open_peer_join_the_route_server":"Peer aperto: entra nel route server di {ix}", @@ -2168,6 +2173,7 @@ "link_panels.ports_at_p_of_the_usual":"Porte al {p}% del prezzo normale.", "link_panels.ports_up_to_port_are_free":"Le porte fino a {port} sono gratis.", "link_panels.price_n_days":"{price} · {n} giorni", +"link_panels.put_this_link_on_standby":"Metti questo link in standby", "link_panels.ready_for_a_pni_in_city":"Pronto per un PNI a {city}", "link_panels.ready_in_n_days":"Pronto tra {n} giorni", "link_panels.really_give_it_up":"Rinunciare davvero?", @@ -2190,6 +2196,7 @@ "link_panels.spares_kit_on":"Kit ricambi attivo ✓", "link_panels.stock_a_spare_optic_price":"Metti da parte un {optic} di scorta {price}", "link_panels.sys_level_n":"{sys} livello {n}", +"link_panels.take_it_off_standby":"Toglilo dallo standby", "link_panels.there_s_no_ix_in_city":"A {city} non c’è ancora un IX. Fondane uno: le reti si uniscono col tempo, ti pagano le porte e fanno peering con te gratis.", "link_panels.they_need_the_full_internet_your":"Vogliono internet per intero. La tua copertura è del {pct}.", "link_panels.this_fiber_is_dark_add_optics":"Questa fibra è spenta. Aggiungi le ottiche qui sotto per trasportare traffico.", @@ -2349,8 +2356,11 @@ "mergers.net_charges_for_peering":"{net} fa pagare il peering, quindi aspettati un canone mensile.", "mergers.net_has_swallowed_old":"{net} si è mangiata {old}.", "mergers.now_part_of_net":"Ora fa parte di {net}: fai peering con loro.", +"modal_and_names.found_a_bug_or_have_an":"Hai trovato un bug o hai un'idea?", "modal_and_names.join_the_noc_chat":"Entra nella chat del NOC", -"modal_and_names.our_signal_group_swap_screenshots":"Il nostro gruppo Signal: scambia screenshot, segnala bug e litiga sulle politiche di peering con altri giocatori. Meno ruspe che nella realtà.", +"modal_and_names.open":"Apri →", +"modal_and_names.our_signal_group_screenshots_chat":"Il nostro gruppo Signal: scambia screenshot e litiga sulle politiche di peering con altri giocatori. Meno ruspe che nella realtà.", +"modal_and_names.tell_us_on_github_a_short":"Raccontacelo su GitHub: un breve modulo per bug, idee per nuove funzioni, bilanciamento e traduzioni. Li leggiamo tutti.", "modal_and_names.the_real_thing_by_thomas_kj":"La versione vera, di Thomas Kjær Aabo: una mappa interattiva e zoomabile di come viaggiano davvero i tuoi pacchetti, dal Wi-Fi alla fibra sottomarina, oggi, nel 2010 e nel 1995 (in inglese, danese e tedesco). Questo gioco se lo inventa strada facendo. Quello ci azzecca.", "modal_and_names.the_real_thing_follow_a_packet":"La versione vera: segui un pacchetto dal Wi-Fi alla fibra sottomarina.", "modals.lay_your_own_subsea_cable":"Posa il tuo cavo sottomarino…", @@ -3022,16 +3032,19 @@ "supply_chain.until_date_at_p":"fino al {date}, a +{p}", "supply_chain.what_p_n_days_left":"{what} +{p} · {n} giorni rimasti", "supply_chain.your_price_lock_covers_you_until":"Il tuo blocco dei prezzi ti copre fino al {date}.", +"title.anywhere_else":"Altrove", "title.asia_hub_great_peering_far_from":"Hub dell’Asia. Ottimo peering, lontano da casa.", "title.back_to_my_network":"Torna alla mia rete", "title.big_hungry_market_few_providers":"Mercato grande e affamato, pochi provider.", "title.build_an_internet_lay_fiber_between":"Costruisci un internet. Posa fibra tra le città, compra transit, fai peering agli exchange, metti sotto contratto le aziende e tieni contenti gli eyeball, mentre ruspe, squali e route leak fanno di tutto per fermarti.", "title.chat_on_signal":"Chat su Signal", +"title.choose":"Scegli…", "title.continue_name_date":"Continua {name} · {date}", "title.cookieless_stats_no_tracking":"Statistiche senza cookie, nessun tracciamento", "title.crossroads_of_europe_de_kicks_ix":"Crocevia d’Europa. IX DE-KICKS, transit economico.", -"title.hard_mode_everything_overseas_costs":"Modalità difficile. Tutto ciò che va all’estero costa una fortuna, la gente del posto paga cifre altissime, soprattutto alla Nearly Broadband Network, e tutto il resto cerca di ucciderti.", +"title.hard_mode_pricey_everything":"Modalità difficile. Tutto carissimo, e la fauna ti vuole morto.", "title.huge_eyeball_market_pricey":"Enorme mercato di eyeball. Vicini costosi.", +"title.n_more_cities_with_transit":{"one":"Ancora {n} città dove comprare transit","other":"Altre {n} città dove comprare transit"}, "title.name_your_network":"Dai un nome alla tua rete", "title.new_in_series_of_tubes_v":"Novità di Series of Tubes {v}", "title.pick_your_home_city":"Scegli la tua città di partenza", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index e3fd3ba..9f43be6 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -1249,6 +1249,7 @@ "common.spreadsheet_ipam":"IPAM em planilha", "common.stage_six":"Estágio seis", "common.standard":"Padrão", +"common.standby":"Reserva", "common.start_a_new_network":"Começar uma nova rede", "common.start_building":"Começar a construir", "common.start_construction":"Iniciar obra", @@ -2092,6 +2093,7 @@ "link_modal.waves_on_the_same_route_share":"Waves na mesma rota compartilham o destino: uma retroescavadeira corta todas.", "link_modal.you_already_have_n_link_here":{"one":"Você já tem {n} link aqui ({list}). Links paralelos somam capacidade. Como este deve ser roteado?","other":"Você já tem {n} links aqui ({list}). Links paralelos somam capacidade. Como este deve ser roteado?"}, "link_panels.a_bigger_fabric_carries_more_traffic":"Um fabric maior carrega mais tráfego e tem espaço para mais membros. Seu router aqui ainda precisa dar conta.", +"link_panels.a_link_on_standby_carries_traffic":"Um link de reserva só leva tráfego quando os outros links entre estas cidades estão cheios ou fora do ar.", "link_panels.a_regen_site_turns_the_light":"Um site de regeneração transforma a luz de volta em bits no meio do caminho e a reenvia novinha, então as ópticas só precisam alcançar o próximo site. Cada um precisa de uma placa de regeneração para cada canal aceso. {price}/mês por site pelo abrigo.", "link_panels.abandon_the_fiber":"Abandonar a fibra", "link_panels.add_parallel_link":"Adicionar link paralelo", @@ -2151,6 +2153,9 @@ "link_panels.not_present_in_any_of_your":"Ainda não está em nenhuma das suas cidades", "link_panels.nothing_spare_to_sell_on_this":"Nada sobrando para vender nesta fibra por enquanto.", "link_panels.off_while_your_peering_policy_is":"Desligado enquanto sua política de peering for {pol}", +"link_panels.on_standby_but_carrying_the_traffic":"De reserva, mas levando o tráfego: nenhum link ativo entre estas cidades está no ar.", +"link_panels.on_standby_idle_while_the_other":"De reserva: ocioso enquanto os outros links entre estas cidades tiverem espaço.", +"link_panels.on_standby_taking_the_overflow":"De reserva: levando o excedente, porque os outros links entre estas cidades estão cheios.", "link_panels.open_peer_but_not_on_any":"Peer aberto, mas em nenhum IX onde você tem POP. O mais próximo: {city}", "link_panels.open_peer_but_not_on_any_bfbb":"Peer aberto, mas em nenhum IX onde você tem POP", "link_panels.open_peer_join_the_route_server":"Peer aberto: entre no route server do {ix}", @@ -2168,6 +2173,7 @@ "link_panels.ports_at_p_of_the_usual":"Portas a {p}% do preço normal.", "link_panels.ports_up_to_port_are_free":"Portas até {port} são grátis.", "link_panels.price_n_days":"{price} · {n} dias", +"link_panels.put_this_link_on_standby":"Deixar este link de reserva", "link_panels.ready_for_a_pni_in_city":"Pronto para um PNI em {city}", "link_panels.ready_in_n_days":"Pronto em {n} dias", "link_panels.really_give_it_up":"Desistir mesmo?", @@ -2190,6 +2196,7 @@ "link_panels.spares_kit_on":"Kit de reserva ativo ✓", "link_panels.stock_a_spare_optic_price":"Guardar um {optic} sobressalente {price}", "link_panels.sys_level_n":"{sys} nível {n}", +"link_panels.take_it_off_standby":"Tirar da reserva", "link_panels.there_s_no_ix_in_city":"Ainda não há IX em {city}. Funde um: as redes entram com o tempo, pagam pelas portas e fazem peering com você de graça.", "link_panels.they_need_the_full_internet_your":"Eles querem a internet inteira. Seu alcance é de {pct}.", "link_panels.this_fiber_is_dark_add_optics":"Esta fibra está apagada. Adicione ópticas abaixo para levar tráfego.", @@ -2349,8 +2356,11 @@ "mergers.net_charges_for_peering":"{net} cobra pelo peering, então conte com uma mensalidade.", "mergers.net_has_swallowed_old":"{net} engoliu {old}.", "mergers.now_part_of_net":"Agora faz parte de {net}: faça peering com eles.", +"modal_and_names.found_a_bug_or_have_an":"Achou um bug ou teve uma ideia?", "modal_and_names.join_the_noc_chat":"Entre no chat do NOC", -"modal_and_names.our_signal_group_swap_screenshots":"Nosso grupo no Signal: troque capturas de tela, reporte bugs e discuta política de peering com outros jogadores. Menos retroescavadeiras que na vida real.", +"modal_and_names.open":"Abrir →", +"modal_and_names.our_signal_group_screenshots_chat":"Nosso grupo no Signal: troque capturas de tela e discuta política de peering com outros jogadores. Menos retroescavadeiras que na vida real.", +"modal_and_names.tell_us_on_github_a_short":"Conte para a gente no GitHub: um formulário curto para bugs, ideias de recursos, balanceamento e traduções. Lemos todos.", "modal_and_names.the_real_thing_by_thomas_kj":"A coisa de verdade, por Thomas Kjær Aabo: um mapa interativo com zoom de como seus pacotes viajam de fato, do Wi-Fi à fibra submarina, hoje, em 2010 e em 1995. Este jogo inventa tudo pelo caminho. Aquele acerta.", "modal_and_names.the_real_thing_follow_a_packet":"A coisa de verdade: siga um pacote do Wi-Fi até a fibra submarina.", "modals.lay_your_own_subsea_cable":"Lançar seu próprio cabo submarino…", @@ -3022,16 +3032,19 @@ "supply_chain.until_date_at_p":"até {date}, a +{p}", "supply_chain.what_p_n_days_left":"{what} +{p} · faltam {n} dias", "supply_chain.your_price_lock_covers_you_until":"Seu congelamento de preços te cobre até {date}.", +"title.anywhere_else":"Outro lugar", "title.asia_hub_great_peering_far_from":"Hub da Ásia. Ótimo peering, longe de casa.", "title.back_to_my_network":"Voltar para minha rede", "title.big_hungry_market_few_providers":"Mercado grande e faminto, poucos provedores.", "title.build_an_internet_lay_fiber_between":"Construa uma internet. Lance fibra entre cidades, compre transit, faça peering nos exchanges, feche contratos com empresas e mantenha os eyeballs felizes enquanto retroescavadeiras, tubarões e route leaks fazem de tudo para te parar.", "title.chat_on_signal":"Chat no Signal", +"title.choose":"Escolha…", "title.continue_name_date":"Continuar {name} · {date}", "title.cookieless_stats_no_tracking":"Estatísticas sem cookies, sem rastreamento", "title.crossroads_of_europe_de_kicks_ix":"Encruzilhada da Europa. IX DE-KICKS, transit barato.", -"title.hard_mode_everything_overseas_costs":"Modo difícil. Tudo que vai para fora custa uma fortuna, os locais pagam caro, principalmente para a Nearly Broadband Network, e todo o resto quer te matar.", +"title.hard_mode_pricey_everything":"Modo difícil. Tudo caro, e a fauna quer te ver morto.", "title.huge_eyeball_market_pricey":"Mercado enorme de eyeballs. Vizinhos caros.", +"title.n_more_cities_with_transit":{"one":"Mais {n} cidade com transit à venda","other":"Mais {n} cidades com transit à venda"}, "title.name_your_network":"Dê um nome à sua rede", "title.new_in_series_of_tubes_v":"Novidades no Series of Tubes {v}", "title.pick_your_home_city":"Escolha sua cidade natal", diff --git a/src/game/10-catalog/50-dark-fiber.js b/src/game/10-catalog/50-dark-fiber.js index 932e7c3..3e08603 100644 --- a/src/game/10-catalog/50-dark-fiber.js +++ b/src/game/10-catalog/50-dark-fiber.js @@ -37,3 +37,5 @@ const vxcMo=(km,sub,t)=>Math.round((150+km*0.12)*VXC[t].m*(sub?2:1)); const MET={prefer:{l:tr('common.prefer'),f:0.5},normal:{l:tr('common.normal'),f:1},avoid:{l:tr('common.avoid'),f:4},backup:{l:tr('common.backup_only'),f:60}}; const PREF={high:tr('common.prefer'),normal:tr('common.normal'),low:tr('common.backup_only')}; const edgeKey=l=>l.a[c.id,c])); diff --git a/src/game/60-features/20-scenarios.js b/src/game/60-features/20-scenarios.js index 7504e67..935eb4b 100644 --- a/src/game/60-features/20-scenarios.js +++ b/src/game/60-features/20-scenarios.js @@ -35,6 +35,8 @@ function beginGame(nm,city,o={}){if(needPitch()&&!UI.pitched){UI.pendGame=[nm,ci if(o.scn){const sc=o.scn;S.scn={id:sc.id,rules:sc.rules||{},days:sc.days,name:sc.n||tr('features.weekly_challenge_key',{key:sc.key}),key:sc.key||null,mods:(sc.mods||[]).map(m=>m.id)};S.rng=(o.seed||hstr(sc.id))|0;S.mode='scenario';S.asn=200000+Math.floor(Math.random()*15000); if(sc.cash)S.cash=sc.cash;if(sc.setup)sc.setup(); for(const m of S.scn.mods){if(m==='pricey')S.priceMul=1.3;if(m==='poor')S.cash=100000;if(m==='chaos')S.scn.rules.chaos=true;if(m==='boom')S.scn.rules.boom=true;if(m==='dk')S.scn.rules.dkAll=true;if(m==='sharks')S.scn.rules.sharks=true;}} + // Every new network starts at ½ speed (#186), whatever the last one ran at: slow enough to look around, but things happen. + UI.speed=UI.lastSpeed=0.5;UI.resumeSpeed=null; track('game_new');UI.started=true;closeModal();compute();cam.x=CITY[city].x;cam.y=CITY[city].y;cam.z=innerWidth<760?1.1:1.4;selectCity(city); toast(S.scn?`${esc(S.scn.name)}
${o.scn.goal?esc(o.scn.goal)+'.':tr('common.serve_as_much_traffic_as_you')} ${tr('scenarios.you_have_n_days',{n:S.scn.days})}`:S.mode==='sandbox'?tr('scenarios.sandbox_mode_a_billion_dollars_every'):tr('scenarios.welcome_name_the_ripe_ncc_assigned',{name:esc(nm),asn:S.asn,city:CITY[city].name}),'goal'); renderAll();save();if(!S.scn&&S.mode!=='sandbox')tutorialStart();} diff --git a/src/game/60-features/50-traceroute.js b/src/game/60-features/50-traceroute.js index 00209a6..dd7ad77 100644 --- a/src/game/60-features/50-traceroute.js +++ b/src/game/60-features/50-traceroute.js @@ -1,7 +1,9 @@ /* ---------- traceroute and looking glass ---------- */ const slug=t=>String(t).toLowerCase().normalize('NFKD').replace(/[̀-ͯ]/g,'').replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'x'; function trPaths(src){const live=S.links.filter(l=>!linkDown(l)),rem=remoteCities(),ok=c=>popUp(c)||rem.includes(c),adj={}; - for(const l of live){if(!ok(l.a)||!ok(l.b))continue;const w=(l.km+60)*MET[l.metric||'normal'].f;(adj[l.a]=adj[l.a]||[]).push([l.b,l,w]);(adj[l.b]=adj[l.b]||[]).push([l.a,l,w]);} + // Every link between two cities costs what the pair costs, as in compute(); the trace shows an active link over one on standby. + const pw={};for(const l of live){const k=edgeKey(l);pw[k]=Math.min(pw[k]??Infinity,(l.km+60)*MET[pairMet(k)].f);} + for(const l of live){if(!ok(l.a)||!ok(l.b))continue;const w=pw[edgeKey(l)]+(l.standby?1e-6:0);(adj[l.a]=adj[l.a]||[]).push([l.b,l,w]);(adj[l.b]=adj[l.b]||[]).push([l.a,l,w]);} const dist={[src]:0},prev={},done=new Set();for(;;){let u=null,ud=Infinity;for(const k in dist)if(!done.has(k)&&dist[k]{if(dist[dst]===undefined)return null;const out=[];let v=dst;while(v!==src){const l=prev[v];out.unshift({l,from:l.a===v?l.b:l.a,to:v});v=l.a===v?l.b:l.a;}return out;};return {dist,path};} function trExits(net){const day=S.day,ev=S.ev,leak=ev.leak&&ev.leak.until>day?ev.leak.net:null,out=[]; diff --git a/src/game/60-features/80-new-game.js b/src/game/60-features/80-new-game.js index 2fa348b..6a368e3 100644 --- a/src/game/60-features/80-new-game.js +++ b/src/game/60-features/80-new-game.js @@ -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:3,auV:1,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:{}, + ltv:2,t1v:3,auV:1,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:[],ev:{},priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',capDeal:null,won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0,inbox:{items:[],down:{},tiny:{},rep:0,bot:false,log:[],seq:0},hw:{}}; } diff --git a/src/game/80-simulation/30-compute.js b/src/game/80-simulation/30-compute.js index 5c1200f..da0023d 100644 --- a/src/game/80-simulation/30-compute.js +++ b/src/game/80-simulation/30-compute.js @@ -6,7 +6,10 @@ function compute(){ const remote=remoteCities(),adj=new Array(NC); pops.concat(remote).forEach(p=>adj[CIDX[p]]=[]); const edges={},TRX=teRules(),live=[];let NE=0;R2.bizDem={};R2.bizSrv={}; for(const l of S.links){const ai=CIDX[l.a],bi=CIDX[l.b];if(linkDown(l)||!adj[ai]||!adj[bi])continue;live.push(l);const key=l.ae.w,wLat=e=>e.lat+0.05; @@ -242,7 +245,8 @@ function compute(){ Object.defineProperty(R2.ef,l.id,{enumerable:true,configurable:true,get(){if(!rec){rec={eg:{},net:{},dst:{}};for(const [k,v] of t.g)rec.eg[k]=v; for(const j of t.n)rec.net[j0?sp*c/e.scap:0):(ac>0?a*c/ac:0);}} R2.peerShare=R2.served>0?R2.peered/R2.served:0; for(const e of E){if(e.k==='t')R2.useT[e.id]=(R2.useT[e.id]||0)+e.used;else if(e.k==='ix')R2.useIx[e.id]=e.used;else if(e.k==='p')R2.usePni[e.id]=e.used;else R2.useCache[e.id]=e.used;} // money diff --git a/src/game/80-simulation/50-sanitize.js b/src/game/80-simulation/50-sanitize.js index f649b24..b6a38e3 100644 --- a/src/game/80-simulation/50-sanitize.js +++ b/src/game/80-simulation/50-sanitize.js @@ -6,7 +6,7 @@ const num=(v,d=0)=>{v=+v;return Number.isFinite(v)?v:d;},int=(v,lo,hi,d)=>{v=Mat function sanitize(s){ const arr=k=>{if(!Array.isArray(s[k]))s[k]=[];},obj=k=>{if(!s[k]||typeof s[k]!=='object'||Array.isArray(s[k]))s[k]={};}; ['links','nni','transit','pni','caches','biz','offers','inc','usedNames','loans','loanOffers','hist','log'].forEach(arr); - ['pops','ixp','rs','peers','myIx','done','ev','stats','ixn','ixPref','ixSite','confReg','ach'].forEach(obj); + ['pops','ixp','rs','peers','myIx','done','ev','stats','ixn','ixPref','ixSite','confReg','ach','pairMet'].forEach(obj); s.v=1;s.name=String(s.name==null?'Packet Pals':s.name).slice(0,24);s.day=int(s.day,0,1e7,0);s.cash=num(s.cash,0);s.asn=int(s.asn,1,4294967294,200000); s.priceMul=num(s.priceMul,1);s.nextFail=num(s.nextFail,s.day+45);s.nextEvent=num(s.nextEvent,s.day+40);s.lvl=int(s.lvl,1,LEVELS.length,1);s.neg=int(s.neg,0,1e7,0);s.loanStrikes=int(s.loanStrikes,0,1e3,0); for(const k of Object.keys(s.stats)){const v=s.stats[k];if(k==='by'||k==='f'){if(!v||typeof v!=='object')s.stats[k]={};else for(const j of Object.keys(v))v[j]=num(v[j],0);}else if(typeof v!=='boolean')s.stats[k]=num(v,0);} @@ -14,8 +14,13 @@ function sanitize(s){ for(const c of Object.keys(s.pops)){const p=s.pops[c];if(!isCity(c)||!p||typeof p!=='object'){delete s.pops[c];continue;}p.routers=int(p.routers,1,RMAX,1);if(p.rupDay!==undefined)p.rupDay=num(p.rupDay,-1);if(p.rgen!==undefined)p.rgen=int(p.rgen,0,RG.length-1,0);p.down=num(p.down,0);if(p.bb&&typeof p.bb==='object')p.bb.d=num(p.bb.d,0);else p.bb=null;} if(!isCity(s.home))s.home=Object.keys(s.pops)[0]||'fra'; const tier=v=>int(v,0,PORT.length-1,0),lag=v=>int(v,1,LAG_MAX,1),sid=v=>String(v==null?uid():v).slice(0,40); - s.links=s.links.filter(l=>l&&isCity(l.a)&&isCity(l.b)&&l.a!==l.b).map(l=>{l.id=sid(l.id);l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.pairs!==undefined)l.pairs=Math.min(l.sub?SUB_PAIRS_MAX:s.lvl>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,Math.max(1,Math.floor(+l.pairs)||1));if(l.kind!=='df'&&l.kind!=='vxc')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&!own(CAB,l.cable))l.cable=null;if(l.kind==='vxc'&&!own(VXC,l.vt))l.vt=0;if(l.kind==='df'){if(!own(DF_SYS,l.sys))l.sys='lite';l.ch=Array.isArray(l.ch)?l.ch.filter(o=>own(OPT,o)):[];l.ready=num(l.ready,0);for(const k of Object.keys(SUB_UPGRADES)){const f='sub'+k;if(l[f]!==undefined){if(l.own&&l.sub&&Number.isFinite(l[f])&&l[f]>=0)l[f]=Math.round(l[f]);else delete l[f];}}if(l.seaPath!==undefined){if(l.own&&l.sub&&Array.isArray(l.seaPath)&&l.seaPath.length>=2&&l.seaPath.length<=2048&&l.seaPath.every(p=>Array.isArray(p)&&p.length===2&&p.every(Number.isFinite)&&Math.abs(p[0])<=180&&Math.abs(p[1])<=90))l.seaPath=l.seaPath.map(p=>p.slice());else delete l.seaPath;}if(l.paid!==undefined){if(l.own&&l.sub&&Number.isFinite(l.paid)&&l.paid>=0)l.paid=Math.round(l.paid);else delete l.paid;}if(l.own&&l.sub&&!own(SEA_DESIGNS,l.seaDesign))l.seaDesign='standard';l.regen=int(l.regen,0,REGEN_MAX,0);}const deg=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;if(l.loss)l.loss=deg(l.loss);if(l.metric&&!own(MET,l.metric))l.metric='normal';return l;}); + s.links=s.links.filter(l=>l&&isCity(l.a)&&isCity(l.b)&&l.a!==l.b).map(l=>{l.id=sid(l.id);l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.pairs!==undefined)l.pairs=Math.min(l.sub?SUB_PAIRS_MAX:s.lvl>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,Math.max(1,Math.floor(+l.pairs)||1));if(l.kind!=='df'&&l.kind!=='vxc')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&!own(CAB,l.cable))l.cable=null;if(l.kind==='vxc'&&!own(VXC,l.vt))l.vt=0;if(l.kind==='df'){if(!own(DF_SYS,l.sys))l.sys='lite';l.ch=Array.isArray(l.ch)?l.ch.filter(o=>own(OPT,o)):[];l.ready=num(l.ready,0);for(const k of Object.keys(SUB_UPGRADES)){const f='sub'+k;if(l[f]!==undefined){if(l.own&&l.sub&&Number.isFinite(l[f])&&l[f]>=0)l[f]=Math.round(l[f]);else delete l[f];}}if(l.seaPath!==undefined){if(l.own&&l.sub&&Array.isArray(l.seaPath)&&l.seaPath.length>=2&&l.seaPath.length<=2048&&l.seaPath.every(p=>Array.isArray(p)&&p.length===2&&p.every(Number.isFinite)&&Math.abs(p[0])<=180&&Math.abs(p[1])<=90))l.seaPath=l.seaPath.map(p=>p.slice());else delete l.seaPath;}if(l.paid!==undefined){if(l.own&&l.sub&&Number.isFinite(l.paid)&&l.paid>=0)l.paid=Math.round(l.paid);else delete l.paid;}if(l.own&&l.sub&&!own(SEA_DESIGNS,l.seaDesign))l.seaDesign='standard';l.regen=int(l.regen,0,REGEN_MAX,0);}const deg=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;if(l.loss)l.loss=deg(l.loss);return l;}); for(const l of s.links)repairSubUpgradeDates(l,s.day); + /* Metrics moved from each link to its city pair (#122). Older saves routed a pair at the lowest metric of its + links, with all of them carrying traffic, so the pair keeps that metric and nothing goes on standby. */ + {const pm=s.pairMet,lo={};for(const l of s.links){if(l.metric!==undefined){const k=edgeKey(l),m=own(MET,l.metric)?l.metric:'normal';if(!lo[k]||MET[m].fv&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null; s.transit=s.transit.filter(t=>t&&isCity(t.city)&&isNet(t.net)).map(t=>(t.lacp=degO(t.lacp),t.site=['a','b','ab'].includes(t.site)?t.site:'a',t.id=sid(t.id),t.tier=tier(t.tier),t.n=lag(t.n),t.down=num(t.down,0),t.clean=!!t.clean,t)); s.pni=s.pni.filter(x=>x&&isCity(x.city)&&isNet(x.net)).map(x=>(x.lacp=degO(x.lacp),x.site=['a','b','ab'].includes(x.site)?x.site:'a',x.id=sid(x.id),x.tier=tier(x.tier),x.n=lag(x.n),x.sacrif=!!x.sacrif,x)); diff --git a/src/game/90-actions/60-links.js b/src/game/90-actions/60-links.js index c816d7f..0e6faff 100644 --- a/src/game/90-actions/60-links.js +++ b/src/game/90-actions/60-links.js @@ -3,7 +3,7 @@ Object.assign(ACT,{ decomOpen:({city})=>{UI.decom=new Set(city&&S.pops[city]?[city]:[]);decomModal();}, decomToggle:({city})=>{if(!S.pops[city])return;UI.decom=UI.decom||new Set();if(UI.decom.has(city))UI.decom.delete(city);else UI.decom.add(city);decomModal();}, decomGo:()=>{const sel=[...(UI.decom||[])].filter(c=>S.pops[c]);if(!sel.length||sel.length>=Object.keys(S.pops).length)return;closeModal();UI.decom=null;UI.sel=null;decommission(sel);sfx('alert');after();}, - rmLink:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}{const l=S.links.find(x=>x.id===id),back=cabBack(l);if(back>0){S.cash+=back;toast(tr('links.name_is_called_off_the_cable',{name:esc(l.cname||tr('common.your_cable')),price:fmt$(back)}),'good');}}S.links=S.links.filter(l=>l.id!==id);UI.sel=null;UI.confirm=null;after();}, + rmLink:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}{const l=S.links.find(x=>x.id===id),back=cabBack(l);if(back>0){S.cash+=back;toast(tr('links.name_is_called_off_the_cable',{name:esc(l.cname||tr('common.your_cable')),price:fmt$(back)}),'good');}}S.links=S.links.filter(l=>l.id!==id);prunePairMet();UI.sel=null;UI.confirm=null;after();}, fixInc:({id})=>{const i=S.inc.find(x=>x.id===id);if(!i||!(i.cost>0))return;if(i.slow&&i.rushed)return;if(!spend(i.cost))return; if(i.slow&&i.until>S.day+1){i.rushed=true;i.cost=0;i.until=S.day+1;const p=S.pops[i.ref];if(p)p.down=Math.min(p.down,S.day+1);toast(tr('links.power_cycled_the_router_in_city',{city:esc(CITY[i.ref].name),chip:esc(RG[(p&&p.rgen)||0].chip)}),'good');after();return;}clearInc(i);toast(tr('links.fixed_what_resolved_early',{what:incTitle(i.type)}),'good');after();}, myIxUp:({city})=>{const m=S.myIx[city];if(!m)return;const f=(m.fab|0)+1,N=MYIX_FAB[f];if(!N)return;if(N.lvl>lvl()){toast(tr('links.a_fab_fabric_unlocks_at_customer',{fab:N.n,lv:N.lvl}),'bad');sfx('err');return;}if(!spend(N.cost))return;m.fab=f;toast(tr('links.ix_now_runs_a_fab_fabric',{ix:esc(m.name),fab:N.n,max:N.max}),'good');m.next=Math.min(m.next,S.day+3);after();}, @@ -26,8 +26,9 @@ Object.assign(ACT,{ const km=kmBetween(a,b),sub=isSub(a,b),mo=vxcMo(km,sub,t);if(!spend(mo))return;S.links.push({id:uid(),a,b,kind:'vxc',prov,vt:t,km,sub,mo,cut:0,day:S.day});closeModal(); toast(tr('links.circuit_up_in_59_seconds_vxc',{vxc:VXC[t].n,fab:esc(FAB[prov].name),a:CITY[a].name,b:CITY[b].name})+(S.pops[b]?'':' '+tr('links.now_grab_an_ix_port_there')),'good');if(!S.pops[b])selectCity(b);after();}, upVxc:({id,t})=>{t=+t;const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='vxc'||!VXC[t]||t<=l.vt)return;const extra=VXC[t].g-VXC[l.vt].g;for(const c of [l.a,l.b]){const pt=nniPort(c,l.prov);if(pt&&nniUsed(c,l.prov)+extra>NNI[pt.tier].g){toast(tr('links.fabric_port_in_city_is_full',{city:CITY[c].name}),'bad');sfx('err');return;}}const mo=vxcMo(l.km,l.sub,t);if(!spend(mo))return;l.vt=t;l.mo=mo;after();}, - cancelVxc:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.links=S.links.filter(l=>l.id!==id);const rem=remoteCities();for(const c in S.ixp){if(!S.pops[ixCity(c)]&&!rem.includes(ixCity(c))){delete S.ixp[c];delete S.rs[c];for(const k in S.peers)if(k.endsWith('@'+c))delete S.peers[k];}}UI.sel=null;UI.confirm=null;after();}, + cancelVxc:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.links=S.links.filter(l=>l.id!==id);prunePairMet();const rem=remoteCities();for(const c in S.ixp){if(!S.pops[ixCity(c)]&&!rem.includes(ixCity(c))){delete S.ixp[c];delete S.rs[c];for(const k in S.peers)if(k.endsWith('@'+c))delete S.peers[k];}}UI.sel=null;UI.confirm=null;after();}, setPref:({kind,id,v})=>{if(!own(PREF,v))return;if(kind!=='t'&&kind!=='p'&&!(isIx(id)&&S.ixp[id]!==undefined))return;if(kind==='t'){const t=S.transit.find(x=>x.id===id);if(t)t.pref=v;}else if(kind==='p'){const x=S.pni.find(y=>y.id===id);if(x)x.pref=v;}else{S.ixPref=S.ixPref||{};S.ixPref[id]=v;}sfx('click');after();}, - setMetric:({id,v})=>{if(!own(MET,v))return;const l=S.links.find(x=>x.id===id);if(!l)return;for(const x of pairLinks(l.a,l.b))x.metric=v;sfx('click');after();}, + setMetric:({id,v})=>{if(!own(MET,v))return;const l=S.links.find(x=>x.id===id);if(!l)return;const m=S.pairMet||(S.pairMet={}),k=edgeKey(l);if(v==='normal')delete m[k];else m[k]=v;sfx('click');after();}, + setStandby:({id,on})=>{const l=S.links.find(x=>x.id===id);if(!l)return;if(on)l.standby=true;else delete l.standby;sfx('click');after();}, goEgress:({city,k})=>{ACT.focusCity({city});UI.tab=k==='t'?'up':k==='l2'?'cust':k==='nni'?'links':'peer';renderPanel();}, }); diff --git a/src/game/90-actions/89-game-and-settings.js b/src/game/90-actions/89-game-and-settings.js index d4b8822..3ec2894 100644 --- a/src/game/90-actions/89-game-and-settings.js +++ b/src/game/90-actions/89-game-and-settings.js @@ -1,11 +1,12 @@ Object.assign(ACT,{ randomName:()=>{const input=$('nmIn');if(input)input.value=UI.nm=randomNetworkName(input.value);}, - start:()=>{const nm=(($('nmIn')&&$('nmIn').value)||randomNetworkName()).slice(0,24);beginGame(nm,UI.startCity,{mode:UI.mode==='sandbox'?'sandbox':'normal'});}, + start:()=>{const nm=(($('nmIn')&&$('nmIn').value)||randomNetworkName()).slice(0,24);beginGame(nm,homeOk(UI.startCity)?UI.startCity:'fra',{mode:UI.mode==='sandbox'?'sandbox':'normal'});}, modeSet:({m})=>{UI.mode=m;document.querySelectorAll('.modeb').forEach(b=>b.classList.toggle('pink',b.dataset.m===m));document.querySelectorAll('.modeb').forEach(b=>b.classList.toggle('ghost',b.dataset.m!==m));}, scenarios:()=>{UI.nm=(($('nmIn')&&$('nmIn').value)||UI.nm||(S&&S.name)||randomNetworkName()).slice(0,24);scenarioModal();}, startScn:({id,sure})=>{const sc=SCN.find(x=>x.id===id);if(!sc)return;if(!sure&&S&&UI.started&&!S.lost&&!(S.scn&&(S.scn.done||S.scn.failed))){openModal(`

${tr('game_and_settings.start_name',{name:esc(sc.n)})}

${tr('game_and_settings.name_will_be_replaced_export_it',{name:esc(S.name)})}

${btn(tr('game_and_settings.start_the_scenario'),'startScn',{id,sure:1},'pink big')}${btn(tr('common.keep_playing'),'closeModal',{},'ghost big')}
`);return;}beginGame(UI.nm||(S&&S.name)||randomNetworkName(),sc.city,{scn:sc});}, startWeekly:({sure}={})=>{if(!sure&&S&&UI.started&&!S.lost&&!(S.scn&&(S.scn.done||S.scn.failed))){openModal(`

${tr('game_and_settings.start_the_weekly_challenge')}

${tr('game_and_settings.name_will_be_replaced_export_it',{name:esc(S.name)})}

${btn(tr('game_and_settings.start_the_challenge'),'startWeekly',{sure:1},'pink big')}${btn(tr('common.keep_playing'),'closeModal',{},'ghost big')}
`);return;}const wk=weekly();beginGame(UI.nm||(S&&S.name)||randomNetworkName(),wk.city,{scn:wk,seed:wk.seed});}, - pickStart:({city})=>{UI.startCity=city;document.querySelectorAll('.start').forEach(b=>b.classList.toggle('on',b.dataset.city===city));}, + pickStart:({city})=>{if(!homeOk(city))return;UI.startCity=city;document.querySelectorAll('.start').forEach(b=>b.classList.toggle('on',b.dataset.city===city||(b.classList.contains('own')&&!START5.includes(city))));const s=$('homeSel');if(s&&START5.includes(city))s.value='';const w=$('homeWhat');if(w)w.innerHTML=homeWhat();}, + pickHome:({v})=>{if(v)ACT.pickStart({city:v});else ACT.pickStart({city:'fra'});}, cont:()=>{migrate(S);track('game_continue',true);UI.started=true;closeModal();renderAll();}, newgame:()=>{try{localStorage.removeItem('sot-save-v1');}catch(e){}S=null;UI.started=false;UI.sel=null;UI.nm=null;$('dash').hidden=true;$('bankBox').hidden=true;renderAll();showTitle();}, keepPlaying:()=>{closeModal();}, @@ -24,7 +25,7 @@ Object.assign(ACT,{ ${RELEASE_NOTES.length?btn(tr('common.what_s_new_in_v',{v:esc(APP_VERSION)}),'whatsNewShow',{},'ghost'):''} ${btn(tr('common.settings'),'settings',{},'ghost')} ${btn(tr('common.start_a_new_network'),'resetAsk',{},'red')} - ${chatHtml()}`);}, + ${chatHtml()}${issueHtml()}`);}, settings:()=>{UI.setOpen=true;openModal(settingsHtml());}, settingsClose:()=>{UI.setOpen=false;if(!S||!UI.started)showTitle();else closeModal();}, prefSet:({v})=>{const [k,b]=String(v).split(':');if(!own(PREF_DEF,k))return;setPref(k,b==='1');sfx('click');refreshSettings();}, diff --git a/src/game/90-actions/90-action-helpers.js b/src/game/90-actions/90-action-helpers.js index 67c8055..0efe713 100644 --- a/src/game/90-actions/90-action-helpers.js +++ b/src/game/90-actions/90-action-helpers.js @@ -4,6 +4,8 @@ function landTrenches(a,b){const out=[];for(const l of pairLinks(a,b)){if(l.kind // Which route a new wave joins: null = a new diverse route. 'same' is the old two-way choice (the main route). function routeJoin(a,b){const ts=landTrenches(a,b),r=UI.route||'';if(r==='same')return ts[0]||null;if(r.startsWith('t:'))return ts.find(t=>t.k===r.slice(2))||null;return null;} function pairLinks(a,b){return S.links.filter(l=>(l.a===a&&l.b===b)||(l.a===b&&l.b===a));} +// A city pair's metric goes with its last link, so a new link between the same cities starts on normal. +function prunePairMet(){const m=S.pairMet;if(!m)return;const k=new Set(S.links.map(edgeKey));for(const x of Object.keys(m))if(!k.has(x))delete m[x];} // Short, busy subsea routes (London–Amsterdam, London–Paris) sell dark fiber pairs too. function subDfCable(a,b){return cablesOk(a,b).filter(c=>CAB[c.cid].df).sort((x,y)=>x.km-y.km)[0]||null;} function dfAllowed(a,b){if(isSub(a,b))return !!subDfCable(a,b);return cnCity(a)===cnCity(b)&&!uaePair(a,b)&&!landX(a,b);} diff --git a/src/game/93-ui/60-decommission.js b/src/game/93-ui/60-decommission.js index 148b08a..4386098 100644 --- a/src/game/93-ui/60-decommission.js +++ b/src/game/93-ui/60-decommission.js @@ -13,7 +13,7 @@ function decomModal(){const sel=[...(UI.decom||[])],im=decomImpact(sel),all=Obje ${left<1?`

${tr('decommission.keep_at_least_one_pop')}

`:''}
${btn(sel.length?trn('decommission.decommission_n_pop_pay_fee',sel.length,{fee:fmt$(im.fee)}):tr('decommission.pick_a_pop'),'decomGo',{},'red',!sel.length||left<1)}${btn(tr('common.keep_them'),'closeModal',{},'ghost')}
`);} function decommission(cities){const set=new Set(cities),im=decomImpact(cities),lids=new Set(im.links.map(l=>l.id)),bids=new Set(im.biz.map(b=>b.id)); - S.links=S.links.filter(l=>!lids.has(l.id));S.biz=S.biz.filter(b=>!bids.has(b.id));S.offers=S.offers.filter(o=>!bCities(o).some(c=>set.has(c))); + S.links=S.links.filter(l=>!lids.has(l.id));prunePairMet();S.biz=S.biz.filter(b=>!bids.has(b.id));S.offers=S.offers.filter(o=>!bCities(o).some(c=>set.has(c))); S.transit=S.transit.filter(t=>!set.has(t.city));S.pni=S.pni.filter(x=>!set.has(x.city));S.caches=S.caches.filter(x=>!set.has(x.city));S.nni=(S.nni||[]).filter(x=>!set.has(x.city)); for(const c of cities){for(const x of ixIdsIn(c)){delete S.ixp[x];delete S.rs[x];if(S.ixn)delete S.ixn[x];if(S.ixSite)delete S.ixSite[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}delete S.myIx[c];S.scrubs=S.scrubs.filter(x=>x.city!==c);delete S.pops[c];} const rem=remoteCities();for(const x in S.ixp){const c=ixCity(x);if(!S.pops[c]&&!rem.includes(c)){delete S.ixp[x];delete S.rs[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}} diff --git a/src/game/93-ui/70-link-panels.js b/src/game/93-ui/70-link-panels.js index 19b6eb7..0378b3f 100644 --- a/src/game/93-ui/70-link-panels.js +++ b/src/game/93-ui/70-link-panels.js @@ -51,8 +51,13 @@ function trafficSection(l){ if(u>=0.8&&egs.length){const d=R.egDesc[egs[0][0]];h+=`

${tr('link_panels.biggest_feeder_egress_in_city_set',{egress:esc(d.lab),city:CITY[d.city].name})}

`;} return h+``; } -function metricSection(l){const cur=l.metric||'normal'; - return `

${tr('common.routing_metric')}

${tr('link_panels.your_routers_pick_the_lowest_cost')}

${Object.keys(MET).map(k=>btn(MET[k].l,'setMetric',{id:l.id,v:k},cur===k?'pink sm':'ghost sm')).join('')}
`;} +function metricSection(l){const cur=pairMet(edgeKey(l)),pl=pairLinks(l.a,l.b),sb=!!l.standby; + let h=`

${tr('common.routing_metric')}

${tr('link_panels.your_routers_pick_the_lowest_cost')}

${Object.keys(MET).map(k=>btn(MET[k].l,'setMetric',{id:l.id,v:k},cur===k?'pink sm':'ghost sm')).join('')}
`; + // Standby only means something next to another link; a link left on standby alone can still be taken off it. + if(pl.length>1||sb){const busy=(R.load[l.id]||0)>1e-3,alone=!pl.some(x=>x!==l&&!x.standby&&!linkDown(x)); + const st=!sb?tr('link_panels.a_link_on_standby_carries_traffic'):!busy?tr('link_panels.on_standby_idle_while_the_other'):alone?tr('link_panels.on_standby_but_carrying_the_traffic'):tr('link_panels.on_standby_taking_the_overflow'); + h+=`

${tr('common.standby')}

${st}

${sb?btn(tr('link_panels.take_it_off_standby'),'setStandby',{id:l.id,on:0},'pink sm'):btn(tr('link_panels.put_this_link_on_standby'),'setStandby',{id:l.id,on:1},'ghost sm')}
`;} + return h+`
`;} function chinaSection(c){const st=S.cnLic?S.cnLic.state:'none',loss=S.ev.gfw>S.day?0.35:0.2; let h=`

${tr('link_panels.behind_the_great_firewall')}

${tr('link_panels.mainland_china_plays_by_its_own',{list:CN_BLOCKED.slice(0,4).map(esc).join(', '),pct:pct(loss)})}

`; if(st==='none')h+=`

${tr('link_panels.foreign_networks_need_a_local_joint')}

${btn(tr('link_panels.apply_for_a_license_price_mo',{price:fmt$(CN_LIC),mo:fmt$(CN_JV_MO)}),'applyCn',{},'pink',S.casha+optCost(c),0)*REGEN_CH); h+=`

${tr('common.line_system')}

${esc(sysD.n)}${tr('link_panels.n_amplifiers',{n:amps})}
${tr('common.regen_sites')}${rg?tr('link_panels.n_optical_spans_of_km_km',{n:rg,km:spanKm(l).toLocaleString()}):tr('common.none')}

${tr('link_panels.a_regen_site_turns_the_light',{price:fmt$(REGEN_MO)})}

${l.sub&&l.own?`

${tr('link_panels.no_regen_sites_in_the_middle')}

`:`
${rg`}

${esc(sysD.blurb)}

${(()=>{const t=sysNext(l);if(!t)return '';const T=DF_SYS[t],c=sysUpCost(l);return T.lvl>lvl()?btn(tr('link_panels.sys_level_n',{sys:T.n,n:T.lvl}),'upSys',{id:l.id},'sm',true):btn(tr('link_panels.upgrade_to_sys_price',{sys:T.n,price:fmt$(c)}),'upSys',{id:l.id},'sm',S.cash

${tr('link_panels.spare_optics_and_amplifier_cards_on')}

`; - {const sib=pairLinks(l.a,l.b).filter(x=>x!==l&&x.kind!=='vxc');h+=`

${tr('common.redundancy')}

${sib.length?tr('link_panels.other_links_between_these_cities'):tr('link_panels.this_is_the_only_link_between')}

${sib.map(x=>`
${esc(capName(x))} ${linkDown(x)?''+tr('common.cut')+'':''}
${(x.trench||x.id)===(l.trench||l.id)?tr('common.same_trench'):tr('common.diverse_route')}
${btn(tr('common.open'),'selLink',{id:x.id},'ghost sm')}
`).join('')}
${btn(tr('link_panels.add_parallel_link'),'addParallel',{id:l.id},'pink sm')}
`;} + {const sib=pairLinks(l.a,l.b).filter(x=>x!==l&&x.kind!=='vxc');h+=`

${tr('common.redundancy')}

${sib.length?tr('link_panels.other_links_between_these_cities'):tr('link_panels.this_is_the_only_link_between')}

${sib.map(x=>`
${esc(capName(x))} ${linkDown(x)?''+tr('common.cut')+'':''}${x.standby?' '+tr('common.standby')+'':''}
${(x.trench||x.id)===(l.trench||l.id)?tr('common.same_trench'):tr('common.diverse_route')}
${btn(tr('common.open'),'selLink',{id:x.id},'ghost sm')}
`).join('')}
${btn(tr('link_panels.add_parallel_link'),'addParallel',{id:l.id},'pink sm')}
`;} h+=`${trafficSection(l)}${metricSection(l)}
${btn(UI.confirm===l.id?tr('link_panels.really_give_it_up'):(l.own?tr('link_panels.abandon_the_fiber'):tr('link_panels.cancel_the_iru')),'rmLink',{id:l.id},'ghost sm')}${cabBack(l)>0?`

${tr('link_panels.giving_it_up_now_returns_price',{price:fmt$(cabBack(l))})}

`:''}
`; return h; } diff --git a/src/game/95-modals/30-modal-and-names.js b/src/game/95-modals/30-modal-and-names.js index b9c9894..258d523 100644 --- a/src/game/95-modals/30-modal-and-names.js +++ b/src/game/95-modals/30-modal-and-names.js @@ -20,5 +20,8 @@ const HTIW='https://tkjaer.github.io/how-the-internet-works/'; // The real thing: an interactive, zoomable guide to how packets actually travel. Go read it. // Where players hang out: the community Signal group. const SIGNAL='https://signal.group/#CjQKIJwvEt5fYt1pvw7J2pV664CyUyGJXmAJLV8ia3nUdAD7EhA_FzdxflEzkNmcvDHdVgLQ'; -const chatHtml=()=>`${tr('modal_and_names.join_the_noc_chat')}${tr('modal_and_names.our_signal_group_swap_screenshots')}${tr('common.join')}`; +const chatHtml=()=>`${tr('modal_and_names.join_the_noc_chat')}${tr('modal_and_names.our_signal_group_screenshots_chat')}${tr('common.join')}`; +// Bugs and ideas go to GitHub, where they get tracked; the chat is for chatting. Its forms sort them by kind. +const ISSUES='https://github.com/fjaeckel/seriesoftubes/issues/new/choose'; +const issueHtml=()=>`${tr('modal_and_names.found_a_bug_or_have_an')}${tr('modal_and_names.tell_us_on_github_a_short')}${tr('modal_and_names.open')}`; const plugHtml=(big)=>`How the Internet Works${big?tr('modal_and_names.the_real_thing_by_thomas_kj'):tr('modal_and_names.the_real_thing_follow_a_packet')}${tr('common.explore')}`; diff --git a/src/game/95-modals/40-title.js b/src/game/95-modals/40-title.js index c07dc78..86683e7 100644 --- a/src/game/95-modals/40-title.js +++ b/src/game/95-modals/40-title.js @@ -1,16 +1,25 @@ +// Five suggested homes, or any city with someone selling transit there. Hidden cities and China (which needs +// a license first) can't be a home, and neither can a city where nobody sells transit: you'd start cut off. +const homeOk=c=>own(CITY,c)&&!CITY[c].off&&!CITY[c].cn&&NETS.some(n=>sellsAt(n,c)); +const START5=['fra','nyc','sin','sao','syd']; +function homePick(){const cs=Object.keys(CITY).filter(homeOk),cur=START5.includes(UI.startCity)?'':UI.startCity; + return ``;} +// A dropdown can't wrap, so long names (Yuzhno-Sakhalinsk) get cut on phones: the line above it says the whole name. +const homeWhat=()=>START5.includes(UI.startCity)?trn('title.n_more_cities_with_transit',Object.keys(CITY).filter(c=>homeOk(c)&&!START5.includes(c)).length):`${esc(CITY[UI.startCity].name)} · ${esc(REG[CITY[UI.startCity].reg])}`; function showTitle(){ const sv=loadSave(); if(UI.nm==null)UI.nm=randomNetworkName(); - const starts=[['fra',tr('title.crossroads_of_europe_de_kicks_ix')],['nyc',tr('title.huge_eyeball_market_pricey')],['sin',tr('title.asia_hub_great_peering_far_from')],['sao',tr('title.big_hungry_market_few_providers')],['syd',tr('title.hard_mode_everything_overseas_costs')]]; + const starts=[['fra',tr('title.crossroads_of_europe_de_kicks_ix')],['nyc',tr('title.huge_eyeball_market_pricey')],['sin',tr('title.asia_hub_great_peering_far_from')],['sao',tr('title.big_hungry_market_few_providers')],['syd',tr('title.hard_mode_pricey_everything')]]; openModal(`

Series
of Tubes

${tr('title.build_an_internet_lay_fiber_between')}

${plugHtml(false)}${isPhone()?installRow():''} ${sv?`
${btn(tr('title.continue_name_date',{name:esc(sv.name),date:dateStr(sv.day)}),'cont',{},'pink big')}
`:''}
${btn(tr('common.another_one'),'randomName',{},'ghost sm')}
-
${starts.map(([c,d])=>``).join('')}
+
${starts.map(([c,d])=>``).join('')}
${[['normal',tr('common.normal')],['sandbox',tr('common.sandbox')]].map(([m,l])=>``).join('')}${btn(tr('title.scenarios_amp_weekly_challenge'),'scenarios',{},'sm')}
-
${segBtns('langSet',LANG,Object.entries(LANGS))}
-
${btn(sv?tr('common.start_a_new_network'):tr('common.start_building'),'start',{},'big')}${btn(tr('common.how_to_play'),'help',{},'ghost')}${btn(tr('common.import_a_save'),'importPick',{},'ghost sm')}${btn(tr('common.settings'),'settings',{},'ghost sm')}

v${APP_VERSION} · ${tr('title.source_on_github')} · ${tr('title.chat_on_signal')} · ${tr('title.cookieless_stats_no_tracking')}

`); + ${langPick('langTitle')} +
${btn(sv?tr('common.start_a_new_network'):tr('common.start_building'),'start',{},'big')}${btn(tr('common.how_to_play'),'help',{},'ghost')}${btn(tr('common.import_a_save'),'importPick',{},'ghost')}${btn(tr('common.settings'),'settings',{},'ghost')}

v${APP_VERSION} · ${tr('title.source_on_github')} · ${tr('title.chat_on_signal')} · ${tr('title.cookieless_stats_no_tracking')}

`); $('nmIn').addEventListener('input',e=>{UI.nm=e.target.value;}); if(sv){S=migrate(sv);compute();} } diff --git a/src/game/95-modals/60-help.js b/src/game/95-modals/60-help.js index 282f511..e8e5e51 100644 --- a/src/game/95-modals/60-help.js +++ b/src/game/95-modals/60-help.js @@ -18,7 +18,7 @@ function showHelp(){
${tr('common.waves')}
${tr('help.your_fiber_links_are_leased_waves')}
${tr('common.95th_percentile')}
${tr('help.transit_bills_sample_your_usage')}
${tr('common.routers')}
${tr('help.each_pop_s_router_model_caps')}
${tr('common.dark_fiber')}
${tr('help.lease_an_iru_or_build_your')}
${tr('common.subsea_cables')}
${tr('help.subsea_waves_can_only_follow_cable')}
${tr('common.latency')}
${tr('help.every_link_has_latency_high')}
${tr('common.noc_dashboard')}
${tr('help.the_chart_button_at_the_top')}
${tr('common.asia')}
${tr('help.a_weird_underserved_market_transit')}
${tr('common.russia')}
${tr('help.moscow_needs_a_mandatory_government')}
${tr('help.events_chains_and_wholesale')}
${tr('help.event_networks_a_final_a_festival')}
${tr('common.bank')}
${tr('help.tap_your_cash_to_open_the')}
${tr('common.lags')}
${tr('help.out_of_port_speed_bundle_up')}
${tr('common.traffic_engineering')}
${tr('help.tap_a_link_to_see_which')}
${tr('common.china')}
${tr('help.mainland_china_needs_a_license_and')}
${tr('common.weird_requirements')}
${tr('help.some_customers_come_with_conditions')}
${tr('common.customer_levels')}
${tr('help.as_your_peak_traffic_and_footprint')}
${tr('help.l2vpn_ddos_protection')}
${tr('help.businesses_may_want_a_private')}
${tr('common.scrubbing_centers')}
${tr('help.build_one_in_as_many_pops')}
${tr('common.nni_fabrics')}
${tr('help.megapork_pocketfabric_and')}
${tr('common.conferences')}
${tr('help.nanog_ripe_denog_and_friends_come')}
${tr('common.modes')}
${tr('help.sandbox_gives_you_a_billion_dollars')}
${tr('common.traceroute')}
${tr('help.tap_traceroute_on_any_of_your')}
${tr('common.badges')}
${tr('help.below_your_goals_sits_a_wall')}
${tr('common.the_giants')}
${tr('help.at_customer_level_3_and_4')}
RouteScript
${tr('help.once_auto_te_is_installed_you')}
Auto-TE
${tr('help.traffic_follows_the_shortest_path_by')}
${tr('common.metro_diversity')}
${tr('help.a_pop_is_one_building_until')}
${tr('common.wave_markets')}
${tr('help.what_a_wave_costs_depends_on')}
${tr('common.regional_quirks')}
${tr('help.in_the_gulf_saudi_pops_need')}
${tr('common.boot_times')}
${tr('help.some_routers_take_forever_to_boot')}
${tr('common.failures')}
${tr('help.things_break_all_the_time_fiber')}
RouteScript
${tr('help.rules_for_your_auto_te_controller')}
-

${tr('help.want_to_know_how_it_really')}

${plugHtml(true)}${chatHtml()}
${btn(UI.started?tr('common.back_to_the_map'):tr('common.got_it'),'helpClose',{},'big')}${RELEASE_NOTES.length?btn(tr('common.what_s_new_in_v',{v:esc(APP_VERSION)}),'whatsNewShow',{},'ghost'):''}${UI.started&&S&&!S.lost?btn(tr('common.start_a_new_network'),'resetAsk',{},'ghost sm'):''}
${UI.started&&S&&!S.lost?btn(tr('common.export_save'),'exportSave',{},'ghost sm'):''}${btn(tr('common.import_a_save'),'importPick',{},'ghost sm')}${btn(tr('common.settings'),'settings',{},'ghost sm')}
`); +

${tr('help.want_to_know_how_it_really')}

${plugHtml(true)}${chatHtml()}${issueHtml()}
${btn(UI.started?tr('common.back_to_the_map'):tr('common.got_it'),'helpClose',{},'big')}${RELEASE_NOTES.length?btn(tr('common.what_s_new_in_v',{v:esc(APP_VERSION)}),'whatsNewShow',{},'ghost'):''}${UI.started&&S&&!S.lost?btn(tr('common.start_a_new_network'),'resetAsk',{},'ghost sm'):''}
${UI.started&&S&&!S.lost?btn(tr('common.export_save'),'exportSave',{},'ghost sm'):''}${btn(tr('common.import_a_save'),'importPick',{},'ghost sm')}${btn(tr('common.settings'),'settings',{},'ghost sm')}
`); } function showWin(){setTimeout(()=>{const m=$('modalCard');if(m&&!m.querySelector('[data-act=share]'))m.insertAdjacentHTML('beforeend',`
${btn(tr('help.share_my_network'),'share',{},'pink')}

${tr('help.you_built_a_cartoon_internet_now')}

${plugHtml(true)}`);},0);openModal(`

${tr('help.you_re_a_tier_1')}

${tr('help.name_as_asn_is_transit_free',{name:esc(S.name),asn:S.asn,days:S.day,n:S.stats.incidents})}

${btn(tr('common.keep_building'),'keepPlaying',{},'pink big')}`);sfx('coin');} function showLose(){openModal(`

${tr('common.bankrupt')}

${tr('help.the_bank_repossessed_your_routers',{name:esc(S.name),days:S.day,peak:fmtG(S.stats.peak)})}

${btn(tr('common.try_again'),'newgame',{},'pink big')}`);try{localStorage.removeItem('sot-save-v1');}catch(e){}} diff --git a/src/game/96-map/30-settings.js b/src/game/96-map/30-settings.js index 5dd5c11..61aade4 100644 --- a/src/game/96-map/30-settings.js +++ b/src/game/96-map/30-settings.js @@ -3,6 +3,9 @@ function i18nDom(){if(LANG==='en')return;for(const el of document.querySelectorAll('[data-i18n]'))el.textContent=tr(el.dataset.i18n); for(const a of ['aria-label','title'])for(const el of document.querySelectorAll(`[data-i18n-${a}]`))el.setAttribute(a,tr(el.getAttribute('data-i18n-'+a)));} // One button per [value,label] option; the current one is highlighted. +// One dropdown instead of a button per language: the list keeps growing, and on phones the system picker opens. +// Each language is named in itself (lang= lets screen readers say it right). +const langPick=id=>``; function segBtns(act,cur,opts){return opts.map(([v,l])=>btn(l,act,{v},cur===v?'pink sm':'ghost sm')).join('');} /* Animation setting: auto follows the system's reduced-motion preference, or force it on or off. */ /* Settings are per device (localStorage), not part of the save: they are about how you like to play. */ @@ -23,7 +26,7 @@ function settingsHtml(){const seg=(lab,act,cur,opts,note)=>`
${tr('settings.display_and_sound')} ${seg(tr('common.animations'),'animSet',UI.anim||'auto',[['auto',tr('common.auto')],['on',tr('common.on')],['off',tr('common.off')]],tr('settings.auto_follows_your_device_s_reduce'))} ${seg(tr('common.sound'),'soundSet',UI.muted?'off':'on',[['on',tr('common.on')],['off',tr('common.off')]])} - ${seg(tr('common.language'),'langSet',LANG,Object.entries(LANGS))} +
${langPick('langSel')}
${seg(tr('common.viewport_info'),'vpSet',VP_T?'on':'off',[['on',tr('common.on')],['off',tr('common.off')]],tr('settings.for_reporting_layout_bugs_shows_what'))} ${installRow()}
${btn(tr('common.done_8dd3'),'settingsClose',{},'pink')}
`;} const refreshSettings=()=>{if(UI.setOpen)openModal(settingsHtml());}; diff --git a/src/game/96-map/60-draw.js b/src/game/96-map/60-draw.js index 8b2a2a3..fe22967 100644 --- a/src/game/96-map/60-draw.js +++ b/src/game/96-map/60-draw.js @@ -27,7 +27,7 @@ function drawFrame(now){ // links const far=lodFar(),PI=pairIdx(),LG=linkGroups(),GM=LG.map(g=>linkGeom(g[0],PI.get(edgeKey(g[0])))),busy=linesOnScreen(GM,ks)>MAP_BUSY; for(let gi=0;gi1,up=many?grp.filter(x=>!linkDown(x)):null; - const gm=GM[gi],cap=many?up.reduce((a,x)=>a+capOf(x),0):capOf(l),load=many?grp.reduce((a,x)=>a+(R.load[x.id]||0),0):(R.load[l.id]||0),u=cap?load/cap:0,df=l.kind==='df',bld=df&&l.ready>day,cut=!bld&&(many?!up.length:linkDown(l))&&!(df&&!(l.ch||[]).length),dark=df&&!bld&&!(l.ch||[]).length,vx=l.kind==='vxc'; + const gm=GM[gi],cap=many?up.reduce((a,x)=>a+capOf(x),0):capOf(l),load=many?grp.reduce((a,x)=>a+(R.load[x.id]||0),0):(R.load[l.id]||0),u=cap?load/cap:0,df=l.kind==='df',bld=df&&l.ready>day,cut=!bld&&(many?!up.length:linkDown(l))&&!(df&&!(l.ch||[]).length),dark=df&&!bld&&!(l.ch||[]).length,vx=l.kind==='vxc',idle=!cut&&!bld&&load<1e-3&&(many?up.length>0&&up.every(x=>x.standby):!!l.standby); const sel=UI.sel&&UI.sel.type==='link'&&grp.some(x=>x.id===UI.sel.id);let lab=null; const w=(vx?2.2:(2.5+Math.max(...grp.map(tierW))*1.8+(many?Math.min(1.5,(grp.length-1)*0.5):0)))*sc*(far?0.5:1),np=gm.pts.length; if(SX.length{ctx.beginPath();ctx.moveTo(SX[0],SY[0]);for(let i=1;i0.001?utilCol(u):'#7FD8EE'):utilCol(u);ctx.lineWidth=w;ctx.stroke();ctx.setLineDash([]); + ctx.strokeStyle='#1E2640';ctx.lineWidth=w+4;ctx.setLineDash(cut?[8,8]:vx?[2,7]:bld?[10,8]:idle?[4,6]:[]);path();ctx.stroke(); + ctx.strokeStyle=bld?'#C9B27C':dark?'#5D6788':cut?'#FF4D5E':idle?'#9AA3BE':vx?FAB[l.prov].col:l.sub?(u>0.001?utilCol(u):'#7FD8EE'):utilCol(u);ctx.lineWidth=w;ctx.stroke();ctx.setLineDash([]); // Still the same path: strokes keep it, so the dotted fiber line goes on top without building it again. if(df&&!bld&&!dark&&!busy){ctx.strokeStyle='rgba(255,255,255,.75)';ctx.lineWidth=Math.max(1,w*0.25);ctx.setLineDash([1,6]);ctx.stroke();ctx.setLineDash([]);} const at=t=>polyAtXY(SX,SY,gm.cum,t); diff --git a/src/game/96-map/95-clicks.js b/src/game/96-map/95-clicks.js index 7513a99..e486276 100644 --- a/src/game/96-map/95-clicks.js +++ b/src/game/96-map/95-clicks.js @@ -3,7 +3,7 @@ let pressing=false; document.addEventListener('pointerdown',e=>{if(e.target.closest('#panel,#left,#dash,#bankBox,#modal,#tabbar,#toasts'))pressing=true;}); addEventListener('pointerup',()=>setTimeout(()=>pressing=false,0)); addEventListener('pointercancel',()=>{pressing=false;});addEventListener('blur',()=>{pressing=false;}); -document.addEventListener('change',e=>{const el=e.target.closest('[data-chg]');if(!el||!S)return;const fn=ACT[el.dataset.chg];if(fn)fn({v:el.value});}); +document.addEventListener('change',e=>{const el=e.target.closest('[data-chg]');if(!el||(!S&&!['langSet','pickHome'].includes(el.dataset.chg)))return;const fn=ACT[el.dataset.chg];if(fn)fn({v:el.value});}); /* Taps that land on the wrong thing (#44): a real tap only fires the button it went down on, never something that appeared or moved under the finger, nothing behind a menu that opened or closed mid-tap, and no toast button in the first half second after the toast popped up. Synthetic clicks (keyboard, tests) are not affected. */ diff --git a/src/i18n/en.js b/src/i18n/en.js index 64c4e7f..75e5dfe 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -1250,6 +1250,7 @@ "common.spreadsheet_ipam":"Spreadsheet IPAM", "common.stage_six":"Stage Six", "common.standard":"Standard", +"common.standby":"Standby", "common.start_a_new_network":"Start a new network", "common.start_building":"Start building", "common.start_construction":"Start construction", @@ -2093,6 +2094,7 @@ "link_modal.waves_on_the_same_route_share":"Waves on the same route share its fate: one backhoe cuts them all.", "link_modal.you_already_have_n_link_here":{"one":"You already have {n} link here ({list}). Parallel links add capacity. How should this one be routed?","other":"You already have {n} links here ({list}). Parallel links add capacity. How should this one be routed?"}, "link_panels.a_bigger_fabric_carries_more_traffic":"A bigger fabric carries more traffic and has room for more members. Your router here still has to keep up.", +"link_panels.a_link_on_standby_carries_traffic":"A link on standby carries traffic only when the other links between these cities are full or down.", "link_panels.a_regen_site_turns_the_light":"A regen site turns the light back into bits halfway and sends it on fresh, so optics only have to reach the next site. Each needs a regen card for every lit channel. {price}/mo per site for the hut.", "link_panels.abandon_the_fiber":"Abandon the fiber", "link_panels.add_parallel_link":"Add parallel link", @@ -2152,6 +2154,9 @@ "link_panels.not_present_in_any_of_your":"Not present in any of your cities yet", "link_panels.nothing_spare_to_sell_on_this":"Nothing spare to sell on this fiber right now.", "link_panels.off_while_your_peering_policy_is":"Off while your peering policy is {pol}", +"link_panels.on_standby_but_carrying_the_traffic":"On standby, but carrying the traffic: no active link between these cities is up.", +"link_panels.on_standby_idle_while_the_other":"On standby: idle while the other links between these cities have room.", +"link_panels.on_standby_taking_the_overflow":"On standby: taking the overflow, because the other links between these cities are full.", "link_panels.open_peer_but_not_on_any":"Open peer, but not on any IX where you have a POP. Nearest: {city}", "link_panels.open_peer_but_not_on_any_bfbb":"Open peer, but not on any IX where you have a POP", "link_panels.open_peer_join_the_route_server":"Open peer: join the route server at {ix}", @@ -2169,6 +2174,7 @@ "link_panels.ports_at_p_of_the_usual":"Ports at {p}% of the usual price.", "link_panels.ports_up_to_port_are_free":"Ports up to {port} are free.", "link_panels.price_n_days":"{price} · {n} days", +"link_panels.put_this_link_on_standby":"Put this link on standby", "link_panels.ready_for_a_pni_in_city":"Ready for a PNI in {city}", "link_panels.ready_in_n_days":"Ready in {n} days", "link_panels.really_give_it_up":"Really give it up?", @@ -2191,6 +2197,7 @@ "link_panels.spares_kit_on":"Spares kit on ✓", "link_panels.stock_a_spare_optic_price":"Stock a spare {optic} {price}", "link_panels.sys_level_n":"{sys} level {n}", +"link_panels.take_it_off_standby":"Take it off standby", "link_panels.there_s_no_ix_in_city":"There's no IX in {city} yet. Found one: networks join over time, pay you for ports, and peer with you for free.", "link_panels.they_need_the_full_internet_your":"They need the full internet. Your reach is {pct}.", "link_panels.this_fiber_is_dark_add_optics":"This fiber is dark. Add optics below to carry traffic.", @@ -2350,8 +2357,11 @@ "mergers.net_charges_for_peering":"{net} charges for peering, so expect a monthly fee.", "mergers.net_has_swallowed_old":"{net} has swallowed {old}.", "mergers.now_part_of_net":"Now part of {net}: peer with them instead.", +"modal_and_names.found_a_bug_or_have_an":"Found a bug or have an idea?", "modal_and_names.join_the_noc_chat":"Join the NOC chat", -"modal_and_names.our_signal_group_swap_screenshots":"Our Signal group: swap screenshots, report bugs and argue about peering policy with other players. Fewer backhoes than the real thing.", +"modal_and_names.open":"Open →", +"modal_and_names.our_signal_group_screenshots_chat":"Our Signal group: swap screenshots and argue about peering policy with other players. Fewer backhoes than the real thing.", +"modal_and_names.tell_us_on_github_a_short":"Tell us on GitHub: a short form for bug reports, feature ideas, balance and translations. Every one gets read.", "modal_and_names.the_real_thing_by_thomas_kj":"The real thing, by Thomas Kjær Aabo: a zoomable, interactive map of how your packets actually travel, from Wi-Fi to undersea fiber, today, in 2010 and in 1995. This game makes it up as it goes. That one gets it right.", "modal_and_names.the_real_thing_follow_a_packet":"The real thing: follow a packet from Wi-Fi to undersea fiber.", "modals.lay_your_own_subsea_cable":"Lay your own subsea cable…", @@ -3023,16 +3033,19 @@ "supply_chain.until_date_at_p":"until {date}, at +{p}", "supply_chain.what_p_n_days_left":"{what} +{p} · {n} days left", "supply_chain.your_price_lock_covers_you_until":"Your price lock covers you until {date}.", +"title.anywhere_else":"Anywhere else", "title.asia_hub_great_peering_far_from":"Asia hub. Great peering, far from home.", "title.back_to_my_network":"Back to my network", "title.big_hungry_market_few_providers":"Big hungry market, few providers.", "title.build_an_internet_lay_fiber_between":"Build an internet. Lay fiber between cities, buy transit, peer at exchanges, sign up businesses, and keep the eyeballs happy while backhoes, sharks and route leaks do their best to stop you.", "title.chat_on_signal":"Chat on Signal", +"title.choose":"Choose…", "title.continue_name_date":"Continue {name} · {date}", "title.cookieless_stats_no_tracking":"Cookieless stats, no tracking", "title.crossroads_of_europe_de_kicks_ix":"Crossroads of Europe. DE-KICKS IX, cheap transit.", -"title.hard_mode_everything_overseas_costs":"Hard mode. Everything overseas costs a fortune, locals pay top dollar, mostly to the Nearly Broadband Network, and everything else is trying to kill you.", +"title.hard_mode_pricey_everything":"Hard mode. Pricey everything, and the wildlife wants you dead.", "title.huge_eyeball_market_pricey":"Huge eyeball market. Pricey neighbours.", +"title.n_more_cities_with_transit":{"one":"{n} more city with transit to buy","other":"{n} more cities with transit to buy"}, "title.name_your_network":"Name your network", "title.new_in_series_of_tubes_v":"New in Series of Tubes {v}", "title.pick_your_home_city":"Pick your home city", diff --git a/src/styles/40-modal.css b/src/styles/40-modal.css index 721724b..4e1845f 100644 --- a/src/styles/40-modal.css +++ b/src/styles/40-modal.css @@ -26,7 +26,15 @@ @media (prefers-reduced-motion:reduce){:root:not(.anim-force) .coach-glow{animation:none;outline:3px solid #FF4F9A}} :root.no-anim .coach-glow{outline:3px solid #FF4F9A} .setline{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:4px 0} -.setline>span{font-weight:800} +.setline>span,.setline>label{font-weight:800} +/* Title screen: the big start button across the top, the three others below it, all the same size. */ +.btns.tcta{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px} +.btns.tcta .b{margin:0;display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.15;white-space:normal;hyphens:auto;-webkit-hyphens:auto;min-height:40px;padding:4px 6px;font-size:14px} +.btns.tcta .b.big{grid-column:1/-1;font-size:18px;padding:7px 18px 5px} +/* Dropdowns that look like the game's buttons. 16px text: iOS zooms into anything smaller when it is tapped. */ +select.pick{-webkit-appearance:none;appearance:none;font:800 16px var(--display);color:var(--ink);background:var(--soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231E2640' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;border:3px solid var(--ink);border-radius:12px;padding:6px 36px 6px 12px;min-height:44px;cursor:pointer;box-shadow:0 3px 0 var(--ink)} +select.pick:focus-visible{outline:3px solid #FF4F9A;outline-offset:2px} +label.f+select.pick{width:100%} .thb{font:inherit;font-weight:900;background:none;border:0;padding:0;cursor:pointer;color:inherit} .ttop{margin:4px 0;padding:4px 8px;border-left:3px solid #FF8A3D;background:#FFF6EC;border-radius:6px} .ibx{border:2px solid var(--line,#DDE3EE);border-radius:12px;padding:8px 10px;margin:8px 0;background:#fff}.ibx .nm{font-weight:800}.ibx.mp{border-color:#FF5A5F;background:#FFF1F1}.ibx.ai{border-color:#8E5CF7;background:#F7F2FF}.ibx .term{font-size:11.5px;white-space:pre-wrap;max-height:180px;overflow:auto}.ibx .cnt{display:inline-block;min-width:18px;padding:0 5px;border-radius:9px;background:var(--me);color:#fff;font-size:11px;text-align:center}.ibx .cnt.red{background:#FF5A5F} @@ -97,6 +105,15 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi .start.on{background:#FFE3F0;border-color:var(--me);box-shadow:0 3px 0 var(--me)} .start b{font-family:var(--display);font-size:17px;display:block} .start span{font-size:12px;color:var(--ink2);line-height:1.3;display:block} +/* Home cities: compact tiles stacked in one column, the dropdown for any other city last. */ +.starts.homes{display:flex;flex-direction:column;gap:6px} +.homes .start{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:10px;row-gap:2px;padding:6px 12px;box-shadow:0 2px 0 var(--ink)} +.homes .start.on{box-shadow:0 2px 0 var(--me)} +.homes .start b{font-size:16px;flex:0 0 8.4em} +.homes .start span{flex:1 1 10em;min-width:0} +.homes .start.own select.pick{flex:1 1 100%;margin:4px 0 2px;min-height:40px;font-size:16px;box-shadow:none;border-width:2px;padding-right:30px;background-position:right 9px center} +/* In Settings it sits next to small On/Off pills: same 16px text, slimmer frame. */ +.setline select.pick{min-height:36px;padding:4px 30px 4px 10px;border-width:2px;border-radius:10px;box-shadow:0 2px 0 var(--ink);background-position:right 9px center} .tiers{display:grid;gap:7px;margin-top:10px} .tierbtn{display:flex;align-items:center;gap:10px;border:3px solid var(--ink);border-radius:13px;padding:8px 12px;background:var(--paper);cursor:pointer;box-shadow:0 3px 0 var(--ink);text-align:left} .tierbtn:hover{background:#FFF6CF} diff --git a/tests/any-home-city.test.js b/tests/any-home-city.test.js new file mode 100644 index 0000000..e1d411c --- /dev/null +++ b/tests/any-home-city.test.js @@ -0,0 +1,56 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +const choose = (ev, v) => ev(`(()=>{const s=document.getElementById('homeSel');s.value=${JSON.stringify(v)};s.dispatchEvent(new Event('change',{bubbles:true}));})()`); +const onTiles = ev => JSON.parse(ev("JSON.stringify([...document.querySelectorAll('.starts .start.on')].map(b=>b.dataset.city||'own'))")); + +test('the title screen offers five homes and a sixth tile for any city, grouped by continent', () => { + const { ev, errors } = load(); + assert.equal(ev('S'), null, 'before any game exists'); + assert.equal(ev("document.querySelectorAll('.starts .start').length"), 6); + const opts = JSON.parse(ev("JSON.stringify([...document.querySelectorAll('#homeSel option')].map(o=>o.value).filter(Boolean))")); + assert.ok(opts.length > 150, `lots of cities (${opts.length})`); + assert.ok(opts.every(c => ev(`homeOk('${c}')`)), 'only cities that work as a home'); + assert.ok(!opts.some(c => ev(`!!CITY['${c}'].cn||!!CITY['${c}'].off`)), 'no hidden or Chinese cities'); + assert.ok(!opts.includes('stg'), 'no city without transit to buy'); + assert.ok(ev("document.querySelectorAll('#homeSel optgroup').length") >= 5, 'grouped by continent'); + assert.deepEqual(errors, []); +}); + +test('picking any city starts the network there, and the tiles follow the choice', () => { + const { ev, errors } = load(); + choose(ev, 'lis'); + assert.equal(ev('UI.startCity'), 'lis'); + assert.deepEqual(onTiles(ev), ['own'], 'the sixth tile lights up'); + assert.equal(ev("document.getElementById('homeWhat').textContent"), 'Lisbon · ' + ev("REG[CITY.lis.reg]"), 'and names the city in full'); + ev("document.querySelector('.start[data-city=nyc]').click()"); + assert.deepEqual(onTiles(ev), ['nyc'], 'a suggested tile takes over again'); + assert.equal(ev("document.getElementById('homeSel').value"), '', 'and the dropdown resets'); + assert.match(ev("document.getElementById('homeWhat').textContent"), /more cities/); + choose(ev, 'akl'); + ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip()"); + assert.equal(ev('S.home'), 'akl'); + assert.ok(ev("!!S.pops.akl"), 'the first POP is in Auckland'); + assert.ok(ev("NETS.some(n=>sellsAt(n,'akl'))"), 'with transit to buy'); + assert.deepEqual(errors, []); +}); + +test('a home that cannot work is refused, and the game falls back to Frankfurt', () => { + const { ev, errors } = load(); + ev("ACT.pickStart({city:'stg'});ACT.pickStart({city:'pek'});ACT.pickStart({city:'nowhere'})"); + assert.equal(ev('UI.startCity'), 'fra'); + ev("UI.startCity='pek';ACT.start({})"); + assert.equal(ev('S.home'), 'fra'); + assert.deepEqual(errors, []); +}); + +test('the sixth tile works on a phone and in every language', () => { + for (const lang of ['en', 'it', 'pt', 'fr', 'es']) { + const { ev, errors } = load(lang === 'en' ? {} : { lang }); + ev('window.innerWidth=360;showTitle()'); + assert.equal(ev("document.querySelector('label.start.own b').textContent"), ev("tr('title.anywhere_else')"), lang); + if (lang !== 'en') assert.notEqual(ev("tr('title.anywhere_else')"), 'Anywhere else', `${lang}: translated`); + assert.deepEqual(errors, []); + } +}); diff --git a/tests/i18n.test.js b/tests/i18n.test.js index 3de8051..9b38d9a 100644 --- a/tests/i18n.test.js +++ b/tests/i18n.test.js @@ -108,9 +108,10 @@ test('the static markup is translated by label', () => { assert.equal(ev("document.querySelector('[data-act=help]').getAttribute('aria-label')"), ev("tr('common.how_to_play')")); }); -test('the language buttons on the title screen work before any game exists', () => { +test('the language dropdown on the title screen works before any game exists', () => { const { ev } = load(); - ev("[...document.querySelectorAll('#modalCard [data-act=langSet]')].find(b=>b.textContent==='Italiano').click()"); + assert.equal(ev('S'), null); + ev("const s=document.querySelector('#modalCard select#langTitle');s.value='it';s.dispatchEvent(new Event('change',{bubbles:true}))"); assert.equal(ev("localStorage.getItem('sot-lang')"), 'it'); }); diff --git a/tests/issues.test.js b/tests/issues.test.js index e4b3264..13164fe 100644 --- a/tests/issues.test.js +++ b/tests/issues.test.js @@ -331,7 +331,8 @@ test('#40 overland between continents costs ten times subsea or more, and has no const sub=waveMo(c.km,true,2)*CAB[c.cid].price*waveMarket(c.a,c.b,true).m;return [land/sub,!!(CITY[c.a].land2||CITY[c.b].land2)];}))`)); assert.ok(r.length >= 4, 'Europe–Asia cable routes exist to compare'); // Across a land bridge (Cairo, #47) the cable goes the long way round Arabia, so overland is "only" 4–9× dearer. - for (const [x, bridge] of r) assert.ok(x >= (bridge ? 4 : 10), `overland is at least ${bridge ? 4 : 10}× subsea (${x.toFixed(1)})`); + // EIG from Dubai now follows Arabia and the Suez Canal at sea, which makes it a little longer: 9.97× (#183). + for (const [x, bridge] of r) assert.ok(x >= (bridge ? 4 : 9.5), `overland is at least ${bridge ? 4 : 9.5}× subsea (${x.toFixed(1)})`); assert.equal(ev("landX('mrs','hkg')"), true); assert.equal(ev("landX('fra','mrs')"), false, 'inside Europe stays normal'); assert.equal(ev("landMult('fra','mrs')"), 1); diff --git a/tests/language-picker.test.js b/tests/language-picker.test.js new file mode 100644 index 0000000..9bca04a --- /dev/null +++ b/tests/language-picker.test.js @@ -0,0 +1,39 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +const pick = (ev, id) => JSON.parse(ev(`(()=>{const s=document.getElementById('${id}');return JSON.stringify(s&&{tag:s.tagName,value:s.value,chg:s.dataset.chg, + opts:[...s.options].map(o=>[o.value,o.textContent,o.lang]),label:(document.querySelector('label[for=${id}]')||{}).textContent});})()`)); + +test('language is one dropdown on the title screen and in Settings, in every language, with the current one selected', () => { + for (const lang of ['en', 'it', 'pt', 'fr', 'es']) { + const { ev, errors } = load(lang === 'en' ? {} : { lang }); + const langs = JSON.parse(ev('JSON.stringify(Object.entries(LANGS))')); + const title = pick(ev, 'langTitle'); + assert.equal(title.tag, 'SELECT', `${lang}: title screen`); + assert.equal(title.value, lang); + assert.deepEqual(title.opts, langs.map(([v, l]) => [v, l, v]), `${lang}: every language, named in itself`); + assert.equal(title.label, ev("tr('common.language')"), `${lang}: labelled`); + assert.equal(ev("document.querySelectorAll('#modalCard [data-act=langSet]').length"), 0, `${lang}: no language buttons left`); + ev("ACT.start({});ACT.settings()"); + const set = pick(ev, 'langSel'); + assert.equal(set.value, lang, `${lang}: settings`); + assert.equal(set.label, ev("tr('common.language')")); + assert.deepEqual(errors, []); + } +}); + +test('changing the dropdown in Settings switches language and keeps the game', () => { + const { ev, errors } = load(); + ev("ACT.start({});dayTick();ACT.settings();const s=document.getElementById('langSel');s.value='fr';s.dispatchEvent(new Event('change',{bubbles:true}))"); + assert.equal(ev("localStorage.getItem('sot-lang')"), 'fr'); + assert.ok(ev("localStorage.getItem('sot-save-v1')"), 'saved before reloading'); + assert.deepEqual(errors, []); +}); + +test('the dropdown fits a phone', () => { + const { ev, errors } = load(); + ev('window.innerWidth=360;showTitle()'); + assert.ok(ev("document.getElementById('langTitle').classList.contains('pick')")); + assert.deepEqual(errors, []); +}); diff --git a/tests/link-metrics.test.js b/tests/link-metrics.test.js new file mode 100644 index 0000000..e5ed30b --- /dev/null +++ b/tests/link-metrics.test.js @@ -0,0 +1,139 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +// Waves between Frankfurt and Amsterdam (tier 3 is 800G, tier 0 is 10G), transit in Amsterdam, eyeballs in Frankfurt. +function setup(ev, tiers = [3, 3]) { + ev("ACT.start({});S.cash=1e8;S.lvl=4;for(const g of GOALS)S.done[g.id]=0"); + ev("ACT.buildPop({city:'ams'});for(const c in S.pops){S.pops[c].rgen=3;S.pops[c].routers=2}"); + ev("ACT.launchBB({city:'fra'});ACT.buyTransit({city:'ams',net:'lvl',tier:3})"); + tiers.forEach((t, i) => ev(`UI.via=null;openLinkModal('fra','ams');ACT.buildLink({tier:${t}});closeModal();S.links[S.links.length-1].tag=${i}`)); + ev("var L=i=>S.links.find(l=>l.tag===i),L1=L(0),L2=L(1);compute()"); +} +const load_ = (ev, x) => ev(`R.load[${x}.id]||0`); +const body = dom => dom.window.document.body.textContent; + +test('#122 the routing metric belongs to the city pair', () => { + const { ev, errors } = load(); + setup(ev); + ev("ACT.setMetric({id:L2.id,v:'avoid'})"); + assert.equal(ev("S.pairMet['ams|fra']"), 'avoid'); + ev("ACT.selLink({id:L1.id});renderAll()"); + assert.ok(ev("[...document.querySelectorAll('[data-act=\"setMetric\"]')].some(b=>b.className.includes('pink')&&/Avoid/.test(b.textContent))"), 'the other link shows the same metric'); + ev("ACT.setMetric({id:L1.id,v:'normal'})"); + assert.equal(ev("'ams|fra' in S.pairMet"), false); + assert.deepEqual(errors, []); +}); + +test('#122 a link on standby idles while the others have room and takes over when they fail', () => { + const { ev, dom, errors } = load(); + setup(ev); + const total = ev("R.served"); + assert.ok(load_(ev, 'L1') > 0 && load_(ev, 'L2') > 0, 'active links share the load'); + ev("ACT.setStandby({id:L2.id,on:1});compute()"); + assert.equal(ev("L2.standby"), true); + assert.ok(load_(ev, 'L1') > 0); + assert.equal(load_(ev, 'L2'), 0, 'standby link idles'); + assert.ok(Math.abs(ev("R.served") - total) < 1e-6, 'nothing is lost'); + ev("ACT.selLink({id:L2.id});renderAll()"); + assert.match(body(dom), /On standby: idle while the other links/); + ev("L1.cut=S.day+5;compute();renderAll()"); + assert.ok(load_(ev, 'L2') > 0, 'standby link takes over when the active one is cut'); + assert.match(body(dom), /On standby, but carrying the traffic/); + // Every link on standby: they share the traffic like active ones, and the note does not claim the others are down. + ev("L1.cut=0;ACT.setStandby({id:L1.id,on:1});compute();renderAll()"); + assert.ok(load_(ev, 'L1') > 0 && load_(ev, 'L2') > 0); + assert.match(body(dom), /no active link between these cities is up/); + ev("ACT.setStandby({id:L2.id,on:0})"); + assert.equal(ev("'standby' in L2"), false); + assert.deepEqual(errors, []); +}); + +test('#122 a standby link takes the overflow when the active links are full', () => { + const { ev, dom, errors } = load(); + setup(ev, [0, 3]); // 10G active, 800G next to it + const total = ev("R.served"); + ev("ACT.setStandby({id:L2.id,on:1});compute()"); + const cap = ev("capOf(L1)"); + assert.ok(Math.abs(load_(ev, 'L1') - cap) < 1e-6, 'the active link fills up first'); + assert.ok(load_(ev, 'L2') > 0, 'the rest spills onto the standby link'); + assert.ok(Math.abs(ev("R.served") - total) < 1e-6, 'standby capacity is never wasted'); + ev("ACT.selLink({id:L2.id});renderAll()"); + assert.match(body(dom), /taking the overflow/); + assert.deepEqual(errors, []); +}); + +test('#122 the order links are built in does not change where traffic goes', () => { + const tiers = [3, 0, 3], standby = [true, false, false], seen = new Set(); + for (const order of [[0, 1, 2], [2, 1, 0], [1, 0, 2], [2, 0, 1]]) { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e8;S.lvl=4;for(const g of GOALS)S.done[g.id]=0"); + ev("ACT.buildPop({city:'ams'});for(const c in S.pops){S.pops[c].rgen=3;S.pops[c].routers=2}"); + ev("ACT.launchBB({city:'fra'});ACT.buyTransit({city:'ams',net:'lvl',tier:3})"); + for (const i of order) ev(`UI.via=null;openLinkModal('fra','ams');ACT.buildLink({tier:${tiers[i]}});closeModal();const l=S.links[S.links.length-1];l.tag=${i};if(${standby[i]})ACT.setStandby({id:l.id,on:1})`); + ev("ACT.setMetric({id:S.links[0].id,v:'prefer'});compute()"); + seen.add(ev("JSON.stringify([0,1,2].map(i=>Math.round((R.load[S.links.find(l=>l.tag===i).id]||0)*1e6)))")); + assert.deepEqual(errors, []); + } + assert.equal(seen.size, 1, [...seen].join(' vs ')); +}); + +test('#122 a new link between the same cities adds capacity and keeps the pair metric', () => { + const { ev, errors } = load(); + setup(ev, [0]); + ev("ACT.setMetric({id:L1.id,v:'avoid'});ACT.setStandby({id:L1.id,on:1});compute()"); + const before = ev("R.served"); + ev("UI.via=null;openLinkModal('fra','ams');ACT.buildLink({tier:3});closeModal();compute()"); + const nl = "S.links[S.links.length-1]"; + assert.equal(ev(`'standby' in ${nl}`), false, 'a new link starts active'); + assert.equal(ev("pairMet('ams|fra')"), 'avoid'); + assert.ok(ev("R.served") > before, 'more capacity, more traffic'); + // The metric leaves with the last link, so a fresh link later starts on normal. + for (const id of ev("S.links.map(l=>l.id)")) ev(`UI.confirm=null;ACT.rmLink({id:'${id}'});ACT.rmLink({id:'${id}'})`); + assert.equal(ev("'ams|fra' in S.pairMet"), false); + assert.deepEqual(errors, []); +}); + +test('#122 old saves keep routing as before: per-link metrics become the pair metric', () => { + const { ev, errors } = load(); + setup(ev); + // Every link on avoid: the pair is on avoid. + ev("delete S.pairMet;L1.metric='avoid';L2.metric='avoid';S=migrate(JSON.parse(JSON.stringify(S)))"); + assert.equal(ev("S.pairMet['ams|fra']"), 'avoid'); + assert.equal(ev("S.links.some(l=>'metric' in l)"), false); + // Mixed metrics routed at the lowest one, all links carrying: no standby, normal. + ev("S.pairMet={};S.links[0].metric='backup';S.links[1].standby='yes';S=migrate(JSON.parse(JSON.stringify(S)));compute()"); + assert.equal(ev("'ams|fra' in S.pairMet"), false); + assert.equal(ev("S.links.some(l=>'standby' in l||'metric' in l)"), false); + assert.ok(ev("S.links.every(l=>R.load[l.id]>0)")); + // Junk in the new field is dropped. + ev("S.pairMet={'ams|fra':'warp','fra|lon':'avoid'};S=migrate(JSON.parse(JSON.stringify(S)))"); + assert.deepEqual(JSON.parse(ev("JSON.stringify(S.pairMet)")), {}); + assert.deepEqual(errors, []); +}); + +test('#122 traceroute shows an active link, not one on standby', () => { + const { ev, errors } = load(); + setup(ev); + ev("ACT.setStandby({id:L1.id,on:1})"); + assert.equal(ev("trPaths('ams').path('fra')[0].l.id===L2.id"), true); + ev("ACT.setStandby({id:L1.id,on:0});ACT.setStandby({id:L2.id,on:1})"); + assert.equal(ev("trPaths('ams').path('fra')[0].l.id===L1.id"), true); + assert.deepEqual(errors, []); +}); + +test('#122 the standby button shows next to another link, on desktop and phone', () => { + const { ev, dom, errors } = load(); + setup(ev); + for (const w of [1280, 390]) { + ev(`window.innerWidth=${w};ACT.selLink({id:L1.id});renderAll()`); + const b = dom.window.document.querySelector('[data-act="setStandby"]'); + assert.ok(b, `standby button at ${w}px`); + assert.match(b.textContent, /Put this link on standby/); + } + ev("S.links=S.links.filter(l=>l!==L2);ACT.selLink({id:L1.id});renderAll()"); + assert.equal(dom.window.document.querySelector('[data-act="setStandby"]'), null, 'nothing to stand by for'); + ev("L1.standby=true;renderAll()"); + assert.match(dom.window.document.querySelector('[data-act="setStandby"]').textContent, /Take it off standby/); + assert.deepEqual(errors, []); +}); diff --git a/tests/more-cables.test.js b/tests/more-cables.test.js index e0998f7..ba03420 100644 --- a/tests/more-cables.test.js +++ b/tests/more-cables.test.js @@ -41,6 +41,18 @@ test('the Indian Ocean and Asia-Pacific: the big real cables, Muscat, the Maldiv } // every cable pair has a drawn route and a sane length assert.equal(ev("CABLE_PAIRS.filter(p=>!(p.km>0&&p.km<25000)||p.pts.some(q=>!isFinite(q[0])||!isFinite(q[1]))).length"), 0); + // no route jumps across the whole map at the ±180° seam: waypoints keep continuous longitudes (#183) + assert.deepEqual(JSON.parse(ev("JSON.stringify(CABLE_PAIRS.filter(p=>p.pts.some((q,i)=>i&&Math.abs(q[0]-p.pts[i-1][0])>W/3)).map(p=>p.cid+':'+p.a+'-'+p.b))")), []); + assert.ok(ev("cablePair('fast','sea','osa').km") < 9500, 'FASTEST to Osaka crosses the Pacific, not the world'); + // subsea cables stay at sea: a stretch over land with sea on both sides is the line cutting across a coast. + // Allowed: the Suez Canal and the Dardanelles (not water in the coastline), and Quintillion's overland Alaska leg. + const cross = JSON.parse(ev(`JSON.stringify((()=>{const big=COAST.filter(p=>ringArea(p)>=40).map(p=>{let a=1e9,b=-1e9,c=1e9,d=-1e9;for(const [x,y] of p){a=Math.min(a,x);b=Math.max(b,x);c=Math.min(c,y);d=Math.max(d,y);}return {p,a,b,c,d};}); + const on=(x,y)=>{x=((x%W)+W)%W;return big.some(q=>x>=q.a&&x<=q.b&&y>=q.c&&y<=q.d&&inPoly(x,y,q.p));};const out=[]; + for(const p of CABLE_PAIRS){if(p.cid==='qtl'&&[p.a,p.b].sort().join()==='anc,brw')continue;const s=[]; + for(let i=1;ion(q[0],q[1]));let i=0;while(i0&&j160)out.push(p.cid+':'+p.a+'-'+p.b+' '+Math.round(km)+' km');i=j+1;}} + return out;})())`)); + assert.deepEqual(cross, [], 'cables cutting across land'); // a hop on one of the new cables carries traffic ev("for(const c of ['sin','hkg']){ACT.buildPop({city:c});S.pops[c].rgen=3;}UI.via='sjc2';UI.route='same';openLinkModal('sin','hkg');ACT.buildLink({tier:2});closeModal();compute()"); assert.ok(ev("S.links.some(l=>l.cable==='sjc2')"), 'a wave on SJC2'); diff --git a/tests/new-game-speed.test.js b/tests/new-game-speed.test.js new file mode 100644 index 0000000..c7c9699 --- /dev/null +++ b/tests/new-game-speed.test.js @@ -0,0 +1,38 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +test('#186 a new network starts at half speed, even after a game at 8×', () => { + const { ev, dom, errors } = load(); + ev("ACT.start({});ACT.speed({v:8})"); + assert.equal(ev('UI.speed'), 8); + ev("ACT.newgame();ACT.start({})"); + assert.equal(ev('UI.speed'), 0.5, 'normal game'); + assert.ok(dom.window.document.getElementById('sp0.5').classList.contains('on'), 'the HUD shows ½×'); + ev("ACT.speed({v:0});ACT.newgame();UI.mode='sandbox';ACT.start({})"); + assert.equal(ev('UI.speed'), 0.5, 'sandbox, and a paused game does not stay paused'); + ev("ACT.speed({v:4});ACT.startScn({id:SCN[0].id,sure:1})"); + assert.equal(ev('UI.speed'), 0.5, 'scenario'); + ev("ACT.speed({v:2});ACT.startWeekly({sure:1})"); + assert.equal(ev('UI.speed'), 0.5, 'weekly challenge'); + assert.deepEqual(errors, []); +}); + +test('#186 on a phone, play after pause resumes at half speed, not the old game\'s speed', () => { + const { ev, errors } = load(); + ev("window.innerWidth=360;ACT.start({});ACT.phoneSpeed();ACT.phoneSpeed();ACT.phoneSpeed()"); + assert.notEqual(ev('UI.lastSpeed'), 0.5); + ev("ACT.newgame();ACT.start({});if(UI.pendGame)ACT.pitchSkip();ACT.phonePlay();ACT.phonePlay()"); + assert.ok(ev("UI.started&&!UI.pendGame"), "the new game is running"); + assert.equal(ev('UI.speed'), 0.5); + assert.deepEqual(errors, []); +}); + +test('#186 a saved game still continues at the speed it was saved at', () => { + const a = load(); + a.ev("ACT.start({});ACT.speed({v:4});save(true)"); + const b = load({ storage: { 'sot-save-v1': a.ev("localStorage.getItem('sot-save-v1')") } }); + assert.equal(b.ev('UI.speed'), 4); + assert.deepEqual(a.errors, []); + assert.deepEqual(b.errors, []); +}); diff --git a/tests/regions.test.js b/tests/regions.test.js index f5947af..1ac3be1 100644 --- a/tests/regions.test.js +++ b/tests/regions.test.js @@ -786,8 +786,9 @@ test('Atlantic islands and Halifax: real landings, real exchanges only, and isla assert.equal(hop(['mia', 'pdl', 'lis']), 1600, 'Florida to Lisbon via the Azores'); assert.equal(direct('atn', 'lis'), 1200); assert.equal(hop(['atn', 'bda', 'lis']), 1600); - assert.equal(direct('lis', 'lag'), 1200); + // Equi-yes follows the coast close enough to fit 1.6T on its own; the Canaries hop matches it assert.equal(hop(['lis', 'tci', 'lag']), 1600, 'Lisbon to Lagos via the Canaries'); + assert.ok(hop(['lis', 'tci', 'lag']) >= direct('lis', 'lag')); assert.equal(direct('for', 'mad'), 1200); assert.equal(hop(['for', 'rai', 'lis']), 1600, 'Brazil to Europe via Cape Verde'); assert.equal(hop(['nyc', 'hfx']), 3200); diff --git a/tests/report-link.test.js b/tests/report-link.test.js new file mode 100644 index 0000000..cd0e2a6 --- /dev/null +++ b/tests/report-link.test.js @@ -0,0 +1,29 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +const ISSUES = 'https://github.com/fjaeckel/seriesoftubes/issues/new/choose'; + +test('bugs and ideas point to GitHub from the menu and How to play, and the chat no longer asks for bug reports', () => { + for (const lang of ['en', 'it', 'pt', 'fr', 'es']) { + const { ev, errors } = load(lang === 'en' ? {} : { lang }); + ev('ACT.start({})'); + for (const [where, setup] of [['menu', 'ACT.menu()'], ['help', 'showHelp()']]) { + const cards = JSON.parse(ev(`(()=>{${setup};return JSON.stringify([...document.querySelectorAll('#modal a[href="${ISSUES}"]')].map(a=>[a.target,a.rel,a.textContent.trim()]));})()`)); + assert.equal(cards.length, 1, `${lang}: one GitHub card in ${where}`); + assert.deepEqual(cards[0].slice(0, 2), ['_blank', 'noopener'], `${lang}: opens in a new tab`); + if (lang !== 'en') assert.doesNotMatch(cards[0][2], /Found a bug/, `${lang}: translated`); + const chat = ev(`[...document.querySelectorAll('#modal a.chat')].map(a=>a.textContent).join(' ')`); + assert.doesNotMatch(chat, /report bugs|segnala bug|reporte bugs|signale des bugs|informa de fallos/, `${lang}: the chat card is for chatting`); + } + assert.deepEqual(errors, []); + } +}); + +test('the GitHub card fits a phone', () => { + const { ev, errors } = load(); + ev("ACT.start({});window.innerWidth=360;ACT.menu()"); + assert.ok(ev('isPhone()')); + assert.ok(ev(`!!document.querySelector('#modal a.plug[href="${ISSUES}"] .go')`), 'same card layout as the chat card'); + assert.deepEqual(errors, []); +});