diff --git a/CHANGELOG.md b/CHANGELOG.md index e1dc2b2..73bcf21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- The NOC dashboard has a new tab listing every city where you have no POP yet, with its eyeballs, exchange and price. Sort it, filter by region, and jump to a city to build there. - Sweden gets Gothenburg, Malmö and Haparanda (#206). Gothenburg sits between Oslo and Copenhagen with its own exchange, Malmö faces Copenhagen across the Øresund, and Haparanda on the Finnish border is where the fibre crosses over land to Finland, with no exchange yet for you to found one. A Nordic fibre carrier sells transit along that route from Berlin to the border, and Swedish home networks reach the new cities. - The NOC charts have tooltips, on the dashboard and on the wallboard in the NOC window: hover (or touch) a chart to see every series on that day, with a total. Click an entry in the legend to hide or show that series, and the scale follows what is left. The "how it arrives" bars on the Traffic tab show the same kind of tooltip, and its legend picks which ways in (caches, PNIs, IX peering, transit) the table counts. - Bilbao joins the map, where the transatlantic cables really come ashore: Marea Carey, Grace Hopscotch and Sol Survivor now land there instead of Madrid. It has no exchange of its own, so traffic heads inland to Madrid, and Drizzle Electric, Tangerine Telecom and the big carriers sell transit there. A link you already run on the old Madrid landings keeps working as a plain subsea link, and the Mid-Atlantic Accent scenario now goes Azores, Bilbao, Madrid, and Marea Carey now leaves the American coast at Virginia Beach instead of crossing the northeast to New Jersey. Columbus III-and-a-half now comes ashore near Cádiz, where it really landed, on its way to Madrid. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index f067aa0..de92159 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -39,7 +39,7 @@ hoisted across files, and top-level statements run in path order. Find code by n | `90-actions/` | The `ACT` map, one file per area (`const ACT` in `10-interface.js`, `Object.assign(ACT,…)` in the rest), and their helpers | | `91-save.js`, `92-audio.js` | Save, export and import; sound effects | | `93-ui/` | DOM helpers (`$`, `btn`, `morph`), the phone tab bar, install pitch, HUD, left panel, city and link panels, decommissioning | -| `94-dashboard/` | Scenario and level progress, where to meet a network, customers and connections overviews, lease swaps, the NOC dashboard and its own window for a second display (`90-noc-window.js`: this page at `?noc=`, a read-only copy of `S` and `R` over a BroadcastChannel, clicks sent back to the game; `91-noc-wall.js`: its wallboard), the bank, hints | +| `94-dashboard/` | Scenario and level progress, where to meet a network, customers and connections overviews, cities with no POP yet, lease swaps, the NOC dashboard and its own window for a second display (`90-noc-window.js`: this page at `?noc=`, a read-only copy of `S` and `R` over a BroadcastChannel, clicks sent back to the game; `91-noc-wall.js`: its wallboard), the bank, hints | | `95-modals/` | Toasts, notifications, modals, title screen, what's new, help, the link and own-cable modals | | `96-map/` | The canvas: resize, land and clouds, settings, level of detail, link geometry, `draw()`, the world layer, cities, input and click delegation | | `99-loop.js` | `frame()` and `boot()` | diff --git a/scripts/lib/route-fuzz.js b/scripts/lib/route-fuzz.js index b5b5eb2..ca90eb5 100644 --- a/scripts/lib/route-fuzz.js +++ b/scripts/lib/route-fuzz.js @@ -56,7 +56,7 @@ const LEFT = ['nets', 'noc', 'deals', 'goals']; const PRESETS = ['freeze', 'oncall', 'bgp']; // How often a button is pressed against the others on screen: what changes the network often, looking around rarely. const BUILD = /^(buy\w*|pni\w*All|pni|peer|peerAll|unpeer|cache|cacheSite|rmCache|buildLink|buildPop|launchBB|accept|decline|dropBiz|takeLoan|repayLoan|lag[TPI]x?|setPref|setCarry|setStandby|setMetric|togglePrem|cleanPipe|sacrif|rs|foundIx|myIxUp|addRouter|rmRouter|upRouter|addSite|rmSite|siteSet|decomToggle|rmLink|upLink|addParallel|cancel\w*|upVxc|buyNni|rmNni|buildScrub|scrubUp|rmScrub|addGen|regen|addCh|rmCh|addPair|upSys|spares|layShip|crews|fixInc|seaPackage|subUpgrade|orderCable|orderDf|ownCab|opsHire|opsToggle|opsParam|opsCap|opsPop|opsTpl|opsNewPop|popStdSet|coreSet|teRecipe|dkOptOut|dkStay|utility\w*|listFiber|unlistFiber|leaseSwap|custGo|confGo|confSponsor|seatBuy|charter|cnPrem|applyCn|ad|ddosAuto|pz(Pop|RmPop|Link|AddPar|Tier|RmLink|RtAdd|RtRm|RtModel|Route|Via|Div)|setRoute|route|via|metricSet)$/; -const UIACT = /^(tab|dashTab|leftTab|\w*Sort|\w*Filter|pniGrp|trace\w*|focusCity|findGo|selLink|dashLink|logAll|tailTog|listMore|netFocus|netFilter|meetGo|phoneTab|dashClose|connF|connCity|connNet|connFor|custF|custCity|opsOpen|decomOpen|linkCheck)$/; +const UIACT = /^(tab|dashTab|leftTab|\w*Sort|\w*Filter|pniGrp|trace\w*|focusCity|findGo|selLink|dashLink|logAll|tailTog|listMore|netFocus|netFilter|meetGo|phoneTab|dashClose|connF|connCity|connNet|connFor|custF|custCity|popGo|popsReg|opsOpen|decomOpen|linkCheck)$/; const DW = { launchBB: 4, accept: 4, buyTransit: 3, pni: 3, buyIx: 3, setPref: 4, cache: 2, peerAll: 2, setCarry: 2, takeLoan: 2 }; const weight = (b) => (BUILD.test(b.act) ? 8 : UIACT.test(b.act) ? 0.3 : 1); diff --git a/site/i18n/de.js b/site/i18n/de.js index 159a8d4..8858e6f 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -4148,6 +4148,16 @@ "tutorial.your_customers_want_the_whole":"Deine Kunden wollen das ganze Internet. Öffne den Tab Transit und kauf einen Port bei einem Carrier.", "tutorial.your_router_is_live_press_launch":"Dein Router ist live. Drück auf „Breitband starten“, um den Leuten in deiner Stadt Internet zu verkaufen.", "ui.n_d_left":"noch {n} T.", +"unbuilt_pops.all_regions":"Alle Regionen", +"unbuilt_pops.cities_without_a_pop_n":"Städte ohne POP ({n})", +"unbuilt_pops.cost_then_mo":"{cost}, dann {mo}/Monat", +"unbuilt_pops.every_city_where_you_could_still":"Jede Stadt, in der du noch einen POP eröffnen kannst. Öffne eine, um zu sehen, was sie bietet, und dort zu bauen.", +"unbuilt_pops.n_more_city":{"one":"{n} weitere Stadt","other":"{n} weitere Städte"}, +"unbuilt_pops.needs_a_license_first":"Braucht zuerst eine Lizenz", +"unbuilt_pops.no_pop_yet":"Noch kein POP", +"unbuilt_pops.nothing_left_to_build_in_this":"In dieser Region gibt es nichts mehr zu bauen.", +"unbuilt_pops.region":"Region", +"unbuilt_pops.you_have_a_pop_in_every":"Du hast in jeder Stadt auf der Karte einen POP. Die Karte braucht wohl mehr Städte.", "utilities.apply_kit":"Redundanz-Kit anwenden", "utilities.cache_moves":"Zu verschiebende Cache-Boxen: {n} (je Anbieter ausgeglichen)", "utilities.cache_note":"Fordert an jedem bestehenden Standort einen Cache pro berechtigtem Anbieter an. Vorhandene Boxen bleiben; die Anbieter verlangen weiterhin genug Traffic.", diff --git a/site/i18n/es.js b/site/i18n/es.js index 6b51464..858e274 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -4146,6 +4146,16 @@ "tutorial.your_customers_want_the_whole":"Tus clientes quieren todo internet. Abre la pestaña Tránsito y compra un puerto a un operador.", "tutorial.your_router_is_live_press_launch":"Tu router está activo. Pulsa «Lanzar banda ancha» para vender internet a la gente de tu ciudad.", "ui.n_d_left":"quedan {n} d", +"unbuilt_pops.all_regions":"Todas las regiones", +"unbuilt_pops.cities_without_a_pop_n":"Ciudades sin POP ({n})", +"unbuilt_pops.cost_then_mo":"{cost}, luego {mo}/mes", +"unbuilt_pops.every_city_where_you_could_still":"Todas las ciudades donde aún puedes abrir un POP. Abre una para ver qué ofrece y construir allí.", +"unbuilt_pops.n_more_city":{"one":"{n} ciudad más","other":"{n} ciudades más"}, +"unbuilt_pops.needs_a_license_first":"Primero necesita una licencia", +"unbuilt_pops.no_pop_yet":"Sin POP aún", +"unbuilt_pops.nothing_left_to_build_in_this":"No queda nada por construir en esta región.", +"unbuilt_pops.region":"Región", +"unbuilt_pops.you_have_a_pop_in_every":"Tienes un POP en todas las ciudades del mapa. Al mapa le hacen falta más ciudades.", "utilities.apply_kit":"Aplicar kit de redundancia", "utilities.cache_moves":"Cachés que mover: {n} (equilibradas por proveedor)", "utilities.cache_note":"Solicita una caché por proveedor elegible en cada ubicación existente. Se conservan las cachés actuales; los proveedores siguen exigiendo tráfico suficiente.", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index c530438..4b306c9 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -4146,6 +4146,16 @@ "tutorial.your_customers_want_the_whole":"Tes clients veulent tout Internet. Ouvre l’onglet Transit et achète un port chez un opérateur.", "tutorial.your_router_is_live_press_launch":"Ton routeur est en ligne. Appuie sur « Lancer le haut débit » pour vendre Internet aux habitants de ta ville.", "ui.n_d_left":"encore {n} j", +"unbuilt_pops.all_regions":"Toutes les régions", +"unbuilt_pops.cities_without_a_pop_n":"Villes sans POP ({n})", +"unbuilt_pops.cost_then_mo":"{cost}, puis {mo}/mois", +"unbuilt_pops.every_city_where_you_could_still":"Toutes les villes où tu peux encore ouvrir un POP. Ouvres-en une pour voir ce qu'elle offre et y construire.", +"unbuilt_pops.n_more_city":{"one":"{n} ville de plus","other":"{n} villes de plus"}, +"unbuilt_pops.needs_a_license_first":"Il faut d'abord une licence", +"unbuilt_pops.no_pop_yet":"Pas encore de POP", +"unbuilt_pops.nothing_left_to_build_in_this":"Plus rien à construire dans cette région.", +"unbuilt_pops.region":"Région", +"unbuilt_pops.you_have_a_pop_in_every":"Tu as un POP dans chaque ville de la carte. Il faudrait plus de villes.", "utilities.apply_kit":"Appliquer le kit de redondance", "utilities.cache_moves":"Caches à déplacer : {n} (équilibrés par fournisseur)", "utilities.cache_note":"Demande un cache par fournisseur éligible sur chaque site existant. Les caches existants sont conservés ; les fournisseurs exigent toujours un trafic suffisant.", diff --git a/site/i18n/it.js b/site/i18n/it.js index e37fafe..8c76f65 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -4146,6 +4146,16 @@ "tutorial.your_customers_want_the_whole":"I tuoi clienti vogliono tutta internet. Apri la scheda Transit e compra una porta da un carrier.", "tutorial.your_router_is_live_press_launch":"Il tuo router è acceso. Premi “Lancia la banda larga” per vendere internet alla gente della tua città.", "ui.n_d_left":"ancora {n}g", +"unbuilt_pops.all_regions":"Tutte le regioni", +"unbuilt_pops.cities_without_a_pop_n":"Città senza POP ({n})", +"unbuilt_pops.cost_then_mo":"{cost}, poi {mo}/mese", +"unbuilt_pops.every_city_where_you_could_still":"Tutte le città dove puoi ancora aprire un POP. Aprine una per vedere cosa offre e costruire lì.", +"unbuilt_pops.n_more_city":{"one":"{n} altra città","other":"altre {n} città"}, +"unbuilt_pops.needs_a_license_first":"Serve prima una licenza", +"unbuilt_pops.no_pop_yet":"Ancora senza POP", +"unbuilt_pops.nothing_left_to_build_in_this":"In questa regione non resta niente da costruire.", +"unbuilt_pops.region":"Regione", +"unbuilt_pops.you_have_a_pop_in_every":"Hai un POP in ogni città della mappa. Alla mappa servono più città.", "utilities.apply_kit":"Applica il kit di ridondanza", "utilities.cache_moves":"Cache da spostare: {n} (bilanciate per fornitore)", "utilities.cache_note":"Richiedi una cache per ogni fornitore idoneo in ciascuna sede esistente. Le cache esistenti restano; i fornitori richiedono comunque traffico sufficiente.", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 06e7c30..29335c4 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -4146,6 +4146,16 @@ "tutorial.your_customers_want_the_whole":"Seus clientes querem a internet inteira. Abra a aba Transit e compre uma porta de uma operadora.", "tutorial.your_router_is_live_press_launch":"Seu router está no ar. Aperte “Lançar banda larga” para vender internet ao pessoal da sua cidade.", "ui.n_d_left":"faltam {n}d", +"unbuilt_pops.all_regions":"Todas as regiões", +"unbuilt_pops.cities_without_a_pop_n":"Cidades sem POP ({n})", +"unbuilt_pops.cost_then_mo":"{cost}, depois {mo}/mês", +"unbuilt_pops.every_city_where_you_could_still":"Todas as cidades onde você ainda pode abrir um POP. Abra uma para ver o que ela oferece e construir lá.", +"unbuilt_pops.n_more_city":{"one":"mais {n} cidade","other":"mais {n} cidades"}, +"unbuilt_pops.needs_a_license_first":"Precisa de uma licença primeiro", +"unbuilt_pops.no_pop_yet":"Ainda sem POP", +"unbuilt_pops.nothing_left_to_build_in_this":"Não há mais nada para construir nesta região.", +"unbuilt_pops.region":"Região", +"unbuilt_pops.you_have_a_pop_in_every":"Você tem um POP em todas as cidades do mapa. O mapa precisa de mais cidades.", "utilities.apply_kit":"Aplicar kit de redundância", "utilities.cache_moves":"Caches a mover: {n} (equilibradas por fornecedor)", "utilities.cache_note":"Solicita uma cache por fornecedor elegível em cada local existente. As caches existentes são mantidas; os fornecedores continuam a exigir tráfego suficiente.", diff --git a/src/agent/10-domains.js b/src/agent/10-domains.js index 953c915..277e6ad 100644 --- a/src/agent/10-domains.js +++ b/src/agent/10-domains.js @@ -56,7 +56,8 @@ const API_DOMAINS={ leftTab:{kind:'enum',values:['goals','deals','noc','nets']}, netFilter:{kind:'enum',values:['all','out']}, pniFilter:{kind:'enum',values:['all','t','worth','pni']}, - listPage:{kind:'enum',values:['conn','cust','nets','pni']}, + listPage:{kind:'enum',values:['conn','cust','nets','pni','pops']}, + popsSortKey:{kind:'enum',values:['eye','cost','name']}, custSortKey:{kind:'enum',values:['mood','mo','name','city']}, connFilter:{kind:'enum',values:['all','k']}, connSortKey:{kind:'enum',values:['k','city','name','use','mo']}, diff --git a/src/agent/20-commands.js b/src/agent/20-commands.js index a725106..15977c5 100644 --- a/src/agent/20-commands.js +++ b/src/agent/20-commands.js @@ -443,6 +443,9 @@ const API_VIEW={ custCity:{args:[['v','string']],doc:'Filter the customers list by city.'}, custSort:{args:[['k','custSortKey']],doc:'Flip the customers list sort.'}, custOpen:{args:[['sad','boolean',false]],doc:'Open the customers dashboard tab.'}, + popGo:{args:[['city','cityId']],doc:'Jump from the dashboard to a city with no POP yet.'}, + popsReg:{args:[['v','string']],doc:'Filter the list of cities with no POP by region.'}, + popsSort:{args:[['k','popsSortKey']],doc:'Flip the sort of the list of cities with no POP.'}, goConn:{args:[['city','cityId'],['k','connKind']],doc:'Open a city\'s connections tab.'}, goEgress:{args:[['city','cityId'],['k','egressKind']],doc:'Open a city\'s connections tab (l2 for the customer list).'}, connOpen:{args:[],doc:'Open the connections dashboard tab.'}, diff --git a/src/game/90-actions/70-dashboard-lists.js b/src/game/90-actions/70-dashboard-lists.js index 96ae70d..da73f96 100644 --- a/src/game/90-actions/70-dashboard-lists.js +++ b/src/game/90-actions/70-dashboard-lists.js @@ -1,10 +1,13 @@ Object.assign(ACT,{ custGo:({id})=>{const b=S.biz.find(x=>x.id===id);if(!b)return;$('dash').hidden=true;ACT.focusCity({city:b.city});UI.tab='cust';renderPanel();}, - listMore:({k})=>{if(k!=='conn'&&k!=='cust'&&k!=='nets'&&k!=='pni')return;UI.listN=UI.listN||{};UI.listN[k]=listN(k)+LIST_PAGE;if(k==='nets'){renderLeft();return;}if(k==='pni'){renderPanel();return;}renderDash();}, + listMore:({k})=>{if(k!=='conn'&&k!=='cust'&&k!=='nets'&&k!=='pni'&&k!=='pops')return;UI.listN=UI.listN||{};UI.listN[k]=listN(k)+LIST_PAGE;if(k==='nets'){renderLeft();return;}if(k==='pni'){renderPanel();return;}renderDash();}, custF:({v})=>{UI.kf=UI.kf||{};UI.kf.f=v==='sad'?'sad':'';listReset('cust');renderDash();}, custCity:({v})=>{UI.kf=UI.kf||{};UI.kf.city=isCity(v)?v:'';listReset('cust');renderDash();}, custSort:({k})=>{if(!['mood','mo','name','city'].includes(k))return;listReset('cust');if(UI.custSort===k)UI.custDir=-(UI.custDir||1);else{UI.custSort=k;UI.custDir=k==='mo'?-1:1;}renderDash();}, custOpen:({sad}={})=>{if(!S)return;UI.kf=sad?{f:'sad'}:{};listReset('cust');UI.dtab='cust';const d=$('dash');d.hidden=false;renderDash();d.scrollTop=0;}, + popGo:({city})=>{if(!isCity(city)||!cityOn(city))return;$('dash').hidden=true;ACT.focusCity({city});}, + popsReg:({v})=>{UI.popF=UI.popF||{};UI.popF.reg=own(REG,v)?v:'';listReset('pops');renderDash();}, + popsSort:({k})=>{if(!['eye','cost','name'].includes(k))return;listReset('pops');const sk=UI.popSort||'eye',d0=k==='eye'?-1:1;UI.popDir=sk===k?-(UI.popDir||d0):d0;UI.popSort=k;renderDash();}, goConn:({city,k})=>{if(!isCity(city)||!own(CONN_K,k))return;$('dash').hidden=true;ACT.goEgress({city,k});}, connF:({f,v})=>{const F=UI.cf=UI.cf||{};listReset('conn');if(f==='all'){UI.cf={};}else if(f==='k'){F.k=own(CONN_K,v)?v:'';}renderDash();}, connCity:({v})=>{UI.cf=UI.cf||{};listReset('conn');UI.cf.city=isCity(v)?v:'';renderDash();}, diff --git a/src/game/94-dashboard/35-unbuilt-pops.js b/src/game/94-dashboard/35-unbuilt-pops.js new file mode 100644 index 0000000..7a4b23e --- /dev/null +++ b/src/game/94-dashboard/35-unbuilt-pops.js @@ -0,0 +1,13 @@ +/* ---------- cities with no POP of yours yet ---------- */ +function popsSection(){const F=UI.popF||{},q=popStdQuote(),cost=c=>popCost(c)+(q?q.cost:0),mo=c=>popMo(c)+(q?q.mo:0); + const all=CITIES.filter(C=>cityOn(C.id)&&!S.pops[C.id]); + let h=`

${tr('unbuilt_pops.cities_without_a_pop_n',{n:all.length})}

`; + if(!all.length)return h+`

${tr('unbuilt_pops.you_have_a_pop_in_every')}

`; + h+=`

${tr('unbuilt_pops.every_city_where_you_could_still')}

`; + const sk=UI.popSort||'eye',dir=UI.popDir||-1,val=C=>sk==='name'?C.name.toLowerCase():sk==='cost'?cost(C.id):eyeP(C.id); + h+=`
`; + h+=`
${[['eye',tr('common.eyeballs')],['cost',tr('common.cost')],['name',tr('common.name')]].map(([k,l])=>btn(l+(sk===k?(dir>0?' ▲':' ▼'):''),'popsSort',{k},sk===k?'pink sm':'ghost sm')).join('')}
`; + const rows=all.filter(C=>!F.reg||C.reg===F.reg).sort((a,b)=>{const A=val(a),B=val(b);return (AB?1:0)*dir||a.name.localeCompare(b.name);}); + if(!rows.length)return h+`

${tr('unbuilt_pops.nothing_left_to_build_in_this')}

`; + h+=rows.slice(0,listN('pops')).map(C=>{const ix=ixName(C.id);return `
${esc(C.name)} ${esc(REG[C.reg])}
${tr('city_panel.g_of_eyeballs',{g:fmtG(eyeP(C.id))})}${ix?` · ${tr('city_panel.ix_ix',{ix:esc(ix)})}`:''} · ${tr('unbuilt_pops.cost_then_mo',{cost:fmt$(cost(C.id)),mo:fmt$(mo(C.id))})}
${C.cn&&!cnOk()?`
${tr('unbuilt_pops.needs_a_license_first')}
`:''}
${btn(tr('common.open'),'popGo',{city:C.id},'ghost sm')}
`;}).join(''); + return h+listMore('pops',rows.length,n=>trn('unbuilt_pops.n_more_city',n))+``;} diff --git a/src/game/94-dashboard/40-connections.js b/src/game/94-dashboard/40-connections.js index 9f4e440..568a32b 100644 --- a/src/game/94-dashboard/40-connections.js +++ b/src/game/94-dashboard/40-connections.js @@ -64,4 +64,4 @@ function netWhereIdx(){const B={t:{},p:{},ix:{},c:{}},add=(k,id,x)=>(B[k][id]||( function netWhere(n,where){const ch=(where||netWhereIdx())(n.id); if(!ch.length)return '';const MAX=6; return `
${ch.slice(0,MAX).map(([l,c,k])=>btn(`${esc(l)} ${esc(CITY[c].name)}`,'goConn',{city:c,k},'ghost sm')).join('')}${ch.length>MAX?btn(tr('dashboard.n_more',{n:ch.length-MAX}),'connFor',{net:n.id},'ghost sm'):''}
`;} -const DTABS=['overview','cust','conn','traffic','infra','lease']; +const DTABS=['overview','cust','conn','traffic','infra','pops','lease']; diff --git a/src/game/94-dashboard/60-dashboard.js b/src/game/94-dashboard/60-dashboard.js index 4ea4fae..4a1e450 100644 --- a/src/game/94-dashboard/60-dashboard.js +++ b/src/game/94-dashboard/60-dashboard.js @@ -1,4 +1,4 @@ -function dashTabs(){const u=custStats().unhappy,cur=UI.dtab||'overview',L={overview:tr('common.overview'),cust:tr('common.customers'),conn:tr('common.connections'),traffic:tr('common.traffic'),infra:tr('common.links_routers'),lease:tr('common.leased_lines')}; +function dashTabs(){const u=custStats().unhappy,cur=UI.dtab||'overview',L={overview:tr('common.overview'),cust:tr('common.customers'),conn:tr('common.connections'),traffic:tr('common.traffic'),infra:tr('common.links_routers'),pops:tr('unbuilt_pops.no_pop_yet'),lease:tr('common.leased_lines')}; return ``;} function renderDash(){checkLayer(); const H=S.hist||[],rows=H.slice(-90),last30=H.slice(-30); @@ -29,6 +29,7 @@ function renderDash(){checkLayer(); if(DT==='infra')h+=`

${tr('common.busiest_links')}

${ls.length?ls.map(({l,u})=>`
${CITY[l.a].name} ⇄ ${CITY[l.b].name} ${capName(l)} · ${linkLat(l).toFixed(1)} ms
${pct(u)}${btn(tr('common.open'),'dashLink',{id:l.id},'ghost sm')}
`).join(''):'

'+tr('common.no_links_yet')+'

'}

${tr('common.router_load')}

${rs.map(({c,u})=>`
${CITY[c].name} ${(S.pops[c].routers||1)} × ${esc(RG[S.pops[c].rgen||0].n)}
${pct(u)}
`).join('')}

${tr('common.your_as')}

${tr('common.as_number')}AS${S.asn}
${tr('common.prefixes')}${Math.max(1,Math.ceil(Object.keys(S.pops).length/3))} × /22 IPv4, 1 × /32 IPv6
${tr('common.bgp_sessions')}${R.sessions}
${tr('common.upstreams')}${new Set(S.transit.map(t=>t.net)).size}
${tr('common.reach')}${pct(R.reach)}
${tr('common.customers')}${tr('dashboard.n_businesses',{n:S.biz.length})}
`; + if(DT==='pops')h+=popsSection(); if(DT==='lease')h+=leaseTab(); if(h!==UI._dh){UI._dh=h;morph($('dashCard'),h);} } diff --git a/src/game/94-dashboard/90-noc-window.js b/src/game/94-dashboard/90-noc-window.js index 83d8189..db66bed 100644 --- a/src/game/94-dashboard/90-noc-window.js +++ b/src/game/94-dashboard/90-noc-window.js @@ -5,8 +5,8 @@ per network, opened once a window says hello, so other games' tabs never unpack them. With no window nothing is sent. */ const NOC_HB=3000,NOC_LOST=10000,NOC_GAP=1000; // What a click in the window does: changes only its own view, or runs in the game. Every button the dashboard draws is in one list. -const NOC_LOCAL=['chartToggle','connCity','connF','connNet','connSort','custCity','custF','custSort','dashClose','dashSort','dashTab','listMore']; -const NOC_GO=['buyIx','buyNni','buyTransit','cache','connCancel','custGo','dashLink','goConn','lagIx','lagP','lagT','leaseSwap','netFocus','opsOpen','pni','pniAllOpen']; +const NOC_LOCAL=['chartToggle','connCity','connF','connNet','connSort','custCity','custF','custSort','dashClose','dashSort','dashTab','listMore','popsReg','popsSort']; +const NOC_GO=['buyIx','buyNni','buyTransit','cache','connCancel','custGo','dashLink','goConn','lagIx','lagP','lagT','leaseSwap','netFocus','opsOpen','pni','pniAllOpen','popGo']; const NOC={win:false,id:null,ctl:null,st:null,stId:null,peer:false,until:0,dirty:false,sent:0,speed:1,hid:false,yoAt:0,gone:false}; {const id=RW_IN?null:new URLSearchParams(location.search).get('noc');if(slotOkId(id)){NOC.win=true;NOC.id=id;}} if(!RW_IN)try{if(typeof BroadcastChannel==='function'){NOC.ctl=new BroadcastChannel('sot-noc');NOC.ctl.onmessage=e=>{const m=e.data;if(!m||typeof m!=='object'||!slotOkId(m.id))return;if(NOC.win)nocWinMsg(m);else nocGameMsg(m);};}}catch(e){} diff --git a/src/i18n/en.js b/src/i18n/en.js index ad8a9de..00ecaf3 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -4147,6 +4147,16 @@ "tutorial.your_customers_want_the_whole":"Your customers want the whole internet. Open the Transit tab and buy a port from a carrier.", "tutorial.your_router_is_live_press_launch":"Your router is live. Press “Launch broadband” to sell internet to the people of your city.", "ui.n_d_left":"{n}d left", +"unbuilt_pops.all_regions":"All regions", +"unbuilt_pops.cities_without_a_pop_n":"Cities without a POP ({n})", +"unbuilt_pops.cost_then_mo":"{cost}, then {mo}/mo", +"unbuilt_pops.every_city_where_you_could_still":"Every city where you could still open a POP. Open one to see what it offers and build there.", +"unbuilt_pops.n_more_city":{"one":"{n} more city","other":"{n} more cities"}, +"unbuilt_pops.needs_a_license_first":"Needs a license first", +"unbuilt_pops.no_pop_yet":"No POP yet", +"unbuilt_pops.nothing_left_to_build_in_this":"Nothing left to build in this region.", +"unbuilt_pops.region":"Region", +"unbuilt_pops.you_have_a_pop_in_every":"You have a POP in every city on the map. The map may need more cities.", "utilities.apply_kit":"Apply redundancy kit", "utilities.cache_moves":"Cache boxes to move: {n} (balanced per provider)", "utilities.cache_note":"Request one cache per eligible provider at each existing site. Existing boxes are kept; providers still require sufficient traffic.", diff --git a/tests/unbuilt-pops.test.js b/tests/unbuilt-pops.test.js new file mode 100644 index 0000000..04d47b4 --- /dev/null +++ b/tests/unbuilt-pops.test.js @@ -0,0 +1,137 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +// The NOC dashboard's list of cities where the player has no POP yet. +function game(t) { + const h = load(); + t.after(() => h.dom.window.close()); + h.ev("ACT.start({});closeModal();UI.speed=0;S.nextFail=S.nextEvent=1e9;compute();ACT.dash();ACT.dashTab({k:'pops'})"); + return h; +} +const json = (ev, code) => JSON.parse(ev(`JSON.stringify(${code})`)); +const shown = (ev) => json(ev, "[...document.querySelectorAll('#popsSec [data-act=\"popGo\"]')].map(b=>JSON.parse(b.dataset.args).city)"); +const open = (ev) => json(ev, 'CITIES.filter(C=>cityOn(C.id)&&!S.pops[C.id]).map(C=>C.id)'); +const more = (ev) => { while (ev("!!document.querySelector('#popsSec [data-act=\"listMore\"]')")) ev("ACT.listMore({k:'pops'})"); }; +const rowOf = (ev, c) => ev(`[...document.querySelectorAll('#popsSec .row')].find(r=>JSON.parse(r.querySelector('[data-act="popGo"]').dataset.args).city==='${c}').textContent`); + +test('it lists exactly the cities you could still open, biggest first', (t) => { + const { ev, errors } = game(t); + more(ev); + const c = shown(ev), want = open(ev); + assert.deepEqual([...c].sort(), [...want].sort()); + assert.ok(!c.includes(ev('S.home')), 'not where you already are'); + const hidden = json(ev, 'CITIES.filter(C=>!cityOn(C.id)).map(C=>C.id)'); + assert.ok(hidden.every((x) => !c.includes(x)), 'a city not on the map is not listed'); + const sizes = json(ev, `${JSON.stringify(c)}.map(eyeP)`); + assert.deepEqual(sizes, [...sizes].sort((a, b) => b - a)); + assert.match(ev("$('popsSec').textContent"), new RegExp(`Cities without a POP \\(${want.length}\\)`)); + assert.deepEqual(errors, []); +}); + +test('a row says what a player needs: eyeballs, exchange, and what the build would charge', (t) => { + const { ev, errors } = game(t); + more(ev); + const c = shown(ev).find((x) => ev(`!!ixName('${x}')`)); + const text = rowOf(ev, c); + for (const part of [`fmtG(eyeP('${c}'))`, `ixName('${c}')`, `fmt$(popCost('${c}'))`, `fmt$(popMo('${c}'))`, `CITY['${c}'].name`]) assert.ok(text.includes(ev(part)), part); + ev(`S.cash=1e9;ACT.buildPop({city:'${c}'})`); + assert.ok(ev(`!!S.pops['${c}']`)); + assert.ok(text.includes(ev(`fmt$(1e9-S.cash)`)), 'the listed price is what it costs'); + assert.deepEqual(errors, []); +}); + +test('the listed price includes your POP standard, like the build button', (t) => { + const { ev, errors } = game(t); + ev('popStdQuote=()=>({cost:1234567,mo:7654,rt:1,g:0});UI._dh=null;renderDash()'); + more(ev); + const c = shown(ev)[0], text = rowOf(ev, c); + assert.ok(text.includes(ev(`fmt$(popCost('${c}')+1234567)`))); + assert.ok(text.includes(ev(`fmt$(popMo('${c}')+7654)`))); + assert.deepEqual(errors, []); +}); + +test('building a POP takes the city off the list; none left says so', (t) => { + const { ev, errors } = game(t); + const c = shown(ev).find((x) => ev(`!CITY['${x}'].cn`)); // the biggest cities can be Chinese, and those need a license first + ev(`S.cash=1e9;ACT.buildPop({city:'${c}'});$('dash').hidden=false;UI.dtab='pops';renderDash()`); + assert.ok(!shown(ev).includes(c)); + ev('for(const C of CITIES)if(cityOn(C.id)&&!S.pops[C.id])S.pops[C.id]={day:0,routers:1};UI._dh=null;popsCheck=popsSection();'); + assert.match(ev('popsCheck'), /You have a POP in every city/); + assert.doesNotMatch(ev('popsCheck'), /popGo/); + assert.deepEqual(errors, []); +}); + +test('sorts flip, each starts the useful way round, and bad keys are ignored', (t) => { + const { ev, errors } = game(t); + const vals = (code) => { more(ev); return json(ev, `${JSON.stringify(shown(ev))}.map(c=>${code})`); }; + const asc = (a) => a.every((x, i) => !i || a[i - 1] <= x), desc = (a) => a.every((x, i) => !i || a[i - 1] >= x); + ev("ACT.popsSort({k:'eye'})"); + assert.ok(asc(vals('eyeP(c)')), 'clicking the default sort flips it'); + ev("ACT.popsSort({k:'eye'})"); + assert.ok(desc(vals('eyeP(c)'))); + ev("ACT.popsSort({k:'cost'})"); + assert.ok(asc(vals('popCost(c)')), 'cheapest first'); + ev("ACT.popsSort({k:'cost'})"); + assert.ok(desc(vals('popCost(c)'))); + ev("ACT.popsSort({k:'name'})"); + const names = vals('CITY[c].name.toLowerCase()'); + assert.deepEqual(names, [...names].sort()); + ev("ACT.popsSort({k:'eye'})"); + assert.ok(desc(vals('eyeP(c)')), 'coming back to eyeballs starts biggest first'); + ev("ACT.popsSort({k:'nope'})"); + assert.equal(ev('UI.popSort'), 'eye'); + assert.deepEqual(errors, []); +}); + +test('the region filter narrows the list, ignores nonsense, and an emptied region says so', (t) => { + const { ev, errors } = game(t); + ev("ACT.popsReg({v:'OC'})"); + more(ev); + const oc = shown(ev); + assert.ok(oc.length > 0); + assert.ok(ev(`${JSON.stringify(oc)}.every(c=>CITY[c].reg==='OC')`)); + assert.equal(oc.length, ev("CITIES.filter(C=>cityOn(C.id)&&!S.pops[C.id]&&C.reg==='OC').length")); + ev("for(const C of CITIES)if(C.reg==='OC'&&cityOn(C.id))S.pops[C.id]={day:0,routers:1};UI._dh=null;renderDash()"); + assert.equal(shown(ev).length, 0); + assert.match(ev("$('popsSec').textContent"), /Nothing left to build in this region/); + assert.ok(ev("!!document.querySelector('#popsSec [data-chg=\"popsReg\"]')"), 'the filter is still there to change'); + ev("ACT.popsReg({v:'constructor'})"); + assert.equal(ev('UI.popF.reg'), ''); + assert.ok(shown(ev).length > 0); + assert.deepEqual(errors, []); +}); + +test('the list pages like the other long lists, and a new sort or filter starts from the top', (t) => { + const { ev, errors } = game(t); + assert.equal(shown(ev).length, ev('LIST_PAGE')); + ev("ACT.listMore({k:'pops'})"); + assert.ok(shown(ev).length > ev('LIST_PAGE')); + ev("ACT.popsSort({k:'name'})"); + assert.equal(shown(ev).length, ev('LIST_PAGE')); + ev("ACT.listMore({k:'pops'});ACT.popsReg({v:'EU'})"); + assert.equal(ev("listN('pops')"), ev('LIST_PAGE')); + assert.deepEqual(errors, []); +}); + +test('Open closes the dashboard and selects the city, without building anything', (t) => { + const { ev, errors } = game(t); + const c = shown(ev)[0], cash = ev('S.cash'); + ev(`ACT.popGo({city:'${c}'})`); + assert.equal(ev("$('dash').hidden"), true); + assert.equal(ev('UI.sel.id'), c); + assert.equal(ev('S.cash'), cash); + assert.ok(ev(`!S.pops['${c}']`)); + for (const bad of ["'nope'", "'constructor'", '1']) { ev('UI.sel=null'); ev(`ACT.popGo({city:${bad}})`); assert.equal(ev('UI.sel'), null, bad); } + assert.deepEqual(errors, []); +}); + +test('a Chinese city says it needs a license until you have one', (t) => { + const { ev, errors } = game(t); + more(ev); + const c = ev('CITIES.find(C=>C.cn&&cityOn(C.id)&&!S.pops[C.id]).id'); + assert.match(rowOf(ev, c), /Needs a license first/); + ev("S.cnLic={state:'ok'};UI._dh=null;renderDash()"); + assert.doesNotMatch(rowOf(ev, c), /Needs a license first/); + assert.deepEqual(errors, []); +});