From 8ccf84cf4a82c7b3c3f921ce14011de5961a7f58 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Thu, 29 Oct 2026 18:59:07 +0100 Subject: [PATCH] Pick your own AS number next to the name; a round green arrow for another name (#135) --- CHANGELOG.md | 1 + site/i18n/de.js | 2 ++ site/i18n/es.js | 2 ++ site/i18n/fr.js | 2 ++ site/i18n/it.js | 2 ++ site/i18n/pt.js | 2 ++ src/i18n/en.js | 2 ++ src/styles/40-modal.css | 2 +- tests/own-asn.test.js | 32 ++++++++++++++++++++++++++++++++ 9 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/own-asn.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d2a230..4d9898a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ All notable changes to this project are documented here. The project follows - When a new release changes prices so that this week's or a coming week's puzzle no longer adds up, that puzzle gets a fair new budget, and only its stars start again. Weeks that are over keep theirs. - The Networks list shows 100 networks at a time, with a button for the rest, so it opens quickly now that every country has its own networks. - A tidier start screen: language first, then your network's name, the doors, three compact difficulty buttons with the chosen one explained below, and one drop-down for your home city with the five suggested homes at the top. +- Pick your own AS number next to your network's name when you start (#135). Leave it empty and the game picks one, and the round green arrow in the name box suggests another name. ## [1.37.0] — 2026-10-28 diff --git a/site/i18n/de.js b/site/i18n/de.js index 82a1847..b0585cb 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -3519,7 +3519,9 @@ "supply_chain.what_p_n_days_left":"{what} +{p} · noch {n} Tage", "supply_chain.your_price_lock_covers_you_until":"Deine Preisgarantie gilt bis {date}.", "title.a_billion_dollars_and_every_toy":"Eine Milliarde Dollar und jedes Spielzeug im Laden.", +"title.as_number":"AS-Nummer", "title.asia_hub_great_peering_far_from":"Asien-Drehkreuz. Tolles Peering, weit weg von zu Hause.", +"title.asn_not_usable":"Diese AS-Nummer routet nicht: Wähle eine von 1 bis 4294967294, die kein Netz auf der Karte nutzt (kein AS 0, 23456, keine Dokumentations- oder privaten Bereiche). Leer lassen für eine zufällige.", "title.back_to_my_network":"Zurück zu meinem Netz", "title.big_hungry_market_few_providers":"Großer, hungriger Markt, wenige Anbieter.", "title.build_an_internet_lay_fiber_between":"Baue deinen eigenen ISP auf. Verlege Glasfaser zwischen Städten, kauf Transit, peere an Exchanges, gewinne Geschäftskunden und halte deine Privatkunden bei Laune, während Bagger, Haie und Route Leaks alles tun, um dich aufzuhalten.", diff --git a/site/i18n/es.js b/site/i18n/es.js index f9f661a..d81f013 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -3517,7 +3517,9 @@ "supply_chain.what_p_n_days_left":"{what} +{p} · quedan {n} días", "supply_chain.your_price_lock_covers_you_until":"Tu precio fijo te cubre hasta {date}.", "title.a_billion_dollars_and_every_toy":"Mil millones de dólares y todos los juguetes de la tienda.", +"title.as_number":"Número de AS", "title.asia_hub_great_peering_far_from":"Hub de Asia. Gran peering, lejos de casa.", +"title.asn_not_usable":"Ese número de AS no enruta: elige uno de 1 a 4294967294 que no use ninguna red del mapa (ni AS 0, ni 23456, ni rangos de documentación o privados). Déjalo vacío para uno al azar.", "title.back_to_my_network":"Volver a mi red", "title.big_hungry_market_few_providers":"Mercado enorme y hambriento, pocos proveedores.", "title.build_an_internet_lay_fiber_between":"Construye un internet. Tiende fibra entre ciudades, compra tránsito, haz peering en intercambios, firma con empresas y mantén contentos a los eyeballs mientras retroexcavadoras, tiburones y fugas de rutas hacen lo posible por detenerte.", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index f4056b9..d8e7f47 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -3517,7 +3517,9 @@ "supply_chain.what_p_n_days_left":"{what} +{p} · encore {n} jours", "supply_chain.your_price_lock_covers_you_until":"Votre blocage des prix vous couvre jusqu’au {date}.", "title.a_billion_dollars_and_every_toy":"Un milliard de dollars et tous les jouets du magasin.", +"title.as_number":"Numéro d'AS", "title.asia_hub_great_peering_far_from":"Hub de l’Asie. Super peering, loin de chez soi.", +"title.asn_not_usable":"Ce numéro d'AS ne route pas : choisis-en un de 1 à 4294967294 qu'aucun réseau de la carte n'utilise (pas d'AS 0, 23456, ni de plages de documentation ou privées). Laisse vide pour un numéro au hasard.", "title.back_to_my_network":"Retour à mon réseau", "title.big_hungry_market_few_providers":"Gros marché affamé, peu d’opérateurs.", "title.build_an_internet_lay_fiber_between":"Construis un Internet. Pose de la fibre entre les villes, achète du transit, fais du peering aux IX, signe des entreprises et garde les eyeballs contents pendant que pelleteuses, requins et fuites de routes font tout pour t’arrêter.", diff --git a/site/i18n/it.js b/site/i18n/it.js index fe99435..58c52b8 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -3517,7 +3517,9 @@ "supply_chain.what_p_n_days_left":"{what} +{p} · {n} giorni rimasti", "supply_chain.your_price_lock_covers_you_until":"Il tuo blocco dei prezzi ti copre fino al {date}.", "title.a_billion_dollars_and_every_toy":"Un miliardo di dollari e tutti i giocattoli del negozio.", +"title.as_number":"Numero di AS", "title.asia_hub_great_peering_far_from":"Hub dell’Asia. Ottimo peering, lontano da casa.", +"title.asn_not_usable":"Quel numero di AS non instrada: scegline uno da 1 a 4294967294 che nessuna rete sulla mappa usa (niente AS 0, 23456, intervalli di documentazione o privati). Lascia vuoto per uno a caso.", "title.back_to_my_network":"Torna alla mia rete", "title.big_hungry_market_few_providers":"Mercato grande e affamato, pochi provider.", "title.build_an_internet_lay_fiber_between":"Costruisci un internet. Posa fibra tra le città, compra transit, fai peering agli exchange, metti sotto contratto le aziende e tieni contenti gli eyeball, mentre ruspe, squali e route leak fanno di tutto per fermarti.", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 1eadf43..cd27409 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -3517,7 +3517,9 @@ "supply_chain.what_p_n_days_left":"{what} +{p} · faltam {n} dias", "supply_chain.your_price_lock_covers_you_until":"Seu congelamento de preços te cobre até {date}.", "title.a_billion_dollars_and_every_toy":"Um bilhão de dólares e todos os brinquedos da loja.", +"title.as_number":"Número de AS", "title.asia_hub_great_peering_far_from":"Hub da Ásia. Ótimo peering, longe de casa.", +"title.asn_not_usable":"Esse número de AS não roteia: escolha um de 1 a 4294967294 que nenhuma rede do mapa use (nada de AS 0, 23456, faixas de documentação ou privadas). Deixe vazio para um aleatório.", "title.back_to_my_network":"Voltar para minha rede", "title.big_hungry_market_few_providers":"Mercado grande e faminto, poucos provedores.", "title.build_an_internet_lay_fiber_between":"Construa uma internet. Lance fibra entre cidades, compre transit, faça peering nos exchanges, feche contratos com empresas e mantenha os eyeballs felizes enquanto retroescavadeiras, tubarões e route leaks fazem de tudo para te parar.", diff --git a/src/i18n/en.js b/src/i18n/en.js index cf18cc8..81093a4 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -3518,7 +3518,9 @@ "supply_chain.what_p_n_days_left":"{what} +{p} · {n} days left", "supply_chain.your_price_lock_covers_you_until":"Your price lock covers you until {date}.", "title.a_billion_dollars_and_every_toy":"A billion dollars and every toy in the shop.", +"title.as_number":"AS number", "title.asia_hub_great_peering_far_from":"Asia hub. Great peering, far from home.", +"title.asn_not_usable":"That AS number won't route: pick one from 1 to 4294967294 that no network on the map uses (no AS 0, 23456, documentation or private ranges). Leave it empty for a random one.", "title.back_to_my_network":"Back to my network", "title.big_hungry_market_few_providers":"Big hungry market, few providers.", "title.build_an_internet_lay_fiber_between":"Build an internet. Lay fiber between cities, buy transit, peer at exchanges, sign up businesses, and keep the eyeballs happy while backhoes, sharks and route leaks do their best to stop you.", diff --git a/src/styles/40-modal.css b/src/styles/40-modal.css index 2e27172..4050efa 100644 --- a/src/styles/40-modal.css +++ b/src/styles/40-modal.css @@ -111,7 +111,7 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi .network-name{display:flex;flex-wrap:wrap;align-items:center;gap:8px} .network-name{flex-wrap:nowrap}.nmwrap{position:relative;flex:1 1 auto;min-width:0}.nmwrap input.t{width:100%;padding-right:44px;font-size:16px} .reroll{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:32px;height:32px;border-radius:50%;border:2px solid var(--ink);background:#22C47A;color:#fff;font:900 18px/1 var(--display);cursor:pointer;padding:0;display:flex;align-items:center;justify-content:center}.reroll:active{transform:translateY(-50%) rotate(-90deg)} -.asnwrap{display:flex;align-items:center;gap:4px;flex:0 0 auto;font:800 14px var(--display);color:var(--ink2)}.asnwrap input.t{width:112px;font-size:16px;padding:8px 8px}.asnwrap input.t.bad{border-color:#E03A3A;background:#FFE8E8} +.asnwrap{display:flex;align-items:center;gap:4px;flex:0 0 auto;font:800 14px var(--display);color:var(--ink2)}.asnwrap input.t{width:92px;font-size:15px;padding:8px 6px}.asnwrap input.t::placeholder{color:var(--ink2);opacity:.7}.asnwrap input.t.bad{border-color:#E03A3A;background:#FFE8E8} .metric-in{display:flex;gap:6px;align-items:center;margin-top:6px}.metric-in input.t{flex:1 1 120px;width:auto;min-width:0;font-size:16px;padding:4px 10px} .plug{display:flex;gap:12px;align-items:center;border:3px solid var(--ink);border-radius:14px;padding:10px 12px;margin:10px 0 4px;background:var(--soft);box-shadow:0 3px 0 var(--ink);color:var(--ink);text-decoration:none} .plug:hover{background:#FFF6D6}.plug .pi{font-size:30px;line-height:1}.plug b{font-family:var(--display);font-size:16px}.plug .meta{display:block;margin-top:2px}.plug .go{margin-left:auto;font-weight:900;white-space:nowrap} diff --git a/tests/own-asn.test.js b/tests/own-asn.test.js new file mode 100644 index 0000000..c39ec0b --- /dev/null +++ b/tests/own-asn.test.js @@ -0,0 +1,32 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +test('pick your own AS number next to the name, or leave it empty for a random one (#135)', () => { + const { ev, errors } = load(); + assert.ok(ev("!!document.querySelector('.network-name .nmwrap #nmIn')&&!!document.querySelector('.nmwrap .reroll[data-act=randomName]')"), 'round reroll button inside the name box'); + const sug = ev("+document.getElementById('asnIn').placeholder"); + assert.ok(ev(`asnOk(${sug})`), 'the suggestion is usable'); + const set = v => ev(`(()=>{const i=document.getElementById('asnIn');i.value=${JSON.stringify(v)};i.dispatchEvent(new Event('input'));return i.value})()`); + assert.equal(set('AS 2-0-1-9-1-7'), '201917', 'only digits stay'); + ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip()"); + assert.equal(ev('S.asn'), 201917); + assert.match(ev("document.getElementById('hAsn').textContent"), /AS201917/); + assert.deepEqual(errors, []); +}); + +test('an AS number that would not route is refused before the game starts', () => { + const { ev, errors } = load(); + for (const bad of ['0', '23456', '64512', '4200000001', String(ev('NETS[0].asn'))]) { + assert.equal(ev(`asnOk(${bad})`), false, bad); + } + ev("(()=>{const i=document.getElementById('asnIn');i.value='64512';i.dispatchEvent(new Event('input'))})()"); + assert.ok(ev("document.getElementById('asnIn').classList.contains('bad')")); + ev('ACT.start({})'); + assert.equal(ev('S'), null, 'no game'); + assert.match(ev("document.getElementById('toasts').textContent"), /won't route/); + ev("(()=>{const i=document.getElementById('asnIn');i.value='';i.dispatchEvent(new Event('input'))})()"); + ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip()"); + assert.ok(ev('asnOk(S.asn)&&S.asn>=200000'), 'empty: a random one'); + assert.deepEqual(errors, []); +});