Satellite teleports: GEO and MEO circuits for islands and remote towns (#83)

The early and mid-game satellite option, before Pie in the Sky. Build a
teleport at a POP that a satellite sees, then rent capacity from it to
a remote POP: GEO (Intelsplat, Kacophony) needs no capex but costs a lot
a month per Gbps, 1-10 Gbps at about 600 ms; MEO (O3bservant) needs
tracking antennas at the teleport and gives multi-Gbps at about 130 ms
where both ends are under its ring, at least 5 degrees up. Coverage
follows each bird's footprint by ocean region. Latency feeds the latency
model: users who ride a satellite notice, in proportion to the share.

A circuit beside a cable goes on standby, whichever came first, and
carries only what the cable cannot: the classic single-cable island
backup. Satellites are not subsea links for covenants, scenario goals or
subsidies (Pitcairn's UK grant needs a cable). Express fiber and the
build standard leave satellite circuits alone.
This commit is contained in:
jvanvik 2026-11-07 01:12:23 +01:00
parent 8e1f2d66a5
commit e1ae8e0164
46 changed files with 1176 additions and 55 deletions

View file

@ -24,7 +24,7 @@ These are what the game promises, held up by `tests/gameplay-rules.test.js` (one
| --- | --- | --- |
| W1 | Every city has a country code (`cc`, ISO 3166-1 alpha-2; territories have their own: PR, GU, RE, MQ, CW…), a region, a landmass and coordinates. | Borders, prices and the eyeball rule all hang off the country. |
| W2 | Every country on the map has at least two consumer networks of its own: an eyeball network, or a Tier 1 or Tier 2 incumbent that sells to homes, whose home markets (`cc` on the network) include that country and which has a PoP there. | Real countries have competing local ISPs, and peering locally is half the game. Add real operators in `src/game/30-networks/32-homegrown-eyeballs.js`. |
| W3 | Every city can buy transit from someone, or is a documented exception (Pitcairn: land your own cable, or reach it through a pie dish; Stuttgart: peering only). | A start or an expansion must never be a dead end by accident. |
| W3 | Every city can buy transit from someone, or is a documented exception (Pitcairn: land your own cable, reach it through a pie dish, or rent a satellite circuit from a teleport; Stuttgart: peering only). | A start or an expansion must never be a dead end by accident. |
| W4 | Cable pairs join two distinct real cities, have a length, and cable ids are unique. | Broken landings break routing and the own-cable planner. |
| W5 | A city alone on its landmass has a cable or a beach to land one. | Islands are reachable. |
@ -33,7 +33,7 @@ These are what the game promises, held up by `tests/gameplay-rules.test.js` (one
| Id | Rule | Why |
| --- | --- | --- |
| N1 | Network ids and ASNs are unique; ASNs are public (the real one for real-world networks). | Saves key on ids; players look ASNs up. |
| N2 | Names are puns: no network, cable, exchange, data center, router, optic, cable ship or maintenance club is called by a real name (blocklist `REAL_NAMES` in the test), and no lazy "-ish" names. | CLAUDE.md. Add the real name to the blocklist whenever you add its pun. |
| N2 | Names are puns: no network, cable, exchange, data center, router, optic, satellite or satellite operator, cable ship or maintenance club is called by a real name (blocklist `REAL_NAMES` in the test), and no lazy "-ish" names. | CLAUDE.md. Add the real name to the blocklist whenever you add its pun. |
| N3 | Every non-Tier-1, non-content network is in a founding Tier 1's customer cone (`up`), or is a documented island (transit-free incumbents, China, Korea, Australia…). Upstreams exist and are never content. | Tier 1 by customer cone (#85): a new network outside the cones makes Tier 1 harder for every save, old ones included. |
| N4 | No upstream cycles. | Cones must be trees, not loops. |
| N5 | Traffic shares are positive and below 20%; `NSH` and the regional tables sum to 1; content carries at least 30%. | Shares drive every flow; eyeballs mostly ask for traffic. |

View file

@ -10,6 +10,7 @@ All notable changes to this project are documented here. The project follows
- Copies of the game you host yourself can now have multiplayer: friends join your session with a six-character code and build their networks next to yours in the same world, with a leaderboard, a feed with chat, saves kept on your server and a link to carry a network to another device. It needs the small session server that comes with the source code, so the game at seriesoftub.es stays single-player.
- Dark mode: pick Light, Dark or Auto (follows your device) under Settings › Theme. The panels, the NOC dashboard and the map all go dark, with a night-time sea and land, and the setting is kept on your device (#80).
- Express lightpaths: light a wave straight through the cities between your own dark fibers, without touching the routers there. Wherever two or more of your ROADM fibers on land meet, a fiber's panel lists where an express can go and the link window gets an Express tab; it uses ports only at its two ends, saves a hop of latency and takes one channel slot on every fiber it rides, and the light has to reach all the way between regen sites. A cut or a line system swap on any of those fibers darkens it, and a fiber can only be given up once no express rides it. (#58)
- Teleports bring satellites to small islands and remote towns, long before you have a cable there or a rocket company (#83). Build one at a POP from level 2 and rent GEO circuits (about 600 ms round trip, and users notice) or, with tracking antennas from level 3, MEO circuits (about 130 ms) to any island or town its satellites see. Next to an island's only cable a circuit waits on standby (whether the cable or the circuit came first) and carries the island when the cable is cut, and a city with no cable at all gets a POP and a circuit in one order.
- Your intern can standardize your routers on a model you choose: pick it in Keep routers ahead, and every POP on a smaller model is swapped to it, the busiest first, within the monthly budget. Every setting in the Standing orders sheet is now a list to pick from instead of a button to tap through.
- Set a build standard for your whole network: routers, a second building and a generator at every POP, LAGs, exchange ports and PNIs, line systems, optics and wave sizes, all in one sheet. New POPs get the POP part the day they open, the sheet shows what is below the standard and what fixing it costs, one tap brings everything up, and the new "Keep to the build standard" order has your intern do it a few jobs a day with money to spare. Find it in the menu, the Standing orders sheet and every POP's router section.
- IPv4 is scarce now: business customers need public address blocks, and the homes that do not fit share addresses behind CGNAT. A new network starts with a /21 from its registry, enough for its first months; buy, lease or sell blocks from /24 to /16 on the transfer market in the bank's new Address space section, or lease spare ones out for a monthly income. An offer you have no addresses for says so and waits, a customer that wants to grow at renewal stays at its size until you have the addresses, CGNAT costs a little and annoys some gamers, and you pick how many homes share an address. IPv6 stays free for everyone. This is part of On-call and BGP at 3 a.m.; the gentler rules, Sandbox, puzzles and scenarios keep IPv4 plentiful, and saved games get the addresses they already use plus room to grow (#150).

View file

@ -3927,6 +3927,7 @@
"pie_traffic.via_dishes":"hoch in {up}, runter in {down}",
"pitcairn.uk_grant_mo":"Zuschuss aus UK {mo}/Monat",
"pitcairn.uk_grant_mo_once_islanders":"Zuschuss aus UK {mo}/Monat, sobald die Inselbewohner online sind",
"pitcairn.uk_grant_needs_a_cable":"Zuschuss aus UK {mo}/Monat nur mit Kabel: gemietete Satellitenkapazität zählt nicht",
"pitcairn.uk_sky_grant_mo":"Satelliten-Zuschuss aus UK {mo}/Monat (Glasfaser bekommt {full})",
"pni_all.additional_per_month":"Zusätzliche Kosten pro Monat",
"pni_all.all_at_port":"Mit allen Netzen peeren · {port}",
@ -4534,6 +4535,75 @@
"sales.w_last":"Letzte Woche: {name} {list}.",
"sales.w_now":"Diese Woche: {name} {list}.",
"sales.w_signed":{"one":"hat einen Kunden gewonnen ({rev}/Monat)","other":"hat {n} Kunden gewonnen ({rev}/Monat)"},
"satellites.a_teleport_is_a_satellite_gateway":"Ein Teleport ist ein Satelliten-Gateway: große Schüsseln an diesem POP, die Kapazität auf fremden Satelliten mieten, für kleine Inseln und abgelegene Orte, die kein Kabel erreicht, oder die an einem Kabel und einem Stoßgebet hängen.",
"satellites.add_tracking_antennas_cost_mo":"MEO-Nachführantennen <small>{cost} + {mo}/Monat</small>",
"satellites.being_commissioned":"Wird in Betrieb genommen",
"satellites.build_a_teleport_cost_mo":"Teleport bauen <small>{cost} + {mo}/Monat</small>",
"satellites.by_satellite":"Per Satellit",
"satellites.cancel_n_circuits_first":{"one":"Kündige zuerst seine Satellitenverbindung.","other":"Kündige zuerst seine {n} Satellitenverbindungen."},
"satellites.choose":"Wählen",
"satellites.circuit_ordered":{"one":"<b>{cap} auf {bird} bestellt.</b> {a} ⇄ {b} wird ausgerichtet und getestet: läuft in {n} Tag.","other":"<b>{cap} auf {bird} bestellt.</b> {a} ⇄ {b} wird ausgerichtet und getestet: läuft in {n} Tagen."},
"satellites.close_the_teleport":"Teleport schließen",
"satellites.costs_row":"Teleports und Satelliten",
"satellites.geo_dishes":"GEO-Schüsseln",
"satellites.geo_dishes_and_meo_tracking":"GEO-Schüsseln und MEO-Nachführantennen",
"satellites.geo_users_notice":"Aus 36.000 km Höhe dauert die Runde etwa 600 ms: Videocalls und Games ruckeln, und die Nutzer werten {p} des Service als schlecht.",
"satellites.grow_to":"Auf {cap} vergrößern",
"satellites.in_view_list":"In Sicht: {list}.",
"satellites.it_waits_on_standby":"Zwischen den beiden hast du schon einen Link: Der Satellit wartet im Standby und trägt Traffic nur, wenn dieser Link ausfällt.",
"satellites.its_blurb":"Klassische C- und Ku-Band-Strahlen, die einen ganzen Ozean abdecken. Zuverlässig, überall, und so bepreist.",
"satellites.kac_blurb":"Ka-Band-Spotbeams über dem Westpazifik: das billigste Gbps im Orbit, wenn deine Insel unter einem Beam liegt.",
"satellites.meo_comes_at_level":"Der MEO-Ring (etwa 130 ms hin und zurück) kommt auf Level {lv}.",
"satellites.meo_ring_misses_city":"Der MEO-Ring sieht {city} nicht: Er deckt {lat}° beiderseits des Äquators ab.",
"satellites.meo_users_notice":"Viel näher am Boden, etwa 130 ms hin und zurück: Die Nutzer merken kaum etwas ({p} des Service gilt als schlecht).",
"satellites.more_islands_and_towns":"Weitere Inseln und Orte in Sicht",
"satellites.ms_one_way_rtt":"{ms} ms pro Richtung, {rtt} ms hin und zurück",
"satellites.ms_round_trip":"{ms} ms hin und zurück",
"satellites.n_birds_see_both":{"one":"{n} Satellit sieht beide","other":"{n} Satelliten sehen beide"},
"satellites.n_circuits_go_on_standby":{"one":"Deine Satellitenverbindung zwischen {a} und {b} geht neben dem neuen Link in Standby: Sie trägt Traffic nur, wenn dieser Link ausfällt.","other":"Deine {n} Satellitenverbindungen zwischen {a} und {b} gehen neben dem neuen Link in Standby: Sie tragen Traffic nur, wenn dieser Link ausfällt."},
"satellites.n_places_in_reach":{"one":"{n} Insel oder abgelegener Ort in Reichweite auf deinem Level.","other":"{n} Inseln und abgelegene Orte in Reichweite auf deinem Level."},
"satellites.needs_tracking_antennas":"Der MEO-Ring braucht Nachführantennen an deinem Teleport in {city}.",
"satellites.new_pop_cost":"neuer POP {cost}",
"satellites.no_bird_sees_both":"Kein Satellit im Angebot sieht {a} und {b} zugleich.",
"satellites.no_bird_sees_this_city":"Kein Satellit im Angebot sieht diese Stadt.",
"satellites.no_cable_needed_a_pop_here":"Kein Kabel nötig: Eine Satellitenverbindung von einem deiner Teleports bringt einen POP in {city} online.",
"satellites.no_pop_in_city":"Du hast keinen POP in {city}.",
"satellites.no_pop_there_yet":"Noch kein POP in {city}: Der wird gleich mitgebaut ({cost}).",
"satellites.no_such_circuit":"Diese Satellitenverbindung gibt es nicht.",
"satellites.no_teleport_in_city":"Du hast keinen Teleport in {city}.",
"satellites.no_teleport_reaches_city":"Keiner deiner Teleports erreicht {city}. Bau einen an einem POP, dessen Satelliten die Stadt sehen.",
"satellites.not_remote":"{city} ist ein zu großer Markt für Satellitenkapazität: Die ist für kleine Inseln und abgelegene Orte da.",
"satellites.nothing_in_view_from_here":"Von hier ist keine Insel und kein abgelegener Ort in Sicht.",
"satellites.on_standby_beside_your_link":"Er wartet im Standby neben deinem Link zwischen den beiden und trägt Traffic nur, wenn dieser Link ausfällt.",
"satellites.orbit_unlocks_at_level":"{orb}-Satelliten gibt es ab Level {lv}.",
"satellites.out_of_footprint":"{bird} sieht nicht {a} und {b} zugleich.",
"satellites.pointing_dishes_and_testing":"Schüsseln ausrichten und testen",
"satellites.radio_path":"Funkweg, hoch und runter",
"satellites.reachable_from_your_teleports":"Deine Teleports erreichen {city} per Satellit:",
"satellites.really_close_it":"Wirklich schließen?",
"satellites.rent":"Miete",
"satellites.rent_satellite_capacity":"Satellitenkapazität mieten",
"satellites.satellite_capacity":"Satellitenkapazität",
"satellites.satellites":"Satelliten",
"satellites.sea_americas":"Amerika",
"satellites.sea_atlantic":"Atlantik",
"satellites.sea_indian":"Indischer Ozean",
"satellites.sea_pacific":"Pazifik",
"satellites.sea_tropics":"bis 50° um den Äquator",
"satellites.sea_west_pacific":"Westpazifik",
"satellites.sesa_blurb":"Ein Ring aus Satelliten 8.000 km über dem Äquator, für die anderen drei Milliarden. Sesam, öffne dich: etwa 130 ms hin und zurück.",
"satellites.shrink_to":"Auf {cap} verkleinern",
"satellites.teleport":"Teleport",
"satellites.teleport_closed":"Der Teleport in {city} ist geschlossen.",
"satellites.teleport_up_in_city":"<b>Teleport in {city} läuft.</b> Große Schüsseln auf dem Dach, ab in den Himmel: Miete von hier Kapazität zu den Inseln in Sicht.",
"satellites.teleports_unlock_at_level":"Teleports gibt es ab Level {lv}.",
"satellites.tracking_antennas_up":"<b>Nachführantennen in {city} laufen.</b> Sie folgen dem MEO-Ring über den Himmel.",
"satellites.up_in_n_days":{"one":"läuft in {n} Tag","other":"läuft in {n} Tagen"},
"satellites.users_notice_geo_meo":"Die Nutzer merken die Verzögerung: Breitband über GEO zählt als halber Service, über MEO fast als ganzer. Ein Kabel gewinnt immer, deine Router schicken Traffic also nur nach oben, wenn es keinen anderen Weg gibt.",
"satellites.users_ride_a_satellite":"Nutzer hängen am Satelliten",
"satellites.via_bird":"über {bird}",
"satellites.who_a_satellite_serves":"Satelliten bedienen kleine Inseln und abgelegene Orte, die derselbe Satellit sieht wie dein Teleport. Wähle das Ziel.",
"satellites.your_pops_in_view":"Deine POPs in Sicht",
"save.cash_in_the_bank":"{cash} auf der Bank",
"save.import_failed_err":"<b>Import fehlgeschlagen.</b><br>{err}",
"save.load_name":"{name} laden?",

View file

@ -3925,6 +3925,7 @@
"pie_traffic.via_dishes":"sube en {up}, baja en {down}",
"pitcairn.uk_grant_mo":"Subvención británica {mo}/mes",
"pitcairn.uk_grant_mo_once_islanders":"Subvención británica {mo}/mes cuando los isleños estén en línea",
"pitcairn.uk_grant_needs_a_cable":"Subvención británica {mo}/mes solo con cable: la capacidad satelital alquilada no cuenta",
"pitcairn.uk_sky_grant_mo":"Subvención británica por satélite {mo}/mes (la fibra recibe {full})",
"pni_all.additional_per_month":"Coste mensual adicional",
"pni_all.all_at_port":"Peering con todas las redes · {port}",
@ -4532,6 +4533,75 @@
"sales.w_last":"La semana pasada {name} {list}.",
"sales.w_now":"Esta semana {name} {list}.",
"sales.w_signed":{"one":"firmó un cliente ({rev}/mes)","other":"firmó {n} clientes ({rev}/mes)"},
"satellites.a_teleport_is_a_satellite_gateway":"Un teleport es una pasarela satelital: antenas grandes en este POP que alquilan capacidad en satélites ajenos, para islas pequeñas y pueblos remotos a los que no llega ningún cable, o que cuelgan de un solo cable y una plegaria.",
"satellites.add_tracking_antennas_cost_mo":"Antenas de seguimiento MEO <small>{cost} + {mo}/mes</small>",
"satellites.being_commissioned":"En puesta en servicio",
"satellites.build_a_teleport_cost_mo":"Construir un teleport <small>{cost} + {mo}/mes</small>",
"satellites.by_satellite":"Por satélite",
"satellites.cancel_n_circuits_first":{"one":"Primero cancela su circuito satelital.","other":"Primero cancela sus {n} circuitos satelitales."},
"satellites.choose":"Elegir",
"satellites.circuit_ordered":{"one":"<b>{cap} en {bird} pedidos.</b> {a} ⇄ {b} se está apuntando y probando: listo en {n} día.","other":"<b>{cap} en {bird} pedidos.</b> {a} ⇄ {b} se está apuntando y probando: listo en {n} días."},
"satellites.close_the_teleport":"Cerrar el teleport",
"satellites.costs_row":"Teleports y satélites",
"satellites.geo_dishes":"Antenas GEO",
"satellites.geo_dishes_and_meo_tracking":"Antenas GEO y antenas de seguimiento MEO",
"satellites.geo_users_notice":"Desde 36.000 km de altura la ida y vuelta tarda unos 600 ms: las videollamadas y los juegos se traban, y los usuarios cuentan {p} del servicio como malo.",
"satellites.grow_to":"Ampliar a {cap}",
"satellites.in_view_list":"A la vista: {list}.",
"satellites.it_waits_on_standby":"Ya tienes un enlace entre estas dos: el satélite espera en reserva y solo lleva tráfico cuando ese enlace cae.",
"satellites.its_blurb":"Haces de banda C y Ku de toda la vida que cubren un océano entero. Fiables, en todas partes, y con precio a juego.",
"satellites.kac_blurb":"Haces puntuales en banda Ka sobre el Pacífico occidental: el Gbps más barato en órbita, si tu isla queda bajo un haz.",
"satellites.meo_comes_at_level":"El anillo MEO (unos 130 ms de ida y vuelta) llega en el nivel {lv}.",
"satellites.meo_ring_misses_city":"El anillo MEO no ve {city}: cubre {lat}° a cada lado del ecuador.",
"satellites.meo_users_notice":"Mucho más cerca del suelo, unos 130 ms de ida y vuelta: los usuarios apenas lo notan ({p} del servicio cuenta como malo).",
"satellites.more_islands_and_towns":"Más islas y pueblos a la vista",
"satellites.ms_one_way_rtt":"{ms} ms de ida, {rtt} ms de ida y vuelta",
"satellites.ms_round_trip":"{ms} ms de ida y vuelta",
"satellites.n_birds_see_both":{"one":"{n} satélite ve los dos","other":"{n} satélites ven los dos"},
"satellites.n_circuits_go_on_standby":{"one":"Tu circuito satelital entre {a} y {b} pasa a reserva junto al nuevo enlace: solo lleva tráfico cuando ese enlace cae.","other":"Tus {n} circuitos satelitales entre {a} y {b} pasan a reserva junto al nuevo enlace: solo llevan tráfico cuando ese enlace cae."},
"satellites.n_places_in_reach":{"one":"{n} isla o pueblo remoto a tu alcance en tu nivel.","other":"{n} islas y pueblos remotos a tu alcance en tu nivel."},
"satellites.needs_tracking_antennas":"El anillo MEO necesita antenas de seguimiento en tu teleport de {city}.",
"satellites.new_pop_cost":"POP nuevo {cost}",
"satellites.no_bird_sees_both":"Ningún satélite a la venta ve a la vez {a} y {b}.",
"satellites.no_bird_sees_this_city":"Ningún satélite a la venta ve esta ciudad.",
"satellites.no_cable_needed_a_pop_here":"Sin cable: un circuito satelital desde uno de tus teleports pone en línea un POP en {city}.",
"satellites.no_pop_in_city":"No tienes POP en {city}.",
"satellites.no_pop_there_yet":"Aún no hay POP en {city}: esto también construye uno ({cost}).",
"satellites.no_such_circuit":"Ese circuito satelital no existe.",
"satellites.no_teleport_in_city":"No tienes teleport en {city}.",
"satellites.no_teleport_reaches_city":"Ninguno de tus teleports llega a {city}. Construye uno en un POP cuyos satélites la vean.",
"satellites.not_remote":"{city} es un mercado demasiado grande para capacidad satelital: es para islas pequeñas y pueblos remotos.",
"satellites.nothing_in_view_from_here":"Desde aquí no hay ninguna isla ni pueblo remoto a la vista.",
"satellites.on_standby_beside_your_link":"Espera en reserva junto a tu enlace entre las dos y solo lleva tráfico cuando ese enlace cae.",
"satellites.orbit_unlocks_at_level":"Los satélites {orb} se desbloquean en el nivel {lv}.",
"satellites.out_of_footprint":"{bird} no ve a la vez {a} y {b}.",
"satellites.pointing_dishes_and_testing":"Apuntando antenas y probando",
"satellites.radio_path":"Trayecto de radio, subida y bajada",
"satellites.reachable_from_your_teleports":"Tus teleports llegan a {city} por satélite:",
"satellites.really_close_it":"¿Cerrarlo de verdad?",
"satellites.rent":"Alquiler",
"satellites.rent_satellite_capacity":"Alquilar capacidad satelital",
"satellites.satellite_capacity":"Capacidad satelital",
"satellites.satellites":"Satélites",
"satellites.sea_americas":"Américas",
"satellites.sea_atlantic":"Atlántico",
"satellites.sea_indian":"Océano Índico",
"satellites.sea_pacific":"Pacífico",
"satellites.sea_tropics":"hasta 50° del ecuador",
"satellites.sea_west_pacific":"Pacífico occidental",
"satellites.sesa_blurb":"Un anillo de satélites a 8.000 km sobre el ecuador, para los otros tres mil millones. Ábrete, sésamo: unos 130 ms de ida y vuelta.",
"satellites.shrink_to":"Reducir a {cap}",
"satellites.teleport":"Teleport",
"satellites.teleport_closed":"El teleport de {city} está cerrado.",
"satellites.teleport_up_in_city":"<b>Teleport en marcha en {city}.</b> Antenas enormes en la azotea, apuntando al cielo: alquila desde aquí capacidad hacia las islas a la vista.",
"satellites.teleports_unlock_at_level":"Los teleports se desbloquean en el nivel {lv}.",
"satellites.tracking_antennas_up":"<b>Antenas de seguimiento en marcha en {city}.</b> Siguen el anillo MEO por el cielo.",
"satellites.up_in_n_days":{"one":"listo en {n} día","other":"listo en {n} días"},
"satellites.users_notice_geo_meo":"Los usuarios notan el retardo: la banda ancha por GEO cuenta como medio servicio, por MEO casi como el servicio entero. Un cable siempre gana, así que tus routers solo mandan tráfico arriba cuando no hay otro camino.",
"satellites.users_ride_a_satellite":"usuarios vía satélite",
"satellites.via_bird":"vía {bird}",
"satellites.who_a_satellite_serves":"Los satélites sirven a islas pequeñas y pueblos remotos que ve el mismo satélite que tu teleport. Elige el destino.",
"satellites.your_pops_in_view":"Tus POP a la vista",
"save.cash_in_the_bank":"{cash} en el banco",
"save.import_failed_err":"<b>Falló la importación.</b><br>{err}",
"save.load_name":"¿Cargar {name}?",

View file

@ -3925,6 +3925,7 @@
"pie_traffic.via_dishes":"monte à {up}, descend à {down}",
"pitcairn.uk_grant_mo":"Subvention britannique {mo}/mois",
"pitcairn.uk_grant_mo_once_islanders":"Subvention britannique {mo}/mois une fois les insulaires en ligne",
"pitcairn.uk_grant_needs_a_cable":"Subvention britannique {mo}/mois seulement avec un câble : la capacité satellite louée ne compte pas",
"pitcairn.uk_sky_grant_mo":"Subvention britannique satellite {mo}/mois (la fibre touche {full})",
"pni_all.additional_per_month":"Coût mensuel supplémentaire",
"pni_all.all_at_port":"Peering avec tous les réseaux · {port}",
@ -4532,6 +4533,75 @@
"sales.w_last":"La semaine dernière, {name} {list}.",
"sales.w_now":"Cette semaine, {name} {list}.",
"sales.w_signed":{"one":"a signé un client ({rev}/mois)","other":"a signé {n} clients ({rev}/mois)"},
"satellites.a_teleport_is_a_satellite_gateway":"Un téléport est une passerelle satellite : de grandes paraboles sur ce POP qui louent de la capacité sur les satellites des autres, vers les petites îles et les villes isolées qu’aucun câble ne dessert, ou qui ne tiennent qu’à un câble et une prière.",
"satellites.add_tracking_antennas_cost_mo":"Antennes de poursuite MEO <small>{cost} + {mo}/mois</small>",
"satellites.being_commissioned":"Mise en service",
"satellites.build_a_teleport_cost_mo":"Construire un téléport <small>{cost} + {mo}/mois</small>",
"satellites.by_satellite":"Par satellite",
"satellites.cancel_n_circuits_first":{"one":"Résilie d’abord son circuit satellite.","other":"Résilie d’abord ses {n} circuits satellite."},
"satellites.choose":"Choisir",
"satellites.circuit_ordered":{"one":"<b>{cap} sur {bird} commandé.</b> {a} ⇄ {b} est en cours de pointage et de test : en service dans {n} jour.","other":"<b>{cap} sur {bird} commandé.</b> {a} ⇄ {b} est en cours de pointage et de test : en service dans {n} jours."},
"satellites.close_the_teleport":"Fermer le téléport",
"satellites.costs_row":"Téléports et satellites",
"satellites.geo_dishes":"Paraboles GEO",
"satellites.geo_dishes_and_meo_tracking":"Paraboles GEO et antennes de poursuite MEO",
"satellites.geo_users_notice":"Depuis 36 000 km d’altitude, l’aller-retour prend environ 600 ms : visios et jeux saccadent, et les utilisateurs comptent {p} du service comme mauvais.",
"satellites.grow_to":"Passer à {cap}",
"satellites.in_view_list":"En vue : {list}.",
"satellites.it_waits_on_standby":"Tu as déjà un lien entre ces deux villes : le satellite attend en réserve et ne porte du trafic que quand ce lien tombe.",
"satellites.its_blurb":"De bons vieux faisceaux en bande C et Ku qui couvrent tout un océan. Fiables, partout, et facturés en conséquence.",
"satellites.kac_blurb":"Des spots en bande Ka sur le Pacifique occidental : le Gbps le moins cher en orbite, si ton île est sous un spot.",
"satellites.meo_comes_at_level":"L’anneau MEO (environ 130 ms aller-retour) arrive au niveau {lv}.",
"satellites.meo_ring_misses_city":"L’anneau MEO ne voit pas {city} : il couvre {lat}° de part et d’autre de l’équateur.",
"satellites.meo_users_notice":"Bien plus près du sol, environ 130 ms aller-retour : les utilisateurs le remarquent à peine ({p} du service compte comme mauvais).",
"satellites.more_islands_and_towns":"Autres îles et villes en vue",
"satellites.ms_one_way_rtt":"{ms} ms aller, {rtt} ms aller-retour",
"satellites.ms_round_trip":"{ms} ms aller-retour",
"satellites.n_birds_see_both":{"one":"{n} satellite voit les deux","other":"{n} satellites voient les deux"},
"satellites.n_circuits_go_on_standby":{"one":"Ton circuit satellite entre {a} et {b} passe en réserve à côté du nouveau lien : il ne porte du trafic que quand ce lien tombe.","other":"Tes {n} circuits satellite entre {a} et {b} passent en réserve à côté du nouveau lien : ils ne portent du trafic que quand ce lien tombe."},
"satellites.n_places_in_reach":{"one":"{n} île ou ville isolée à portée à ton niveau.","other":"{n} îles et villes isolées à portée à ton niveau."},
"satellites.needs_tracking_antennas":"L’anneau MEO a besoin d’antennes de poursuite à ton téléport de {city}.",
"satellites.new_pop_cost":"nouveau POP {cost}",
"satellites.no_bird_sees_both":"Aucun satellite en vente ne voit à la fois {a} et {b}.",
"satellites.no_bird_sees_this_city":"Aucun satellite en vente ne voit cette ville.",
"satellites.no_cable_needed_a_pop_here":"Pas besoin de câble : un circuit satellite depuis un de tes téléports met un POP à {city} en ligne.",
"satellites.no_pop_in_city":"Tu n’as pas de POP à {city}.",
"satellites.no_pop_there_yet":"Pas encore de POP à {city} : on en construit un au passage ({cost}).",
"satellites.no_such_circuit":"Ce circuit satellite n’existe pas.",
"satellites.no_teleport_in_city":"Tu n’as pas de téléport à {city}.",
"satellites.no_teleport_reaches_city":"Aucun de tes téléports n’atteint {city}. Construis-en un sur un POP dont les satellites la voient.",
"satellites.not_remote":"{city} est un trop gros marché pour de la capacité satellite : elle sert les petites îles et les villes isolées.",
"satellites.nothing_in_view_from_here":"Aucune île ni ville isolée en vue d’ici.",
"satellites.on_standby_beside_your_link":"Il attend en réserve à côté de ton lien entre les deux et ne porte du trafic que quand ce lien tombe.",
"satellites.orbit_unlocks_at_level":"Les satellites {orb} se débloquent au niveau {lv}.",
"satellites.out_of_footprint":"{bird} ne voit pas à la fois {a} et {b}.",
"satellites.pointing_dishes_and_testing":"Pointage des paraboles et tests",
"satellites.radio_path":"Trajet radio, montée et descente",
"satellites.reachable_from_your_teleports":"Tes téléports atteignent {city} par satellite :",
"satellites.really_close_it":"Vraiment le fermer ?",
"satellites.rent":"Location",
"satellites.rent_satellite_capacity":"Louer de la capacité satellite",
"satellites.satellite_capacity":"Capacité satellite",
"satellites.satellites":"Satellites",
"satellites.sea_americas":"Amériques",
"satellites.sea_atlantic":"Atlantique",
"satellites.sea_indian":"Océan Indien",
"satellites.sea_pacific":"Pacifique",
"satellites.sea_tropics":"jusqu’à 50° de l’équateur",
"satellites.sea_west_pacific":"Pacifique occidental",
"satellites.sesa_blurb":"Un anneau de satellites à 8 000 km au-dessus de l’équateur, pour les trois autres milliards. Sésame, ouvre-toi : environ 130 ms aller-retour.",
"satellites.shrink_to":"Réduire à {cap}",
"satellites.teleport":"Téléport",
"satellites.teleport_closed":"Le téléport de {city} est fermé.",
"satellites.teleport_up_in_city":"<b>Téléport en service à {city}.</b> De grandes paraboles sur le toit, pointées vers le ciel : loue d’ici de la capacité vers les îles en vue.",
"satellites.teleports_unlock_at_level":"Les téléports se débloquent au niveau {lv}.",
"satellites.tracking_antennas_up":"<b>Antennes de poursuite en service à {city}.</b> Elles suivent l’anneau MEO dans le ciel.",
"satellites.up_in_n_days":{"one":"en service dans {n} jour","other":"en service dans {n} jours"},
"satellites.users_notice_geo_meo":"Les utilisateurs sentent le délai : le haut débit par GEO compte pour la moitié du service, par MEO presque pour tout. Un câble gagne toujours, donc tes routeurs n’envoient du trafic là-haut que s’il n’y a pas d’autre chemin.",
"satellites.users_ride_a_satellite":"utilisateurs sur satellite",
"satellites.via_bird":"via {bird}",
"satellites.who_a_satellite_serves":"Les satellites desservent les petites îles et les villes isolées que voit le même satellite que ton téléport. Choisis la destination.",
"satellites.your_pops_in_view":"Tes POP en vue",
"save.cash_in_the_bank":"{cash} en banque",
"save.import_failed_err":"<b>Échec de l’import.</b><br>{err}",
"save.load_name":"Charger {name} ?",

View file

@ -3925,6 +3925,7 @@
"pie_traffic.via_dishes":"su a {up}, giù a {down}",
"pitcairn.uk_grant_mo":"Contributo UK {mo}/mese",
"pitcairn.uk_grant_mo_once_islanders":"Contributo UK {mo}/mese quando gli isolani saranno online",
"pitcairn.uk_grant_needs_a_cable":"Contributo UK {mo}/mese solo con un cavo: la capacità satellitare in affitto non conta",
"pitcairn.uk_sky_grant_mo":"Contributo UK via satellite {mo}/mese (la fibra prende {full})",
"pni_all.additional_per_month":"Costo mensile aggiuntivo",
"pni_all.all_at_port":"Peering con tutte le reti · {port}",
@ -4532,6 +4533,75 @@
"sales.w_last":"La settimana scorsa {name} {list}.",
"sales.w_now":"Questa settimana {name} {list}.",
"sales.w_signed":{"one":"ha firmato un cliente ({rev}/mese)","other":"ha firmato {n} clienti ({rev}/mese)"},
"satellites.a_teleport_is_a_satellite_gateway":"Un teleport è un gateway satellitare: grandi parabole in questo POP che noleggiano capacità sui satelliti di altri, verso piccole isole e città remote che nessun cavo raggiunge, o che stanno appese a un solo cavo e a una preghiera.",
"satellites.add_tracking_antennas_cost_mo":"Antenne a inseguimento MEO <small>{cost} + {mo}/mese</small>",
"satellites.being_commissioned":"In attivazione",
"satellites.build_a_teleport_cost_mo":"Costruisci un teleport <small>{cost} + {mo}/mese</small>",
"satellites.by_satellite":"Via satellite",
"satellites.cancel_n_circuits_first":{"one":"Prima disdici il suo circuito satellitare.","other":"Prima disdici i suoi {n} circuiti satellitari."},
"satellites.choose":"Scegli",
"satellites.circuit_ordered":{"one":"<b>{cap} su {bird} ordinati.</b> {a} ⇄ {b} si sta puntando e testando: attivo tra {n} giorno.","other":"<b>{cap} su {bird} ordinati.</b> {a} ⇄ {b} si sta puntando e testando: attivo tra {n} giorni."},
"satellites.close_the_teleport":"Chiudi il teleport",
"satellites.costs_row":"Teleport e satelliti",
"satellites.geo_dishes":"Parabole GEO",
"satellites.geo_dishes_and_meo_tracking":"Parabole GEO e antenne a inseguimento MEO",
"satellites.geo_users_notice":"Da 36.000 km di quota il giro dura circa 600 ms: videochiamate e giochi scattano, e gli utenti contano {p} del servizio come pessimo.",
"satellites.grow_to":"Porta a {cap}",
"satellites.in_view_list":"In vista: {list}.",
"satellites.it_waits_on_standby":"Tra queste due hai già un link: il satellite aspetta in standby e porta traffico solo quando quel link cade.",
"satellites.its_blurb":"I classici fasci in banda C e Ku che coprono un oceano intero. Affidabili, ovunque, e con il prezzo che ne consegue.",
"satellites.kac_blurb":"Spot beam in banda Ka sul Pacifico occidentale: il Gbps più economico in orbita, se la tua isola sta sotto un fascio.",
"satellites.meo_comes_at_level":"L’anello MEO (circa 130 ms andata e ritorno) arriva al livello {lv}.",
"satellites.meo_ring_misses_city":"L’anello MEO non vede {city}: copre {lat}° a nord e a sud dell’equatore.",
"satellites.meo_users_notice":"Molto più vicino a terra, circa 130 ms andata e ritorno: gli utenti se ne accorgono appena ({p} del servizio conta come pessimo).",
"satellites.more_islands_and_towns":"Altre isole e città in vista",
"satellites.ms_one_way_rtt":"{ms} ms solo andata, {rtt} ms andata e ritorno",
"satellites.ms_round_trip":"{ms} ms andata e ritorno",
"satellites.n_birds_see_both":{"one":"{n} satellite vede entrambe","other":"{n} satelliti vedono entrambe"},
"satellites.n_circuits_go_on_standby":{"one":"Il tuo circuito satellitare tra {a} e {b} va in standby accanto al nuovo link: porta traffico solo quando quel link cade.","other":"I tuoi {n} circuiti satellitari tra {a} e {b} vanno in standby accanto al nuovo link: portano traffico solo quando quel link cade."},
"satellites.n_places_in_reach":{"one":"{n} isola o città remota a portata al tuo livello.","other":"{n} isole e città remote a portata al tuo livello."},
"satellites.needs_tracking_antennas":"L’anello MEO vuole antenne a inseguimento al tuo teleport di {city}.",
"satellites.new_pop_cost":"nuovo POP {cost}",
"satellites.no_bird_sees_both":"Nessun satellite in vendita vede insieme {a} e {b}.",
"satellites.no_bird_sees_this_city":"Nessun satellite in vendita vede questa città.",
"satellites.no_cable_needed_a_pop_here":"Niente cavo: un circuito satellitare da uno dei tuoi teleport mette online un POP a {city}.",
"satellites.no_pop_in_city":"Non hai un POP a {city}.",
"satellites.no_pop_there_yet":"A {city} non c’è ancora un POP: così ne costruisci anche uno ({cost}).",
"satellites.no_such_circuit":"Questo circuito satellitare non esiste.",
"satellites.no_teleport_in_city":"Non hai un teleport a {city}.",
"satellites.no_teleport_reaches_city":"Nessuno dei tuoi teleport raggiunge {city}. Costruiscine uno in un POP i cui satelliti la vedano.",
"satellites.not_remote":"{city} è un mercato troppo grande per la capacità satellitare: quella serve piccole isole e città remote.",
"satellites.nothing_in_view_from_here":"Da qui non si vede nessuna isola né città remota.",
"satellites.on_standby_beside_your_link":"Aspetta in standby accanto al tuo link tra le due e porta traffico solo quando quel link cade.",
"satellites.orbit_unlocks_at_level":"I satelliti {orb} si sbloccano al livello {lv}.",
"satellites.out_of_footprint":"{bird} non vede insieme {a} e {b}.",
"satellites.pointing_dishes_and_testing":"Puntamento delle parabole e test",
"satellites.radio_path":"Percorso radio, su e giù",
"satellites.reachable_from_your_teleports":"I tuoi teleport raggiungono {city} via satellite:",
"satellites.really_close_it":"Lo chiudi davvero?",
"satellites.rent":"Noleggio",
"satellites.rent_satellite_capacity":"Noleggia capacità satellitare",
"satellites.satellite_capacity":"Capacità satellitare",
"satellites.satellites":"Satelliti",
"satellites.sea_americas":"Americhe",
"satellites.sea_atlantic":"Atlantico",
"satellites.sea_indian":"Oceano Indiano",
"satellites.sea_pacific":"Pacifico",
"satellites.sea_tropics":"entro 50° dall’equatore",
"satellites.sea_west_pacific":"Pacifico occidentale",
"satellites.sesa_blurb":"Un anello di satelliti a 8.000 km sopra l’equatore, per gli altri tre miliardi. Apriti sesamo: circa 130 ms andata e ritorno.",
"satellites.shrink_to":"Riduci a {cap}",
"satellites.teleport":"Teleport",
"satellites.teleport_closed":"Il teleport di {city} è chiuso.",
"satellites.teleport_up_in_city":"<b>Teleport attivo a {city}.</b> Grandi parabole sul tetto, puntate al cielo: da qui noleggi capacità verso le isole in vista.",
"satellites.teleports_unlock_at_level":"I teleport si sbloccano al livello {lv}.",
"satellites.tracking_antennas_up":"<b>Antenne a inseguimento attive a {city}.</b> Seguono l’anello MEO nel cielo.",
"satellites.up_in_n_days":{"one":"attivo tra {n} giorno","other":"attivo tra {n} giorni"},
"satellites.users_notice_geo_meo":"Gli utenti sentono il ritardo: la banda larga via GEO conta come mezzo servizio, via MEO quasi come tutto. Un cavo vince sempre, quindi i tuoi router mandano traffico lassù solo se non c’è altra strada.",
"satellites.users_ride_a_satellite":"utenti via satellite",
"satellites.via_bird":"via {bird}",
"satellites.who_a_satellite_serves":"I satelliti servono piccole isole e città remote che lo stesso satellite vede insieme al tuo teleport. Scegli la destinazione.",
"satellites.your_pops_in_view":"I tuoi POP in vista",
"save.cash_in_the_bank":"{cash} in cassa",
"save.import_failed_err":"<b>Importazione fallita.</b><br>{err}",
"save.load_name":"Caricare {name}?",

View file

@ -3925,6 +3925,7 @@
"pie_traffic.via_dishes":"sobe em {up}, desce em {down}",
"pitcairn.uk_grant_mo":"Subsídio do Reino Unido {mo}/mês",
"pitcairn.uk_grant_mo_once_islanders":"Subsídio do Reino Unido {mo}/mês quando os ilhéus estiverem online",
"pitcairn.uk_grant_needs_a_cable":"Subsídio do Reino Unido {mo}/mês só com cabo: capacidade de satélite alugada não conta",
"pitcairn.uk_sky_grant_mo":"Subsídio britânico por satélite {mo}/mês (a fibra recebe {full})",
"pni_all.additional_per_month":"Custo mensal adicional",
"pni_all.all_at_port":"Peering com todas as redes · {port}",
@ -4532,6 +4533,75 @@
"sales.w_last":"Semana passada {name} {list}.",
"sales.w_now":"Esta semana {name} {list}.",
"sales.w_signed":{"one":"assinou um cliente ({rev}/mês)","other":"assinou {n} clientes ({rev}/mês)"},
"satellites.a_teleport_is_a_satellite_gateway":"Um teleporto é um gateway de satélite: antenas grandes neste POP que alugam capacidade nos satélites dos outros, para ilhas pequenas e cidades remotas aonde nenhum cabo chega, ou que dependem de um só cabo e de uma reza.",
"satellites.add_tracking_antennas_cost_mo":"Antenas de rastreamento MEO <small>{cost} + {mo}/mês</small>",
"satellites.being_commissioned":"Em comissionamento",
"satellites.build_a_teleport_cost_mo":"Construir um teleporto <small>{cost} + {mo}/mês</small>",
"satellites.by_satellite":"Por satélite",
"satellites.cancel_n_circuits_first":{"one":"Cancele primeiro o circuito de satélite dele.","other":"Cancele primeiro os {n} circuitos de satélite dele."},
"satellites.choose":"Escolher",
"satellites.circuit_ordered":{"one":"<b>{cap} no {bird} encomendados.</b> {a} ⇄ {b} está sendo apontado e testado: no ar em {n} dia.","other":"<b>{cap} no {bird} encomendados.</b> {a} ⇄ {b} está sendo apontado e testado: no ar em {n} dias."},
"satellites.close_the_teleport":"Fechar o teleporto",
"satellites.costs_row":"Teleportos e satélites",
"satellites.geo_dishes":"Antenas GEO",
"satellites.geo_dishes_and_meo_tracking":"Antenas GEO e antenas de rastreamento MEO",
"satellites.geo_users_notice":"De 36.000 km de altura a ida e volta leva uns 600 ms: chamadas de vídeo e jogos travam, e os usuários contam {p} do serviço como ruim.",
"satellites.grow_to":"Aumentar para {cap}",
"satellites.in_view_list":"À vista: {list}.",
"satellites.it_waits_on_standby":"Você já tem um link entre as duas: o satélite espera de reserva e só leva tráfego quando esse link cai.",
"satellites.its_blurb":"Feixes clássicos em banda C e Ku que cobrem um oceano inteiro. Confiáveis, em todo lugar, e com preço à altura.",
"satellites.kac_blurb":"Feixes pontuais em banda Ka sobre o Pacífico ocidental: o Gbps mais barato em órbita, se a sua ilha estiver debaixo de um feixe.",
"satellites.meo_comes_at_level":"O anel MEO (uns 130 ms de ida e volta) chega no nível {lv}.",
"satellites.meo_ring_misses_city":"O anel MEO não vê {city}: ele cobre {lat}° de cada lado do equador.",
"satellites.meo_users_notice":"Muito mais perto do chão, uns 130 ms de ida e volta: os usuários mal percebem ({p} do serviço conta como ruim).",
"satellites.more_islands_and_towns":"Mais ilhas e cidades à vista",
"satellites.ms_one_way_rtt":"{ms} ms só de ida, {rtt} ms de ida e volta",
"satellites.ms_round_trip":"{ms} ms de ida e volta",
"satellites.n_birds_see_both":{"one":"{n} satélite vê as duas","other":"{n} satélites veem as duas"},
"satellites.n_circuits_go_on_standby":{"one":"Seu circuito de satélite entre {a} e {b} fica de reserva ao lado do novo link: só leva tráfego quando esse link cai.","other":"Seus {n} circuitos de satélite entre {a} e {b} ficam de reserva ao lado do novo link: só levam tráfego quando esse link cai."},
"satellites.n_places_in_reach":{"one":"{n} ilha ou cidade remota ao alcance no seu nível.","other":"{n} ilhas e cidades remotas ao alcance no seu nível."},
"satellites.needs_tracking_antennas":"O anel MEO precisa de antenas de rastreamento no seu teleporto em {city}.",
"satellites.new_pop_cost":"POP novo {cost}",
"satellites.no_bird_sees_both":"Nenhum satélite à venda vê {a} e {b} ao mesmo tempo.",
"satellites.no_bird_sees_this_city":"Nenhum satélite à venda vê esta cidade.",
"satellites.no_cable_needed_a_pop_here":"Sem cabo: um circuito de satélite de um dos seus teleportos coloca um POP em {city} no ar.",
"satellites.no_pop_in_city":"Você não tem POP em {city}.",
"satellites.no_pop_there_yet":"Ainda não há POP em {city}: isto também constrói um ({cost}).",
"satellites.no_such_circuit":"Esse circuito de satélite não existe.",
"satellites.no_teleport_in_city":"Você não tem teleporto em {city}.",
"satellites.no_teleport_reaches_city":"Nenhum dos seus teleportos alcança {city}. Construa um num POP cujos satélites a vejam.",
"satellites.not_remote":"{city} é um mercado grande demais para capacidade de satélite: ela é para ilhas pequenas e cidades remotas.",
"satellites.nothing_in_view_from_here":"Daqui não há nenhuma ilha nem cidade remota à vista.",
"satellites.on_standby_beside_your_link":"Ele espera de reserva ao lado do seu link entre as duas e só leva tráfego quando esse link cai.",
"satellites.orbit_unlocks_at_level":"Satélites {orb} são liberados no nível {lv}.",
"satellites.out_of_footprint":"{bird} não vê {a} e {b} ao mesmo tempo.",
"satellites.pointing_dishes_and_testing":"Apontando antenas e testando",
"satellites.radio_path":"Caminho de rádio, subida e descida",
"satellites.reachable_from_your_teleports":"Seus teleportos alcançam {city} por satélite:",
"satellites.really_close_it":"Fechar mesmo?",
"satellites.rent":"Aluguel",
"satellites.rent_satellite_capacity":"Alugar capacidade de satélite",
"satellites.satellite_capacity":"Capacidade de satélite",
"satellites.satellites":"Satélites",
"satellites.sea_americas":"Américas",
"satellites.sea_atlantic":"Atlântico",
"satellites.sea_indian":"Oceano Índico",
"satellites.sea_pacific":"Pacífico",
"satellites.sea_tropics":"até 50° do equador",
"satellites.sea_west_pacific":"Pacífico ocidental",
"satellites.sesa_blurb":"Um anel de satélites a 8.000 km acima do equador, para os outros três bilhões. Abre-te, sésamo: uns 130 ms de ida e volta.",
"satellites.shrink_to":"Reduzir para {cap}",
"satellites.teleport":"Teleporto",
"satellites.teleport_closed":"O teleporto em {city} foi fechado.",
"satellites.teleport_up_in_city":"<b>Teleporto no ar em {city}.</b> Antenas enormes no telhado, apontadas para o céu: alugue daqui capacidade para as ilhas à vista.",
"satellites.teleports_unlock_at_level":"Teleportos são liberados no nível {lv}.",
"satellites.tracking_antennas_up":"<b>Antenas de rastreamento no ar em {city}.</b> Elas seguem o anel MEO pelo céu.",
"satellites.up_in_n_days":{"one":"no ar em {n} dia","other":"no ar em {n} dias"},
"satellites.users_notice_geo_meo":"Os usuários sentem o atraso: banda larga por GEO conta como meio serviço, por MEO quase como o serviço inteiro. Um cabo sempre ganha, então seus roteadores só mandam tráfego para cima quando não há outro caminho.",
"satellites.users_ride_a_satellite":"usuários via satélite",
"satellites.via_bird":"via {bird}",
"satellites.who_a_satellite_serves":"Satélites atendem ilhas pequenas e cidades remotas que o mesmo satélite vê junto com o seu teleporto. Escolha o destino.",
"satellites.your_pops_in_view":"Seus POPs à vista",
"save.cash_in_the_bank":"{cash} no banco",
"save.import_failed_err":"<b>Falha na importação.</b><br>{err}",
"save.load_name":"Carregar {name}?",

View file

@ -22,6 +22,8 @@ const API_DOMAINS={
vxcTier:{table:'VXC',kind:'index'},
routerModel:{table:'RG',kind:'index'},
scrubTier:{table:'SCRUB_TIERS',kind:'index'},
satBird:{table:'SATS',kind:'key'},
satG:{kind:'enum',values:()=>[...new Set(Object.values(SAT_ORB).flatMap(o=>o.g))].sort((a,b)=>a-b)},
// Small fixed vocabularies the game itself checks by list membership.
// The link metric presets, plus "custom" for a hand-tuned number (ACT.setMetric).
metric:{kind:'enum',values:()=>[...Object.keys(MET),'custom']},

View file

@ -123,7 +123,7 @@ const API_CMD={
quote:a=>{const A=a.a,B=a.b,tier=a.tier;
if(!S.pops[A])return {blocked:[linkFromWhy(A)]};
if(!waveOk(A,B,tier))return {blocked:[tr('links.a_wave_wave_needs_need_at',{wave:LT[tier].n,need:waveNeed(tier)})]};
const sib=pairLinks(A,B).filter(l=>l.kind!=='vxc'&&l.kind!=='xp'),jn=sib.length?routeJoin(A,B):null,border=cnCity(A)!==cnCity(B);
const sib=pairLinks(A,B).filter(l=>l.kind!=='vxc'&&l.kind!=='xp'&&l.kind!=='sat'),jn=sib.length?routeJoin(A,B):null,border=cnCity(A)!==cnCity(B);
const mult=(sib.length&&!(jn&&jn.k===(landTrenches(A,B)[0]||{}).k)?DIVERSE:1)*(border?3*((a.premiumCrossing&&(A==='hkg'||B==='hkg'))?1.6:1):1);
const wr=waveRoute(A,B,mult,border);if(!wr)return {blocked:[tr('links.no_cable_available_for_that_route')]};
const blocked=[],so=soldOut(A,B,tier,wr.cab);
@ -167,6 +167,22 @@ const API_CMD={
doc:'Egress preference for one exit: high sends more traffic that way, low keeps it for backup.'},
siteSet:{args:[['k','connKind'],['id','entityId'],['s','site']],watch:['transit.#id','pni.#id'],
doc:'Put a transit port, PNI or IX port in building A, B or both. Choosing both with a single member adds a LAG member first, and charges for it.'},
/* ---------- teleports and satellite capacity (#83) ---------- */
teleBuild:{args:[['city','cityId']],watch:['pops.#city'],
quote:a=>({setup:TPORT_COST,monthly:TPORT_MO,blocked:[teleOf(a.city)?'there is a teleport here already':teleWhy(a.city)].filter(Boolean)}),
doc:'Build a teleport (a satellite gateway) at one of your POPs: it rents circuits on GEO birds to small islands and remote towns in their footprint. Refused where no satellite on sale at your level sees the city.'},
teleTrk:{args:[['city','cityId']],watch:['pops.#city'],
quote:a=>({setup:TRK_COST,monthly:TRK_MO,blocked:[teleOf(a.city)===2?'this teleport has tracking antennas already':trkWhy(a.city)].filter(Boolean)}),
doc:'Add tracking antennas to a teleport, so it can work the MEO ring (about 130 ms round trip instead of GEO\'s 600). Only within 50 degrees of the equator, where the ring is in view.'},
teleRm:{args:[['city','cityId']],confirm:'double',watch:['pops.#city'],
doc:'Close a teleport. Refused while circuits still start there.'},
buySat:{args:[['a','cityId'],['b','cityId'],['bird','satBird'],['g','satG']],
quote:a=>{const ok=own(SATS,a.bird),mo=ok?satMo(a.bird,+a.g):0;return {setup:mo+(S.pops[a.b]||!CITY[a.b]?0:popCost(a.b)),monthly:mo,days:ok?leadDays(SAT_ORB[SATS[a.bird].orb].days):0,blocked:[satWhy(a.a,a.b,a.bird,+a.g)].filter(Boolean)};},
doc:'Rent a satellite circuit from your teleport in a to b (a small island or a remote town) on a bird that sees both: GEO 1-10 Gbps, MEO 2-20 with tracking antennas. The first month up front; builds a POP at b if there is none. Next to an existing link between the two it goes on standby, as backup; a link built later between the two puts it on standby too. Cancel with rmLink.'},
satSize:{args:[['id','entityId'],['g','satG']],watch:['links.#id'],
quote:a=>{const l=S.links.find(x=>x.id===a.id&&x.kind==='sat'),g=+a.g,ok=!!l&&g!==l.g&&SAT_ORB[SATS[l.bird].orb].g.includes(g),mo=ok?satMo(l.bird,g):0;
return {setup:ok&&g>l.g?mo:0,monthly:mo,blocked:!l?['not a satellite circuit']:ok?[]:[tr('satellites.no_such_circuit')]};},
doc:'Resize a satellite circuit on the same bird. A bigger one pays its new month up front.'},
/* ---------- dark fiber and own cable ---------- */
orderDf:{args:[['a','cityId'],['b','cityId'],['source','dfSource'],['system','systemId']],
bindsUI:['pending','dfSrc','dfSys'],bind:a=>{UI.pending={a:a.a,b:a.b};UI.dfSrc=a.source;UI.dfSys=a.system;},
@ -574,6 +590,7 @@ const API_BOUND={
teRecipe:{command:'teDeploy',arg:'script',note:'a recipe from catalog(\'TE_RECIPES\')'},
trace:{command:'traceRun',arg:'from'},
decomToggle:{command:'decomGo',arg:'cities'},
satOpen:{command:'buySat',note:'opens the satellite order sheet from a teleport (a) or for a city (b); buySat takes a, b, bird and g itself'},
openVxc:{command:'buyVxc',note:'opens the circuit picker from a fabric port ({from, prov}); buyVxc takes a, b, prov and t itself'},
connCancel:{command:'cancelTransit',note:'the connections list\'s cancel button: it arms, then dispatches cancelTransit, cancelPni, cancelIx, rmCache or rmNni'},
cnPrem:{command:'buildLink',arg:'premiumCrossing'},

View file

@ -19,8 +19,8 @@ const API_STATE_DOC={
t1v:{type:'integer',doc:'Level at which Tier 1 transit was offered.'},
auV:{type:'integer',doc:'Australia content level gate.'},
seen:{type:'array',doc:'Network ids the deals panel has already shown. Vestigial: written by newGame, read nowhere.'},
pops:{type:'map',doc:'Your POPs by city id: day opened, broadband (bb), ad boost, downtime, routers, generator, second site.'},
links:{type:'array',doc:'Your links: waves, dark fiber (df), own cables, fabric circuits (vxc) and express lightpaths (xp: via lists the dark fibers it rides from a, ch its optics), each with an entity id.'},
pops:{type:'map',doc:'Your POPs by city id: day opened, broadband (bb), ad boost, downtime, routers, generator, second site, teleport (tele: 1 GEO dishes, 2 with MEO tracking antennas).'},
links:{type:'array',doc:'Your links: waves, dark fiber (df), own cables, fabric circuits (vxc), express lightpaths (xp: via lists the dark fibers it rides from a, ch its optics) and rented satellite circuits (sat: bird, g Gbps, km of radio path, ready day), each with an entity id.'},
transit:{type:'array',doc:'Transit ports: city, net, tier, LAG members, port history for 95th-percentile billing.'},
ixp:{type:'map',doc:'IX ports by exchange city; tier per port (may exceed 1 with LAG members in ixn).'},
rs:{type:'map',doc:'Route-server sessions by exchange city.'},
@ -130,6 +130,7 @@ const API_RESULTS_DOC={
cityEye:{type:'map',doc:'Eyeballs online per city.'},
latF:{type:'map',doc:'Fraction of each city\'s traffic that goes far (over a threshold latency).'},
latFar:{type:'map',doc:'The far exit each slow city sends traffic through.'},
satU:{type:'map',doc:'Of each city\'s served traffic, the Gbps that rode a rented satellite circuit (its users notice the orbit\'s latency on that share). Only there while you have a satellite circuit up.'},
demTo:{type:'map',doc:'Your traffic destined to each network, in Gbps. The number CDN caches ask about.'},
served:{type:'number',doc:'Total traffic served, in Gbps.'},
demand:{type:'number',doc:'Total traffic demanded, in Gbps.'},

View file

@ -26,7 +26,7 @@ function apiJson(v){
carries the keys confGo/confSponsor need, which exist in no field of S; TE_RECIPES renders
each recipe's script, because the source is a function and some read the live network. The
recipes' relevance score is not exposed: judging which one fits is the agent's job. */
const API_TABLES={ROCKETS,CRUSTS,PIE_RD,PIE_SPAT_DEF,SALES,CITIES,NETS,CABLES,XIX,PORT,LT,NNI,VXC,RG,OPT,DF_SYS,FAB,SCRUB_TIERS,BIZ_T,LEVELS,GOALS,BROKER_GOALS,SCN,BANKS,REQS,NSH,MET,PREF,RT,PPOL,CONFS,LAG_MAX,RMAX,REGEN_MAX,START_CASH,CONF_COST,CONF_SP,CAP_COST,CAP_LV,CONF_DAYS,SUB_UPGRADES,SEA_DESIGNS,TE_COST,TE_MO,MYIX_COST,CN_LIC,SITE2_COST,MYIX_FAB,INTERNS,OPSK,CHARTERS,SEAT_N,CORE_LV,CORE_COST,CORE_REQ,CORE_LAB,INTERN_MO,PZ_TIERS,AR_TIERS,PZ_RG};
const API_TABLES={ROCKETS,CRUSTS,PIE_RD,PIE_SPAT_DEF,SATS,SAT_ORB,SAT_PROV,SALES,CITIES,NETS,CABLES,XIX,PORT,LT,NNI,VXC,RG,OPT,DF_SYS,FAB,SCRUB_TIERS,BIZ_T,LEVELS,GOALS,BROKER_GOALS,SCN,BANKS,REQS,NSH,MET,PREF,RT,PPOL,CONFS,LAG_MAX,RMAX,REGEN_MAX,START_CASH,CONF_COST,CONF_SP,CAP_COST,CAP_LV,CONF_DAYS,SUB_UPGRADES,SEA_DESIGNS,TE_COST,TE_MO,MYIX_COST,CN_LIC,SITE2_COST,MYIX_FAB,INTERNS,OPSK,CHARTERS,SEAT_N,CORE_LV,CORE_COST,CORE_REQ,CORE_LAB,INTERN_MO,PZ_TIERS,AR_TIERS,PZ_RG};
const API_MADE={
BADGES:()=>!S?[]:BADGES.map(b=>{const on=S.ach&&S.ach[b.id]!==undefined,ever=!!hof()[b.id];
return b.secret&&!on&&!ever?{id:b.id,i:'❔',t:'???',d:tr('badges.a_secret_badge'),r:b.r,secret:true}:{...b,ever};}),

View file

@ -69,9 +69,9 @@ const regenNeed=(o,l)=>Math.max(0,Math.ceil(l.km/reachOn(OPT[o].reach,l.sub))-1)
let DFC=null;
const dfCap=l=>{if(!DFC)return dfCap0(l);let g=DFC.get(l);if(g===undefined)DFC.set(l,g=dfCap0(l));return g;};
const dfCap0=l=>{if(l.ready>S.day||l.eqDown>S.day)return 0;const ch=l.ch||[];let g=0;for(const c of ch)g+=optG(c,l);const f=l.chFail&&l.chFail.until>S.day?l.chFail:null;if(f){const fo=f.o&&ch.includes(f.o)?f.o:ch.slice().sort((a,b)=>optG(a,l)-optG(b,l))[0];if(fo)g-=optG(fo,l);}return Math.max(0,g);};
const capOf=l=>(l.kind==='vxc'?VXC[l.vt].g:l.kind==='df'?dfCap(l):l.kind==='xp'?xpG(l):LT[l.tier].g)*(l.deg>S.day?0.5:1)*(l.loss&&l.loss.until>S.day?l.loss.f:1);
const capOf=l=>(l.kind==='vxc'?VXC[l.vt].g:l.kind==='df'?dfCap(l):l.kind==='xp'?xpG(l):l.kind==='sat'?l.g:LT[l.tier].g)*(l.deg>S.day?0.5:1)*(l.loss&&l.loss.until>S.day?l.loss.f:1);
// A sick LAG (LACP trouble) keeps only part of its capacity until the incident clears.
const lagF=o=>o&&o.lacp&&o.lacp.until>S.day?o.lacp.f:1,ixLagF=x=>lagF(S.ev&&S.ev.ixlacp&&{lacp:S.ev.ixlacp[x]});
const tierW=l=>{if(l.kind==='wave')return l.tier;if(l.kind==='vxc')return 0;const g=l.kind==='xp'?xpG(l):dfCap(l);return g>=6400?4:g>=1600?3:g>=400?2:g>=100?1:0;};
const capName=l=>l.kind==='vxc'?VXC[l.vt].n:l.kind==='xp'?(g=>g?tr('express.cap',{cap:fmtCap(g)}):tr('common.dark'))(xpG(l)):l.kind==='df'?(l.ready>S.day?tr('common.building'):(l.ch||[]).length?fmtCap(dfCap(l)||(l.ch||[]).reduce((a,c)=>a+optG(c,l),0))+' DF':tr('common.dark')):LT[l.tier].n;
const tierW=l=>{if(l.kind==='wave')return l.tier;if(l.kind==='vxc'||l.kind==='sat')return 0;const g=l.kind==='xp'?xpG(l):dfCap(l);return g>=6400?4:g>=1600?3:g>=400?2:g>=100?1:0;};
const capName=l=>l.kind==='vxc'?VXC[l.vt].n:l.kind==='sat'?fmtCap(l.g)+' '+SAT_ORB[SATS[l.bird].orb].n:l.kind==='xp'?(g=>g?tr('express.cap',{cap:fmtCap(g)}):tr('common.dark'))(xpG(l)):l.kind==='df'?(l.ready>S.day?tr('common.building'):(l.ch||[]).length?fmtCap(dfCap(l)||(l.ch||[]).reduce((a,c)=>a+optG(c,l),0))+' DF':tr('common.dark')):LT[l.tier].n;

View file

@ -0,0 +1,61 @@
/* ---------- Satellites (#83): capacity rented on someone else's birds ----------
A teleport (a satellite gateway at one of your POPs) links to a small island or a remote town over rented capacity:
the early answer to "no cable lands there", and the warm backup for an island hanging on one cable. Geostationary
birds (GEO, 35,786 km up) see a whole ocean from one dish: no build, dear per Gbps, about 600 ms there and back. A
medium-orbit ring over the equator (MEO, 8,062 km up) gets that down to about 130 ms, but a teleport needs tracking
antennas to follow its satellites across the sky. Your own constellation (LEO, Pie in the Sky) comes much later.
The providers are vendors, like the fabrics: they sell you capacity, they are not networks you route to. */
// h: km up; proc: ms of modems and error correction each way; loss: the share of a city's service its users stop counting
// once their traffic rides it (half for GEO, like any haul past 50 ms; MEO feels almost like fiber); days: to point and
// commission a new circuit; lv: the level it unlocks at; g: the sizes sold (Gbps). A MEO ring covers |lat| <= lat, and a
// circuit's two ends must see the same satellite at once: at most km apart, and at least el degrees above both horizons
// (what a ground terminal needs to clear the trees; far north, two ends 7,000 km apart lose it below the horizon).
const SAT_ORB={
geo:{n:'GEO',h:35786,proc:25,loss:0.5,days:10,lv:2,g:[1,2,5,10]},
meo:{n:'MEO',h:8062,proc:7,loss:0.08,days:21,lv:3,g:[2,5,10,20],lat:50,km:7500,el:5},
};
// pg: dollars a month for the first Gbps; bigger circuits cost less per Gbps (satMo).
const SAT_PROV={
its:{n:'Intelsplat',col:'#2F8CFF',pg:2500,blurb:tr('satellites.its_blurb')},
kac:{n:'Kacophony',col:'#FF8A3D',pg:1400,blurb:tr('satellites.kac_blurb')},
sesa:{n:'SESame',col:'#16A866',pg:2000,blurb:tr('satellites.sesa_blurb')},
};
// The birds. A GEO sits over the equator at lon; r is how far its beams reach, in degrees of arc from the point under it
// (72: a global beam, down to about 5 degrees above the horizon; Kacophony's Ka-band spot beams cover less, for less).
const SATS={
is18:{n:'Intelsplat 18',p:'its',orb:'geo',lon:180,r:72,sea:N_('satellites.sea_pacific')},
is20:{n:'Intelsplat 20',p:'its',orb:'geo',lon:68.5,r:72,sea:N_('satellites.sea_indian')},
is37:{n:'Intelsplat 37e',p:'its',orb:'geo',lon:-18,r:72,sea:N_('satellites.sea_atlantic')},
kac1:{n:'Kacophony-1',p:'kac',orb:'geo',lon:150,r:50,sea:N_('satellites.sea_west_pacific')},
gx19:{n:'Intelsplat 19',p:'its',orb:'geo',lon:-97,r:72,sea:N_('satellites.sea_americas')},
o3b:{n:'O3bservant',p:'sesa',orb:'meo',sea:N_('satellites.sea_tropics')},
};
// The teleport itself (dishes, a building, the licences), and the MEO tracking antennas it may add.
const TPORT_COST=90000,TPORT_MO=2500,TRK_COST=250000,TRK_MO=3000;
// Who a satellite serves: a small island off the big continents, or a remote town anywhere, never a big city's market.
const SAT_MAIN=['af','am','eu','oc','sa'],SAT_ISLE_P=150,SAT_TOWN_P=5;
const SAT_RE=6371,SAT_C=300;
// The arc between two points on the globe, in degrees.
function satArc(la1,lo1,la2,lo2){const r=Math.PI/180,c=Math.sin(la1*r)*Math.sin(la2*r)+Math.cos(la1*r)*Math.cos(la2*r)*Math.cos((lo2-lo1)*r);return Math.acos(Math.max(-1,Math.min(1,c)))/r;}
// From a dish to a satellite h km up over a point arc degrees away, in a straight line.
function satSlant(arc,h){const Q=SAT_RE+h,a=arc*Math.PI/180;return Math.sqrt(SAT_RE*SAT_RE+Q*Q-2*SAT_RE*Q*Math.cos(a));}
// How high above a dish's horizon that satellite stands, in degrees (negative: below it, behind the Earth).
function satElev(arc,h){const a=arc*Math.PI/180;return Math.atan2(Math.cos(a)-SAT_RE/(SAT_RE+h),Math.sin(a))*180/Math.PI;}
// The longitude the bird sits over for a circuit: a GEO's slot; a MEO ring's satellite halfway between the two ends.
function satLon(id,a,b){const B=SATS[id];if(B.orb==='geo')return B.lon;const r=Math.PI/180,A=CITY[a],C=CITY[b];
return Math.atan2(Math.sin(A.lon*r)+Math.sin(C.lon*r),Math.cos(A.lon*r)+Math.cos(C.lon*r))/r;}
// Whether bird id sees city c.
function satSees(id,c){const B=SATS[id],C=CITY[c];if(!B||!C)return false;return B.orb==='meo'?Math.abs(C.lat)<=SAT_ORB.meo.lat:satArc(0,B.lon,C.lat,C.lon)<=B.r;}
function satPairOk(id,a,b){if(a===b||!satSees(id,a)||!satSees(id,b))return false;if(SATS[id].orb!=='meo')return true;const O=SAT_ORB.meo;
if(kmBetween(a,b)>O.km)return false;const lon=satLon(id,a,b);return [a,b].every(c=>satElev(satArc(0,lon,CITY[c].lat,CITY[c].lon),O.h)>=O.el);}
// The radio path: up from one dish and down to the other, the km the signal really travels. It is the link's km, so the
// routers' metric (pairW) sees a satellite as the long way round it is, and a cable wins whenever there is one.
function satKm(id,a,b){const h=SAT_ORB[SATS[id].orb].h,lon=satLon(id,a,b),A=CITY[a],C=CITY[b];
return Math.round(satSlant(satArc(0,lon,A.lat,A.lon),h)+satSlant(satArc(0,lon,C.lat,C.lon),h));}
// One way: the radio path at the speed of light in vacuum, plus the modems at both ends.
const satLat=l=>l.km/SAT_C+SAT_ORB[SATS[l.bird].orb].proc;
const satMo=(id,g)=>Math.round(SAT_PROV[SATS[id].p].pg*Math.pow(g,0.85)/10)*10;
const satRemote=c=>{const C=CITY[c];return !!C&&(C.P<=SAT_TOWN_P||C.P<=SAT_ISLE_P&&!SAT_MAIN.includes(C.land));};
const satName=l=>SATS[l.bird]?SATS[l.bird].n:'?';
// A subsea cable: a satellite circuit is stored as sub (never a land route) but is no cable on the seabed.
const seaLink=l=>!!l.sub&&l.kind!=='sat';

View file

@ -34,7 +34,7 @@ const COVS={
logo:{l:tr('banks.our_logo_goes_on_every_router'),ok:()=>true},
cash50:{l:tr('banks.never_let_cash_drop_below_50k'),ok:()=>S.cash>=50000},
nochina:{l:tr('banks.stay_out_of_mainland_china'),ok:()=>!Object.keys(S.pops).some(cnCity)},
nosub:{l:tr('banks.no_new_subsea_links_while_this'),ok:l=>S.links.filter(x=>x.sub).length<=(l.base&&l.base.sub||0)},
nosub:{l:tr('banks.no_new_subsea_links_while_this'),ok:l=>S.links.filter(seaLink).length<=(l.base&&l.base.sub||0)},
spaetzle:{l:tr('banks.peer_at_the_spatzle_ix_in'),ok:()=>S.ixp.stg!==undefined},
kehrwoche:{l:tr('banks.do_the_kehrwoche_keep_your_noc'),ok:()=>!S.inc.some(i=>S.day-i.start>7)},
app:{l:tr('banks.download_our_app_and_enable_all'),ok:()=>true},
@ -102,7 +102,7 @@ function callOffer(amount){const T=CALL_TERMS[rating()];if(!T||!CALL_AMTS.includ
const RESCUE_APR=0.02,RESCUE_TERM=60;
function rescueLoan(){const amount=niceAmt(Math.max(250000,-S.cash+Math.max(150000,(R.costMo||0)*2)));
S.cash+=amount;S.stats.rescues=(S.stats.rescues||0)+1;S.neg=0;
S.loans.push({id:uid(),bank:'gov',start:S.day,amount,got:amount,bal:amount,apr:RESCUE_APR,apr0:RESCUE_APR,pay:Math.round(annuity(amount,RESCUE_APR,RESCUE_TERM)),left:RESCUE_TERM,term:RESCUE_TERM,share:0,covs:[],base:{sub:S.links.filter(x=>x.sub).length}});
S.loans.push({id:uid(),bank:'gov',start:S.day,amount,got:amount,bal:amount,apr:RESCUE_APR,apr0:RESCUE_APR,pay:Math.round(annuity(amount,RESCUE_APR,RESCUE_TERM)),left:RESCUE_TERM,term:RESCUE_TERM,share:0,covs:[],base:{sub:S.links.filter(seaLink).length}});
track('rescue');toast(`<b>${tr('banks.bank_stepped_in',{bank:esc(BANKS.gov.name)})}</b><br>${tr('banks.a_rescue_loan_of_amount_keeps',{amount:fmt$(amount),pay:fmt$(Math.round(annuity(amount,RESCUE_APR,RESCUE_TERM)))})}`,'bad',[{l:tr('common.open_bank'),act:'bank',args:{}}]);sfx('coin');}
function loanTick(d){
// conditions: 15-day grace, then a penalty every 30 days while broken

View file

@ -2,12 +2,12 @@
gives the same world. Free play keeps using the browser's Math.random. */
const _rand=Math.random;
Math.random=function(){if(S&&typeof S.rng==='number'){let t=(S.rng=(S.rng+0x6D2B79F5)|0);t=Math.imul(t^t>>>15,1|t);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;}return _rand();};
const hopG=l=>l.kind==='vxc'?(VXC[l.vt]||VXC[0]).g:l.kind==='xp'?xpHopG(l):l.kind==='df'?Math.max(0,...(l.ch||[]).map(c=>optG(c,l))):LT[l.tier].g;
const hopG=l=>l.kind==='vxc'?(VXC[l.vt]||VXC[0]).g:l.kind==='sat'?l.g:l.kind==='xp'?xpHopG(l):l.kind==='df'?Math.max(0,...(l.ch||[]).map(c=>optG(c,l))):LT[l.tier].g;
function fastPath(a,b,g){if(!S.pops[a]||!S.pops[b])return false;const adj={};for(const l of S.links){if(linkDown(l)||hopG(l)<g)continue;(adj[l.a]=adj[l.a]||[]).push(l.b);(adj[l.b]=adj[l.b]||[]).push(l.a);}const seen=new Set([a]),q=[a];while(q.length){const u=q.shift();if(u===b)return true;for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return false;}
function pathExists(a,b){if(!S.pops[a]||!S.pops[b])return false;const adj={};for(const l of S.links){if(linkDown(l))continue;(adj[l.a]=adj[l.a]||[]).push(l.b);(adj[l.b]=adj[l.b]||[]).push(l.a);}const seen=new Set([a]),q=[a];while(q.length){const u=q.shift();if(u===b)return true;for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return false;}
// Looked up rather than read from the save, so it follows a language switch mid-scenario.
const scnName=()=>S.scn.wk?wsTxt(S.scn.wk.name):S.scn.id==='weekly'?tr('scenarios.weekly_key',{key:S.scn.key}):SCN.find(x=>x.id===S.scn.id)?.n||S.scn.name;
const AU_BB=['syd','mel','bne','adl','per'],auExits=()=>new Set(S.links.filter(l=>l.sub&&!!CITY[l.a].au!==!!CITY[l.b].au&&!(l.ready>S.day)).map(l=>l.cable||l.id)).size;
const AU_BB=['syd','mel','bne','adl','per'],auExits=()=>new Set(S.links.filter(l=>seaLink(l)&&!!CITY[l.a].au!==!!CITY[l.b].au&&!(l.ready>S.day)).map(l=>l.cable||l.id)).size;
// Ports count only on POPs your backbone joins to São Paulo: islands of POPs with a port each skipped the Amazon (playtest).
const FTTB_G=500;
// Gangnam Style Peering: traffic, how well Seoul is served (delivered and fast) and a monthly profit.

View file

@ -0,0 +1,73 @@
/* ---------- Teleports and rented satellite capacity (#83) ----------
The rules, the money and save repair. Catalog and physics: 10-catalog/75-satellites.js; actions: 90-actions/87-teleports.js;
panels: 93-ui/72-teleport-panels.js. A circuit is a link (kind 'sat'): routing, standby, metrics and the map treat it like
any other, with the radio path as its km and its orbit's latency. */
// A POP's teleport (S.pops[c].tele): 0 none, 1 dishes for GEO birds, 2 with tracking antennas for the MEO ring too.
const teleOf=c=>{const p=S&&S.pops[c];return p&&(p.tele===1||p.tele===2)?p.tele:0;};
const teleCities=()=>Object.keys(S.pops).filter(teleOf);
// The birds that see city c, whatever your level.
const teleSees=c=>Object.keys(SATS).filter(id=>satSees(id,c));
// Why no teleport can go up at city c (nothing on sale sees it at your level, or no POP); '' when it can.
function teleWhy(c){if(!isCity(c)||!S.pops[c])return tr('satellites.no_pop_in_city',{city:isCity(c)?CITY[c].name:'?'});
if(lvl()<SAT_ORB.geo.lv)return tr('satellites.teleports_unlock_at_level',{lv:SAT_ORB.geo.lv});
const ids=teleSees(c);if(!ids.length)return tr('satellites.no_bird_sees_this_city');
if(!ids.some(id=>lvl()>=SAT_ORB[SATS[id].orb].lv)){const O=SAT_ORB[SATS[ids[0]].orb];return tr('satellites.orbit_unlocks_at_level',{orb:O.n,lv:O.lv});}
return '';}
// Why the teleport at c cannot add MEO tracking antennas; '' when it can.
function trkWhy(c){const O=SAT_ORB.meo;if(lvl()<O.lv)return tr('satellites.orbit_unlocks_at_level',{orb:O.n,lv:O.lv});
if(!isCity(c)||!teleOf(c))return tr('satellites.no_teleport_in_city',{city:isCity(c)?CITY[c].name:'?'});
if(!teleSees(c).some(id=>SATS[id].orb==='meo'))return tr('satellites.meo_ring_misses_city',{city:CITY[c].name,lat:O.lat});
return '';}
// The birds that see both ends of a circuit: GEO first, then the cheapest.
function satBirds(a,b){return Object.keys(SATS).filter(id=>satPairOk(id,a,b)).sort((x,y)=>(SATS[x].orb>SATS[y].orb)-(SATS[x].orb<SATS[y].orb)||SAT_PROV[SATS[x].p].pg-SAT_PROV[SATS[y].p].pg);}
// Why a circuit from teleport a to b over bird id (g Gbps, when given) cannot be ordered; '' when it can.
function satWhy(a,b,id,g){const B=own(SATS,id)?SATS[id]:null;if(!B||!isCity(a)||!isCity(b)||a===b)return tr('satellites.no_such_circuit');const O=SAT_ORB[B.orb];
if(lvl()<O.lv)return tr('satellites.orbit_unlocks_at_level',{orb:O.n,lv:O.lv});
if(!teleOf(a))return tr('satellites.no_teleport_in_city',{city:CITY[a].name});
if(B.orb==='meo'&&teleOf(a)<2)return tr('satellites.needs_tracking_antennas',{city:CITY[a].name});
if(!satRemote(b))return tr('satellites.not_remote',{city:CITY[b].name});
if(!satPairOk(id,a,b))return tr('satellites.out_of_footprint',{bird:B.n,a:CITY[a].name,b:CITY[b].name});
if(g!==undefined&&!O.g.includes(g))return tr('satellites.no_such_circuit');
const nt=noTalk(a,b);if(nt)return tr(nt);
if(!S.pops[b]){if(!cityOn(b))return popOffWhy(b);if(cnCity(b)&&!cnOk())return tr('pops_transit_ix.you_need_a_license_first_foreign');}
return '';}
// Where a teleport can reach: small islands and remote towns that one of its birds sees with it, your POPs first.
function satTargets(a){return CITIES.filter(C=>C.id!==a&&satRemote(C.id)&&(S.pops[C.id]||cityOn(C.id))&&satBirds(a,C.id).length).map(C=>C.id)
.sort((x,y)=>(!S.pops[x])-(!S.pops[y])||kmBetween(a,x)-kmBetween(a,y));}
// Your teleports that can reach city b.
const satFrom=b=>satRemote(b)?teleCities().filter(a=>a!==b&&satBirds(a,b).length):[];
// A new link between a and b (a wave, fiber, a fabric circuit, a cable): the circuits already there go on standby beside
// it, as one ordered next to a link does, and the player hears about it. Without this the pair's load is shared with orbit.
function satBeside(a,b){const ls=pairLinks(a,b).filter(l=>l.kind==='sat'&&!l.standby);for(const l of ls)l.standby=true;
if(ls.length)toast(trn('satellites.n_circuits_go_on_standby',ls.length,{a:CITY[a].name,b:CITY[b].name}));return ls.length;}
// What the teleports and their circuits cost a month (R.cost.sat).
function satMoAll(){let m=0;for(const c in S.pops){const t=teleOf(c);if(t)m+=TPORT_MO+(t>1?TRK_MO:0);}for(const l of S.links)if(l.kind==='sat')m+=l.mo||0;return m;}
/* compute(): what users notice on the edges a satellite circuit is on. sv: the losses of the orbits there; sx: the edge's
latency is the satellite's (no cable carries ahead of it), so it is no haul to transit on the ground. Returns how many
edges there were, for compute() to know a satellite is in the picture at all. */
function satEdges(SE){for(const e of SE){let ta=false,ts=false,act=false;const v=e.sv;
for(const l of e.links){const sb=!!l.standby;if(!sb)act=true;if(l.kind==='sat'){const x=SAT_ORB[SATS[l.bird].orb].loss;if(!v.includes(x))v.push(x);}else if(sb)ts=true;else ta=true;}
e.sx=act?!ta:!ts;}
return SE.length;}
// A flow of ok Gbps from city index ci crossed these edges: keep it, and what each orbit would cost it beyond the tl its
// haul to transit already does (users count the worse of the two, not both).
function satNote(se,ci,ok,tl){for(let k=0;k<se.length;k++){const x=se[k],v=x.sv,m=x.sa||(x.sa=new Map());let a=m.get(ci);if(!a)m.set(ci,a=new Float64Array(1+v.length));
a[0]+=ok;for(let j=0;j<v.length;j++)if(v[j]>tl)a[1+j]+=ok*(v[j]-tl);}}
/* After routing: each orbit's share of the edge's traffic, split as compute() splits it (active links by capacity, standby
ones the overflow). A satellite on standby beside a cable that has room carries nothing and costs nobody anything; one
that takes the overflow, or shares the load, costs the users of that share. LATP gets the lost service and SATU the
Gbps that rode a satellite, by city index. */
function satAfter(SE,LATP,SATU){for(const e of SE){const ld=e.ld||0;if(!e.sa||ld<=1e-9)continue;
const v=e.sv,sh=new Float64Array(v.length),ac=e.cap-e.scap,a=Math.min(ld,ac),sp=ld-a;let only=true,all=0;
for(const l of e.links){if(l.kind!=='sat'){only=false;continue;}const c=capOf(l);sh[v.indexOf(SAT_ORB[SATS[l.bird].orb].loss)]+=(l.standby?(e.scap>0?sp*c/e.scap:0):(ac>0?a*c/ac:0))/ld;}
if(only&&v.length===1)sh[0]=1;for(let j=0;j<v.length;j++)all+=sh[j];if(all<=1e-12)continue;
for(const [ci,x] of e.sa){let p=0;for(let j=0;j<v.length;j++)p+=sh[j]*x[1+j];LATP[ci]+=p;SATU[ci]+=all*x[0];}}}
// The share of city c's served traffic that rode a satellite in r (0 to 1).
const satShare=(r,c)=>r&&r.satU&&r.citySrv&&r.citySrv[c]>0?Math.min(1,(r.satU[c]||0)/r.citySrv[c]):0;
// Saves: a teleport is 1 or 2; a circuit needs a known bird that sees both POPs, a teleport able to work it, a size it sells.
function satSanitize(s){
for(const c of Object.keys(s.pops)){const p=s.pops[c];if(p.tele!==undefined&&p.tele!==1&&p.tele!==2)delete p.tele;}
s.links=s.links.filter(l=>{if(l.kind!=='sat')return true;const B=typeof l.bird==='string'&&own(SATS,l.bird)?SATS[l.bird]:null,p=s.pops[l.a];
if(!B||!p||!p.tele||B.orb==='meo'&&p.tele<2||!s.pops[l.b]||!satPairOk(l.bird,l.a,l.b))return false;
const G=SAT_ORB[B.orb].g;if(!G.includes(l.g))l.g=G.reduce((x,v)=>v<=num(l.g,0)?v:x,G[0]);
l.km=satKm(l.bird,l.a,l.b);l.sub=true;l.ready=num(l.ready,0);l.day=Math.min(s.day,Math.max(0,num(l.day,s.day)));for(const k of ['tier','cable','trench','mult','border','premium','vt','prov','own','sys','ch'])delete l[k];return true;});}

View file

@ -32,7 +32,7 @@ function traceroute(src,to,mode){mode=TR_MODES.includes(mode)?mode:'normal';cons
for(const x of pieBhHops(e,h.from===b.city)){const ms=x.ms*2+0.05;if(x.k==='up')hop(`dish.${x.city}.${me}`,ip(hstr(x.city),5),ms,tr('traceroute.sky_up',{city:CITY[x.city].name,crust:tr(cr.n)}));
else if(x.k==='las')hop(`laser.${b.cr}.${me}`,`10.255.${hstr(b.cr)%250}.${(x.km|0)%250}`,ms,tr('traceroute.sky_laser',{km:Math.round(x.km).toLocaleString()}));
else hop(`dish.${x.city}.${me}`,ip(hstr(x.city),6),ms,tr('traceroute.sky_down',{city:CITY[x.city].name}));}continue;}
const lat=linkLat(l)*2+0.15;hop(`ae${1+hstr(l.id)%9}.cr1.${h.to}.${me}`,ip(hstr(h.to),2),lat,`${CITY[h.to].name} · ${l.kind==='df'?tr('common.own_dark_fiber'):l.kind==='vxc'?tr('common.fabric_circuit'):l.kind==='xp'?tr('express.trace_hop',{via:xpVia(l)}):l.cable?CAB[l.cable].name:tr('common.terrestrial_wave')} · ${capName(l)}`);}};
const lat=linkLat(l)*2+0.15;hop(`ae${1+hstr(l.id)%9}.cr1.${h.to}.${me}`,ip(hstr(h.to),2),lat,`${CITY[h.to].name} · ${l.kind==='df'?tr('common.own_dark_fiber'):l.kind==='vxc'?tr('common.fabric_circuit'):l.kind==='xp'?tr('express.trace_hop',{via:xpVia(l)}):l.kind==='sat'?tr('satellites.via_bird',{bird:satName(l)}):l.cable?CAB[l.cable].name:tr('common.terrestrial_wave')} · ${capName(l)}`);}};
if(to.city){const path=P.path(to.city);lines.unshift(`traceroute to ${to.city}.${me} (${CITY[to.city].name}), 30 hops max`);if(!path){lines.push(' 2 * * * ← '+tr('traceroute.no_working_path_between_these_pops'));return {text:lines.join('\n'),why:tr('traceroute.no_path_every_route_between_these')};}walk(path);const bw=trBhWhy(bh,path);return {text:lines.join('\n'),why:bw+(S.te&&S.te.on?trn('traceroute.internal_path_over_n_link_chosen',path.length):trn('traceroute.internal_path_over_n_link_chosen_8620',path.length))};}
const N=NET[to.net],ex=trExits(to.net).filter(e=>P.dist[e.city]!==undefined);
lines.unshift(`traceroute to www.${slug(N.name)}.example (${N.name}, AS${N.asn}) from ${CITY[src].name}, 30 hops max`);

View file

@ -1,12 +1,13 @@
/* Pitcairn (#124): no cable lands there yet, but you may land your own, and the UK pays a monthly grant while the
islanders are online through you: a POP with broadband, up and nearly fully served. */
const GRANT_MO=300000;
const grantOn=r=>!!(S&&S.pops.pcn&&S.pops.pcn.bb&&!(S.pops.pcn.down>S.day)&&sfOf(r,'pcn')>=0.9);
islanders are online through you: a POP with broadband, up and nearly fully served. The money is for a cable: with more
than GRANT_SAT of their traffic on a rented satellite circuit (#83) it never comes, however well MEO serves them. */
const GRANT_MO=300000,GRANT_SAT=0.1;
const grantOn=r=>!!(S&&S.pops.pcn&&S.pops.pcn.bb&&!(S.pops.pcn.down>S.day)&&sfOf(r,'pcn')>=0.9&&satShare(r,'pcn')<=GRANT_SAT);
/* Satellite tier: Pitcairn online through your pies (its POP on backhaul, or home terminals there) is good enough for the
UK at a lower bar, orbit's latency forgiven (sfOf() counts it, so the fiber grant never comes), for less money. */
const GRANT_SKY_MO=120000,GRANT_SKY_Q=0.9;
function grantSky(r){if(!S||!S.pie||!r||!r.pie||grantOn(r))return false;const p=S.pops.pcn;
if(p&&p.bb&&!(p.down>S.day)&&r.pie.bh.some(b=>b.city==='pcn'&&b.g>0)){const d=r.cityDem.pcn||0;if(d>1e-6&&(r.citySrv.pcn||0)/d>=GRANT_SKY_Q)return true;}
return S.biz.some(b=>b.city==='pcn'&&b.type==='pizza'&&(r.pie.sf[b.id]||0)>=GRANT_SKY_Q);}
function grantFact(c){if(c!=='pcn')return '';const on=grantOn(R),sky=!on&&grantSky(R);
return `<span class="fact${on||sky?' mine':''}">${on?tr('pitcairn.uk_grant_mo',{mo:fmt$(GRANT_MO)}):sky?tr('pitcairn.uk_sky_grant_mo',{mo:fmt$(GRANT_SKY_MO),full:fmt$(GRANT_MO)}):tr('pitcairn.uk_grant_mo_once_islanders',{mo:fmt$(GRANT_MO)})}</span>`;}
function grantFact(c){if(c!=='pcn')return '';const on=grantOn(R),sky=!on&&grantSky(R),sat=!on&&!sky&&satShare(R,'pcn')>GRANT_SAT;
return `<span class="fact${on||sky?' mine':''}">${on?tr('pitcairn.uk_grant_mo',{mo:fmt$(GRANT_MO)}):sky?tr('pitcairn.uk_sky_grant_mo',{mo:fmt$(GRANT_SKY_MO),full:fmt$(GRANT_MO)}):sat?tr('pitcairn.uk_grant_needs_a_cable',{mo:fmt$(GRANT_MO)}):tr('pitcairn.uk_grant_mo_once_islanders',{mo:fmt$(GRANT_MO)})}</span>`;}

View file

@ -260,7 +260,7 @@ const OPS_RUN={
for(const q of b.orders.filter(q=>opsHere('pni',q.city)&&loc(q)>=g&&(paid||NET[q.net].pol!=='paid'||paidFree(NET[q.net]))).sort((a,b)=>loc(b)-loc(a))){
if(!X.can('pni',q.cost))break;if(X.pay('pni',()=>{if(!spend(q.cost))return false;pniPlace(q);return true;}))X.did('pni',q.city+' '+q.net);}},
// Hand back smaller waves once a bigger link between the same cities carries the pair with a quarter to spare (#102).
decom(X){const by=new Map();for(const l of S.links)if(l.kind!=='vxc'){const k=edgeKey(l);(by.get(k)||by.set(k,[]).get(k)).push(l);}
decom(X){const by=new Map();for(const l of S.links)if(l.kind!=='vxc'&&l.kind!=='sat'){const k=edgeKey(l);(by.get(k)||by.set(k,[]).get(k)).push(l);}
// Loads must include what this shift already did (a customer just signed, a repair): recompute first, if anything could go.
if(X.dirty&&[...by.values()].some(ls=>ls.length>1&&ls.some(l=>l.kind==='wave'))){compute();X.dirty=false;}
for(const ls of by.values())for(const l of opsDecomPick(ls)){UI.confirm=l.id;X.pay('decom',()=>ACT.rmLink({id:l.id}));if(!S.links.includes(l))X.did('decom',l.a+'|'+l.b);}},

View file

@ -116,7 +116,7 @@ function bstdPlan(intern){const J=[];J.held=[];if(!S||!S.popStd||pzOn())return J
// the sizes these upgrades give: never pay a month's rent on one it is about to return.
if(D.wv!=='keep'){for(const {l} of ls)if(l.kind==='wave'&&l.tier<D.wv)for(let t=D.wv;t>l.tier;t--){if(subWaveWhy(t,l.km,l.sub)||soldOut(l.a,l.b,t,l.cable)||!waveOk(l.a,l.b,t))continue;wv.set(l,t);break;}
if(wv.size&&opsHired()&&S.ops.on.decom){const by=new Map(),cf=x=>wv.has(x)?capOf(x)*LT[wv.get(x)].g/LT[x.tier].g:capOf(x);
for(const x of S.links)if(x.kind!=='vxc'){const k=edgeKey(x);(by.get(k)||by.set(k,[]).get(k)).push(x);}
for(const x of S.links)if(x.kind!=='vxc'&&x.kind!=='sat'){const k=edgeKey(x);(by.get(k)||by.set(k,[]).get(k)).push(x);}
for(const k of new Set([...wv.keys()].map(edgeKey)))for(const x of opsDecomPick(by.get(k),cf))wv.delete(x);}}
for(const {l} of ls){const ch='l:'+l.id;
if(l.kind==='wave'){const t=wv.get(l);if(t){const nm=Math.round(waveMo(l.km,l.sub,t)*(l.mult||1));job('fiber','wv',ch,l.a+'|'+l.b,nm,nm-(l.mo||0),()=>{ACT.upLink({id:l.id,tier:t});return l.tier===t;},{l});}continue;}

View file

@ -61,7 +61,7 @@ function pieEximOffer(d){const P=S.pie,G=P.gov;if(!P.fac||pieEximLoan()||!pieCan
// Taking it: a loan like any other, plus its space covenants.
function pieEximTake(){const P=S.pie,o=P.gov.ex;if(!o||pieEximLoan())return false;const pay=Math.round(annuity(o.amt,o.apr,o.term));
S.cash+=o.amt;S.stats.loans=(S.stats.loans||0)+1;
S.loans.push({id:uid(),bank:'exim',start:S.day,amount:o.amt,got:o.amt,bal:o.amt,apr:o.apr,apr0:o.apr,pay,left:o.term,term:o.term,share:0,covs:['pielaunch','piedish'],base:{sub:S.links.filter(x=>x.sub).length},
S.loans.push({id:uid(),bank:'exim',start:S.day,amount:o.amt,got:o.amt,bal:o.amt,apr:o.apr,apr0:o.apr,pay,left:o.term,term:o.term,share:0,covs:['pielaunch','piedish'],base:{sub:S.links.filter(seaLink).length},
pie:{cc:o.cc,n:o.n,by:S.day+PIE_EXIM_BY,flown:0,br:0}});
P.gov.ex=null;track('loan_taken');return true;}
// A breach (loanTick(), after the bank's own penalty): tighter terms, the launch target rescheduled, and a spat.

View file

@ -16,4 +16,4 @@ function dijkstra(adj,src,wf,skip,stop){const n=adj.length,D=new Float64Array(n)
// The edges of a dijkstra() path back from city index B to A, and the cities on it (B first), as indices.
function walkI(P,A,B){const path=[],ni=[B];let v=B;while(v!==A){const l=P[v];path.push(l);v=l.ai===v?l.bi:l.ai;ni.push(v);}return {path,ni};}
// The same for compute()'s sender, with the marks it keeps on a path (full, its latency, its far-exit traffic) there from the start: one object shape.
function walkP(P,A,B){const path=[],ni=[B];let v=B;while(v!==A){const l=P[v];path.push(l);v=l.ai===v?l.bi:l.ai;ni.push(v);}return {path,ni,dead:0,ms:-1,fg:0};}
function walkP(P,A,B){const path=[],ni=[B];let v=B;while(v!==A){const l=P[v];path.push(l);v=l.ai===v?l.bi:l.ai;ni.push(v);}return {path,ni,dead:0,ms:-1,fg:0,mt:0,se:null};}

View file

@ -29,12 +29,14 @@ function compute(){RW.gen++;
const day=S.day, R2=emptyR(), pops=Object.keys(S.pops).filter(popUp), NC=CITIES.length;
// The graph works on city indices: adj[i] lists [neighbour, edge] in S.links order.
const remote=remoteCities(),adj=new Array(NC); pops.concat(remote).forEach(p=>adj[CIDX[p]]=[]);
const edges={},EA=[],TRX=teRules(),live=[];let NE=0;R2.bizDem={};R2.bizSrv={};
const edges={},EA=[],TRX=teRules(),live=[];let NE=0,SE=null;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.a<l.b?l.a+'|'+l.b:l.b+'|'+l.a;let e=edges[key];
// The metric belongs to the city pair (a preset or a custom one); links on standby add capacity that fills only after the others (#122).
if(!e){e=edges[key]={id:key,a:l.a,b:l.b,ai,bi,i:NE++,km:l.km,cap:0,scap:0,w:Infinity,lat:Infinity,slat:Infinity,links:[],res:0,ld:0,tr:null,pl:0,jk:0,f:TRX&&TRX.avoid.has(key)?60:1};EA.push(e);adj[ai].push([bi,e]);adj[bi].push([ai,e]);}
const c=capOf(l),lt=linkLat(l);e.cap+=c;e.links.push(l);e.w=Math.min(e.w,pairW(key,l.km)*e.f);if(l.standby){e.scap+=c;e.slat=Math.min(e.slat,lt);}else e.lat=Math.min(e.lat,lt);}
if(!e){e=edges[key]={id:key,a:l.a,b:l.b,ai,bi,i:NE++,km:l.km,cap:0,scap:0,w:Infinity,lat:Infinity,slat:Infinity,links:[],res:0,ld:0,tr:null,pl:0,jk:0,f:TRX&&TRX.avoid.has(key)?60:1,sx:0,sv:null,sa:null};EA.push(e);adj[ai].push([bi,e]);adj[bi].push([ai,e]);}
const c=capOf(l),lt=linkLat(l);e.cap+=c;e.links.push(l);e.w=Math.min(e.w,pairW(key,l.km)*e.f);if(l.standby){e.scap+=c;e.slat=Math.min(e.slat,lt);}else e.lat=Math.min(e.lat,lt);if(l.kind==='sat'&&!e.sv){e.sv=[];(SE||(SE=[])).push(e);}}
for(const k in edges){const e=edges[k];if(e.lat===Infinity)e.lat=e.slat;}
// The edges a satellite circuit is on (45-teleports.js): users notice the share of their traffic it carries, whatever the exit.
const SATN=SE?satEdges(SE):0;
// Shortest paths from every POP: SPD[pop] the distance to each city index (Infinity: no path), SPP[pop] the edge it arrives by;
// ALONE and the islands (COMP). Kept between calls while the graph is the same (29-route-cache.js).
const wW=e=>e.w,wLat=e=>e.lat+0.05,RCON=RC.on,GK=RCON?rcGraphKey(pops,remote,EA):null,
@ -245,8 +247,11 @@ function compute(){RW.gen++;
// Backhaul to transit: users notice the round trip to the exit. Up to 20 ms (about 1,500 km) is free, then
// it gets worse, and past 50 ms broadband and internet services count as bad service (#…). Under sender pays,
// Korean users notice any exit far away, transit or not, and much sooner.
if(path.length&&(e.k==='t'||snd&&CITIES[ci].kr)){let ms=P.ms;if(ms<0){ms=0;for(let k=0;k<PN;k++)ms+=path[k].lat;P.ms=ms;}const rtt=2*ms,kl=snd&&CITIES[ci].kr;
if(rtt>(kl?KR_LAT_OK:LAT_OK)){LATP[ci]+=ok*(kl?krLatLoss(rtt):latLoss(rtt));if(!P.fg){P.fg=0;FARL.push(P,ci,e.ci);}P.fg+=ok;}}const kx=e.kx;if(EGT[kx]===0&&!EGO.includes(kx))EGO.push(kx);EGT[kx]+=ok;if(!NEG[nr]){NEG[nr]=R2.netEg[NET_IDS[nr]]={c:0,p:0,ix:0,t:0};NEO.push(nr);}NEA[nr*4+kx]+=ok;
// Over a satellite users notice too, whatever the exit: the path's edges with one (se) keep what this flow would lose
// on each orbit, and satAfter() charges the share the satellite really carried. The haul to transit counts on the ground (mt).
if(path.length&&(e.k==='t'||snd&&CITIES[ci].kr||SATN)){if(P.ms<0){let ms=0,mt=0,se=null;for(let k=0;k<PN;k++){const x=path[k];ms+=x.lat;if(!x.sx)mt+=x.lat;if(x.sv)(se||(se=[])).push(x);}P.ms=ms;P.mt=mt;P.se=se;}const rtt=2*P.mt,kl=snd&&CITIES[ci].kr;
const tl=(e.k==='t'||kl)&&rtt>(kl?KR_LAT_OK:LAT_OK)?(kl?krLatLoss(rtt):latLoss(rtt)):0;
if(tl>0){LATP[ci]+=ok*tl;if(!P.fg){P.fg=0;FARL.push(P,ci,e.ci);}P.fg+=ok;}if(P.se)satNote(P.se,ci,ok,tl);}const kx=e.kx;if(EGT[kx]===0&&!EGO.includes(kx))EGO.push(kx);EGT[kx]+=ok;if(!NEG[nr]){NEG[nr]=R2.netEg[NET_IDS[nr]]={c:0,p:0,ix:0,t:0};NEO.push(nr);}NEA[nr*4+kx]+=ok;
// Where each flow left (the PNI list asks what a PNI here would take over, #175).
if(e.J>0){const m=e.byC||(e.byC=new Map()),v=m.get(ci);if(v){v[0]+=ok;if(bz)v[1]+=ok;}else m.set(ci,[ok,bz?ok:0]);}
if(e.k==='t'){FGT[F]+=ok;FTI[F]=e.xi;}else if(e.k==='ix'){FGI[F]+=ok;FII[F]=e.xi;}else if(e.k==='p'){if(e.ci===ci&&e.net===NET_IDS[nr])FGH[F]+=ok;else FGP[F]+=ok;}}
@ -339,8 +344,10 @@ function compute(){RW.gen++;
if(DD){let rem=0,jf=0;for(let i=0;i<NF;i++)if(FREM[i]>1e-6)rem+=FREM[i];if(JK)for(const k in edges){const e=edges[k];if(e.res<=1e-6&&e.jk)jf+=e.jk;}
ddosAfter(DD,{E,R2,squeeze:Math.min(rem,jf),
lost:(ci,x,y,e)=>{SRV[ci]-=x;R2.served-=x;const c=CITIES[ci].id;if(y)R2.bizSrv[c]-=y;R2.egT[e.k]-=x;if(e.rank<=2)R2.peered-=x;}});}
// R.satU only when a circuit is in the graph, so R stays as it was for networks without one.
const SATU=SATN?new Float64Array(NC):null;if(SATU){R2.satU={};satAfter(SE,LATP,SATU);}
for(const c of Object.keys(S.pops)){const i=CIDX[c];R2.citySrv[c]=SRV[i];
if(LATP[i]>0&&SRV[i]>0)R2.latF[c]=clamp(1-LATP[i]/SRV[i],0,1);}
if(LATP[i]>0&&SRV[i]>0)R2.latF[c]=clamp(1-LATP[i]/SRV[i],0,1);if(SATU&&SATU[i]>1e-9)R2.satU[c]=SATU[i];}
// Each city's slowest big exit: (path, source, exit) triples, one per path that went far, in the order they first did.
{const G=new Map();for(let k=0;k<FARL.length;k+=3){const P=FARL[k],src=FARL[k+1],to=FARL[k+2],key=src*NC+to,o=G.get(key);if(o){o.g+=P.fg;o.ms=Math.max(o.ms,2*P.ms);}else G.set(key,{src,to,g:P.fg,ms:2*P.ms});}
for(const o of G.values()){const c=CITIES[o.src].id,cur=R2.latFar[c];if(!cur||o.g>cur.g)R2.latFar[c]={to:CITIES[o.to].id,g:o.g,ms:o.ms,share:SRV[o.src]>0?o.g/SRV[o.src]:0};}}
@ -362,7 +369,7 @@ function computeMoney(R2,PX=null){
const C=R2.cost,V=R2.rev,pm=S.priceMul;
C.pops=Object.entries(S.pops).reduce((a,[c,p])=>a+popMo(c)+((p.routers||1)-1)*ROUTER_MO+cageMo(p.routers)+(p.routers||1)*RG[p.rgen||0].mo+(p.gen?GEN_MO:0),0);
C.optical=S.links.filter(l=>l.kind==='df').reduce((a,l)=>a+(l.ready>S.day?0:ampCount(l.km)*AMP_MO*(l.own&&isRdm(l.sys)&&!l.sub?Math.max(1,l.pairs|0):1)+(l.regen|0)*REGEN_MO)+(l.spares?Math.round(150+(l.ch||[]).length*80):0),0);
C.links=S.links.reduce((a,l)=>a+(l.mo||0),0);
C.links=S.links.reduce((a,l)=>a+(l.kind==='sat'?0:l.mo||0),0);{const m=satMoAll();if(m)C.sat=m;}
C.nni=(S.nni||[]).reduce((a,x)=>a+nniMo(x),0);
const htd=histToday();C.transit=S.transit.reduce((a,t)=>{const q=p95(t,R2.useT[t.id]||0,htd);R2.p95[t.id]=q;return a+transitMo(t,q);},0);
C.ix=Object.keys(S.ixp).reduce((a,c)=>a+ixMo(c),0);

View file

@ -4,7 +4,7 @@ const histToday=()=>{const H=S.hist,l=H&&H[H.length-1];return !!l&&l.d===S.day;}
function p95(t,cur,today=histToday()){const a=t.hist||[],n=Math.max(0,a.length-(today&&a.length?1:0)),h=a.slice(Math.max(0,n-29),n).concat([cur]).sort((a,b)=>a-b);return h[Math.max(0,Math.ceil(.95*h.length)-1)];}
// Cut, or cut off by an event between its two countries, whatever runs on it (an express asks this of each fiber it rides).
function linkCut(l){return l.cut>S.day||(S.ev.runet>S.day&&ruCity(l.a)!==ruCity(l.b))||(S.ev.gulf>S.day&&((CITY[l.a].qa&&(CITY[l.b].gcc||CITY[l.b].uae))||(CITY[l.b].qa&&(CITY[l.a].gcc||CITY[l.a].uae))));}
function linkDown(l){return linkCut(l)||(l.kind==='vxc'&&!!S.ev.fab&&S.ev.fab[l.prov]>S.day)||(l.kind==='df'&&dfCap(l)<=0)||(l.kind==='xp'&&xpDown(l));}
function linkDown(l){return linkCut(l)||(l.kind==='vxc'&&!!S.ev.fab&&S.ev.fab[l.prov]>S.day)||(l.kind==='df'&&dfCap(l)<=0)||(l.kind==='xp'&&xpDown(l))||(l.kind==='sat'&&l.ready>S.day);}
function remoteCities(){return [...new Set(S.links.filter(l=>l.kind==='vxc').flatMap(l=>[l.a,l.b]))].filter(c=>!S.pops[c]);}
function nniUsed(c,prov){return S.links.filter(l=>l.kind==='vxc'&&l.prov===prov&&(l.a===c||l.b===c)).reduce((a,l)=>a+VXC[l.vt].g,0)+S.biz.filter(b=>BIZ_T[b.type].nni&&b.prov===prov&&b.city===c).reduce((a,b)=>a+b.bw,0);}
// Monthly price of one connection; compute() sums these, the connections overview lists them.

View file

@ -21,7 +21,7 @@ function sanitize(s){
if(!isCity(s.home))s.home=Object.keys(s.pops)[0]||'fra';
opsSanitize(s);
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);if(l.list!==undefined){const L=l.list;if(l.kind==='df'&&L&&typeof L==='object'&&!Array.isArray(L)){const w=int(L.w,0,256,0),p=int(L.p,0,2,0);if(w||p)l.list={w,p};else delete l.list;}else delete l.list;}l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.cname!=null)l.cname=String(l.cname).slice(0,60);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!=='xp')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&(!own(CAB,l.cable)||!cablePair(l.cable,l.a,l.b)))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);if(l.day!==undefined)l.day=Math.min(s.day,Math.max(0,num(l.day,s.day)));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;});
s.links=s.links.filter(l=>l&&isCity(l.a)&&isCity(l.b)&&l.a!==l.b).map(l=>{l.id=sid(l.id);if(l.list!==undefined){const L=l.list;if(l.kind==='df'&&L&&typeof L==='object'&&!Array.isArray(L)){const w=int(L.w,0,256,0),p=int(L.p,0,2,0);if(w||p)l.list={w,p};else delete l.list;}else delete l.list;}l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.cname!=null)l.cname=String(l.cname).slice(0,60);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!=='xp'&&l.kind!=='sat')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&(!own(CAB,l.cable)||!cablePair(l.cable,l.a,l.b)))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);if(l.day!==undefined)l.day=Math.min(s.day,Math.max(0,num(l.day,s.day)));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);
xpSanitize(s);
/* Metrics moved from each link to its city pair (#122). Older saves routed a pair at the lowest metric of its
@ -114,6 +114,7 @@ function sanitize(s){
specSanitize(s);mpSanitize(s);
pieSanitize(s);pieIncFix(s);
ip4Fix(s);
satSanitize(s);
if(s.te){if(typeof s.te!=='object')s.te=null;else{s.te.on=!!s.te.on;s.te.script=typeof s.te.script==='string'?s.te.script.slice(0,4000):'';}}
return s;}
function migrate(s){sanitize(s);

View file

@ -30,7 +30,7 @@ const LAND_X=45,landX=(a,b)=>!isSub(a,b)&&CITY[a].reg!==CITY[b].reg&&CITY[a].cc!
function landMult(a,b){if(isSub(a,b))return 1;if(uaePair(a,b))return 3;return (landX(a,b)?LAND_X:1)*(andesPair(a,b)?2:1)*(nullPair(a,b)?NULLARBOR:1)*(rainPair(a,b)?2:1)*(borderPair(a,b)?2:1);}
function landWhy(a,b){if(isSub(a,b))return '';if(uaePair(a,b))return tr('geography_and_latency.inside_the_uae_only_the_two');
const r=[];if(landX(a,b))r.push(tr('geography_and_latency.overland_between_continents_crosses',{x:LAND_X}));if(andesPair(a,b))r.push(tr('geography_and_latency.this_route_crosses_the_andes_2'));if(nullPair(a,b))r.push(tr('geography_and_latency.this_route_crosses_the_nullarbor_x',{x:NULLARBOR}));if(borderPair(a,b))r.push(tr('geography_and_latency.this_route_crosses_a_border_in'));if(rainPair(a,b))r.push(tr('geography_and_latency.this_route_goes_into_the_amazon'));return r.join(' ');}
function linkLat(l){if(l.kind==='xp')return xpLat(l);const f=l.kind==='df'?(l.own?(l.sub?seaLatencyFactor(l):1.1):1.25):l.kind==='vxc'?1.4:l.cable?(CAB[l.cable].lat||1):1.3;return l.km*f/200;}
function linkLat(l){if(l.kind==='xp')return xpLat(l);if(l.kind==='sat')return satLat(l);const f=l.kind==='df'?(l.own?(l.sub?seaLatencyFactor(l):1.1):1.25):l.kind==='vxc'?1.4:l.cable?(CAB[l.cable].lat||1):1.3;return l.km*f/200;}
/* Wave prices differ a lot by market (TeleGeography): Europe's dense, competitive metro and
long-haul routes are cheap (Frankfurt–London 100G ≈ $1,150/mo), the US costs more, and
routes into Africa are several times dearer (Africa–Europe ≈ 5.9× London–New York).

View file

@ -4,7 +4,7 @@ const anchorProne=l=>!!(l.cable&&CAB[l.cable]&&CAB[l.cable].anchor)||anchorPair(
const wetSeason=()=>{const m=cal(S.day).m;return m>=10||m<=3;},wetCut=l=>!l.sub&&!!(CITY[l.a].wet||CITY[l.b].wet)&&wetSeason();
function fireFailure(only){
const opts=[];
const live=S.links.filter(l=>l.kind!=='vxc'&&l.kind!=='xp'&&!linkDown(l));const fabsUsed=[...new Set(S.links.filter(l=>l.kind==='vxc').map(l=>l.prov))];
const live=S.links.filter(l=>l.kind!=='vxc'&&l.kind!=='xp'&&l.kind!=='sat'&&!linkDown(l));const fabsUsed=[...new Set(S.links.filter(l=>l.kind==='vxc').map(l=>l.prov))];
// A fiber that only carries expresses is dark as a link of its own, but there is light in it: a backhoe still finds it.
const bare=S.links.filter(xpBare),dug=live.concat(bare);
if(dug.length){opts.push(['cut',2+Math.min(6,dug.length/2)]);}

View file

@ -22,7 +22,7 @@ function mkTick(d){const M=S.monkey;if(!M)return;
if(!mkElig()){if(M.on)mkLeave('quiet');return;}
// The first visit is spread by the ASN, not the dice, so a game's other luck stays exactly as it was.
if(M.next==null)M.next=d+(mkSpicy()?180:270)+(S.asn||0)%120;
if(!M.on){if(d<M.next)return;if(S.links.filter(l=>l.kind!=='vxc'&&l.kind!=='xp'&&(!linkDown(l)||xpBare(l))).length<3){M.next=d+30;return;}mkArrive(d);return;}
if(!M.on){if(d<M.next)return;if(S.links.filter(l=>l.kind!=='vxc'&&l.kind!=='xp'&&l.kind!=='sat'&&(!linkDown(l)||xpBare(l))).length<3){M.next=d+30;return;}mkArrive(d);return;}
if(d>=M.until){mkLeave();return;}
if(d>=M.snip){mkSnip();M.snip=d+(mkSpicy()?rint(9,7):rint(14,11));}}
function mkArrive(d){const M=S.monkey,cs=Object.keys(S.pops),len=mkSpicy()?rint(180,61):rint(120,121);
@ -30,7 +30,7 @@ function mkArrive(d){const M=S.monkey,cs=Object.keys(S.pops),len=mkSpicy()?rint(
Object.assign(M,{on:1,start:d,until:d+len,snip:d+3,n:0,hurt:0,c:cs.length?pick(cs):S.home});
toast(tr('chaos_monkey.arrived',{n:len}),'bad',[{l:tr('chaos_monkey.banana',{cost:fmt$(mkBananaCost())}),act:'mkBanana',args:{}}],{a:'tab',v:'noc'});sfx('alert');track('monkey_arrive');
if(typeof mkStart==='function'&&CITY[M.c])mkStart(M.c);}
function mkSnip(){const M=S.monkey,live=S.links.filter(l=>l.kind!=='vxc'&&l.kind!=='xp'&&(!linkDown(l)||xpBare(l)));if(!live.length)return;
function mkSnip(){const M=S.monkey,live=S.links.filter(l=>l.kind!=='vxc'&&l.kind!=='xp'&&l.kind!=='sat'&&(!linkDown(l)||xpBare(l)));if(!live.length)return;
// Weak spots first: a sample keeps this cheap on big networks.
const smp=live.length>40?Array.from({length:40},()=>pick(live)):live,l=pick(smp.flatMap(x=>mkWeak(x)?[x,x,x,x,x]:[x]));
const dur=rint(3,4),trc=l.trench||l.id,hit=S.links.filter(x=>(x.trench||x.id)===trc),A=CITY[l.a].name,B=CITY[l.b].name,before=R.served;

View file

@ -81,7 +81,7 @@ function dayPost(d){
mkTick(d);
if(cm&&d>=S.nextFail&&!mkOn()){dirty=true;fireFailure();const size=S.links.length+Object.keys(S.pops).length;S.nextFail=d+Math.round((Math.max(22,50-size*1.5)+Math.floor(Math.random()*25))*(scnRule('chaos')?0.5:1)/cm);}
// Anchors Away: on top of the usual failures, ships drag anchors over each Baltic seabed link (about three cuts a link-year).
if(cm&&d>45&&scnRule('anchors')){const n=S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l)&&anchorProne(l)).length;if(n&&Math.random()<Math.min(5,+S.scn.rules.anchors||1)*n/365){dirty=true;fireFailure('cut');}}
if(cm&&d>45&&scnRule('anchors')){const n=S.links.filter(l=>l.kind!=='vxc'&&l.kind!=='sat'&&!linkDown(l)&&anchorProne(l)).length;if(n&&Math.random()<Math.min(5,+S.scn.rules.anchors||1)*n/365){dirty=true;fireFailure('cut');}}
if(cm&&d>=S.nextEvent){dirty=true;fireEvent();S.nextEvent=d+Math.round((45+Math.floor(Math.random()*45))/cm);}
if(dirty)compute();
// the sales desk signs and declines deals, when the player lets it (39-sales-auto.js), then the intern's shift sees them

View file

@ -13,7 +13,7 @@ const ACT={
takeLoan:({id})=>{const o=S.loanOffers.find(x=>x.id===id);if(!o)return;S.stats.loans=(S.stats.loans||0)+1;const B=BANKS[o.bank];let got=o.amount,note='';
if(B.crypto){const f=0.55+Math.random()*0.8;got=Math.round(o.amount*f);note=' '+(f>=1?tr('interface.tubecoin_moved_up_p_on_the',{p:Math.round(Math.abs(f-1)*100)}):tr('interface.tubecoin_moved_down_p_on_the',{p:Math.round(Math.abs(f-1)*100)}));}
S.cash+=got;S.loanOffers=S.loanOffers.filter(x=>x!==o);
S.loans.push({id:o.id,bank:o.bank,start:S.day,amount:o.amount,got,bal:o.model==='transit'?o.owe:o.amount,apr:o.apr||0,apr0:o.apr||0,pay:o.pay||0,left:o.term||0,term:o.term||0,share:o.share||0,model:o.model,cut:o.cut,covs:o.covs,base:{sub:S.links.filter(x=>x.sub).length}});
S.loans.push({id:o.id,bank:o.bank,start:S.day,amount:o.amount,got,bal:o.model==='transit'?o.owe:o.amount,apr:o.apr||0,apr0:o.apr||0,pay:o.pay||0,left:o.term||0,term:o.term||0,share:o.share||0,model:o.model,cut:o.cut,covs:o.covs,base:{sub:S.links.filter(seaLink).length}});
track('loan_taken');toast(`<b>${tr('interface.amt_from_bank_has_landed',{amt:fmt$(got),bank:esc(B.name)})}</b><br>${B.equity?tr('interface.they_now_own_p_of_your',{p:pct(o.share)}):loanSummary(o)}${note}`,'good');sfx('coin');after();renderBank();},
callBank:({amount})=>{if(!callOffer(amount))return;track('loan_called');sfx('click');renderBank();renderHUD();save();},
declineLoan:({id})=>{S.loanOffers=S.loanOffers.filter(x=>x.id!==id);sfx('click');renderBank();renderHUD();save();},

View file

@ -14,13 +14,13 @@ Object.assign(ACT,{
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();},
foundIx:({city})=>{if(!isCity(city))return;const why=foundIxWhy(city);if(why){toast(why,'bad');sfx('err');return;}if(!spend(MYIX_COST))return;const nm=(S.name.split(' ')[0]||'My').replace(/[^A-Za-z0-9]/g,'').slice(0,10)+'-IX '+CITY[city].name;
S.myIx[city]={name:nm,members:[],next:S.day+4};S.ixp[city]=2;toast(tr('links.you_founded_ix_networks_will_join',{ix:esc(nm)}),'goal');after();},
buildLink:({tier})=>{tier=+tier;const p=UI.pending;if(!p||noTalk(p.a,p.b))return;const {a,b}=p;const km=kmBetween(a,b),sub=isSub(a,b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'&&l.kind!=='xp'),jn=sib.length?routeJoin(a,b):null,same=!!jn,border=cnCity(a)!==cnCity(b),mult=(sib.length&&!(jn&&jn.k===(landTrenches(a,b)[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1);
buildLink:({tier})=>{tier=+tier;const p=UI.pending;if(!p||noTalk(p.a,p.b))return;const {a,b}=p;const km=kmBetween(a,b),sub=isSub(a,b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'&&l.kind!=='xp'&&l.kind!=='sat'),jn=sib.length?routeJoin(a,b):null,same=!!jn,border=cnCity(a)!==cnCity(b),mult=(sib.length&&!(jn&&jn.k===(landTrenches(a,b)[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1);
if(!linkFromOk(a)||!linkToOk(b)||((cnCity(a)||cnCity(b))&&!cnOk()))return;
if(!waveOk(a,b,tier)){toast(tr('links.a_wave_wave_needs_need_at',{wave:LT[tier].n,need:esc(waveNeed(tier))}),'bad');sfx('err');return;}
const wr=waveRoute(a,b,mult,border);if(!wr){toast(tr('links.no_cable_available_for_that_route'),'bad');sfx('err');return;}
{const so=soldOut(a,b,tier,wr.cab);if(so){toast(tr('links.no_wave_capacity_on_this_route',{wave:LT[tier].n,why:tr(so.why),n:Math.max(1,so.until-S.day)}),'bad');sfx('err');return;}}{const w=subWaveWhy(tier,wr.km,wr.sub);if(w){toast(tr('links.no_wave_waves_on_this_cable',{wave:LT[tier].n,why:esc(w)}),'bad');sfx('err');return;}}const base=Math.round(waveMo(wr.km,wr.sub,tier)*wr.wm),cost=base+(S.pops[b]?0:popCost(b));
if(!portGate(a,1)||!portGate(b,1))return;if(!spend(cost))return;if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false};popStdApply(b);}
const id=uid();const l={id,a,b,kind:'wave',border,premium:border&&!!UI.cnPrem&&(a==='hkg'||b==='hkg'),tier,km:wr.km,sub:wr.sub,cable:wr.cab,mo:base,mult:wr.wm,trench:wr.cab?'cab:'+wr.cab:(jn?jn.k:id),cut:0,day:S.day};S.links.push(l);closeModal();
const id=uid();const l={id,a,b,kind:'wave',border,premium:border&&!!UI.cnPrem&&(a==='hkg'||b==='hkg'),tier,km:wr.km,sub:wr.sub,cable:wr.cab,mo:base,mult:wr.wm,trench:wr.cab?'cab:'+wr.cab:(jn?jn.k:id),cut:0,day:S.day};S.links.push(l);satBeside(a,b);closeModal();
if(sib.length){UI.sel={type:'link',id};}else{UI.sel={type:'city',id:b};UI.tab='cust';}
floater((CITY[a].x+CITY[a].x+wrapDx(CITY[a].x,CITY[b].x))/2,(CITY[a].y+CITY[b].y)/2-20,tr('links.wave_lit',{wave:LT[tier].n}),'#FF4F9A');after();},
// A new fabric port, or every member of one upgraded to a faster speed (#140): as fast as the router takes.
@ -36,7 +36,7 @@ Object.assign(ACT,{
openVxc:(a)=>openVxcModal(a),
buyVxc:({a,b,prov,t})=>{t=+t;if(!CITY[a]||!CITY[b]||noTalk(a,b))return;const g=VXC[t].g,pa=nniPort(a,prov);if(!pa||nniUsed(a,prov)+g>nniCap(pa)+1e-9){toast(tr('links.not_enough_room_on_your_fabric'),'bad');sfx('err');return;}
if(S.pops[b]){const pb=nniPort(b,prov);if(!pb||nniUsed(b,prov)+g>nniCap(pb)+1e-9){toast(tr('links.not_enough_room_on_your_fab',{fab:esc(FAB[prov].name),city:CITY[b].name}),'bad');sfx('err');return;}}
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();
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});satBeside(a,b);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>nniCap(pt)+1e-9){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);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();},

View file

@ -3,7 +3,7 @@ Object.assign(ACT,{
toast(tr('specialist.the_vendor_ships_a_demo_name',{name:esc(it.n),n:at-S.day,p:Math.round((DEMO_MUL-1)*100)}),'good');after();},
seatBuy:({n})=>{const o=S.seatOff;n=+n;if(!o||o.exp<=S.day||!SEAT_N.includes(n))return;const miss=[o.a,o.b].filter(c=>!S.pops[c]),cost=seatCost(o.km,n)+miss.reduce((x,c)=>x+popCost(c),0);if(!spend(cost))return;
for(const c of miss){S.pops[c]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(c);}
const id=uid(),days=seatDays(o.km);S.links.push({id,a:o.a,b:o.b,kind:'df',own:true,sub:true,seat:true,seaDesign:'standard',sys:'roadm',ch:[],km:o.km,cable:null,cname:o.name,mo:seatMo(o.km,n),trench:'seat:'+id,cut:0,day:S.day,ready:S.day+days,spares:false,pairs:n,paid:seatCost(o.km,n)});
const id=uid(),days=seatDays(o.km);S.links.push({id,a:o.a,b:o.b,kind:'df',own:true,sub:true,seat:true,seaDesign:'standard',sys:'roadm',ch:[],km:o.km,cable:null,cname:o.name,mo:seatMo(o.km,n),trench:'seat:'+id,cut:0,day:S.day,ready:S.day+days,spares:false,pairs:n,paid:seatCost(o.km,n)});satBeside(o.a,o.b);
S.seatOff=null;S.stats.seats=(S.stats.seats||0)+1;UI.sel={type:'link',id};
toast(tr('specialist.you_own_n_fiber_pairs_on',{n,name:esc(o.name),a:CITY[o.a].name,b:CITY[o.b].name,d:days}),'goal');sfx('build');after();},
seatNo:()=>{S.seatOff=null;after();},

View file

@ -10,7 +10,7 @@ Object.assign(ACT,{
orderCable:()=>{const p=UI.pending;if(!p||noTalk(p.a,p.b))return;const {a,b}=p;if(ownCabWhy(a,b)||!linkFromOk(a)||!linkToOk(b))return;const design=own(SEA_DESIGNS,UI.seaDesign)?UI.seaDesign:'standard',up=seaUps(seaQuote(a,b,design).km),q=seaQuote(a,b,design,up),km=q.km,cost=q.cost+(S.pops[b]?0:popCost(b));if(seaLack(km,up).length||!spend(cost))return;
if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(b);}
const used=new Set(S.links.map(l=>l.cname).filter(Boolean)),cname=OWNCAB_NAMES.find(n=>!used.has(n))||`${pick(OWNCAB_NAMES)} ${used.size+1}`,id=uid(),ship=layName({id}),days=q.days;
S.links.push({id,a,b,kind:'df',own:true,sub:true,seaDesign:design,seaPath:q.pts.map(p=>p.slice()),sys:'roadm',ch:[],km,cable:null,cname,mo:Math.round(km*OWNCAB_OM),trench:'own:'+id,cut:0,day:S.day,ready:S.day+days,spares:false,pairs:1});
S.links.push({id,a,b,kind:'df',own:true,sub:true,seaDesign:design,seaPath:q.pts.map(p=>p.slice()),sys:'roadm',ch:[],km,cable:null,cname,mo:Math.round(km*OWNCAB_OM),trench:'own:'+id,cut:0,day:S.day,ready:S.day+days,spares:false,pairs:1});satBeside(a,b);
const laid=S.links[S.links.length-1];laid.paid=q.cost;for(const k of Object.keys(SUB_UPGRADES))if(up[k])laid['sub'+k]=laid.ready;UI.seaDesign='standard';UI.seaterminal=UI.seaengineering=false;
S.stats.ownCab=(S.stats.ownCab||0)+1;UI.dfSrc='lease';closeModal();UI.sel={type:'link',id};
toast(tr('fiber_and_hardware.the_ship_sets_sail_name_your',{ship,name:cname,km:km.toLocaleString(),a:CITY[a].name,b:CITY[b].name,n:days}),'goal');sfx('build');after();},
@ -20,7 +20,7 @@ Object.assign(ACT,{
if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(b);}
const sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'&&l.kind!=='xp'),id=uid();
const l={id,a,b,kind:'df',own,sys,ch:[],km,sub:!!sc,cable:sc?sc.cid:null,mo:own?Math.round(km*0.15):dfLeaseMo(km),trench:sc?'cab:'+sc.cid:id,cut:0,day:S.day,ready:S.day+(own?dfBuildDays(km):leadDays(IRU_DAYS)),spares:false};
S.links.push(l);closeModal();UI.sel={type:'link',id};
S.links.push(l);satBeside(a,b);closeModal();UI.sel={type:'link',id};
toast(own?tr('fiber_and_hardware.groundbreaking_your_own_fiber_from_a',{a:CITY[a].name,b:CITY[b].name,n:dfBuildDays(km)}):tr('fiber_and_hardware.dark_fiber_iru_signed_a_b',{a:CITY[a].name,b:CITY[b].name}),'goal');after();},
regen:({id,d})=>{d=+d;const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='df'||(l.sub&&!l.seat)||(d!==1&&d!==-1))return;const n=(l.regen|0)+d;if(n<0||n>REGEN_MAX)return;
if(d<0&&((l.ch||[]).some(o=>!optMode(o,Object.assign({},l,{regen:n})))||xpRegenBad(l,n))){toast(tr('fiber_and_hardware.those_optics_need_the_regen_site'),'bad');sfx('err');return;}

View file

@ -0,0 +1,27 @@
// Teleports and satellite capacity (#83): build the gateway, rent circuits on its birds, resize them. Cancel is rmLink.
Object.assign(ACT,{
teleBuild:({city})=>{const p=S.pops[city];if(!p||teleOf(city))return;
const why=teleWhy(city);if(why){toast(why,'bad');sfx('err');return;}
if(!spend(TPORT_COST))return;p.tele=1;toast(tr('satellites.teleport_up_in_city',{city:CITY[city].name}),'good');after();},
teleTrk:({city})=>{const p=S.pops[city];if(!p||teleOf(city)!==1)return;
const why=trkWhy(city);if(why){toast(why,'bad');sfx('err');return;}
if(!spend(TRK_COST))return;p.tele=2;toast(tr('satellites.tracking_antennas_up',{city:CITY[city].name}),'good');after();},
// Closing a teleport asks twice, and never while circuits still start there.
teleRm:({city})=>{const p=S.pops[city];if(!p||!teleOf(city))return;const n=S.links.filter(l=>l.kind==='sat'&&l.a===city).length;
if(n){toast(trn('satellites.cancel_n_circuits_first',n),'bad');sfx('err');return;}
if(UI.confirm!=='tele:'+city){UI.confirm='tele:'+city;renderPanel();return;}
delete p.tele;UI.confirm=null;toast(tr('satellites.teleport_closed',{city:CITY[city].name}));after();},
satOpen:({a,b})=>satModal(a,b),
// Rent a circuit from teleport a to b: the first month up front, like a wave; a POP at b comes with it if there is none.
// Next to a link you already have between the two, it goes on standby: the backup that carries only when the cable is down.
buySat:({a,b,bird,g})=>{g=+g;const why=satWhy(a,b,bird,g);if(why){toast(why,'bad');sfx('err');return;}
if(!portGate(a,1)||!portGate(b,1))return;const mo=satMo(bird,g),pop=!S.pops[b];if(!spend(mo+(pop?popCost(b):0)))return;
if(pop){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false};popStdApply(b);}
const sb=pairLinks(a,b).some(l=>l.kind!=='sat'),n=leadDays(SAT_ORB[SATS[bird].orb].days),id=uid();
S.links.push({id,a,b,kind:'sat',bird,g,km:satKm(bird,a,b),sub:true,mo,cut:0,day:S.day,ready:S.day+n,...(sb?{standby:true}:{})});
closeModal();UI.sel={type:'link',id};
toast(trn('satellites.circuit_ordered',n,{cap:fmtCap(g),bird:esc(SATS[bird].n),a:CITY[a].name,b:CITY[b].name})+(sb?' '+tr('satellites.on_standby_beside_your_link'):''),'good');after();},
// Bigger or smaller on the same bird: a bigger one pays its new month up front, as a wave upgrade does.
satSize:({id,g})=>{g=+g;const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='sat'||g===l.g||!SAT_ORB[SATS[l.bird].orb].g.includes(g))return;
const mo=satMo(l.bird,g);if(g>l.g&&!spend(mo))return;l.g=g;l.mo=mo;sfx('click');after();},
});

View file

@ -3,14 +3,14 @@ function cityPanel(c){
// Your POP's router model, as a picture left of the name (10-catalog/25-router-art.js).
const art=p?rgArt(p.rgen||0):'';
let h=`<div class="ph">${art?`<span class="rgpic big phpic">${art}</span>`:''}<div style="min-width:0"><div class="eyebrow">${REG[C.reg]} · ${esc(siteName(c,'a'))}</div><h2>${C.name}</h2>
<div class="facts"><span class="fact">${tr('city_panel.g_of_eyeballs',{g:fmtG(eyeP(c))})}</span>${grantFact(c)}${latSlow(c)?`<span class="fact bad">🐢 ${tr('city_panel.ms_ms_to_transit',{ms:Math.round(R.latFar[c].ms)})}</span>`:''}${regionMult(c)>1?`<span class="fact">${tr('city_panel.transit_x_pricier',{x:regionMult(c)})}</span>`:''}${C.kr&&scnRule('sender')?`<span class="fact">${tr('city_panel.sender_pays_fee_per_gbps',{fee:fmt$(KR_FEE)})}</span>`:''}${colo(c)>1?`<span class="fact">${tr('city_panel.few_data_centers_pops_x',{x:colo(c)})}</span>`:''}${C.reg==='AS'&&!C.cn?'<span class="fact ixf">'+tr('city_panel.underserved_users_grow_60_faster')+'</span>':''}${ix?`<span class="fact ixf">${tr('city_panel.ix_ix',{ix:esc(ix)})}</span>`:''}${p?`<span class="fact mine">${tr('common.your_pop')}</span><button class="fact trb" data-act="trace" data-args='{"city":"${c}"}'>🔍 ${tr('common.traceroute')}</button>`:''}${down?`<span class="fact down">DOWN</span>`:''}</div></div>
<div class="facts"><span class="fact">${tr('city_panel.g_of_eyeballs',{g:fmtG(eyeP(c))})}</span>${grantFact(c)}${satFact(c)}${latSlow(c)?`<span class="fact bad">🐢 ${tr('city_panel.ms_ms_to_transit',{ms:Math.round(R.latFar[c].ms)})}</span>`:''}${regionMult(c)>1?`<span class="fact">${tr('city_panel.transit_x_pricier',{x:regionMult(c)})}</span>`:''}${C.kr&&scnRule('sender')?`<span class="fact">${tr('city_panel.sender_pays_fee_per_gbps',{fee:fmt$(KR_FEE)})}</span>`:''}${colo(c)>1?`<span class="fact">${tr('city_panel.few_data_centers_pops_x',{x:colo(c)})}</span>`:''}${C.reg==='AS'&&!C.cn?'<span class="fact ixf">'+tr('city_panel.underserved_users_grow_60_faster')+'</span>':''}${ix?`<span class="fact ixf">${tr('city_panel.ix_ix',{ix:esc(ix)})}</span>`:''}${p?`<span class="fact mine">${tr('common.your_pop')}</span><button class="fact trb" data-act="trace" data-args='{"city":"${c}"}'>🔍 ${tr('common.traceroute')}</button>`:''}${down?`<span class="fact down">DOWN</span>`:''}</div></div>
<button class="x" data-act="closePanel" aria-label="${tr('common.close')}">×</button></div>`;
if(!p){
h+=`<div class="scroll">${C.note?`<p class="note" style="margin-top:0">${esc(C.note)}</p>`:''}
${C.cn?chinaSection(c):''}${C.cn&&!cnOk()?'':`<section><h3>${tr('city_panel.open_a_pop_here')}</h3><p class="lead">${tr('city_panel.a_pop_point_of_presence_is')}</p>
${C.ru?`<p class="why">${tr('city_panel.includes_the_mandatory_government',{cost:fmt$(RU_BOX),mo:fmt$(RU_BOX_MO)})}</p>`:''}${(q=>btn(tr('city_panel.build_pop_cost_mo_mo',{cost:fmt$(popCost(c)+(q?q.cost:0)),mo:fmt$(popMo(c)+(q?q.mo:0))}),'buildPop',{city:c},'pink big',S.cash<popCost(c))+(q?`<p class="note">${q.site2||q.gen?tr('pop_std.includes_the_build_standard',{list:esc(bstdPopParts({g:q.g,rt:q.rt,site2:q.site2,gen:q.gen}).join(', ')),cost:fmt$(q.cost),mo:fmt$(q.mo)}):tr('pop_std.includes_the_standard_n_model',{n:q.rt,model:esc(RG[q.g].n),cost:fmt$(q.cost),mo:fmt$(q.mo)})}</p>`:''))(popStdQuote())}
<p class="note">${tr('city_panel.or_drag_from_one_of_your')}</p></section>${opsTplHtml(c)}`}`;
h+=offersHere(c);
h+=offersHere(c)+satNoPop(c);
const trs=NETS.filter(n=>sellsAt(n,c));
const fh=FABS.filter(f=>f.cities.includes(c));
if(ix&&fh.length){if(remoteCities().includes(c))h+=ixSection(c).replace('<h3>'+tr('common.internet_exchange')+'</h3>','<h3>'+tr('city_panel.remote_peering_at_the_ix')+'</h3>');
@ -103,10 +103,11 @@ function cityPanel(c){
else h+=`<div class="btns">${NNI.map((N,i)=>portShown(i)?btn(tr('city_panel.port_port_price_mo_197d',{port:N.n,price:fmt$(N.mo)}),'buyNni',{city:c,prov:f.id,tier:i},'sm',S.cash<N.mo||!portOk(c,i)):'').join('')}</div>`;
h+=`</div></div>`;}
h+=`</section>`;}
h+=teleHtml(c);
h+=`<section><h3>${tr('city_panel.fiber_from_city',{city:C.name})}</h3><p class="lead">${tr('city_panel.drag_from_this_router_to_any')}</p>`;
if(!ls.length)h+=`<p class="empty">${tr('common.no_links_yet')}</p>`;
for(const l of ls){const o=l.a===c?l.b:l.a,u=capOf(l)?(R.load[l.id]||0)/capOf(l):0,cut=linkDown(l);
h+=`<div class="row"><div class="grow"><div class="nm">→ ${CITY[o].name}${l.mult>1?' · '+tr('common.diverse'):''} ${cut?'<span class="tag restrictive">'+tr('common.cut')+'</span>':''}</div><div class="meta">${capName(l)} · ${l.km.toLocaleString()} km ${l.kind==='vxc'?tr('city_panel.virtual_circuit_via_fab',{fab:esc(FAB[l.prov].name)}):l.kind==='xp'?tr('express.city_via',{via:xpVia(l)}):l.kind==='df'?(l.own?(l.sub&&l.cname?tr('city_panel.your_own_subsea_cable_name',{name:esc(l.cname)}):tr('common.own_dark_fiber')):tr('city_panel.dark_fiber_iru'))+(l.ready>S.day?` · ${tr('city_panel.ready_in_n_d',{n:l.ready-S.day})}`:''):l.sub?tr('common.subsea'):tr('common.terrestrial')} · ${tr('common.price_mo',{price:fmt$(l.mo)})}</div><div class="bar ${barCls(u)}"><i style="width:${u*100}%"></i></div></div>${btn(tr('common.open'),'selLink',{id:l.id},'ghost sm')}</div>`;}
h+=`<div class="row"><div class="grow"><div class="nm">→ ${CITY[o].name}${l.mult>1?' · '+tr('common.diverse'):''} ${cut?'<span class="tag restrictive">'+tr('common.cut')+'</span>':''}</div><div class="meta">${capName(l)} · ${l.km.toLocaleString()} km ${l.kind==='vxc'?tr('city_panel.virtual_circuit_via_fab',{fab:esc(FAB[l.prov].name)}):l.kind==='xp'?tr('express.city_via',{via:xpVia(l)}):l.kind==='sat'?tr('satellites.via_bird',{bird:esc(satName(l))})+(l.ready>S.day?` · ${tr('city_panel.ready_in_n_d',{n:l.ready-S.day})}`:''):l.kind==='df'?(l.own?(l.sub&&l.cname?tr('city_panel.your_own_subsea_cable_name',{name:esc(l.cname)}):tr('common.own_dark_fiber')):tr('city_panel.dark_fiber_iru'))+(l.ready>S.day?` · ${tr('city_panel.ready_in_n_d',{n:l.ready-S.day})}`:''):l.sub?tr('common.subsea'):tr('common.terrestrial')} · ${tr('common.price_mo',{price:fmt$(l.mo)})}</div><div class="bar ${barCls(u)}"><i style="width:${u*100}%"></i></div></div>${btn(tr('common.open'),'selLink',{id:l.id},'ghost sm')}</div>`;}
h+=`</section>`;
if(Object.keys(S.pops).length>1)h+=`<section><h3>${tr('common.decommission')}</h3><p class="lead">${tr('city_panel.shut_this_pop_down_its_links')}</p><div class="btns">${btn(tr('city_panel.decommission_city',{city:C.name}),'decomOpen',{city:c},'ghost sm')}${btn(tr('city_panel.decommission_several_pops'),'decomOpen',{},'ghost sm')}</div></section>`;
}

View file

@ -146,6 +146,7 @@ function offersHere(c){
function linkPanel(id){
const l=S.links.find(x=>x.id===id);if(!l){UI.sel=null;return '';}
if(l.kind==='vxc')return vxcPanel(l);
if(l.kind==='sat')return satPanel(l);
if(l.kind==='df')return dfPanel(l);
if(l.kind==='xp')return xpPanel(l);
const load=R.load[l.id]||0,cap=LT[l.tier].g,u=load/cap,cut=l.cut>S.day,trk=l.trench||l.id,inc=S.inc.find(i=>(LINKCUT_TR.includes(i.type)&&i.ref===trk)||((i.type==='fatwave'||i.type==='label'||i.type==='mtu')&&i.ref===l.id)),sib=pairLinks(l.a,l.b).filter(x=>x!==l&&x.kind!=='vxc'),mates=sib.filter(x=>(x.trench||x.id)===trk);

View file

@ -0,0 +1,60 @@
// Teleports and satellite circuits on screen (#83): a POP's section, the order sheet, a circuit's panel.
const satLogo=P=>`<span class="logo" style="--c:${P.col}">${esc(P.n.slice(0,2).toUpperCase())}</span>`;
// Round trip over bird id between a and b, in whole ms.
const satRtt=(id,a,b)=>Math.round(2*satLat({bird:id,km:satKm(id,a,b)}));
const satModalHead=(eye,title)=>`<div style="display:flex;align-items:center"><div><div class="eyebrow">🛰️ ${eye}</div><h2 style="font-size:24px">${title}</h2></div><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div>`;
// In a city's facts: its own users' traffic rides a satellite today (R.satU), and they count part of the service as bad (sfOf, R.latF).
const satFact=c=>R&&R.latF&&R.latF[c]<1&&R.satU&&R.satU[c]>1e-3?`<span class="fact bad">🛰️ ${tr('satellites.users_ride_a_satellite')}</span>`:'';
// The birds a dish at c sees, in words.
const satInView=c=>{const ids=teleSees(c);return ids.length?tr('satellites.in_view_list',{list:ids.map(id=>`<b>${esc(SATS[id].n)}</b> (${tr(SATS[id].sea)})`).join(', ')}):tr('satellites.no_bird_sees_this_city');};
// In a POP's Infra tab: its teleport (build it, what it sees, its circuits), and the teleports that can reach it.
function teleHtml(c){if(pzOn())return '';const t=teleOf(c),from=satFrom(c),open=lvl()>=SAT_ORB.geo.lv;if(!t&&!open&&!from.length)return '';
let h=`<section><h3>🛰️ ${tr('satellites.satellites')}</h3>`;
if(t){const out=S.links.filter(l=>l.kind==='sat'&&l.a===c),cf=UI.confirm==='tele:'+c,meo=teleSees(c).some(id=>SATS[id].orb==='meo');
h+=`<div class="kv"><span>${tr('satellites.teleport')}</span><b>${t>1?tr('satellites.geo_dishes_and_meo_tracking'):tr('satellites.geo_dishes')} · ${tr('common.price_mo',{price:fmt$(TPORT_MO+(t>1?TRK_MO:0))})}</b></div>
<div class="meta">${satInView(c)}</div>`;
for(const l of out){const u=capOf(l)?(R.load[l.id]||0)/capOf(l):0;
h+=`<div class="row"><div class="grow"><div class="nm">→ ${CITY[l.b].name}${l.standby?' <span class="tag st">'+tr('common.standby')+'</span>':''}</div><div class="meta">${capName(l)} · ${esc(satName(l))}${l.ready>S.day?' · '+tr('city_panel.ready_in_n_d',{n:l.ready-S.day}):''} · ${tr('common.price_mo',{price:fmt$(l.mo)})}</div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div>${btn(tr('common.open'),'selLink',{id:l.id},'ghost sm')}</div>`;}
h+=`<div class="btns">${btn(tr('satellites.rent_satellite_capacity'),'satOpen',{a:c},'pink sm')}${t===1&&lvl()>=SAT_ORB.meo.lv&&meo?btn(tr('satellites.add_tracking_antennas_cost_mo',{cost:fmt$(TRK_COST),mo:fmt$(TRK_MO)}),'teleTrk',{city:c},'sm',S.cash<TRK_COST):''}${out.length?'':btn(cf?tr('satellites.really_close_it'):tr('satellites.close_the_teleport'),'teleRm',{city:c},'ghost sm')}</div>
${t===1&&lvl()<SAT_ORB.meo.lv&&meo?`<p class="note">${tr('satellites.meo_comes_at_level',{lv:SAT_ORB.meo.lv})}</p>`:''}`;}
// Before the build: what its dishes would see and reach at your level, and no button to a teleport that reaches nothing.
else if(open){const why=teleWhy(c),n=why?0:satTargets(c).filter(x=>satBirds(c,x).some(id=>lvl()>=SAT_ORB[SATS[id].orb].lv)).length;
h+=`<p class="lead">${tr('satellites.a_teleport_is_a_satellite_gateway')}</p><div class="meta">${satInView(c)}${why?'':' '+trn('satellites.n_places_in_reach',n)}</div>${why&&teleSees(c).length?`<div class="why">${esc(why)}</div>`:''}
<div class="btns">${btn(tr('satellites.build_a_teleport_cost_mo',{cost:fmt$(TPORT_COST),mo:fmt$(TPORT_MO)}),'teleBuild',{city:c},'sm',S.cash<TPORT_COST||!!why)}</div>`;}
if(from.length)h+=satReach(c,from);
return h+`</section>`;}
// Teleports that reach city c: a button each, to the order sheet.
const satReach=(c,from)=>`<p class="note">${tr('satellites.reachable_from_your_teleports',{city:CITY[c].name})}</p><div class="btns">${from.slice(0,4).map(a=>btn(tr('fiber_modals.from_city',{city:CITY[a].name}),'satOpen',{a,b:c},'ghost sm')).join('')}</div>`;
// A city without a POP of yours, that a teleport of yours reaches: a POP and a circuit in one go.
function satNoPop(c){if(pzOn()||S.pops[c])return '';const from=satFrom(c);if(!from.length)return '';
return `<section><h3>🛰️ ${tr('satellites.by_satellite')}</h3><p class="lead">${tr('satellites.no_cable_needed_a_pop_here',{city:CITY[c].name})}</p>${satReach(c,from)}</section>`;}
// The order sheet: from teleport a to b. With one end missing it lists the choices first.
function satModal(a,b){a=isCity(a)?a:null;b=isCity(b)?b:null;
if(!a&&b){const fr=satFrom(b);if(fr.length===1)a=fr[0];
else{openModal(satModalHead(tr('satellites.satellite_capacity'),tr('fiber_modals.to_city',{city:CITY[b].name}))+(fr.length?fr.map(x=>`<div class="row"><div class="grow"><div class="nm">${CITY[x].name}</div><div class="meta">${tr('satellites.teleport')} · ${trn('satellites.n_birds_see_both',satBirds(x,b).length)}</div></div>${btn(tr('satellites.choose'),'satOpen',{a:x,b},'sm')}</div>`).join(''):`<p class="empty">${tr('satellites.no_teleport_reaches_city',{city:CITY[b].name})}</p>`));return;}}
if(!a||!teleOf(a))return;
if(!b){const ts=satTargets(a),mine=ts.filter(x=>S.pops[x]),more=ts.filter(x=>!S.pops[x]).slice(0,12);
const row=x=>`<div class="row"><div class="grow"><div class="nm">${CITY[x].name}</div><div class="meta">${S.pops[x]?tr('common.your_pop'):tr('satellites.new_pop_cost',{cost:fmt$(newPopCost(x))})} · ${kmBetween(a,x).toLocaleString()} km · ${trn('satellites.n_birds_see_both',satBirds(a,x).length)}</div></div>${btn(tr('satellites.choose'),'satOpen',{a,b:x},'sm')}</div>`;
openModal(satModalHead(tr('satellites.satellite_capacity'),tr('fiber_modals.from_city',{city:CITY[a].name}))+`<p class="lead" style="margin-top:8px">${tr('satellites.who_a_satellite_serves')}</p>`
+(mine.length?`<h4 class="sub4">${tr('satellites.your_pops_in_view')}</h4>`+mine.map(row).join(''):'')+(more.length?`<h4 class="sub4">${tr('satellites.more_islands_and_towns')}</h4>`+more.map(row).join(''):'')+(ts.length?'':`<p class="empty">${tr('satellites.nothing_in_view_from_here')}</p>`));return;}
const pop=S.pops[b]?0:newPopCost(b),sib=pairLinks(a,b).some(l=>l.kind!=='sat'),birds=satBirds(a,b);
const rows=birds.map(id=>{const B=SATS[id],O=SAT_ORB[B.orb],P=SAT_PROV[B.p],why=satWhy(a,b,id);
return `<div class="row">${satLogo(P)}<div class="grow"><div class="nm">${esc(B.n)} <span class="tag">${O.n}</span></div><div class="meta">${esc(P.n)} · ${tr(B.sea)} · ${tr('satellites.ms_round_trip',{ms:satRtt(id,a,b)})} · ${trn('satellites.up_in_n_days',leadDays(O.days))}</div><div class="meta">${esc(P.blurb)}</div>${why?`<div class="why">${esc(why)}</div>`:''}
<div class="btns">${O.g.map(g=>btn(`${fmtCap(g)} <small>${tr('common.price_mo',{price:fmt$(satMo(id,g))})}</small>`,'buySat',{a,b,bird:id,g},'sm',!!why||S.cash<satMo(id,g)+pop)).join('')}</div></div></div>`;}).join('');
openModal(satModalHead(tr('satellites.satellite_capacity'),`${CITY[a].name} → ${CITY[b].name}`)+`<p class="lead" style="margin-top:8px">${tr('satellites.users_notice_geo_meo')}</p>`
+(pop?`<p class="note">${tr('satellites.no_pop_there_yet',{city:CITY[b].name,cost:fmt$(pop)})}</p>`:'')+(sib?`<p class="note">${tr('satellites.it_waits_on_standby')}</p>`:'')
+(rows||`<p class="empty">${tr('satellites.no_bird_sees_both',{a:CITY[a].name,b:CITY[b].name})}</p>`));}
// A circuit's panel: what it carries, its latency and rent, a size up or down, standby and the metric, cancel.
function satPanel(l){const B=SATS[l.bird],O=SAT_ORB[B.orb],P=SAT_PROV[B.p],load=R.load[l.id]||0,cap=capOf(l),u=cap?load/cap:0,ms=satLat(l);
let h=`<div class="ph"><div><div class="eyebrow">🛰️ ${esc(B.n)} · ${O.n} · ${esc(P.n)}</div><h2>${CITY[l.a].name} ⇄ ${CITY[l.b].name}</h2></div><button class="x" data-act="closePanel" aria-label="${tr('common.close')}">×</button></div><div class="scroll">`;
if(l.ready>S.day){const tot=Math.max(1,l.ready-l.day),done=clamp((S.day-l.day)/tot,0,1);
h+=`<section><h3>${tr('satellites.being_commissioned')}</h3><div class="kv"><span>${tr('satellites.pointing_dishes_and_testing')}</span><b>${tr('common.n_days_left',{n:l.ready-S.day})}</b></div><div class="bar me"><i style="width:${done*100}%"></i></div></section>`;}
h+=`<section><h3>${tr('common.capacity')}</h3><div class="kv"><span>${capName(l)}${l.standby?' · '+tr('common.standby'):''}</span><b>${fmtG(load)} / ${fmtG(cap)}</b></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div>
<div class="kv"><span>${tr('common.latency')}</span><b>${tr('satellites.ms_one_way_rtt',{ms:Math.round(ms),rtt:Math.round(2*ms)})}</b></div>
<div class="kv"><span>${tr('satellites.radio_path')}</span><b>${l.km.toLocaleString()} km</b></div>
<div class="kv"><span>${tr('satellites.rent')}</span><b>${tr('common.price_mo',{price:fmt$(l.mo)})}</b></div>
<p class="note">${B.orb==='geo'?tr('satellites.geo_users_notice',{p:pct(O.loss)}):tr('satellites.meo_users_notice',{p:pct(O.loss)})} ${esc(P.blurb)}</p>
<div class="btns">${O.g.filter(g=>g!==l.g).map(g=>btn(`${g>l.g?tr('satellites.grow_to',{cap:fmtCap(g)}):tr('satellites.shrink_to',{cap:fmtCap(g)})} <small>${tr('common.price_mo',{price:fmt$(satMo(l.bird,g))})}</small>`,'satSize',{id:l.id,g},'sm',g>l.g&&S.cash<satMo(l.bird,g))).join('')}</div></section>
${trafficSection(l)}${metricSection(l)}
<section>${btn(UI.confirm===l.id?tr('common.really_cancel'):tr('common.cancel_circuit'),'rmLink',{id:l.id},'ghost sm')}</section></div>`;
return h;}

View file

@ -10,7 +10,7 @@ function litOn(L,cap){const free=chMax(L)-(L.ch||[]).length-soldSlots(L)-xpSlots
for(const o in OPT){const O=OPT[o];if(O.lvl>glassLvl()||(O.sys==='roadm'&&!isRdm(L.sys))||[L.a,L.b].some(c=>S.pops[c]&&RG[S.pops[c].rgen||0].cls<O.rg))continue;const g=optG(o,L),c=chCost(L,o);if(g&&(!b||c/g<b.c/b.g))b={o,g,c};}
if(!b)return {free,n:0,fits:false};const n=Math.ceil(cap/b.g);return {free,n,up:n*b.c,fits:n<=free};}
function leaseSwaps(){const by={};
for(const l of S.links){if(l.kind==='df'&&l.own||l.kind==='xp'||!S.pops[l.a]||!S.pops[l.b])continue;const k=[l.a,l.b].sort().join('|');(by[k]=by[k]||[]).push(l);}
for(const l of S.links){if(l.kind==='df'&&l.own||l.kind==='xp'||l.kind==='sat'||!S.pops[l.a]||!S.pops[l.b])continue;const k=[l.a,l.b].sort().join('|');(by[k]=by[k]||[]).push(l);}
return Object.entries(by).map(([k,ls])=>{const [a,b]=k.split('|'),sub=isSub(a,b),mo=ls.reduce((s,l)=>s+(l.mo||0),0),cap=leaseCap(ls);
const x={a,b,sub,ls,mo,cap,opts:[],own:pairLinks(a,b).find(l=>l.kind==='df'&&l.own&&l.ready<=S.day)};if(x.own){x.fit=litOn(x.own,cap);if(x.fit.fits)x.best=mo;return x;}
// Waves and fabric circuits can also move onto a leased fiber pair: cheaper glass, but you buy the gear.

View file

@ -9,7 +9,7 @@ function renderDash(){checkLayer();
<div class="dgrid">${tile(tr('common.traffic_now'),fmtG(R.served),tr('dashboard.of_g_wanted',{g:fmtG(R.demand)}))}${tile(tr('common.peak'),fmtG(S.stats.peak))}${tile(tr('dashboard.delivered_30_days'),(up*100).toFixed(1)+'%',up>=0.999?tr('dashboard.five_nines_ish'):up>=0.99?tr('dashboard.two_nines_and_change'):tr('dashboard.customers_are_upset'))}${tile(tr('common.peering_ratio'),pct(R.peerShare||0),tr('dashboard.caches_pnis_and_ix'))}${tile(tr('dashboard.monthly_p_l'),`<span style="color:${net>=0?'var(--eye)':'var(--bad)'}">${net>=0?'+':''}${fmt$(net)}</span>`,tr('dashboard.in_in_out_out',{in:fmt$(R.revMo),out:fmt$(R.costMo)}))}${tile(tr('common.incidents'),S.stats.incidents,tr('dashboard.n_shrugged_off',{n:S.stats.survived}))}</div>
<div class="dcols"><div class="panel2"><h3>${tr('dashboard.traffic_by_way_out')}</h3>${svgChart(rows,['c','p','ix','t','l2'],[{k:'dem',col:'var(--text)',dash:true}],v=>fmtCap(Math.round(v)),'traffic')}${chartLegend('traffic',k=>k==='dem'?'':' '+pct((R.egT[k]||0)/tot))}</div>
<div class="panel2"><h3>${tr('dashboard.money_per_month')}</h3>${svgChart(rows,[],[{k:'rev',col:'#16A866'},{k:'cost',col:'#FF4D5E'}],v=>fmt$(v),'money')}${chartLegend('money')}
<h3 style="margin-top:8px">${tr('dashboard.where_the_money_goes')}</h3>${Object.entries(R.cost).filter(([k,v])=>v>0).sort((a,b)=>b[1]-a[1]).map(([k,v])=>`<div class="kv"><span>${{pops:tr('dashboard.pops_and_routers'),links:tr('dashboard.waves_and_fiber'),transit:tr('common.transit'),ix:tr('common.ix_ports'),pni:tr('common.pnis'),caches:tr('common.cache_power'),nni:tr('common.fabric_ports'),optical:tr('dashboard.amp_huts_and_spares'),loans:tr('common.loan_repayments'),revshare:tr('dashboard.investor_revenue_share'),extras:tr('dashboard.licenses_and_scrubbing'),wholesale:tr('dashboard.nearly_broadband_network_wholesale'),levy:tr('dashboard.regional_broadband_levy'),pie:tr('pie.costs_row'),ip4:tr('ip4.costs_row')}[k]||k}</span><b>${tr('common.price_mo',{price:fmt$(v)})}</b></div>`).join('')}</div></div>`;
<h3 style="margin-top:8px">${tr('dashboard.where_the_money_goes')}</h3>${Object.entries(R.cost).filter(([k,v])=>v>0).sort((a,b)=>b[1]-a[1]).map(([k,v])=>`<div class="kv"><span>${{pops:tr('dashboard.pops_and_routers'),links:tr('dashboard.waves_and_fiber'),transit:tr('common.transit'),ix:tr('common.ix_ports'),pni:tr('common.pnis'),caches:tr('common.cache_power'),nni:tr('common.fabric_ports'),optical:tr('dashboard.amp_huts_and_spares'),loans:tr('common.loan_repayments'),revshare:tr('dashboard.investor_revenue_share'),extras:tr('dashboard.licenses_and_scrubbing'),wholesale:tr('dashboard.nearly_broadband_network_wholesale'),levy:tr('dashboard.regional_broadband_levy'),pie:tr('pie.costs_row'),ip4:tr('ip4.costs_row'),sat:tr('satellites.costs_row')}[k]||k}</span><b>${tr('common.price_mo',{price:fmt$(v)})}</b></div>`).join('')}</div></div>`;
const tT=(R.egT.t||0)||1;
const offMix=(UI.chartOff&&UI.chartOff.mix)||{},filt=Object.keys(offMix).length>0;
// The legend above the table picks which ways in count; "lost" still looks at everything the network gets.

View file

@ -21,7 +21,7 @@ function renderBank(){
h+=CT?`<div class="meta">${tr('bank.bank_picks_up_apr_apr_over',{bank:esc(BANKS[CT.bank].name),apr:(CT.apr*100).toFixed(1),n:CALL_MONTHS,limit:fmt$(lim)})}</div><div class="btns" style="margin-top:6px">${CALL_AMTS.map(a=>btn(fmt$(a),'callBank',{amount:a},'sm',a>lim)).join('')}</div>`:`<p class="empty">${tr('bank.get_to_an_aa_rating_and')}</p>`;}
h+=`<h3 style="font-size:18px;margin-top:14px">${tr('common.offers')}</h3>`;
if(!S.loanOffers.length)h+=`<p class="empty">${tr('bank.no_offers_right_now_banks_get')}</p>`;
for(const o of S.loanOffers){const B=BANKS[o.bank];h+=`<div class="loan"><span class="logo" style="--c:${B.col}">${initials(B)}</span><div class="grow"><div class="nm">${tr('bank.bank_offers_amount',{bank:esc(B.name),amount:fmt$(o.amount)})}</div><div class="meta">${esc(B.blurb)} · ${tr('bank.offer_ends_in_n_d',{n:o.exp-S.day})}</div><div class="terms">${terms(o)}</div>${covList({covs:o.covs,start:S.day,base:{sub:S.links.filter(x=>x.sub).length}})}<div class="btns" style="margin-top:6px">${btn(tr('bank.take_the_money'),'takeLoan',{id:o.id},'pink')}${btn(tr('common.no_thanks'),'declineLoan',{id:o.id},'ghost sm')}</div></div></div>`;}
for(const o of S.loanOffers){const B=BANKS[o.bank];h+=`<div class="loan"><span class="logo" style="--c:${B.col}">${initials(B)}</span><div class="grow"><div class="nm">${tr('bank.bank_offers_amount',{bank:esc(B.name),amount:fmt$(o.amount)})}</div><div class="meta">${esc(B.blurb)} · ${tr('bank.offer_ends_in_n_d',{n:o.exp-S.day})}</div><div class="terms">${terms(o)}</div>${covList({covs:o.covs,start:S.day,base:{sub:S.links.filter(seaLink).length}})}<div class="btns" style="margin-top:6px">${btn(tr('bank.take_the_money'),'takeLoan',{id:o.id},'pink')}${btn(tr('common.no_thanks'),'declineLoan',{id:o.id},'ghost sm')}</div></div></div>`;}
h+=`<h3 style="font-size:18px;margin-top:14px">${tr('common.your_loans')}</h3>`;
if(!S.loans.length)h+=`<p class="empty">${tr('bank.debt_free_your_accountant_is')}</p>`;
for(const l of S.loans){const B=BANKS[l.bank];const cost=repayCost(l,B);

View file

@ -1,7 +1,7 @@
function openLinkModal(a,b){
{const nt=noTalk(a,b);if(nt){openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:24px">${tr('common.not_happening')}</h2><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div><p class="lead" style="margin-top:8px">${tr(nt)}</p>`);return;}}
if((cnCity(a)||cnCity(b))&&!cnOk()){openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:24px">${tr('link_modal.not_without_a_license')}</h2><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div><p class="lead" style="margin-top:8px">${tr('link_modal.building_into_mainland_china_needs_a',{city:CITY[cnCity(a)?a:b].name})}</p>`);return;}
let route='';UI.pending={a,b};const km=kmBetween(a,b),sub=isSub(a,b),pop=S.pops[b]?0:newPopCost(b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'&&l.kind!=='xp');
let route='';UI.pending={a,b};const km=kmBetween(a,b),sub=isSub(a,b),pop=S.pops[b]?0:newPopCost(b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'&&l.kind!=='xp'&&l.kind!=='sat');
if(!sib.length)UI.route='diverse';const border=cnCity(a)!==cnCity(b),jn=sib.length?routeJoin(a,b):null,ts=landTrenches(a,b),mult=(sib.length&&!(jn&&jn.k===(ts[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1);
if(border)route+=`<p class="lead" style="margin-top:8px">${tr('link_modal.cross_border_circuits_into_mainland')}</p>${a==='hkg'||b==='hkg'?`<div class="seg">${btn(tr('common.regular_crossing'),'cnPrem',{v:0},!UI.cnPrem?'pink':'ghost')}${btn(tr('link_modal.premium_crossing_60_3_loss'),'cnPrem',{v:1},UI.cnPrem?'pink':'ghost')}</div>`:`<p class="note">${tr('link_modal.premium_crossings_are_only_sold_in')}</p>`}`;
if(sib.length&&!(isSub(a,b)&&cablesFor(a,b).length)&&!(UI.via&&UI.via!=='land'&&cablesFor(a,b).some(c=>c.cid===UI.via))){route+=`<p class="lead" style="margin-top:8px">${trn('link_modal.you_already_have_n_link_here',sib.length,{list:sib.map(l=>capName(l)).join(', ')})}</p>

View file

@ -5,9 +5,9 @@
const LDASH=[[],[8,8],[2,7],[10,8],[4,6],[1,6],[6,5],[2,12],[14,5]];
// A tube is a group of links drawn as one line: its capacity, load and state, its base width, colour and dash.
function linkLook(grp,day){const l=grp[0],many=grp.length>1,up=many?grp.filter(x=>!linkDown(x)):null;
const 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',xp=l.kind==='xp',bld=df&&l.ready>day,cut=!bld&&!xp&&(many?!up.length:linkDown(l))&&!(df&&!(l.ch||[]).length),dark=df&&!bld&&!(l.ch||[]).length||xp&&linkDown(l),vx=l.kind==='vxc',idle=!cut&&!bld&&load<1e-3&&(many?up.length>0&&up.every(x=>x.standby):!!l.standby);
const 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',xp=l.kind==='xp',st=l.kind==='sat',bld=(df||st)&&l.ready>day,cut=!bld&&!xp&&(many?!up.length:linkDown(l))&&!(df&&!(l.ch||[]).length),dark=df&&!bld&&!(l.ch||[]).length||xp&&linkDown(l),vx=l.kind==='vxc'||st,idle=!cut&&!bld&&load<1e-3&&(many?up.length>0&&up.every(x=>x.standby):!!l.standby);
return {l,many,up,cap,load,u,df,bld,cut,dark,vx,idle,w0:vx||xp?2.2:(2.5+Math.max(...grp.map(tierW))*1.8+(many?Math.min(1.5,(grp.length-1)*0.5):0)),
col:bld?'#C9B27C':dark?'#5D6788':cut?'#FF4D5E':idle?'#9AA3BE':vx?FAB[l.prov].col:l.sub?(u>0.001?utilCol(u):'#7FD8EE'):utilCol(u),dash:cut?1:vx?2:xp?8:bld?3:idle?4:0,
col:bld?'#C9B27C':dark?'#5D6788':cut?'#FF4D5E':idle?'#9AA3BE':vx?(st?SAT_PROV[SATS[l.bird].p].col:FAB[l.prov].col):l.sub?(u>0.001?utilCol(u):'#7FD8EE'):utilCol(u),dash:cut?1:vx?2:xp?8:bld?3:idle?4:0,
pk:!cut&&load>0.01?clamp(Math.round(2+u*10),2,12):0};} // packets on the line: more as it fills
// The map's tubes as the picture needs them: the groups, their geometry and how each one looks. It changes with the
// links and with the day's routing (R), not with the camera, so it is kept until one of those changes.

View file

@ -3926,6 +3926,7 @@
"pie_traffic.via_dishes":"up at {up}, down at {down}",
"pitcairn.uk_grant_mo":"UK grant {mo}/mo",
"pitcairn.uk_grant_mo_once_islanders":"UK grant {mo}/mo once the islanders are online",
"pitcairn.uk_grant_needs_a_cable":"UK grant {mo}/mo needs a cable: rented satellite capacity does not count",
"pitcairn.uk_sky_grant_mo":"UK satellite grant {mo}/mo (fiber gets {full})",
"pni_all.additional_per_month":"Additional monthly cost",
"pni_all.all_at_port":"Peer all networks · {port}",
@ -4533,6 +4534,75 @@
"sales.w_last":"Last week {name} {list}.",
"sales.w_now":"This week {name} {list}.",
"sales.w_signed":{"one":"signed a customer ({rev}/mo)","other":"signed {n} customers ({rev}/mo)"},
"satellites.a_teleport_is_a_satellite_gateway":"A teleport is a satellite gateway: big dishes at this POP that rent capacity on other people’s satellites, to small islands and remote towns no cable reaches, or that hang on one cable and a prayer.",
"satellites.add_tracking_antennas_cost_mo":"MEO tracking antennas <small>{cost} + {mo}/mo</small>",
"satellites.being_commissioned":"Being commissioned",
"satellites.build_a_teleport_cost_mo":"Build a teleport <small>{cost} + {mo}/mo</small>",
"satellites.by_satellite":"By satellite",
"satellites.cancel_n_circuits_first":{"one":"Cancel its satellite circuit first.","other":"Cancel its {n} satellite circuits first."},
"satellites.choose":"Choose",
"satellites.circuit_ordered":{"one":"<b>{cap} on {bird} ordered.</b> {a} ⇄ {b} is being pointed and tested: up in {n} day.","other":"<b>{cap} on {bird} ordered.</b> {a} ⇄ {b} is being pointed and tested: up in {n} days."},
"satellites.close_the_teleport":"Close the teleport",
"satellites.costs_row":"Teleports and satellites",
"satellites.geo_dishes":"GEO dishes",
"satellites.geo_dishes_and_meo_tracking":"GEO dishes and MEO tracking antennas",
"satellites.geo_users_notice":"From 36,000 km up the round trip is about 600 ms: video calls and games stutter, and users count {p} of the service as bad.",
"satellites.grow_to":"Grow to {cap}",
"satellites.in_view_list":"In view: {list}.",
"satellites.it_waits_on_standby":"You already have a link between these two: the satellite waits on standby and carries traffic only when that link is down.",
"satellites.its_blurb":"Old-school C-band and Ku-band beams that cover a whole ocean. Reliable, everywhere, and priced like it.",
"satellites.kac_blurb":"Ka-band spot beams over the western Pacific: the cheapest Gbps in orbit, if your island is under a beam.",
"satellites.meo_comes_at_level":"The MEO ring (about 130 ms round trip) comes at level {lv}.",
"satellites.meo_ring_misses_city":"The MEO ring does not see {city}: it covers {lat}° either side of the equator.",
"satellites.meo_users_notice":"Much closer to the ground, about 130 ms round trip: users barely notice ({p} of the service counts as bad).",
"satellites.more_islands_and_towns":"More islands and towns in view",
"satellites.ms_one_way_rtt":"{ms} ms one way, {rtt} ms round trip",
"satellites.ms_round_trip":"{ms} ms round trip",
"satellites.n_birds_see_both":{"one":"{n} satellite sees both","other":"{n} satellites see both"},
"satellites.n_circuits_go_on_standby":{"one":"Your satellite circuit between {a} and {b} goes on standby beside the new link: it carries traffic only when that link is down.","other":"Your {n} satellite circuits between {a} and {b} go on standby beside the new link: they carry traffic only when that link is down."},
"satellites.n_places_in_reach":{"one":"{n} island or remote town in reach at your level.","other":"{n} islands and remote towns in reach at your level."},
"satellites.needs_tracking_antennas":"The MEO ring needs tracking antennas at your teleport in {city}.",
"satellites.new_pop_cost":"new POP {cost}",
"satellites.no_bird_sees_both":"No satellite on sale sees both {a} and {b}.",
"satellites.no_bird_sees_this_city":"No satellite on sale sees this city.",
"satellites.no_cable_needed_a_pop_here":"No cable needed: a satellite circuit from one of your teleports brings a POP in {city} online.",
"satellites.no_pop_in_city":"You have no POP in {city}.",
"satellites.no_pop_there_yet":"No POP in {city} yet: this builds one too ({cost}).",
"satellites.no_such_circuit":"No such satellite circuit.",
"satellites.no_teleport_in_city":"You have no teleport in {city}.",
"satellites.no_teleport_reaches_city":"None of your teleports can reach {city}. Build one at a POP whose satellites see it.",
"satellites.not_remote":"{city} is too big a market for satellite capacity: it serves small islands and remote towns.",
"satellites.nothing_in_view_from_here":"No island or remote town is in view from here.",
"satellites.on_standby_beside_your_link":"It waits on standby beside your link between the two and carries traffic only when that link is down.",
"satellites.orbit_unlocks_at_level":"{orb} satellites unlock at level {lv}.",
"satellites.out_of_footprint":"{bird} does not see both {a} and {b}.",
"satellites.pointing_dishes_and_testing":"Pointing dishes and testing",
"satellites.radio_path":"Radio path, up and down",
"satellites.reachable_from_your_teleports":"Your teleports can reach {city} by satellite:",
"satellites.really_close_it":"Really close it?",
"satellites.rent":"Rent",
"satellites.rent_satellite_capacity":"Rent satellite capacity",
"satellites.satellite_capacity":"Satellite capacity",
"satellites.satellites":"Satellites",
"satellites.sea_americas":"Americas",
"satellites.sea_atlantic":"Atlantic",
"satellites.sea_indian":"Indian Ocean",
"satellites.sea_pacific":"Pacific",
"satellites.sea_tropics":"within 50° of the equator",
"satellites.sea_west_pacific":"Western Pacific",
"satellites.sesa_blurb":"A ring of satellites 8,000 km up over the equator, for the other three billion. Open sesame: about 130 ms round trip.",
"satellites.shrink_to":"Shrink to {cap}",
"satellites.teleport":"Teleport",
"satellites.teleport_closed":"The teleport in {city} is closed.",
"satellites.teleport_up_in_city":"<b>Teleport up in {city}.</b> Big dishes on the roof, pointed at the sky: rent capacity from it to the islands in view.",
"satellites.teleports_unlock_at_level":"Teleports unlock at level {lv}.",
"satellites.tracking_antennas_up":"<b>Tracking antennas up in {city}.</b> They follow the MEO ring across the sky.",
"satellites.up_in_n_days":{"one":"up in {n} day","other":"up in {n} days"},
"satellites.users_notice_geo_meo":"Users notice the lag: broadband over GEO counts as half the service, over MEO almost all of it. A cable always beats it, so your routers only send traffic up when there is no other way.",
"satellites.users_ride_a_satellite":"users ride a satellite",
"satellites.via_bird":"via {bird}",
"satellites.who_a_satellite_serves":"Satellites serve small islands and remote towns that the same satellite sees as your teleport. Pick where to.",
"satellites.your_pops_in_view":"Your POPs in view",
"save.cash_in_the_bank":"{cash} in the bank",
"save.import_failed_err":"<b>Import failed.</b><br>{err}",
"save.load_name":"Load {name}?",

View file

@ -32,7 +32,7 @@ const EXCEPTIONS = {
W3: {
ivc: 'Invercargill waits for its AI campus; nobody sells transit there yet',
jub: 'Nobody sells transit in Juba: MTN and Zain haul it in from abroad',
pcn: 'Pitcairn: no cable, no network, land your own (#124), or reach it with a pie dish (backhaul through orbit)',
pcn: 'Pitcairn: no cable, no network, land your own (#124), reach it with a pie dish (backhaul through orbit), or rent a satellite circuit from a teleport (#83)',
prr: 'Prince Rupert is a remote town with no carrier in it',
smr: 'San Marino buys its transit from Italian carriers in Bologna and Rimini; nobody sells it in the town',
sre: "Sucre has no exchange or carrier facility: Bolivia's transit is bought in La Paz",
@ -118,6 +118,8 @@ const REAL_NAMES = [
'ACMA', 'ASEAN Explorer', 'ASEAN Protector', 'ASEAN Restorer', 'Cable Innovator', 'Cable Retriever', 'Global Marine', 'Léon Thévenin', 'MECMA', 'Orange Marine', 'Pierre de Fermat', 'René Descartes', 'SEAIOCMA', 'Sophie Germain', 'Sovereign', 'Wave Sentinel', 'Yokohama Zone',
// rockets and satellite networks (Pie in the Sky)
'Blue Origin', 'Falcon 9', 'Falcon Heavy', 'Iridium', 'Kuiper', 'OneWeb', 'Project Kuiper', 'SpaceX', 'Starship', 'Starlink',
// satellite operators and their birds (teleports, #83)
'Galaxy 19', 'Intelsat', 'Intelsat 18', 'Intelsat 20', 'Intelsat 37e', 'Intelsat Galaxy 19', 'Kacific', 'Kacific-1', 'O3b', 'O3b mPOWER', 'SES',
// vendors
'Arista', 'Brocade', 'Ciena', 'Cisco', 'Extreme Networks', 'Huawei', 'Infinera', 'Juniper', 'MikroTik', 'Nokia',
];
@ -182,7 +184,7 @@ test('N2: names are puns: no network, cable, exchange, data center, router, opti
const norm = (s) => String(s).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[’`]/g, "'").replace(/\s+/g, ' ').trim();
const real = new Set(REAL_NAMES.map(norm));
const names = J(`[...NETS.map(n=>['network',n.name]),...CABLES.map(c=>['cable',c.name]),...XIX.map(x=>['exchange',x.name]),
...CITIES.flatMap(c=>[['exchange',c.ix],['data center',c.dc],['data center',c.dc2]]),...RG.map(r=>['router',r.n]),...Object.values(OPT).map(o=>['optic',o.n]),...Object.values(SEAT_ROUTES).flat().map(r=>['cable',r[2]]),...SHIPS.map(x=>['cable ship',x.n]),...LAY_SHIPS.map(n=>['cable ship',n]),...Object.values(SHIP_CLUBS).map(c=>['maintenance club',c.n]),...PIE_NAMES.map(n=>['rocket company',tr(n)]),...Object.values(ROCKETS).map(r=>['rocket',tr(r.n)]),...Object.values(CRUSTS).map(c=>['constellation',tr(c.n)])].filter(x=>x[1])`);
...CITIES.flatMap(c=>[['exchange',c.ix],['data center',c.dc],['data center',c.dc2]]),...RG.map(r=>['router',r.n]),...Object.values(OPT).map(o=>['optic',o.n]),...Object.values(SEAT_ROUTES).flat().map(r=>['cable',r[2]]),...SHIPS.map(x=>['cable ship',x.n]),...LAY_SHIPS.map(n=>['cable ship',n]),...Object.values(SHIP_CLUBS).map(c=>['maintenance club',c.n]),...PIE_NAMES.map(n=>['rocket company',tr(n)]),...Object.values(ROCKETS).map(r=>['rocket',tr(r.n)]),...Object.values(CRUSTS).map(c=>['constellation',tr(c.n)]),...Object.values(SAT_PROV).map(p=>['satellite operator',p.n]),...Object.values(SATS).map(b=>['satellite',b.n])].filter(x=>x[1])`);
fail('N2', names.filter(([, n]) => real.has(norm(n))).map(([k, n]) => `${k} “${n}” is a real name`), 'find a pun');
fail('N2', names.filter(([, n]) => /-ish\b/i.test(n)).map(([k, n]) => `${k} “${n}”`), 'no lazy -ish names: find a real pun, or keep the plain word');
});

View file

@ -228,6 +228,7 @@ test('a dry run prices every command that has a price, and changes nothing', ()
opsHire: { id: ev('Object.keys(INTERNS)[0]') }, opsNewPop: { city: 'nyc' }, pniAll: { net: 'cog', tier: 1 }, seatBuy: { n: 2 }, layShip: { id: df }, seaRush: { id: df },
utilityKit: { city: 'fra' }, utilityCaches: { city: 'fra' }, teDeploy: { script: 'spill at 85%' }, upLinkX: {},
pieRd: { k: 'reuse' }, pieAnt: { id: 'none' }, ip4Buy: { len: 24 }, ip4Lease: { len: 22 },
teleBuild: { city: 'fra' }, teleTrk: { city: 'fra' }, buySat: { a: 'fra', b: 'rek', bird: 'is37', g: 1 }, satSize: { id: wave, g: 2 },
};
const missing = quoted.filter((n) => !sample[n] && T('schema', { section: 'commands' })[n].args.some((a) => a.required));
assert.deepEqual(missing, [], 'every priced command with arguments has a sample here');

445
tests/satellites.test.js Normal file
View file

@ -0,0 +1,445 @@
// Teleports and rented satellite capacity (#83): a teleport at a POP rents GEO or MEO circuits to small islands and
// remote towns its birds see. A circuit is a link (kind 'sat'): its radio path is its km, so routers take a cable
// whenever there is one; its orbit's latency is what users notice; next to the island's only cable it waits on standby.
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { load } = require('./harness');
const { createSession, TOOLS } = require('../scripts/lib/mcp-game');
const SAVE = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8');
// Level 3, Change Freeze (nothing breaks, lead times quick), plenty of cash.
const BASE = "ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;S.lvl=3;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');";
// Sydney (transit, broadband) and Nuku'alofa (broadband, no transit of its own).
const ISLE = "ACT.buildPop({city:'syd'});ACT.launchBB({city:'syd'});ACT.buyTransit({city:'syd',net:'cog',tier:1});ACT.buildPop({city:'tbu'});ACT.launchBB({city:'tbu'});";
function game(t, setup = '') {
const h = load();
t.after(() => h.dom.window.close());
h.ev(BASE + setup);
return h;
}
const J = (ev, s) => JSON.parse(ev(`JSON.stringify(${s})`));
const sat = "S.links.find(l=>l.kind==='sat')";
// Past the day a circuit is commissioned.
const ready = `S.day=${sat}.ready;compute()`;
test('the footprint: which birds see where, who a satellite serves, and how long the trip is', (t) => {
const { ev, errors } = game(t);
const sees = J(ev, "[['is18','syd'],['is18','tbu'],['is18','mia'],['is37','mia'],['is37','sju'],['kac1','tbu'],['kac1','hnl'],['is20','mru'],['o3b','tbu'],['o3b','yfb']].map(([b,c])=>CITY[c]?satSees(b,c):null)");
assert.deepEqual(sees, [true, true, false, true, true, true, false, true, true, false], 'the Pacific bird does not see Miami, Kacophony’s spot beams miss Hawaii, the MEO ring misses Iqaluit');
// Both ends of a MEO circuit must see one satellite at a time.
assert.ok(ev("kmBetween('sju','hnl')") > ev('SAT_ORB.meo.km') && !ev("satPairOk('o3b','sju','hnl')"), 'San Juan to Honolulu is too far apart for one MEO satellite');
assert.equal(ev("satPairOk('is18','syd','tbu')"), true);
assert.deepEqual(J(ev, "['tbu','pcn','asp','sju','lon','syd','mel'].map(satRemote)"), [true, true, true, true, false, false, false], 'small islands and remote towns, never a big city');
const geo = ev("satRtt('is18','syd','tbu')"), meo = ev("satRtt('o3b','syd','tbu')");
assert.ok(geo > 520 && geo < 650, 'GEO: about 600 ms round trip, got ' + geo);
assert.ok(meo > 110 && meo < 160, 'MEO: about 130 ms round trip, got ' + meo);
assert.ok(ev("satKm('is18','syd','tbu')") > 2 * 35786, 'the radio path goes up to the GEO belt and back down');
// A MEO satellite halfway between Winnipeg and Vaduz is below both horizons: within 7,500 km and 50 degrees is not enough.
assert.ok(ev("kmBetween('ywg','vdz')") <= ev('SAT_ORB.meo.km') && ev("satSees('o3b','ywg')&&satSees('o3b','vdz')"));
assert.equal(ev("satPairOk('o3b','ywg','vdz')"), false, 'Winnipeg to Vaduz: no MEO satellite sees both');
assert.ok(ev("satElev(satArc(0,satLon('o3b','ywg','vdz'),CITY.ywg.lat,CITY.ywg.lon),SAT_ORB.meo.h)") < ev('SAT_ORB.meo.el'));
assert.ok(ev("satPairOk('o3b','syd','tbu')") && ev("satElev(0,SAT_ORB.meo.h)") === 90, 'straight overhead is 90 degrees');
// Every MEO pair on sale clears the horizon at both ends, so its radio path never runs through the Earth.
const low = J(ev, "(()=>{const O=SAT_ORB.meo,out=[];for(const A of CITIES)for(const B of CITIES){if(A.id>=B.id||!satRemote(B.id)||!satPairOk('o3b',A.id,B.id))continue;const lon=satLon('o3b',A.id,B.id);for(const C of [A,B])if(satElev(satArc(0,lon,C.lat,C.lon),O.h)<O.el)out.push(A.id+'-'+B.id);}return out;})()");
assert.deepEqual(low, []);
// A bird over the Americas: inland North America and Mexico see a GEO satellite too.
assert.deepEqual(J(ev, "['chi','den','dal','mex','yeg','yfb'].map(c=>Object.keys(SATS).some(id=>SATS[id].orb==='geo'&&satSees(id,c)))"), [true, true, true, true, true, true]);
assert.deepEqual(errors, []);
});
test('a teleport and a GEO circuit: level, price, lead time, capacity, latency, the bill, resizing and cancelling', (t) => {
const { ev, errors } = game(t, ISLE);
ev("S.lvl=1;ACT.teleBuild({city:'syd'})");
assert.equal(ev("teleOf('syd')"), 0, 'teleports unlock at level 2');
ev('S.lvl=3');
let c0 = ev('S.cash');
ev("ACT.teleBuild({city:'syd'})");
assert.equal(ev("S.pops.syd.tele"), 1);
assert.equal(c0 - ev('S.cash'), ev('TPORT_COST'));
c0 = ev('S.cash');
ev("ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:2})");
const l = J(ev, sat);
assert.equal(l.bird, 'kac1');
assert.equal(l.g, 2);
assert.equal(l.sub, true, 'never a land route');
assert.equal(!!l.standby, false, 'alone between the two cities, it carries');
assert.equal(c0 - ev('S.cash'), ev("satMo('kac1',2)"), 'no build: the first month up front');
assert.equal(l.ready, ev('S.day+leadDays(SAT_ORB.geo.days)'));
ev('compute()');
assert.equal(ev(`linkDown(${sat})`), true, 'down while it is pointed and tested');
assert.equal(ev(`R.load[${sat}.id]||0`), 0);
ev(ready);
assert.equal(ev(`capOf(${sat})`), 2);
const ld = ev(`R.load[${sat}.id]`);
assert.ok(ld > 1 && ld <= 2 + 1e-9, 'the island’s traffic fills the circuit: ' + ld);
const ms = ev(`linkLat(${sat})`);
assert.ok(ms > 255 && ms < 310, 'one way over GEO: ' + ms);
assert.equal(ev('R.latF.tbu'), 0.5, 'broadband over GEO counts as half the service');
assert.ok(ev("sfOf(R,'tbu')") <= 0.5);
ev("UI.sel={type:'city',id:'tbu'};UI.tab='cust';renderAll()");
assert.match(ev("document.querySelector('#panel').textContent"), /users ride a satellite/, 'the island’s panel says why');
assert.equal(ev('R.cost.sat'), ev(`TPORT_MO+${sat}.mo`), 'the teleport and the rent have a row of their own');
assert.equal(ev("S.links.filter(l=>l.kind!=='sat').reduce((a,l)=>a+l.mo,0)"), ev('R.cost.links'), 'and are not in waves and fiber');
// Bigger pays its month up front; smaller just costs less from now on.
c0 = ev('S.cash');
ev(`ACT.satSize({id:${sat}.id,g:5})`);
assert.equal(c0 - ev('S.cash'), ev("satMo('kac1',5)"));
assert.equal(ev(`${sat}.mo`), ev("satMo('kac1',5)"));
c0 = ev('S.cash');
ev(`ACT.satSize({id:${sat}.id,g:1})`);
assert.equal(ev('S.cash'), c0);
assert.equal(ev(`${sat}.g`), 1);
ev(`ACT.satSize({id:${sat}.id,g:3})`);
assert.equal(ev(`${sat}.g`), 1, 'only the sizes on sale');
// Satellite capacity costs several times a subsea wave per Gbps, so a cable wins once there is one; the cheapest
// backup still fits inside what a small island's homes pay.
const wave = ev("waveMo(kmBetween('suv','tbu'),true,1)/LT[1].g");
for (const id of ['is18', 'kac1']) assert.ok(ev(`satMo('${id}',10)/10`) > 3 * wave, id + ' per Gbps against a wave');
assert.ok(ev("satMo('o3b',20)/20") > 3 * wave, 'MEO per Gbps against a wave');
assert.ok(ev("satMo('kac1',1)") <= ev("CITY.suv.P*EYE_RATE"), 'a 1G backup costs less than Suva’s homes pay');
// Cancelling asks twice.
ev(`ACT.rmLink({id:${sat}.id})`);
assert.ok(ev(`!!${sat}`), 'armed, not gone');
ev(`ACT.rmLink({id:${sat}.id})`);
assert.equal(ev(`!!${sat}`), false);
assert.deepEqual(errors, []);
});
test('MEO needs tracking antennas and a higher level, and users barely notice it', (t) => {
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});");
ev("ACT.buySat({a:'syd',b:'tbu',bird:'o3b',g:5})");
assert.equal(ev(`!!${sat}`), false, 'no tracking antennas yet');
assert.match(ev("satWhy('syd','tbu','o3b',5)"), /tracking antennas/);
ev("S.lvl=2;ACT.teleTrk({city:'syd'})");
assert.equal(ev("teleOf('syd')"), 1, 'MEO comes at level 3');
ev('S.lvl=3');
const c0 = ev('S.cash');
ev("ACT.teleTrk({city:'syd'})");
assert.equal(ev("teleOf('syd')"), 2);
assert.equal(c0 - ev('S.cash'), ev('TRK_COST'));
ev("ACT.buySat({a:'syd',b:'tbu',bird:'o3b',g:5})");
assert.equal(ev(`${sat}.bird`), 'o3b');
assert.equal(ev(`${sat}.ready`), ev('S.day+leadDays(SAT_ORB.meo.days)'));
ev(ready);
const ms = ev(`linkLat(${sat})`);
assert.ok(ms > 55 && ms < 80, 'one way over MEO: ' + ms);
assert.ok(Math.abs(ev('R.latF.tbu') - 0.92) < 1e-9, 'MEO costs users 8% of the service, GEO half');
assert.ok(ev("sfOf(R,'tbu')") >= 0.9, 'enough for broadband to keep growing');
assert.equal(ev('R.cost.sat'), ev(`TPORT_MO+TRK_MO+${sat}.mo`));
assert.deepEqual(errors, []);
});
test('orders outside a footprint, to a big city or without a teleport are refused, in words', (t) => {
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});ACT.buildPop({city:'mel'});ACT.buildPop({city:'sju'});");
const tries = [
["{a:'syd',b:'tbu',bird:'is37',g:1}", /does not see both/],
["{a:'syd',b:'sju',bird:'is18',g:1}", /does not see both/],
["{a:'syd',b:'mel',bird:'is18',g:1}", /too big a market/],
["{a:'tbu',b:'syd',bird:'is18',g:1}", /no teleport in Nuku/],
["{a:'syd',b:'tbu',bird:'is18',g:3}", /No such satellite circuit/],
["{a:'syd',b:'tbu',bird:'nope',g:1}", /No such satellite circuit/],
];
const c0 = ev('S.cash');
for (const [a, why] of tries) {
const o = JSON.parse(ev(`JSON.stringify(${a})`));
assert.match(ev(`satWhy(${JSON.stringify(o.a)},${JSON.stringify(o.b)},${JSON.stringify(o.bird)},${o.g})`), why, a);
ev(`ACT.buySat(${a})`);
}
assert.equal(ev("S.links.filter(l=>l.kind==='sat').length"), 0);
assert.equal(ev('S.cash'), c0, 'nothing charged');
assert.deepEqual(errors, []);
});
test('beside the island’s only cable, a satellite waits on standby and takes over when the cable is cut', (t) => {
const { ev, errors } = game(t, "ACT.buildPop({city:'suv'});ACT.launchBB({city:'suv'});ACT.buyTransit({city:'suv',net:" +
"NETS.find(n=>sellsAt(n,'suv')).id,tier:1});ACT.buildPop({city:'tbu'});ACT.launchBB({city:'tbu'});UI.pending={a:'suv',b:'tbu'};ACT.buildLink({tier:1});ACT.teleBuild({city:'suv'});");
const wave = "S.links.find(l=>l.kind==='wave')";
assert.equal(ev(`${wave}.cable`), 'tonga', 'the wave rides the only cable');
ev("ACT.buySat({a:'suv',b:'tbu',bird:'kac1',g:5})");
assert.equal(ev(`${sat}.standby`), true, 'next to the cable it goes on standby by itself');
ev(ready);
assert.equal(ev(`R.load[${sat}.id]`), 0, 'idle while the cable is up');
assert.ok(ev(`R.load[${wave}.id]`) > 1);
assert.equal(ev('R.latF.tbu'), undefined, 'nobody notices a satellite that carries nothing');
// The anchor drags across the cable: the satellite carries the island.
ev(`${wave}.cut=S.day+30;compute()`);
assert.ok(ev(`R.load[${sat}.id]`) > 1, 'the satellite takes over');
assert.ok(ev('R.citySrv.tbu') > 1);
assert.equal(ev('R.latF.tbu'), 0.5, 'at GEO’s latency');
// Without it, the island is dark.
ev(`S.links=S.links.filter(l=>l.kind!=='sat');compute()`);
assert.ok((ev('R.citySrv.tbu') || 0) < 1e-6, 'no satellite, no internet in Tonga');
assert.deepEqual(errors, []);
});
test('a cable laid beside a circuit puts it on standby; overflow and a shared load cost users their share', (t) => {
// The issue's own order: the satellite first, a cable later.
const { ev, errors } = game(t, "ACT.buildPop({city:'suv'});ACT.launchBB({city:'suv'});ACT.buyTransit({city:'suv',net:" +
"NETS.find(n=>sellsAt(n,'suv')).id,tier:1});ACT.buildPop({city:'tbu'});ACT.launchBB({city:'tbu'});ACT.teleBuild({city:'suv'});");
const wave = "S.links.find(l=>l.kind==='wave')";
ev("ACT.buySat({a:'suv',b:'tbu',bird:'kac1',g:10});" + ready);
assert.equal(!!ev(`${sat}.standby`), false, 'alone, it carries the island');
assert.equal(ev('R.latF.tbu'), 0.5);
ev("UI.pending={a:'suv',b:'tbu'};ACT.buildLink({tier:0})");
assert.equal(ev(`${sat}.standby`), true, 'the cable puts it on standby');
assert.match(ev("document.querySelector('#toasts').textContent"), /goes on standby beside the new link/);
ev('compute()');
assert.equal(ev(`R.load[${sat}.id]`), 0, 'idle while the cable has room');
assert.ok(ev(`R.load[${wave}.id]`) > 1);
assert.equal(ev('R.latF.tbu'), undefined, 'nobody notices');
assert.equal(ev("R.satU.tbu||0"), 0);
assert.doesNotMatch(ev("traceroute('tbu',{city:'suv'}).text"), /Kacophony/, 'the trace takes the cable');
// The cable loses three quarters of its light: the satellite takes the overflow, and users notice that share.
ev(`${wave}.loss={until:S.day+60,f:0.25};compute()`);
const cab = ev(`capOf(${wave})`), dem = ev('R.cityDem.tbu');
assert.ok(dem > cab, 'more than the cable carries');
const sl = ev(`R.load[${sat}.id]`), wl = ev(`R.load[${wave}.id]`), share = sl / (sl + wl);
assert.ok(Math.abs(wl - cab) < 1e-6 && sl > 0.5, 'the cable fills, the satellite takes the rest');
assert.ok(Math.abs(ev('R.latF.tbu') - (1 - 0.5 * share)) < 1e-6, 'GEO costs half the service of the share it carries: ' + ev('R.latF.tbu'));
assert.ok(Math.abs(ev('R.satU.tbu') / ev('R.citySrv.tbu') - share) < 1e-6);
ev("UI.sel={type:'city',id:'tbu'};UI.tab='cust';renderAll()");
assert.match(ev("document.querySelector('#panel').textContent"), /users ride a satellite/);
ev("UI.sel={type:'city',id:'suv'};renderAll()");
assert.doesNotMatch(ev("document.querySelector('#panel .facts').textContent"), /users ride a satellite/, 'not on the teleport’s own city');
// Taken off standby by hand, it shares the load by capacity, and users notice that share too.
ev(`ACT.setStandby({id:${sat}.id,on:false})`);
const s2 = ev(`R.load[${sat}.id]`) / (ev(`R.load[${sat}.id]`) + ev(`R.load[${wave}.id]`));
assert.ok(Math.abs(s2 - 10 / (10 + cab)) < 1e-6, 'split by capacity');
assert.ok(Math.abs(ev('R.latF.tbu') - (1 - 0.5 * s2)) < 1e-6);
assert.deepEqual(errors, []);
});
test('the teleport city’s own users get the satellite tag only when they ride it', (t) => {
// Honolulu: transit only in Los Angeles (a haul users notice), and a teleport carrying Papeete.
const { ev, errors } = game(t, "ACT.buildPop({city:'lax'});ACT.buyTransit({city:'lax',net:NETS.find(n=>sellsAt(n,'lax')).id,tier:1});ACT.buildPop({city:'hnl'});ACT.launchBB({city:'hnl'});" +
"UI.pending={a:'hnl',b:'lax'};ACT.buildLink({tier:1});ACT.teleBuild({city:'hnl'});ACT.buildPop({city:'ppt'});ACT.launchBB({city:'ppt'});ACT.buySat({a:'hnl',b:'ppt',bird:'is18',g:1});");
ev('S.day=Math.max(...S.links.map(l=>l.ready||0))+1;compute()');
assert.ok(ev(`R.load[${sat}.id]`) > 0.5, 'Papeete rides the satellite');
assert.ok(ev('R.latF.hnl') < 1, 'Honolulu’s users notice the haul to Los Angeles');
assert.equal(ev("R.satU.hnl||0"), 0, 'but none of their traffic goes up');
assert.equal(ev("satFact('hnl')"), '');
assert.match(ev("satFact('ppt')"), /users ride a satellite/);
assert.deepEqual(errors, []);
});
test('subsea counts leave satellites out: a no-subsea covenant and the cables overseas of Fibre to the Basement', (t) => {
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});");
ev("S.loanOffers.push({id:'wf1',bank:'wf',amount:200000,exp:S.day+25,covs:['nosub','logo','reach99'],apr:0.15,term:12,pay:Math.round(annuity(200000,0.15,12))});ACT.takeLoan({id:'wf1'})");
const L = "S.loans.find(l=>l.id==='wf1')";
assert.equal(ev(`COVS.nosub.ok(${L})`), true);
ev("ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:1})");
assert.equal(ev(`COVS.nosub.ok(${L})`), true, 'a satellite circuit is no subsea link');
const bal = ev(`${L}.bal`);
ev('for(let i=0;i<40;i++){S.day++;loanTick(S.day);}');
assert.ok(!(ev(`${L}.breach`) > 0), 'no breach');
assert.ok(ev(`${L}.bal`) <= bal, 'no penalty');
// A real subsea wave still breaks it.
ev("ACT.buildPop({city:'akl'});UI.pending={a:'syd',b:'akl'};ACT.buildLink({tier:1})");
assert.equal(ev(`COVS.nosub.ok(${L})`), false);
assert.deepEqual(errors, []);
});
test('two satellite circuits are not two cables overseas in Fibre to the Basement', (t) => {
const { ev, errors } = game(t);
ev("ACT.startScn({id:'fttb'});S.cash=1e8;S.lvl=2;S.nextFail=S.nextEvent=1e9;ACT.teleBuild({city:'syd'});ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:1});ACT.buySat({a:'syd',b:'nou',bird:'kac1',g:1});");
assert.equal(ev("S.links.filter(l=>l.kind==='sat').length"), 2);
ev('S.day=Math.max(...S.links.map(l=>l.ready||0))+1;compute()');
assert.equal(ev('auExits()'), 0, 'no cable leaves Australia');
assert.equal(J(ev, 'SCN_PROG.fttb()').find((r) => r.max === 2).v, 0, 'the progress row says so');
assert.deepEqual(errors, []);
});
test('a teleport is offered only where a satellite on sale sees the POP, and tracking antennas only under the MEO ring', (t) => {
const { ev, errors } = game(t, "S.lvl=2;ACT.buildPop({city:'hpa'});ACT.buildPop({city:'chi'});ACT.buildPop({city:'lon'});");
const panel = (c) => { ev(`UI.sel={type:'city',id:'${c}'};UI.tab='links';renderAll()`); return ev("document.querySelector('#panel').textContent"); };
const disabled = (c) => ev(`(b=>!!b&&b.disabled)(document.querySelector('#panel [data-act="teleBuild"]'))`);
// Haparanda, by the Arctic Circle: nothing on sale sees it, and the panel says so before any money moves.
assert.match(panel('hpa'), /No satellite on sale sees this city/);
assert.equal(disabled('hpa'), true);
const c0 = ev('S.cash');
ev("ACT.teleBuild({city:'hpa'})");
assert.equal(ev("teleOf('hpa')"), 0);
assert.equal(ev('S.cash'), c0, 'nothing charged');
assert.match(ev("teleWhy('hpa')"), /No satellite/);
// Chicago sees the bird over the Americas, and the panel says what is in reach before the build.
assert.match(panel('chi'), /In view: Intelsplat 19/);
assert.match(ev("document.querySelector('#panel').textContent"), /in reach at your level/);
assert.equal(disabled('chi'), false);
ev("ACT.teleBuild({city:'chi'})");
assert.equal(ev("teleOf('chi')"), 1);
// London is north of the MEO ring: no tracking antennas there, at any level.
ev("S.lvl=3;ACT.teleBuild({city:'lon'})");
assert.equal(ev("teleOf('lon')"), 1);
assert.ok(!J(ev, "(()=>{UI.sel={type:'city',id:'lon'};UI.tab='links';renderAll();return [...document.querySelectorAll('#panel [data-act]')].map(b=>b.dataset.act);})()").includes('teleTrk'));
const c1 = ev('S.cash');
ev("ACT.teleTrk({city:'lon'})");
assert.equal(ev("teleOf('lon')"), 1);
assert.equal(ev('S.cash'), c1);
assert.match(ev("trkWhy('lon')"), /does not see London/);
assert.equal(ev("trkWhy('chi')"), '', 'Chicago is under the ring');
assert.deepEqual(errors, []);
});
test('the order sheet prices a new POP with your POP standard, as the list before it does', (t) => {
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});S.pops.syd.rgen=2;ACT.popStdSet({city:'syd'});");
const std = ev('newPopCost("pcn")');
assert.ok(std > ev('popCost("pcn")'), 'the standard adds routers');
ev("ACT.satOpen({a:'syd'})");
assert.ok(ev("document.querySelector('#modalCard').textContent").includes(ev(`fmt$(${std})`)));
ev("ACT.satOpen({a:'syd',b:'pcn'})");
assert.ok(ev("document.querySelector('#modalCard').textContent").includes(ev(`fmt$(${std})`)), 'the same price one tap later');
assert.deepEqual(errors, []);
});
test('MCP: dry runs for satellites quote what the game then does', () => {
const s = createSession(), T = (n, a = {}) => TOOLS.find((x) => x.name === n).run(s, a), ev = (x) => s.game.ev(x);
T('new_game', { city: 'syd', preset: 'sandbox', seed: 7, name: 'Probe' });
ev('S.lvl=Math.max(S.lvl,3);S.cash=1e9');
assert.deepEqual(T('act', { action: 'teleBuild', args: { city: 'syd' }, dryRun: true }).quote.blocked, []);
T('act', { action: 'teleBuild', args: { city: 'syd' } });
assert.deepEqual(T('act', { action: 'teleTrk', args: { city: 'syd' }, dryRun: true }).quote.blocked, [], 'Sydney is under the MEO ring');
assert.match(T('act', { action: 'teleTrk', args: { city: 'mel' }, dryRun: true }).quote.blocked.join(' '), /no teleport in Melbourne/);
T('act', { action: 'buySat', args: { a: 'syd', b: 'asp', bird: 'is18', g: 1 } });
const id = ev("S.links.find(l=>l.kind==='sat').id");
// A wave beside the circuit: no diversity premium, in the quote as in the bill.
const q = T('act', { action: 'buildLink', args: { a: 'syd', b: 'asp', tier: 1 }, dryRun: true }).quote;
const c0 = ev('S.cash');
T('act', { action: 'buildLink', args: { a: 'syd', b: 'asp', tier: 1 } });
assert.equal(q.setup, c0 - ev('S.cash'), 'quote equals charge');
assert.equal(ev(`S.links.find(l=>l.id==='${id}').standby`), true);
// Resizing: only sizes the bird sells, and not the one it has.
for (const g of [20, 1]) {
const r = T('act', { action: 'satSize', args: { id, g }, dryRun: true }).quote;
assert.match(r.blocked.join(' '), /No such satellite circuit/, 'g ' + g);
}
const up = T('act', { action: 'satSize', args: { id, g: 5 }, dryRun: true }).quote;
assert.deepEqual(up.blocked, []);
const c1 = ev('S.cash');
T('act', { action: 'satSize', args: { id, g: 5 } });
assert.equal(up.setup, c1 - ev('S.cash'));
assert.deepEqual(s.errors(), []);
});
test('a satellite elsewhere is the long way round: routers use the cables and fall back to it only when cut', (t) => {
const { ev, errors } = game(t, ISLE + "ACT.buildPop({city:'suv'});UI.pending={a:'syd',b:'suv'};ACT.buildLink({tier:1});UI.pending={a:'suv',b:'tbu'};ACT.buildLink({tier:1});ACT.teleBuild({city:'syd'});");
ev("ACT.buySat({a:'syd',b:'tbu',bird:'is18',g:5})");
assert.equal(!!ev(`${sat}.standby`), false, 'no link between Sydney and Tonga: not on standby');
ev(ready);
assert.ok(ev(`${sat}.km`) > 10 * ev("kmBetween('syd','tbu')"), 'its metric is the radio path');
assert.equal(ev(`R.load[${sat}.id]||0`), 0, 'Tonga goes to Sydney over the cables, not the satellite');
ev("S.links.find(l=>l.kind==='wave'&&(l.a==='tbu'||l.b==='tbu')).cut=S.day+30;compute()");
assert.ok(ev(`R.load[${sat}.id]`) > 1, 'with the Tonga cable cut, the satellite carries it');
// Nobody digs up a satellite: cuts land on the cables only.
ev("S.links.forEach(l=>l.cut=0);S.inc=[];for(let i=0;i<12;i++){fireFailure('cut');for(const l of S.links)if(l.kind!=='sat')l.cut=0;S.inc=[];}");
assert.equal(ev(`${sat}.cut`), 0);
// The traceroute names the bird.
ev("S.links.find(l=>l.kind==='wave'&&(l.a==='tbu'||l.b==='tbu')).cut=S.day+30;compute()");
assert.match(ev("traceroute('tbu',{city:'syd'}).text"), /via Intelsplat 18/);
assert.deepEqual(errors, []);
});
test('Pitcairn by satellite: a POP comes with the circuit, but GEO is not good enough for the UK grant', (t) => {
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});");
assert.equal(ev("!!S.pops.pcn"), false);
const c0 = ev('S.cash');
ev("ACT.buySat({a:'syd',b:'pcn',bird:'is18',g:1})");
assert.ok(ev('!!S.pops.pcn'), 'the order builds the POP');
assert.equal(c0 - ev('S.cash'), ev("satMo('is18',1)+popCost('pcn')"));
ev("ACT.launchBB({city:'pcn'});" + ready);
assert.ok(ev('R.citySrv.pcn') > 0, 'the islanders are online');
assert.ok(ev("sfOf(R,'pcn')") <= 0.5 + 1e-9);
assert.equal(ev('grantOn(R)'), false);
assert.equal(ev('R.rev.grant'), 0);
assert.deepEqual(errors, []);
});
test('Pitcairn over MEO serves the islanders well, but the UK pays its fiber grant only for a cable', (t) => {
const { ev, errors } = game(t, "ACT.buildPop({city:'akl'});ACT.launchBB({city:'akl'});ACT.buyTransit({city:'akl',net:NETS.find(n=>sellsAt(n,'akl')).id,tier:1});ACT.teleBuild({city:'akl'});ACT.teleTrk({city:'akl'});");
assert.equal(ev("teleOf('akl')"), 2);
ev("ACT.buySat({a:'akl',b:'pcn',bird:'o3b',g:2});ACT.launchBB({city:'pcn'});" + ready);
assert.ok(ev('R.citySrv.pcn') > 0, 'the islanders are online');
assert.ok(ev("sfOf(R,'pcn')") >= 0.9, 'MEO serves them nearly as well as fiber');
assert.ok(Math.abs(ev("satShare(R,'pcn')") - 1) < 1e-9, 'all of it over the satellite');
assert.equal(ev('grantOn(R)'), false, 'no fiber grant for a satellite');
assert.equal(ev('R.rev.grant'), 0);
assert.match(ev("grantFact('pcn')"), /needs a cable/);
assert.deepEqual(errors, []);
});
test('saves: circuits survive a round trip, broken ones are dropped, and old saves load as they were', (t) => {
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});S.pops.syd.tele=2;ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:2});ACT.buySat({a:'syd',b:'tbu',bird:'o3b',g:5});");
const before = J(ev, "S.links.filter(l=>l.kind==='sat')");
ev('S=migrate(JSON.parse(JSON.stringify(S)));compute()');
assert.deepEqual(J(ev, "S.links.filter(l=>l.kind==='sat')"), before, 'kind, bird, size and dates kept');
// Garbage in: an unknown bird, an odd size, a MEO circuit on a GEO-only teleport, a teleport that is not 1 or 2.
ev("S.links.push({id:'x1',a:'syd',b:'tbu',kind:'sat',bird:'nope',g:1,km:1,mo:1,cut:0});S.links.find(l=>l.bird==='kac1').g=7;S.links.find(l=>l.bird==='kac1').km=3;S.pops.tbu.tele='big'");
ev('S=migrate(JSON.parse(JSON.stringify(S)))');
assert.equal(ev("S.links.some(l=>l.id==='x1')"), false, 'an unknown bird is dropped');
assert.equal(ev("S.links.find(l=>l.bird==='kac1').g"), 5, 'an odd size becomes the largest size on sale under it');
assert.equal(ev("S.links.find(l=>l.bird==='kac1').km"), ev("satKm('kac1','syd','tbu')"), 'the radio path is the physics, not the save');
assert.equal(ev("'tele' in S.pops.tbu"), false);
// A circuit's order day from a save: a number no later than today, so its commissioning bar is a real width.
ev("(k=>{k.day='junk';k.ready=S.day+5;})(S.links.find(l=>l.bird==='kac1'));S=migrate(JSON.parse(JSON.stringify(S)))");
assert.equal(ev("S.links.find(l=>l.bird==='kac1').day"), ev('S.day'));
ev("S.links.find(l=>l.bird==='kac1').day=S.day+40;S=migrate(JSON.parse(JSON.stringify(S)))");
assert.equal(ev("S.links.find(l=>l.bird==='kac1').day"), ev('S.day'), 'not in the future');
ev("delete S.links.find(l=>l.bird==='kac1').day;S=migrate(JSON.parse(JSON.stringify(S)));compute()");
assert.doesNotMatch(ev("satPanel(S.links.find(l=>l.bird==='kac1'))"), /NaN/);
ev("S.pops.syd.tele=1;S=migrate(JSON.parse(JSON.stringify(S)))");
assert.equal(ev("S.links.some(l=>l.bird==='o3b')"), false, 'a MEO circuit needs tracking antennas at its teleport');
ev("delete S.pops.syd.tele;S=migrate(JSON.parse(JSON.stringify(S)))");
assert.equal(ev("S.links.filter(l=>l.kind==='sat').length"), 0, 'no teleport, no circuits');
// A save from before satellites: nothing about it changes, not even a row in the bill.
ev("S=migrate(JSON.parse(" + JSON.stringify(SAVE) + "));UI.started=true;UI.pitched=true;UI.speed=0;closeModal();compute()");
assert.equal(ev("S.links.some(l=>l.kind==='sat')||Object.values(S.pops).some(p=>'tele' in p)"), false);
assert.equal(ev("'sat' in R.cost"), false);
assert.ok(ev('R.served') > 0);
assert.deepEqual(errors, []);
});
test('closing: a teleport with circuits stays open; closing the island or the teleport’s POP takes the circuit along', (t) => {
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:1});");
ev("ACT.teleRm({city:'syd'});ACT.teleRm({city:'syd'})");
assert.equal(ev("teleOf('syd')"), 1, 'not while a circuit starts there');
ev("decommission(['tbu'])");
assert.equal(ev(`!!${sat}`), false, 'the island’s POP takes its circuit along');
ev("ACT.teleRm({city:'syd'})");
assert.equal(ev("teleOf('syd')"), 1, 'the first tap only arms it');
ev("ACT.teleRm({city:'syd'})");
assert.equal(ev("teleOf('syd')"), 0);
ev("ACT.teleBuild({city:'syd'});ACT.buySat({a:'syd',b:'pcn',bird:'is18',g:1});decommission(['syd'])");
assert.equal(ev("S.links.some(l=>l.kind==='sat')"), false, 'so does the teleport’s');
assert.deepEqual(errors, []);
});
test('on a phone: the teleport section, the order sheet, a circuit’s panel and the map, at 360 px', (t) => {
const { ev, dom, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});");
ev('window.innerWidth=360;window.innerHeight=740;window.dispatchEvent(new window.Event("resize"))');
assert.equal(ev('isPhone()'), true);
const text = (sel) => ev(`(document.querySelector('${sel}')||{}).textContent||''`);
const acts = (sel) => J(ev, `[...document.querySelectorAll('${sel} [data-act]')].map(b=>b.dataset.act)`);
ev("UI.sel={type:'city',id:'syd'};UI.tab='links';renderAll()");
assert.match(text('#panel'), /Satellites/);
assert.ok(acts('#panel').includes('satOpen'));
// A city without a POP that the teleport reaches.
ev("UI.sel={type:'city',id:'apw'};renderAll()");
assert.match(text('#panel'), /By satellite/);
ev("ACT.satOpen({a:'syd'})");
assert.ok(acts('#modalCard').filter((a) => a === 'satOpen').length >= 2, 'a choice of destinations');
ev("ACT.satOpen({a:'syd',b:'tbu'})");
assert.ok(acts('#modalCard').filter((a) => a === 'buySat').length >= 8, 'every bird that sees both, every size');
assert.equal(ev('document.getElementById("modal").hidden'), false);
ev("ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:2});" + ready + ';renderAll()');
assert.match(text('#panel'), /round trip/);
assert.ok(acts('#panel').includes('satSize') && acts('#panel').includes('rmLink'));
for (const s of ['#panel', '#modalCard', '#toasts']) assert.doesNotMatch(text(s), /satellites\.|undefined|NaN/, s);
// How the tube looks on the map: dashed like a virtual circuit, in the operator's colour; then a frame is drawn.
const look = J(ev, `(()=>{const L=linkLook([${sat}],S.day);return {dash:L.dash,col:L.col,w:L.w0};})()`);
assert.equal(look.dash, 2);
assert.equal(look.col, ev("SAT_PROV.kac.col"));
ev('draw(performance.now())');
assert.deepEqual(errors, []);
assert.equal(dom.window.document.querySelectorAll('#panel').length, 1);
});