Merge pull request #291 from thesysadmindev/unbuilt-pops
A dashboard tab listing the cities with no POP yet
This commit is contained in:
commit
57c0594a90
17 changed files with 227 additions and 8 deletions
|
|
@ -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.
|
||||
- A sales desk joins the NOC intern: from customer level 2 you can put one person in charge of sales, and each brings deals their own way. The engineer turned salesdroid books you into every network operators' meeting (you pay the ticket), brings more small and mid deals but never the huge ones, and only sells what your network can do, so their customers stay longer; they haggle badly. The shark lands bigger deals at a quarter more and takes a month of each as commission, but oversells promises your network does not keep yet, ignores technical customers and meetings, and makes peering desks want more traffic from you. Or the CEO runs sales himself, for free: a huge discounted deal on the golf course every couple of months, the odd offer you declined signed anyway, opinions, and no way to fire him short of asking the board for a VP of Sales.
|
||||
- Customers now sign contracts, and when one ends they renew, grow, haggle or leave, not always because of you (#178). Most renew at today's bandwidth price, which falls about 10% a year but rises when hardware is short; happy customers often take a bigger size, and some ask for a discount you can match, meet halfway or turn down in Deals. Others are acquired, go bust, build their own network, move away (they stay if you have a POP where they go), split their traffic with a second provider or end their project, and now and then one leaves for a stranger reason. Nothing changes during a customer's first contract, renewals in an old save are spread over the next year, your happiest long-time customers send you referrals, and the NOC dashboard shows customers won and lost each month and why.
|
||||
- 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.
|
||||
|
|
|
|||
|
|
@ -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=<slot>`, 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=<slot>`, 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, how each tube looks, the WebGL map (the default, 2D as fallback: context, background, tubes, and the sprite atlas cities, labels and markers are drawn from, in 2D too), `draw()`, the world layer, cities, input and click delegation |
|
||||
| `99-loop.js` | `frame()` and `boot()` |
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -4266,6 +4266,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.",
|
||||
|
|
|
|||
|
|
@ -4264,6 +4264,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.",
|
||||
|
|
|
|||
|
|
@ -4264,6 +4264,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.",
|
||||
|
|
|
|||
|
|
@ -4264,6 +4264,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.",
|
||||
|
|
|
|||
|
|
@ -4264,6 +4264,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.",
|
||||
|
|
|
|||
|
|
@ -57,7 +57,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']},
|
||||
|
|
|
|||
|
|
@ -455,6 +455,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.'},
|
||||
|
|
|
|||
|
|
@ -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();},
|
||||
|
|
|
|||
13
src/game/94-dashboard/35-unbuilt-pops.js
Normal file
13
src/game/94-dashboard/35-unbuilt-pops.js
Normal file
|
|
@ -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=`<div class="panel2" id="popsSec" style="margin-top:12px"><h3>${tr('unbuilt_pops.cities_without_a_pop_n',{n:all.length})}</h3>`;
|
||||
if(!all.length)return h+`<p class="empty">${tr('unbuilt_pops.you_have_a_pop_in_every')}</p></div>`;
|
||||
h+=`<p class="note" style="margin-top:0">${tr('unbuilt_pops.every_city_where_you_could_still')}</p>`;
|
||||
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+=`<div class="trsel" style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:6px"><label>${tr('unbuilt_pops.region')} <select data-chg="popsReg"><option value="">${tr('unbuilt_pops.all_regions')}</option>${Object.keys(REG).map(r=>`<option value="${r}"${F.reg===r?' selected':''}>${esc(REG[r])}</option>`).join('')}</select></label></div>`;
|
||||
h+=`<div class="seg" style="margin-bottom:4px">${[['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('')}</div>`;
|
||||
const rows=all.filter(C=>!F.reg||C.reg===F.reg).sort((a,b)=>{const A=val(a),B=val(b);return (A<B?-1:A>B?1:0)*dir||a.name.localeCompare(b.name);});
|
||||
if(!rows.length)return h+`<p class="empty">${tr('unbuilt_pops.nothing_left_to_build_in_this')}</p></div>`;
|
||||
h+=rows.slice(0,listN('pops')).map(C=>{const ix=ixName(C.id);return `<div class="row"><div class="grow"><div class="nm">${esc(C.name)} <span class="meta">${esc(REG[C.reg])}</span></div><div class="meta">${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))})}</div>${C.cn&&!cnOk()?`<div class="why">${tr('unbuilt_pops.needs_a_license_first')}</div>`:''}</div>${btn(tr('common.open'),'popGo',{city:C.id},'ghost sm')}</div>`;}).join('');
|
||||
return h+listMore('pops',rows.length,n=>trn('unbuilt_pops.n_more_city',n))+`</div>`;}
|
||||
|
|
@ -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 `<div class="btns">${ch.slice(0,MAX).map(([l,c,k])=>btn(`${esc(l)} <small>${esc(CITY[c].name)}</small>`,'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'):''}</div>`;}
|
||||
const DTABS=['overview','cust','conn','traffic','infra','lease'];
|
||||
const DTABS=['overview','cust','conn','traffic','infra','pops','lease'];
|
||||
|
|
|
|||
|
|
@ -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 `<nav class="dtabs">${DTABS.map(k=>`<button class="${cur===k?'on':''}" data-act="dashTab" data-args='{"k":"${k}"}'>${L[k]}${k==='cust'&&u?`<span class="cnt red">${u}</span>`:''}</button>`).join('')}</nav>`;}
|
||||
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+=`<div class="dcols" style="margin-top:12px"><div class="panel2"><h3>${tr('common.busiest_links')}</h3>${ls.length?ls.map(({l,u})=>`<div class="row"><div class="grow"><div class="nm">${CITY[l.a].name} ⇄ ${CITY[l.b].name} <span class="meta">${capName(l)} · ${linkLat(l).toFixed(1)} ms</span></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div><b class="num" style="min-width:42px;text-align:right">${pct(u)}</b>${btn(tr('common.open'),'dashLink',{id:l.id},'ghost sm')}</div>`).join(''):'<p class="empty">'+tr('common.no_links_yet')+'</p>'}</div>
|
||||
<div class="panel2"><h3>${tr('common.router_load')}</h3>${rs.map(({c,u})=>`<div class="row"><div class="grow"><div class="nm">${CITY[c].name} <span class="meta">${(S.pops[c].routers||1)} × ${esc(RG[S.pops[c].rgen||0].n)}</span></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div><b class="num" style="min-width:42px;text-align:right">${pct(u)}</b></div>`).join('')}
|
||||
<h3 style="margin-top:10px">${tr('common.your_as')}</h3><div class="kv"><span>${tr('common.as_number')}</span><b>AS${S.asn}</b></div><div class="kv"><span>${tr('common.prefixes')}</span><b>${Math.max(1,Math.ceil(Object.keys(S.pops).length/3))} × /22 IPv4, 1 × /32 IPv6</b></div><div class="kv"><span>${tr('common.bgp_sessions')}</span><b>${R.sessions}</b></div><div class="kv"><span>${tr('common.upstreams')}</span><b>${new Set(S.transit.map(t=>t.net)).size}</b></div><div class="kv"><span>${tr('common.reach')}</span><b>${pct(R.reach)}</b></div><div class="kv"><span>${tr('common.customers')}</span><b>${tr('dashboard.n_businesses',{n:S.biz.length})}</b></div></div></div>`;
|
||||
if(DT==='pops')h+=popsSection();
|
||||
if(DT==='lease')h+=leaseTab();
|
||||
if(h!==UI._dh){UI._dh=h;morph($('dashCard'),h);}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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){}
|
||||
|
|
|
|||
|
|
@ -4265,6 +4265,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.",
|
||||
|
|
|
|||
137
tests/unbuilt-pops.test.js
Normal file
137
tests/unbuilt-pops.test.js
Normal file
|
|
@ -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, []);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue