From 8841fdacb98897313c4e3b30121b4a080d302915 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Thu, 5 Nov 2026 08:15:46 +0100 Subject: [PATCH] Customers come and go: contracts, renewals at the market price, growth, haggles and leaving (#178) Every customer now signs for a term (enterprise and hosting 1-3 years, wholesale and circuits 2-5, fiber pairs 10-20). When it ends most renew at today's bandwidth price, happy ones often grow to the next size, a few with competitors around ask for a discount 30 days ahead (match, meet halfway or let go in Deals; no answer matches), and some leave: unhappy ones because of the service, others acquired, bust, insourced, moved (they stay if you have a POP there), multihomed, project ended, a cheaper bid, or now and then one of the odder reasons (never more than one every 60 days). The bandwidth market is flat for six months, then about 10% cheaper a year, slowed by dearer hardware, moving in a slow three-year cycle and pushed up during a shortage. New offers and renewals are priced in it; one renewal moves a price at most 25% down or 10% up. Nothing happens in a first term. Rolls are hashes of the customer and its term, never Math.random, so seeded games keep their stream. Old saves get renewals spread over the next year. Happy customers of a year or more send a referral about every six weeks. The dashboard's Customers tab shows customers won and lost each month and why, renewals due and the market; customer rows show the contract end. The differential fuzz now leaves out state fields only this checkout has, so a new feature's state does not fail the comparison with main while everything both games share must still match. --- CHANGELOG.md | 1 + docs/ARCHITECTURE.md | 2 +- scripts/lib/fuzz-page.js | 13 +- scripts/lib/route-fuzz.js | 6 +- site/i18n/de.js | 78 +++++++ site/i18n/es.js | 78 +++++++ site/i18n/fr.js | 78 +++++++ site/i18n/it.js | 78 +++++++ site/i18n/pt.js | 78 +++++++ src/agent/20-commands.js | 6 + src/agent/30-docs.js | 5 +- src/game/10-catalog/30-supply-chain.js | 1 + src/game/60-features/37-fiber-broker.js | 2 +- src/game/80-simulation/50-sanitize.js | 4 +- .../80-simulation/75-customer-lifecycle.js | 148 ++++++++++++++ src/game/88-days/10-day-tick.js | 4 +- src/game/90-actions/50-customers.js | 12 +- src/game/93-ui/40-hud-and-panels.js | 6 +- src/game/93-ui/50-city-panel.js | 2 +- src/game/94-dashboard/30-customers.js | 2 +- src/game/94-dashboard/60-dashboard.js | 2 +- src/i18n/en.js | 78 +++++++ tests/customer-lifecycle.test.js | 190 ++++++++++++++++++ tests/save-size.test.js | 4 +- 24 files changed, 859 insertions(+), 19 deletions(-) create mode 100644 src/game/80-simulation/75-customer-lifecycle.js create mode 100644 tests/customer-lifecycle.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index e1dc2b2..bbfce26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- 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. - 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..1dbb155 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -33,7 +33,7 @@ hoisted across files, and top-level statements run in path order. Find code by n | `50-state.js` | The globals `S`, `R`, `UI`; `emptyR()` | | `60-features/` | Banks and loans, scenarios and the weekly challenge, puzzles and the published weekly puzzle, conferences, the tutorial, traceroute, the share card, `newGame()`, the offer trial (`autoOffer()`), standing orders (`S.ops`, `opsDay()`, run from `dayTick()`) | | `70-rules/` | Formatting helpers and market rules: exchanges, PNIs, the peering desk (requests answered by policy), peering policy and snubs, DE-KICKS, sold-out routes, hot ports and the Tier 1/2/3 rank | -| `80-simulation/` | Dijkstra, RouteScript, where a DDoS flood goes (`ddosLoad()`/`ddosAfter()`, called by `compute()`), `compute()`, monthly prices, `sanitize()`/`migrate()`, customer requirements, events, geography pricing and latency, second sites and service | +| `80-simulation/` | Dijkstra, RouteScript, where a DDoS flood goes (`ddosLoad()`/`ddosAfter()`, called by `compute()`), `compute()`, monthly prices, `sanitize()`/`migrate()`, customer requirements, events, the customer lifecycle (contracts, renewals, the bandwidth market, why customers leave), geography pricing and latency, second sites and service | | `85-incidents/` | `addInc()`, DDoS attacks (targets, sizes, scoring, the NOC card) and scrubbing, `fireFailure()`, `clearInc()`, `fireEvent()`, the chaos monkey, cable ships (`50-cable-ships.js`: a subsea cut sends a club ship from its port along the cable routes; voyages in `S.fleet`, drawn by `96-map/88-cable-ships.js`) | | `88-days/` | `dayTick()`, new offers, badges, `checkGoals()` | | `90-actions/` | The `ACT` map, one file per area (`const ACT` in `10-interface.js`, `Object.assign(ACT,…)` in the rest), and their helpers | diff --git a/scripts/lib/fuzz-page.js b/scripts/lib/fuzz-page.js index 71d5ca5..2070d32 100644 --- a/scripts/lib/fuzz-page.js +++ b/scripts/lib/fuzz-page.js @@ -154,8 +154,15 @@ return r + '\n' + fl + '\n' + pf; }; const parts = () => { const o = {}; if (!R) return o; for (const k of Object.keys(R)) o[k] = JSON.stringify(R[k]); o.fl = R.fl ? JSON.stringify(R.fl) : ''; return o; }; - const sDigest = () => JSON.stringify(S); - const sParts = () => { const o = {}; for (const k of Object.keys(S)) o[k] = JSON.stringify(S[k]); return o; }; + // A field only this checkout's game has (a new feature's state, on S or on its customers and offers) cannot match main + // yet: the driver passes those (drop) and they are left out; every field both games have must still match. + const sKeys = () => ({ top: Object.keys(S), items: [...new Set([...(S.biz || []), ...(S.offers || [])].flatMap((x) => Object.keys(x)))] }); + const sDrop = (drop) => { if (!drop || (!drop.top.length && !drop.items.length)) return S; const o = {}; + for (const k of Object.keys(S)) if (!drop.top.includes(k)) o[k] = S[k]; + for (const k of ['biz', 'offers']) if (Array.isArray(o[k])) o[k] = o[k].map((x) => { const y = {}; for (const f of Object.keys(x)) if (!drop.items.includes(f)) y[f] = x[f]; return y; }); + return o; }; + const sDigest = (drop) => JSON.stringify(sDrop(drop)); + const sParts = (drop) => { const s = sDrop(drop), o = {}; for (const k of Object.keys(s)) o[k] = JSON.stringify(s[k]); return o; }; /* After a move: what the move routed (a), routing again from the same state (b: on this checkout's page the kept tables are used), and routing from that state with the cache off (c: RC.on=false where there is an RC). b and c route from the same previous R; c's R is kept, as a plain compute would. */ @@ -170,5 +177,5 @@ if (keep) UI.rkR = R; return { a, b, c }; }; - window.__fz = { direct, lists, start, state, screen, press, close, poke, day, routing, parts, sDigest, sParts, check, errs, modalOpen }; + window.__fz = { direct, lists, start, state, screen, press, close, poke, day, routing, parts, sKeys, sDigest, sParts, check, errs, modalOpen }; })(); diff --git a/scripts/lib/route-fuzz.js b/scripts/lib/route-fuzz.js index b5b5eb2..bbc1683 100644 --- a/scripts/lib/route-fuzz.js +++ b/scripts/lib/route-fuzz.js @@ -78,8 +78,10 @@ function playGame(pages, seed, opts = {}) { const [x, y] = both('check'); for (const k of ['a', 'b', 'c']) if (x[k] !== y[k]) { fail(where + ': routing (' + k + ') base vs head', { diff: firstDiff(base.call('parts'), head.call('parts')) }); return false; } if (y.b !== y.c) { fail(where + ': head cached vs uncached', { diff: 'R from the kept tables differs from a fresh route' }); return false; } - const [s1, s2] = both('sDigest'); - if (s1 !== s2) { fail(where + ': game state S', { diff: firstDiff(base.call('sParts'), head.call('sParts')) }); return false; } + // Fields only this checkout's game has are left out on both sides (see sKeys in fuzz-page.js). + const [k1, k2] = both('sKeys'), drop = { top: k2.top.filter((k) => !k1.top.includes(k)), items: k2.items.filter((k) => !k1.items.includes(k)) }; + const [s1, s2] = both('sDigest', drop); + if (s1 !== s2) { fail(where + ': game state S', { diff: firstDiff(base.call('sParts', drop), head.call('sParts', drop)) }); return false; } return true; }; diff --git a/site/i18n/de.js b/site/i18n/de.js index 159a8d4..248b069 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -2605,6 +2605,84 @@ "lease_swaps.your_fiber_here_has_room_for":"Deine Glasfaser hier hat Platz für {free} weitere Kanäle, für den Umzug dieser Mieten brauchst du aber {n}. Beleuchte zuerst ein weiteres Faserpaar oder rüste das Line System auf.", "lease_swaps.your_own_cable_up_up_front":"Dein eigenes Kabel: {up} vorab, {mo}/Monat, etwa {n} Tage Bauzeit.", "lease_swaps.your_own_fiber_up_up_front":"Deine eigene Glasfaser: {up} vorab, {mo}/Monat, etwa {n} Tage Bauzeit.", +"lifecycle.acquired_stays_bigger":"{name} wurde übernommen und bleibt bei dir, größer: jetzt {bw}.", +"lifecycle.bandwidth_market":"Bandbreitenmarkt", +"lifecycle.bandwidth_prices":"Bandbreitenpreise", +"lifecycle.contract_until":"Vertrag bis {date}", +"lifecycle.haggle":"{name} ({city}) will für {price}/Monat verlängern, {p} weniger. Die Konkurrenz bietet mit. Antworte in den Deals innerhalb von {n} Tagen.", +"lifecycle.last_12_months":"letzte 12 Monate", +"lifecycle.left_acquired":"{name} wurde übernommen, und der Käufer zieht alles auf sein eigenes Netz um.", +"lifecycle.left_bust":"{name} ist pleite. Der Hype ist ohne sie weitergezogen.", +"lifecycle.left_cheaper":"{name} hat ein günstigeres Angebot der Konkurrenz in {city} angenommen.", +"lifecycle.left_insourced":"{name} ist groß genug für ein eigenes Backbone und peert künftig mit dir, statt zu kaufen.", +"lifecycle.left_moved":"{name} ist aus {city} weggezogen, an einen Ort ohne deinen POP.", +"lifecycle.left_multihomed":"{name} hat seinen ganzen Verkehr zu einem zweiten Anbieter verlegt.", +"lifecycle.left_odd":"{name} hat nicht verlängert. {why}", +"lifecycle.left_project_ended":"Das Projekt von {name} ist vorbei, und die Leitung geht mit.", +"lifecycle.left_unhappy":"{name} hat nicht verlängert: Der Service hat sie zu oft im Stich gelassen.", +"lifecycle.let_go":"{name} ist weg. Der Vertrag lief ohnehin aus.", +"lifecycle.let_them_go":"Ziehen lassen", +"lifecycle.lost":"Verloren", +"lifecycle.market_above":"{p} über deinem Start", +"lifecycle.market_as_start":"wie bei deinem Start", +"lifecycle.market_below":"{p} unter deinem Start", +"lifecycle.match":"Mitgehen", +"lifecycle.matched":"{name} hat zum gewünschten Preis verlängert.", +"lifecycle.meet_halfway":"In der Mitte treffen", +"lifecycle.meet_no":"{name} hat das Angebot der Konkurrenz genommen und ist weg.", +"lifecycle.meet_yes":"{name} hat dein Angebot angenommen und für {price}/Monat verlängert.", +"lifecycle.moved_stays":"{name} ist von {from} nach {to} gezogen, wo du einen POP hast, und bleibt also.", +"lifecycle.multihomed_keeps":"{name} hat die Hälfte seines Verkehrs zu einem zweiten Anbieter verlegt. Dir bleiben {bw}.", +"lifecycle.n_grew":{"one":"1 gewachsen","other":"{n} gewachsen"}, +"lifecycle.n_more":{"one":"…und 1 weiterer.","other":"…und {n} weitere."}, +"lifecycle.n_renewed":{"one":"1 Vertrag zu heutigen Preisen verlängert ({p}).","other":"{n} Verträge zu heutigen Preisen verlängert ({p})."}, +"lifecycle.next_30_days":"nächste 30 Tage", +"lifecycle.nobody_left_yet":"Bisher ist niemand gegangen.", +"lifecycle.odd_4g_dongle":"Die ganze Firma läuft jetzt über eine SaaS-App an einem 4G-Stick. Es funktioniert prima, und das ist das Schlimmste.", +"lifecycle.odd_95th":"Ihr CFO hat 95. Perzentil auf der Rechnung gesehen und glaubt, du berechnest die 95 schlimmsten Tage.", +"lifecycle.odd_alphabetical":"Ihr Rebranding-Budget ist aufgebraucht, also sparen sie alphabetisch, und du warst zuerst dran.", +"lifecycle.odd_asn_six":"Ihr neuer CTO traut nur ASNs mit genau drei Siebenen.", +"lifecycle.odd_bad_holiday":"Sie haben herausgefunden, dass du ihre Pakete durch eine Stadt leitest, in der sie mal einen miesen Urlaub hatten.", +"lifecycle.odd_bought_thrice":"Sie wurden von einer Firma gekauft, die von einer Firma gekauft wurde, die schon ein Netz hat. Niemand weiß, wer das Sagen hat.", +"lifecycle.odd_center":"Sie haben gelesen, dass Latenz zählt, und ziehen näher an die Mitte des Internets. Sie glauben, die liegt auf einem Feld auf dem Land.", +"lifecycle.odd_communities":"Sie sind zu einem Anbieter gewechselt, dessen BGP-Communities besser dokumentiert sind. Es gibt zwei davon.", +"lifecycle.odd_dead_beef":"Sie wollten eine IPv6-Adresse, die ihren Namen in Hex buchstabiert. :dead:beef war schon vergeben.", +"lifecycle.odd_espresso":"Die neue Espressomaschine im Büro lässt die Sicherung fliegen. Sie geben dem Router die Schuld, also dir.", +"lifecycle.odd_fewer_vendors":"Der neue CEO will weniger Lieferanten. Du warst der einzige. Jetzt haben sie keinen und sind begeistert.", +"lifecycle.odd_goat_farmer":"Die Person, die bei dir unterschrieben hat, ist Ziegenbäuerin geworden, und die Nachfolge macht alles anders.", +"lifecycle.odd_holiday_card":"Deine Weihnachtskarte kam pünktlich an. Das hat sie misstrauisch gemacht.", +"lifecycle.odd_landlord":"Ihr Vermieter kassiert pro Kabel durch die Wand, und deins ist dick und auffällig.", +"lifecycle.odd_looking_glass":"Dein Looking Glass war eine Stunde weg, und ihr NOC-Leiter hat das persönlich genommen.", +"lifecycle.odd_mate":"Dein Account Manager hat ihren Account Manager in einer Mail Kumpel genannt. Sie sind keine Kumpel.", +"lifecycle.odd_quadrant":"Ein Berater hat eine Folie mit einem Quadranten gemacht, und du warst im falschen.", +"lifecycle.odd_raccoon":"Ein Waschbär ist in ihren einzigen Schrank gezogen und scheint mit dem Cross-Connect eines anderen Carriers glücklicher.", +"lifecycle.odd_rdns":"Dein Reverse-DNS für ihre IP lautet customer-cheapskate-04. Jemand aus ihrem Team hat es bemerkt.", +"lifecycle.odd_space":"Sie haben auf eine KI-native, blockchainbasierte Satellite-first-Strategie umgeschwenkt, und deine Faser ist nicht im All.", +"lifecycle.odd_spreadsheet_cell":"Neue Regel im Einkauf: Jeder Lieferantenname muss ohne Umbruch in eine Tabellenzelle passen.", +"lifecycle.odd_the_cloud":"Sie ziehen alles in die Cloud. Die Cloud ist ein Rack zwei Straßen weiter, angebunden von dir. Sie haben es noch nicht gemerkt.", +"lifecycle.odd_too_many_feet":"Ihr Praktikant hat zum Angeben ein Traceroute gemacht, 14 Hops gesehen und erklärt, das seien zu viele Füße.", +"lifecycle.odd_wireguard":"Sie gehen komplett remote. Alle 40 Leute fahren WireGuard aus ihren Küchen, und die Büroleitung ist nur noch für die Pflanzen.", +"lifecycle.odd_wrong_blue":"Die neue Büroleitung will alle Kabel in derselben Farbe, und deins ist das falsche Blau.", +"lifecycle.referred_by":"Empfohlen von {name}, einem deiner zufriedensten Kunden.", +"lifecycle.renewal_haggle":"Verlängerung am {date}: wird verhandelt", +"lifecycle.renewals":"Verlängerungen", +"lifecycle.renewals_soon":"Verlängerungen", +"lifecycle.renewed_and_grew":"{name} hat verlängert und auf {bw} aufgestockt ({city}).", +"lifecycle.unanswered_matches":"Ohne Antwort bis Vertragsende gehst du auf ihren Preis ein.", +"lifecycle.wants_price":"Zahlt {was}/Monat, will für {price}/Monat ({p} weniger) verlängern.", +"lifecycle.why_acquired":"Übernommen", +"lifecycle.why_bust":"Pleite", +"lifecycle.why_cheaper_bid":"Günstigeres Angebot", +"lifecycle.why_insourced":"Eigenes Netz gebaut", +"lifecycle.why_moved":"Weggezogen", +"lifecycle.why_multihomed":"Zu einem zweiten Anbieter", +"lifecycle.why_other":"Andere Gründe", +"lifecycle.why_project_ended":"Projekt beendet", +"lifecycle.why_they_left":"Warum sie gingen", +"lifecycle.why_unhappy":"Unzufrieden mit dem Service", +"lifecycle.won":"Gewonnen", +"lifecycle.won_and_lost":"Gewonnene und verlorene Kunden", +"lifecycle.won_and_lost_note":"Verträge laufen ein bis fünf Jahre, Faserpaare zehn bis zwanzig. Läuft einer aus, verlängern die meisten zum heutigen Marktpreis, und zufriedene wachsen oft. Manche gehen, und nicht immer deinetwegen.", "link_modal.building_into_mainland_china_needs_a":"Für den Ausbau nach Festlandchina brauchst du ein Joint Venture und eine Betriebslizenz. Öffne {city}, um sie zu beantragen.", "link_modal.cross_border_circuits_into_mainland":"Grenzüberschreitende Verbindungen nach Festlandchina verkaufen nur lizenzierte Carrier, zum dreifachen Preis. Normale verlieren an der Grenze etwa 20 % des Traffics.", "link_modal.diverse_route_40_survives_cuts_alone":"Redundante Route +40 % · übersteht Schnitte allein", diff --git a/site/i18n/es.js b/site/i18n/es.js index 6b51464..2bcc245 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -2603,6 +2603,84 @@ "lease_swaps.your_fiber_here_has_room_for":"Tu fibra de aquí tiene sitio para {free} canales más, y mover estos alquileres necesita {n}. Ilumina otro par de fibra o mejora antes el sistema de línea.", "lease_swaps.your_own_cable_up_up_front":"Tu propio cable: {up} por adelantado, {mo}/mes, unos {n} días de obra.", "lease_swaps.your_own_fiber_up_up_front":"Tu propia fibra: {up} por adelantado, {mo}/mes, unos {n} días de obra.", +"lifecycle.acquired_stays_bigger":"{name} fue adquirida y se queda contigo, más grande: ahora {bw}.", +"lifecycle.bandwidth_market":"Mercado de ancho de banda", +"lifecycle.bandwidth_prices":"Precios del ancho de banda", +"lifecycle.contract_until":"contrato hasta {date}", +"lifecycle.haggle":"{name} ({city}) quiere {price}/mes para renovar, un {p} menos. La competencia está pujando. Responde en Ofertas en {n} días.", +"lifecycle.last_12_months":"últimos 12 meses", +"lifecycle.left_acquired":"{name} fue adquirida, y el comprador lo pasa todo a su propia red.", +"lifecycle.left_bust":"{name} quebró. El hype siguió sin ellos.", +"lifecycle.left_cheaper":"{name} aceptó una oferta más barata de un competidor en {city}.", +"lifecycle.left_insourced":"{name} creció lo bastante para montar su propia red troncal, y ahora hará peering contigo en vez de comprar.", +"lifecycle.left_moved":"{name} se mudó de {city} a un lugar donde no tienes POP.", +"lifecycle.left_multihomed":"{name} pasó todo su tráfico a un segundo proveedor.", +"lifecycle.left_odd":"{name} no renovó. {why}", +"lifecycle.left_project_ended":"El proyecto de {name} terminó, y el circuito se va con él.", +"lifecycle.left_unhappy":"{name} no renovó: el servicio les falló demasiadas veces.", +"lifecycle.let_go":"{name} se fue. Su contrato terminaba de todos modos.", +"lifecycle.let_them_go":"Dejarlos ir", +"lifecycle.lost":"Perdidos", +"lifecycle.market_above":"{p} por encima de cuando empezaste", +"lifecycle.market_as_start":"como cuando empezaste", +"lifecycle.market_below":"{p} por debajo de cuando empezaste", +"lifecycle.match":"Igualar", +"lifecycle.matched":"{name} renovó al precio que pidió.", +"lifecycle.meet_halfway":"Partir la diferencia", +"lifecycle.meet_no":"{name} aceptó la oferta de la competencia y se fue.", +"lifecycle.meet_yes":"{name} aceptó tu oferta y renovó por {price}/mes.", +"lifecycle.moved_stays":"{name} se mudó de {from} a {to}, donde tienes POP, así que se queda.", +"lifecycle.multihomed_keeps":"{name} pasó la mitad de su tráfico a un segundo proveedor. Te quedas con {bw}.", +"lifecycle.n_grew":{"one":"1 creció","other":"{n} crecieron"}, +"lifecycle.n_more":{"one":"…y 1 más.","other":"…y {n} más."}, +"lifecycle.n_renewed":{"one":"1 contrato renovado a precios de hoy ({p}).","other":"{n} contratos renovados a precios de hoy ({p})."}, +"lifecycle.next_30_days":"próximos 30 días", +"lifecycle.nobody_left_yet":"Todavía no se ha ido nadie.", +"lifecycle.odd_4g_dongle":"Toda la empresa funciona ahora con una app SaaS por un pincho 4G. Funciona bien, que es lo peor.", +"lifecycle.odd_95th":"Su director financiero vio percentil 95 en la factura y cree que les cobras los 95 peores días.", +"lifecycle.odd_alphabetical":"Se les acabó el presupuesto del rebranding, así que recortan gastos por orden alfabético, y tú salías primero.", +"lifecycle.odd_asn_six":"Su nuevo CTO solo se fía de los ASN con exactamente tres sietes.", +"lifecycle.odd_bad_holiday":"Descubrieron que enrutas sus paquetes por una ciudad donde una vez tuvieron unas malas vacaciones.", +"lifecycle.odd_bought_thrice":"Los compró una empresa a la que compró una empresa que ya tiene red. Nadie sabe quién manda.", +"lifecycle.odd_center":"Leyeron que la latencia importa, así que se mudan más cerca del centro de internet. Creen que está en un campo en las afueras.", +"lifecycle.odd_communities":"Se pasaron a un proveedor cuyas comunidades BGP están mejor documentadas. Tiene dos.", +"lifecycle.odd_dead_beef":"Querían una dirección IPv6 que deletreara su nombre en hexadecimal. :dead:beef ya estaba ocupada.", +"lifecycle.odd_espresso":"La nueva cafetera de la oficina hace saltar los plomos. Le echan la culpa al router, así que a ti.", +"lifecycle.odd_fewer_vendors":"El nuevo CEO quiere menos proveedores. Tú eras el único. Ahora no tienen ninguno y están encantados.", +"lifecycle.odd_goat_farmer":"La persona que firmó contigo se fue a criar cabras, y su sustituto hace las cosas de otra manera.", +"lifecycle.odd_holiday_card":"Tu tarjeta de felicitación llegó a tiempo. Eso les hizo sospechar.", +"lifecycle.odd_landlord":"Su casero cobra por cada cable que atraviesa la pared, y el tuyo es grueso y llamativo.", +"lifecycle.odd_looking_glass":"Tu looking glass estuvo caído una hora, y su jefe de NOC se lo tomó como algo personal.", +"lifecycle.odd_mate":"Tu gestor de cuenta llamó colega a su gestor de cuenta en un correo. No son colegas.", +"lifecycle.odd_quadrant":"Un consultor hizo una diapositiva con un cuadrante, y tú estabas en el equivocado.", +"lifecycle.odd_raccoon":"Un mapache se instaló en su único armario, y parece más contento con el cross-connect de otro operador.", +"lifecycle.odd_rdns":"Tu DNS inverso para su IP dice customer-cheapskate-04. Alguien de su equipo se dio cuenta.", +"lifecycle.odd_space":"Giraron a una estrategia nativa de IA, respaldada por blockchain y con el satélite primero, y tu fibra no está en el espacio.", +"lifecycle.odd_spreadsheet_cell":"Nueva norma de compras: el nombre de cada proveedor debe caber en una celda sin saltar de línea.", +"lifecycle.odd_the_cloud":"Lo están pasando todo a la nube. La nube es un rack a dos calles, conectado por ti. Aún no se han dado cuenta.", +"lifecycle.odd_too_many_feet":"Su becario hizo un traceroute para lucirse, vio 14 saltos y declaró que eran demasiados pies.", +"lifecycle.odd_wireguard":"Se pasan al teletrabajo total. Los 40 empleados usarán WireGuard desde sus cocinas, y la línea de la oficina es solo para las plantas.", +"lifecycle.odd_wrong_blue":"La nueva responsable de oficina quiere todos los cables del mismo color, y el tuyo es del azul equivocado.", +"lifecycle.referred_by":"Recomendado por {name}, uno de tus clientes más contentos.", +"lifecycle.renewal_haggle":"renovación el {date}: negociando", +"lifecycle.renewals":"Renovaciones", +"lifecycle.renewals_soon":"Renovaciones", +"lifecycle.renewed_and_grew":"{name} renovó y creció a {bw} ({city}).", +"lifecycle.unanswered_matches":"Si no respondes antes de que acabe el contrato, igualas su precio.", +"lifecycle.wants_price":"Paga {was}/mes, quiere {price}/mes ({p} menos) para renovar.", +"lifecycle.why_acquired":"Adquiridos", +"lifecycle.why_bust":"Quebraron", +"lifecycle.why_cheaper_bid":"Oferta más barata", +"lifecycle.why_insourced":"Montaron su propia red", +"lifecycle.why_moved":"Se mudaron", +"lifecycle.why_multihomed":"Se fueron a otro proveedor", +"lifecycle.why_other":"Otros motivos", +"lifecycle.why_project_ended":"Proyecto terminado", +"lifecycle.why_they_left":"Por qué se fueron", +"lifecycle.why_unhappy":"Descontentos con el servicio", +"lifecycle.won":"Ganados", +"lifecycle.won_and_lost":"Clientes ganados y perdidos", +"lifecycle.won_and_lost_note":"Los contratos duran de uno a cinco años, los pares de fibra de diez a veinte. Cuando uno termina, la mayoría renueva al precio de mercado de hoy y los contentos suelen crecer. Algunos se van, y no siempre por tu culpa.", "link_modal.building_into_mainland_china_needs_a":"Construir en China continental necesita una empresa conjunta y una licencia de operación. Abre {city} para solicitarla.", "link_modal.cross_border_circuits_into_mainland":"Los circuitos transfronterizos hacia China continental solo los venden operadores con licencia, a 3× el precio. Los normales pierden cerca del 20 % del tráfico en la frontera.", "link_modal.diverse_route_40_survives_cuts_alone":"Ruta diversa +40 % · sobrevive a cortes sola", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index c530438..eefbefc 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -2603,6 +2603,84 @@ "lease_swaps.your_fiber_here_has_room_for":"Ta fibre ici a de la place pour {free} canaux de plus, et transférer ces locations en demande {n}. Allume d’abord une autre paire de fibres ou mets à niveau le système de ligne.", "lease_swaps.your_own_cable_up_up_front":"Ton propre câble : {up} d’entrée, {mo}/mois, environ {n} jours de travaux.", "lease_swaps.your_own_fiber_up_up_front":"Ta propre fibre : {up} d’entrée, {mo}/mois, environ {n} jours de travaux.", +"lifecycle.acquired_stays_bigger":"{name} a été rachetée et reste chez vous, en plus gros : {bw} désormais.", +"lifecycle.bandwidth_market":"Marché de la bande passante", +"lifecycle.bandwidth_prices":"Prix de la bande passante", +"lifecycle.contract_until":"contrat jusqu'au {date}", +"lifecycle.haggle":"{name} ({city}) veut {price}/mois pour renouveler, soit {p} de moins. La concurrence fait des offres. Répondez dans Offres d'ici {n} jours.", +"lifecycle.last_12_months":"12 derniers mois", +"lifecycle.left_acquired":"{name} a été rachetée, et l'acheteur bascule tout sur son propre réseau.", +"lifecycle.left_bust":"{name} a fait faillite. La hype est passée à autre chose sans eux.", +"lifecycle.left_cheaper":"{name} a accepté une offre moins chère d'un concurrent à {city}.", +"lifecycle.left_insourced":"{name} est devenue assez grande pour construire son propre backbone, et fera du peering avec vous au lieu d'acheter.", +"lifecycle.left_moved":"{name} a quitté {city} pour un endroit où vous n'avez pas de POP.", +"lifecycle.left_multihomed":"{name} a basculé tout son trafic chez un second fournisseur.", +"lifecycle.left_odd":"{name} n'a pas renouvelé. {why}", +"lifecycle.left_project_ended":"Le projet de {name} est terminé, et le circuit part avec.", +"lifecycle.left_unhappy":"{name} n'a pas renouvelé : le service les a trop souvent déçus.", +"lifecycle.let_go":"{name} est partie. Son contrat arrivait à échéance de toute façon.", +"lifecycle.let_them_go":"Les laisser partir", +"lifecycle.lost":"Perdus", +"lifecycle.market_above":"{p} au-dessus de vos débuts", +"lifecycle.market_as_start":"comme à vos débuts", +"lifecycle.market_below":"{p} en dessous de vos débuts", +"lifecycle.match":"S'aligner", +"lifecycle.matched":"{name} a renouvelé au prix demandé.", +"lifecycle.meet_halfway":"Couper la poire en deux", +"lifecycle.meet_no":"{name} a pris l'offre du concurrent et est partie.", +"lifecycle.meet_yes":"{name} a accepté votre offre et renouvelé à {price}/mois.", +"lifecycle.moved_stays":"{name} a déménagé de {from} à {to}, où vous avez un POP : elle reste.", +"lifecycle.multihomed_keeps":"{name} a basculé la moitié de son trafic chez un second fournisseur. Il vous reste {bw}.", +"lifecycle.n_grew":{"one":"1 a grossi","other":"{n} ont grossi"}, +"lifecycle.n_more":{"one":"…et 1 autre.","other":"…et {n} autres."}, +"lifecycle.n_renewed":{"one":"1 contrat renouvelé aux prix du jour ({p}).","other":"{n} contrats renouvelés aux prix du jour ({p})."}, +"lifecycle.next_30_days":"30 prochains jours", +"lifecycle.nobody_left_yet":"Personne n'est encore parti.", +"lifecycle.odd_4g_dongle":"Toute l'entreprise tourne désormais sur une appli SaaS via une clé 4G. Ça marche très bien, et c'est le pire.", +"lifecycle.odd_95th":"Leur directeur financier a vu 95e centile sur la facture et croit que vous facturez les 95 pires jours.", +"lifecycle.odd_alphabetical":"Leur budget de changement d'image est épuisé, alors ils réduisent les coûts par ordre alphabétique, et vous êtes arrivé en premier.", +"lifecycle.odd_asn_six":"Leur nouveau CTO ne fait confiance qu'aux ASN qui contiennent exactement trois 7.", +"lifecycle.odd_bad_holiday":"Ils ont découvert que vous faites passer leurs paquets par une ville où ils ont passé de mauvaises vacances.", +"lifecycle.odd_bought_thrice":"Ils ont été rachetés par une entreprise rachetée par une entreprise qui a déjà un réseau. Personne ne sait qui commande.", +"lifecycle.odd_center":"Ils ont lu que la latence compte, alors ils se rapprochent du centre d'Internet. Ils pensent qu'il est dans un champ à la campagne.", +"lifecycle.odd_communities":"Ils sont passés chez un fournisseur dont les communautés BGP sont mieux documentées. Il y en a deux.", +"lifecycle.odd_dead_beef":"Ils voulaient une adresse IPv6 qui épelle leur nom en hexadécimal. :dead:beef était déjà prise.", +"lifecycle.odd_espresso":"La nouvelle machine à espresso du bureau fait sauter le disjoncteur. Ils accusent le routeur, donc vous.", +"lifecycle.odd_fewer_vendors":"Le nouveau PDG veut moins de fournisseurs. Vous étiez le seul. Ils n'en ont plus aucun, et sont ravis.", +"lifecycle.odd_goat_farmer":"La personne qui avait signé avec vous est partie élever des chèvres, et son remplaçant fait les choses autrement.", +"lifecycle.odd_holiday_card":"Votre carte de vœux est arrivée à l'heure. Ça les a rendus méfiants.", +"lifecycle.odd_landlord":"Leur propriétaire facture chaque câble qui traverse le mur, et le vôtre est épais et voyant.", +"lifecycle.odd_looking_glass":"Votre looking glass a été en panne une heure, et leur chef de NOC l'a pris personnellement.", +"lifecycle.odd_mate":"Votre chargé de compte a appelé leur chargé de compte mon pote dans un e-mail. Ils ne sont pas potes.", +"lifecycle.odd_quadrant":"Un consultant a fait une diapo avec un quadrant, et vous étiez dans le mauvais.", +"lifecycle.odd_raccoon":"Un raton laveur s'est installé dans leur unique baie, et il semble préférer le cross-connect d'un autre opérateur.", +"lifecycle.odd_rdns":"Votre DNS inverse pour leur IP indique customer-cheapskate-04. Quelqu'un de leur équipe l'a remarqué.", +"lifecycle.odd_space":"Ils ont pivoté vers une stratégie IA-native, adossée à la blockchain et satellite d'abord, et votre fibre n'est pas dans l'espace.", +"lifecycle.odd_spreadsheet_cell":"Nouvelle règle des achats : le nom de chaque fournisseur doit tenir dans une cellule de tableur sans retour à la ligne.", +"lifecycle.odd_the_cloud":"Ils migrent tout vers le cloud. Le cloud est une baie à deux rues de là, raccordée par vous. Ils ne l'ont pas encore remarqué.", +"lifecycle.odd_too_many_feet":"Leur stagiaire a lancé un traceroute pour frimer, a vu 14 sauts et a déclaré que ça faisait trop de pieds.", +"lifecycle.odd_wireguard":"Ils passent en télétravail complet. Les 40 salariés utiliseront WireGuard depuis leur cuisine, et la ligne du bureau ne sert plus qu'aux plantes.", +"lifecycle.odd_wrong_blue":"La nouvelle responsable des locaux veut tous les câbles de la même couleur, et le vôtre n'est pas le bon bleu.", +"lifecycle.referred_by":"Recommandé par {name}, l'un de vos clients les plus satisfaits.", +"lifecycle.renewal_haggle":"renouvellement le {date} : en négociation", +"lifecycle.renewals":"Renouvellements", +"lifecycle.renewals_soon":"Renouvellements", +"lifecycle.renewed_and_grew":"{name} a renouvelé et passe à {bw} ({city}).", +"lifecycle.unanswered_matches":"Sans réponse avant la fin du contrat, vous vous alignez sur leur prix.", +"lifecycle.wants_price":"Paie {was}/mois, veut {price}/mois ({p} de moins) pour renouveler.", +"lifecycle.why_acquired":"Rachetés", +"lifecycle.why_bust":"Faillite", +"lifecycle.why_cheaper_bid":"Offre moins chère", +"lifecycle.why_insourced":"Ont construit leur réseau", +"lifecycle.why_moved":"Ont déménagé", +"lifecycle.why_multihomed":"Partis chez un second fournisseur", +"lifecycle.why_other":"Autres raisons", +"lifecycle.why_project_ended":"Projet terminé", +"lifecycle.why_they_left":"Pourquoi ils sont partis", +"lifecycle.why_unhappy":"Mécontents du service", +"lifecycle.won":"Gagnés", +"lifecycle.won_and_lost":"Clients gagnés et perdus", +"lifecycle.won_and_lost_note":"Les contrats durent de un à cinq ans, les paires de fibre de dix à vingt. À l'échéance, la plupart renouvellent au prix du marché du jour et les clients satisfaits grossissent souvent. Certains partent, et pas toujours à cause de vous.", "link_modal.building_into_mainland_china_needs_a":"Construire en Chine continentale exige une coentreprise et une licence d’opérateur. Ouvre {city} pour faire la demande.", "link_modal.cross_border_circuits_into_mainland":"Les circuits transfrontaliers vers la Chine continentale ne sont vendus que par des opérateurs titulaires d’une licence, à 3× le prix. Les circuits normaux perdent environ 20 % du trafic à la frontière.", "link_modal.diverse_route_40_survives_cuts_alone":"Chemin diversifié +40 % · survit seul aux coupures", diff --git a/site/i18n/it.js b/site/i18n/it.js index e37fafe..e75fe8d 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2603,6 +2603,84 @@ "lease_swaps.your_fiber_here_has_room_for":"La tua fibra qui ha spazio per altri {free} canali, e spostare questi affitti ne richiede {n}. Prima accendi un'altra coppia di fibre o aggiorna il line system.", "lease_swaps.your_own_cable_up_up_front":"Il tuo cavo: {up} subito, {mo}/mese, circa {n} giorni di lavori.", "lease_swaps.your_own_fiber_up_up_front":"La tua fibra: {up} subito, {mo}/mese, circa {n} giorni di lavori.", +"lifecycle.acquired_stays_bigger":"{name} è stata acquisita e resta con te, più grande: ora {bw}.", +"lifecycle.bandwidth_market":"Mercato della banda", +"lifecycle.bandwidth_prices":"Prezzi della banda", +"lifecycle.contract_until":"contratto fino al {date}", +"lifecycle.haggle":"{name} ({city}) vuole {price}/mese per rinnovare, il {p} in meno. La concorrenza fa offerte. Rispondi nelle Offerte entro {n} giorni.", +"lifecycle.last_12_months":"ultimi 12 mesi", +"lifecycle.left_acquired":"{name} è stata acquisita, e chi l'ha comprata sposta tutto sulla propria rete.", +"lifecycle.left_bust":"{name} è fallita. L'hype è andato avanti senza di loro.", +"lifecycle.left_cheaper":"{name} ha accettato un'offerta più economica di un concorrente a {city}.", +"lifecycle.left_insourced":"{name} è diventata abbastanza grande da costruirsi la propria dorsale, e farà peering con te invece di comprare.", +"lifecycle.left_moved":"{name} si è trasferita da {city} in un posto dove non hai un POP.", +"lifecycle.left_multihomed":"{name} ha spostato tutto il suo traffico su un secondo fornitore.", +"lifecycle.left_odd":"{name} non ha rinnovato. {why}", +"lifecycle.left_project_ended":"Il progetto di {name} è finito, e il circuito se ne va con lui.", +"lifecycle.left_unhappy":"{name} non ha rinnovato: il servizio li ha delusi troppe volte.", +"lifecycle.let_go":"{name} se n'è andata. Il contratto scadeva comunque.", +"lifecycle.let_them_go":"Lasciarli andare", +"lifecycle.lost":"Persi", +"lifecycle.market_above":"{p} sopra a quando hai iniziato", +"lifecycle.market_as_start":"come quando hai iniziato", +"lifecycle.market_below":"{p} sotto a quando hai iniziato", +"lifecycle.match":"Accettare", +"lifecycle.matched":"{name} ha rinnovato al prezzo richiesto.", +"lifecycle.meet_halfway":"Venirsi incontro", +"lifecycle.meet_no":"{name} ha preso l'offerta del concorrente e se n'è andata.", +"lifecycle.meet_yes":"{name} ha accettato la tua offerta e rinnovato a {price}/mese.", +"lifecycle.moved_stays":"{name} si è trasferita da {from} a {to}, dove hai un POP, quindi resta.", +"lifecycle.multihomed_keeps":"{name} ha spostato metà del traffico su un secondo fornitore. A te restano {bw}.", +"lifecycle.n_grew":{"one":"1 è cresciuto","other":"{n} sono cresciuti"}, +"lifecycle.n_more":{"one":"…e 1 altro.","other":"…e altri {n}."}, +"lifecycle.n_renewed":{"one":"1 contratto rinnovato ai prezzi di oggi ({p}).","other":"{n} contratti rinnovati ai prezzi di oggi ({p})."}, +"lifecycle.next_30_days":"prossimi 30 giorni", +"lifecycle.nobody_left_yet":"Finora non se n'è andato nessuno.", +"lifecycle.odd_4g_dongle":"Tutta l'azienda ora gira su un'app SaaS con una chiavetta 4G. Funziona benissimo, ed è la parte peggiore.", +"lifecycle.odd_95th":"Il loro CFO ha visto 95° percentile in fattura e pensa che fatturi i 95 giorni peggiori.", +"lifecycle.odd_alphabetical":"Il budget del rebranding è finito, quindi tagliano i costi in ordine alfabetico, e tu eri il primo.", +"lifecycle.odd_asn_six":"Il loro nuovo CTO si fida solo degli ASN con esattamente tre 7.", +"lifecycle.odd_bad_holiday":"Hanno scoperto che instradi i loro pacchetti attraverso una città dove una volta hanno fatto una brutta vacanza.", +"lifecycle.odd_bought_thrice":"Li ha comprati un'azienda comprata da un'azienda che ha già una rete. Nessuno sa chi comanda.", +"lifecycle.odd_center":"Hanno letto che la latenza conta, quindi si avvicinano al centro di internet. Pensano che sia in un campo in campagna.", +"lifecycle.odd_communities":"Sono passati a un fornitore con le community BGP meglio documentate. Ne ha due.", +"lifecycle.odd_dead_beef":"Volevano un indirizzo IPv6 che scrivesse il loro nome in esadecimale. :dead:beef era già preso.", +"lifecycle.odd_espresso":"La nuova macchina dell'espresso dell'ufficio fa saltare la corrente. Danno la colpa al router, quindi a te.", +"lifecycle.odd_fewer_vendors":"Il nuovo CEO vuole meno fornitori. Eri l'unico. Ora non ne hanno nessuno, e sono felicissimi.", +"lifecycle.odd_goat_farmer":"La persona che aveva firmato con te è andata ad allevare capre, e chi l'ha sostituita fa le cose diversamente.", +"lifecycle.odd_holiday_card":"Il tuo biglietto di auguri è arrivato in tempo. Questo li ha insospettiti.", +"lifecycle.odd_landlord":"Il loro padrone di casa fa pagare ogni cavo che passa nel muro, e il tuo è spesso e vistoso.", +"lifecycle.odd_looking_glass":"Il tuo looking glass è stato giù per un'ora, e il loro capo NOC l'ha presa sul personale.", +"lifecycle.odd_mate":"Il tuo account manager ha chiamato il loro account manager amico in un'email. Non sono amici.", +"lifecycle.odd_quadrant":"Un consulente ha fatto una slide con un quadrante, e tu eri in quello sbagliato.", +"lifecycle.odd_raccoon":"Un procione si è trasferito nel loro unico armadio, e sembra più felice con il cross-connect di un altro operatore.", +"lifecycle.odd_rdns":"Il tuo DNS inverso per il loro IP dice customer-cheapskate-04. Qualcuno del loro team se n'è accorto.", +"lifecycle.odd_space":"Hanno virato su una strategia AI-native, basata su blockchain e satellite-first, e la tua fibra non è nello spazio.", +"lifecycle.odd_spreadsheet_cell":"Nuova regola degli acquisti: il nome di ogni fornitore deve stare in una cella senza andare a capo.", +"lifecycle.odd_the_cloud":"Stanno spostando tutto nel cloud. Il cloud è un rack a due strade di distanza, collegato da te. Non se ne sono ancora accorti.", +"lifecycle.odd_too_many_feet":"Il loro stagista ha lanciato un traceroute per fare scena, ha visto 14 hop e ha dichiarato che erano troppi piedi.", +"lifecycle.odd_wireguard":"Passano al lavoro tutto da remoto. I 40 dipendenti useranno WireGuard dalle loro cucine, e la linea dell'ufficio serve solo alle piante.", +"lifecycle.odd_wrong_blue":"Il nuovo responsabile dell'ufficio vuole tutti i cavi dello stesso colore, e il tuo è del blu sbagliato.", +"lifecycle.referred_by":"Consigliato da {name}, uno dei tuoi clienti più contenti.", +"lifecycle.renewal_haggle":"rinnovo il {date}: si tratta", +"lifecycle.renewals":"Rinnovi", +"lifecycle.renewals_soon":"Rinnovi", +"lifecycle.renewed_and_grew":"{name} ha rinnovato ed è salita a {bw} ({city}).", +"lifecycle.unanswered_matches":"Senza risposta entro la fine del contratto, accetti il loro prezzo.", +"lifecycle.wants_price":"Paga {was}/mese, vuole {price}/mese ({p} in meno) per rinnovare.", +"lifecycle.why_acquired":"Acquisiti", +"lifecycle.why_bust":"Falliti", +"lifecycle.why_cheaper_bid":"Offerta più economica", +"lifecycle.why_insourced":"Rete propria", +"lifecycle.why_moved":"Trasferiti", +"lifecycle.why_multihomed":"Passati a un secondo fornitore", +"lifecycle.why_other":"Altri motivi", +"lifecycle.why_project_ended":"Progetto finito", +"lifecycle.why_they_left":"Perché se ne sono andati", +"lifecycle.why_unhappy":"Scontenti del servizio", +"lifecycle.won":"Acquisiti", +"lifecycle.won_and_lost":"Clienti acquisiti e persi", +"lifecycle.won_and_lost_note":"I contratti durano da uno a cinque anni, le coppie di fibra da dieci a venti. Alla scadenza quasi tutti rinnovano al prezzo di mercato di oggi, e i clienti contenti spesso crescono. Alcuni se ne vanno, e non sempre per colpa tua.", "link_modal.building_into_mainland_china_needs_a":"Per costruire nella Cina continentale servono una joint venture e una licenza operativa. Apri {city} per fare domanda.", "link_modal.cross_border_circuits_into_mainland":"I circuiti transfrontalieri verso la Cina continentale li vendono solo carrier con licenza, a 3× il prezzo. Quelli normali perdono circa il 20% del traffico al confine.", "link_modal.diverse_route_40_survives_cuts_alone":"Percorso diverso +40% · sopravvive da solo ai tagli", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 06e7c30..2145d01 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -2603,6 +2603,84 @@ "lease_swaps.your_fiber_here_has_room_for":"Sua fibra aqui tem espaço para mais {free} canais, e mover esses aluguéis exige {n}. Acenda outro par de fibras ou atualize o line system primeiro.", "lease_swaps.your_own_cable_up_up_front":"Seu próprio cabo: {up} à vista, {mo}/mês, cerca de {n} dias de obra.", "lease_swaps.your_own_fiber_up_up_front":"Sua própria fibra: {up} à vista, {mo}/mês, cerca de {n} dias de obra.", +"lifecycle.acquired_stays_bigger":"{name} foi comprada e continua com você, maior: agora {bw}.", +"lifecycle.bandwidth_market":"Mercado de banda", +"lifecycle.bandwidth_prices":"Preços de banda", +"lifecycle.contract_until":"contrato até {date}", +"lifecycle.haggle":"{name} ({city}) quer {price}/mês para renovar, {p} a menos. A concorrência está dando lances. Responda em Negócios em até {n} dias.", +"lifecycle.last_12_months":"últimos 12 meses", +"lifecycle.left_acquired":"{name} foi comprada, e o comprador leva tudo para a própria rede.", +"lifecycle.left_bust":"{name} faliu. O hype seguiu em frente sem eles.", +"lifecycle.left_cheaper":"{name} aceitou uma proposta mais barata de um concorrente em {city}.", +"lifecycle.left_insourced":"{name} cresceu o bastante para montar o próprio backbone, e vai fazer peering com você em vez de comprar.", +"lifecycle.left_moved":"{name} saiu de {city} para um lugar onde você não tem POP.", +"lifecycle.left_multihomed":"{name} passou todo o tráfego para um segundo provedor.", +"lifecycle.left_odd":"{name} não renovou. {why}", +"lifecycle.left_project_ended":"O projeto de {name} acabou, e o circuito vai junto.", +"lifecycle.left_unhappy":"{name} não renovou: o serviço falhou com eles vezes demais.", +"lifecycle.let_go":"{name} foi embora. O contrato estava acabando de qualquer jeito.", +"lifecycle.let_them_go":"Deixar ir", +"lifecycle.lost":"Perdidos", +"lifecycle.market_above":"{p} acima do começo", +"lifecycle.market_as_start":"como no começo", +"lifecycle.market_below":"{p} abaixo do começo", +"lifecycle.match":"Igualar", +"lifecycle.matched":"{name} renovou pelo preço que pediu.", +"lifecycle.meet_halfway":"Meio-termo", +"lifecycle.meet_no":"{name} aceitou a proposta do concorrente e foi embora.", +"lifecycle.meet_yes":"{name} aceitou sua proposta e renovou por {price}/mês.", +"lifecycle.moved_stays":"{name} mudou de {from} para {to}, onde você tem POP, então fica.", +"lifecycle.multihomed_keeps":"{name} passou metade do tráfego para um segundo provedor. Você fica com {bw}.", +"lifecycle.n_grew":{"one":"1 cresceu","other":"{n} cresceram"}, +"lifecycle.n_more":{"one":"…e mais 1.","other":"…e mais {n}."}, +"lifecycle.n_renewed":{"one":"1 contrato renovado aos preços de hoje ({p}).","other":"{n} contratos renovados aos preços de hoje ({p})."}, +"lifecycle.next_30_days":"próximos 30 dias", +"lifecycle.nobody_left_yet":"Ninguém saiu ainda.", +"lifecycle.odd_4g_dongle":"A empresa inteira agora roda num app SaaS por um modem 4G. Funciona bem, e essa é a pior parte.", +"lifecycle.odd_95th":"O diretor financeiro deles viu percentil 95 na fatura e acha que você cobra os 95 piores dias.", +"lifecycle.odd_alphabetical":"O orçamento do rebranding acabou, então estão cortando custos em ordem alfabética, e você apareceu primeiro.", +"lifecycle.odd_asn_six":"O novo CTO deles só confia em ASNs com exatamente três setes.", +"lifecycle.odd_bad_holiday":"Descobriram que você roteia os pacotes deles por uma cidade onde tiveram umas férias ruins.", +"lifecycle.odd_bought_thrice":"Foram comprados por uma empresa que foi comprada por uma empresa que já tem rede. Ninguém sabe quem manda.", +"lifecycle.odd_center":"Leram que latência importa, então estão se mudando para perto do centro da internet. Acham que fica num campo no interior.", +"lifecycle.odd_communities":"Mudaram para um provedor cujas comunidades BGP são mais bem documentadas. São duas.", +"lifecycle.odd_dead_beef":"Queriam um endereço IPv6 que soletrasse o nome deles em hexadecimal. :dead:beef já estava em uso.", +"lifecycle.odd_espresso":"A nova máquina de espresso do escritório derruba o disjuntor. Eles culpam o roteador, então culpam você.", +"lifecycle.odd_fewer_vendors":"O novo CEO quer menos fornecedores. Você era o único. Agora eles não têm nenhum, e estão felizes.", +"lifecycle.odd_goat_farmer":"A pessoa que assinou com você saiu para criar cabras, e quem entrou no lugar faz tudo diferente.", +"lifecycle.odd_holiday_card":"Seu cartão de fim de ano chegou na hora. Isso os deixou desconfiados.", +"lifecycle.odd_landlord":"O proprietário cobra por cabo que atravessa a parede, e o seu é grosso e chamativo.", +"lifecycle.odd_looking_glass":"Seu looking glass ficou fora do ar por uma hora, e o chefe do NOC deles levou para o lado pessoal.", +"lifecycle.odd_mate":"Seu gerente de conta chamou o gerente de conta deles de parceiro num e-mail. Eles não são parceiros.", +"lifecycle.odd_quadrant":"Um consultor fez um slide com um quadrante, e você estava no errado.", +"lifecycle.odd_raccoon":"Um guaxinim se mudou para o único rack deles, e parece mais feliz com o cross-connect de outra operadora.", +"lifecycle.odd_rdns":"Seu DNS reverso para o IP deles diz customer-cheapskate-04. Alguém da equipe deles percebeu.", +"lifecycle.odd_space":"Mudaram para uma estratégia nativa de IA, baseada em blockchain e satélite em primeiro lugar, e sua fibra não está no espaço.", +"lifecycle.odd_spreadsheet_cell":"Nova regra de compras: o nome de cada fornecedor tem que caber numa célula da planilha sem quebrar linha.", +"lifecycle.odd_the_cloud":"Estão levando tudo para a nuvem. A nuvem é um rack a duas ruas dali, conectado por você. Eles ainda não perceberam.", +"lifecycle.odd_too_many_feet":"O estagiário deles rodou um traceroute para se exibir, viu 14 saltos e declarou que eram pés demais.", +"lifecycle.odd_wireguard":"Vão trabalhar 100% remoto. Os 40 funcionários vão usar WireGuard da cozinha, e a linha do escritório fica só para as plantas.", +"lifecycle.odd_wrong_blue":"A nova gerente do escritório quer todos os cabos da mesma cor, e o seu é do azul errado.", +"lifecycle.referred_by":"Indicado por {name}, um dos seus clientes mais felizes.", +"lifecycle.renewal_haggle":"renovação em {date}: negociando", +"lifecycle.renewals":"Renovações", +"lifecycle.renewals_soon":"Renovações", +"lifecycle.renewed_and_grew":"{name} renovou e cresceu para {bw} ({city}).", +"lifecycle.unanswered_matches":"Sem resposta até o fim do contrato, você iguala o preço deles.", +"lifecycle.wants_price":"Paga {was}/mês, quer {price}/mês ({p} a menos) para renovar.", +"lifecycle.why_acquired":"Comprados", +"lifecycle.why_bust":"Faliram", +"lifecycle.why_cheaper_bid":"Proposta mais barata", +"lifecycle.why_insourced":"Montaram a própria rede", +"lifecycle.why_moved":"Mudaram", +"lifecycle.why_multihomed":"Foram para outro provedor", +"lifecycle.why_other":"Outros motivos", +"lifecycle.why_project_ended":"Projeto encerrado", +"lifecycle.why_they_left":"Por que saíram", +"lifecycle.why_unhappy":"Insatisfeitos com o serviço", +"lifecycle.won":"Conquistados", +"lifecycle.won_and_lost":"Clientes conquistados e perdidos", +"lifecycle.won_and_lost_note":"Os contratos duram de um a cinco anos, os pares de fibra de dez a vinte. Quando um termina, a maioria renova pelo preço de mercado de hoje e os clientes felizes costumam crescer. Alguns saem, e nem sempre por sua causa.", "link_modal.building_into_mainland_china_needs_a":"Construir na China continental exige uma joint venture e uma licença de operação. Abra {city} para solicitar.", "link_modal.cross_border_circuits_into_mainland":"Circuitos transfronteiriços para a China continental só são vendidos por operadoras licenciadas, a 3× o preço. Os comuns perdem cerca de 20% do tráfego na fronteira.", "link_modal.diverse_route_40_survives_cuts_alone":"Rota diversa +40% · sobrevive a cortes sozinha", diff --git a/src/agent/20-commands.js b/src/agent/20-commands.js index a725106..fd80aa6 100644 --- a/src/agent/20-commands.js +++ b/src/agent/20-commands.js @@ -218,6 +218,12 @@ const API_CMD={ doc:'Sign a pending offer. Rejected without a POP in every city it needs, without free channels for a wave sale, or after an event\'s start date. Extra waves for a carrier you already serve grow that contract.'}, decline:{args:[['id','entityId']], doc:'Throw an offer away.'}, + renewMatch:{args:[['id','entityId']],watch:['biz.#id'], + doc:'Answer a renewal haggle (a customer with hag): renew at the price they asked. Unanswered, this happens on its own when the term ends.'}, + renewMeet:{args:[['id','entityId']],watch:['biz.#id'], + doc:'Answer a renewal haggle by meeting halfway between their price and today\'s market price. They accept about two times in three; otherwise they leave.'}, + renewLet:{args:[['id','entityId']], + doc:'Answer a renewal haggle by letting the customer go now.'}, dropBiz:{args:[['id','entityId']],confirm:'double', doc:'Terminate a signed customer. Rejected once an event contract\'s event has started.'}, setRoute:{args:[['id','entityId'],['m','routeMode']],watch:['biz.#id'], diff --git a/src/agent/30-docs.js b/src/agent/30-docs.js index 72af161..50e5df8 100644 --- a/src/agent/30-docs.js +++ b/src/agent/30-docs.js @@ -32,8 +32,9 @@ const API_STATE_DOC={ pni:{type:'array',doc:'Private interconnects: city, net, tier, ready day, augments (up), LAG, sacrificial flag.'}, caches:{type:'array',doc:'CDN cache boxes: city, net, building.'}, nni:{type:'array',doc:'Fabric ports: city, provider, tier.'}, - biz:{type:'array',doc:'Signed customers: type, cities, bandwidth, rate, mood, contract dates.'}, - offers:{type:'array',doc:'Pending customer offers, each expiring on a day.'}, + biz:{type:'array',doc:'Signed customers: type, cities, bandwidth, rate, mood, contract dates (te: the day the term ends, mk: the bandwidth market it was priced in, hag: an open renewal haggle {rate, until}).'}, + offers:{type:'array',doc:'Pending customer offers, each expiring on a day (mk: the bandwidth market they were priced in; refN: the customer who referred them).'}, + cl:{type:'map',doc:'Customer lifecycle (#178): odd (the day of the last unusual departure) and mo, one entry a month of customers won, renewed, grown, haggling and lost by reason.'}, done:{type:'map',doc:'Goals landed, by goal id → day.'}, ach:{type:'map',doc:'Badges earned this game, by badge id → day.'}, inc:{type:'array',doc:'Open incidents: type, what they hit, until when, optional rush-repair price.'}, diff --git a/src/game/10-catalog/30-supply-chain.js b/src/game/10-catalog/30-supply-chain.js index 8fc363b..14128da 100644 --- a/src/game/10-catalog/30-supply-chain.js +++ b/src/game/10-catalog/30-supply-chain.js @@ -17,6 +17,7 @@ function hwShockStart(){const k=pick(Object.keys(HW_SHOCK)),n=45+Math.floor(Math function hwCard(){if(!S||!rule('market')||(S.day<=HW_FREE&&!hwShock()&&!hwLock()))return '';const t=hwTrend(S.day),s=hwShock(),l=hwLock(); return `
📦 ${tr('common.supply_chain')}
${tr('common.hardware_prices')}${t>1.005?tr('supply_chain.p_since_you_started',{p:pct(t-1)}):tr('supply_chain.as_when_you_started')}
+
${tr('lifecycle.bandwidth_prices')}${mktTxt()}
${s?`
${tr('common.shortage')}${tr('supply_chain.what_p_n_days_left',{what:tr(HW_SHOCK[s.k].n),p:pct(s.mul-1),n:s.until-S.day})}
`:''} ${l?`
${tr('common.price_lock')}${tr('supply_chain.until_date_at_p',{date:dateStr(l.until),p:pct(l.mul-1)})}
` :`

${tr('supply_chain.routers_optics_and_new_builds_at')}

${btn(tr('supply_chain.lock_prices_for_a_year_cost',{cost:fmt$(hwLockCost())}),'hwLock',{},'sm',S.cash`}
`;} diff --git a/src/game/60-features/37-fiber-broker.js b/src/game/60-features/37-fiber-broker.js index e208f6f..d419095 100644 --- a/src/game/60-features/37-fiber-broker.js +++ b/src/game/60-features/37-fiber-broker.js @@ -31,6 +31,6 @@ function brTick(){for(const l of S.links){const L=l.list;if(!L||l.kind!=='df'||! function brSell(l,t,n){const T=BIZ_T[t],nm=()=>{const list=T.names.filter(x=>!S.usedNames.includes(x)),x=list.length?pick(list):pick(T.names);useName(x);return x;}; const o=fiberOffer(t,l,nm,0.9);if(t==='wwave'){o.slots=n;o.rate=wwRate(l,n,0.9);o.what=wwWhat(l,n);} const more=t==='wwave'&&S.biz.find(b=>b.type==='wwave'&&b.link===l.id&&b.name===o.name); - if(more){more.slots=(more.slots||0)+n;more.rate+=o.rate;more.what=wwWhat(l,more.slots);}else S.biz.push(offerCustomer(o)); + if(more){more.slots=(more.slots||0)+n;more.rate+=o.rate;more.what=wwWhat(l,more.slots);}else S.biz.push(clSign(offerCustomer(o))); toast(tr('broker.sold',{name:esc(o.name),what:esc(t==='wwave'?wwWhat(l,n):o.what),price:fmt$(o.rate)}),'good'); floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,tr('common.signed'),'#16A866');} diff --git a/src/game/80-simulation/50-sanitize.js b/src/game/80-simulation/50-sanitize.js index 394874d..c318652 100644 --- a/src/game/80-simulation/50-sanitize.js +++ b/src/game/80-simulation/50-sanitize.js @@ -55,7 +55,9 @@ function sanitize(s){ for(const c of Object.keys(s.myIx)){const m=s.myIx[c];if(!isCity(c)||!m||typeof m!=='object'){delete s.myIx[c];continue;}m.members=Array.isArray(m.members)?m.members.filter(isNet):[];m.name=String(m.name||tr('common.your_ix')).slice(0,40);m.next=num(m.next,s.day);m.fab=int(m.fab,0,MYIX_FAB.length-1,0);} const okBiz=b=>b&&own(BIZ_T,b.type)&&(!BIZ_T[b.type].nni||own(FAB,b.prov))&&isCity(b.city)&&(!b.city2||isCity(b.city2))&&(!b.sites||Array.isArray(b.sites)&&b.sites.every(isCity)); const fixBiz=b=>{b.id=sid(b.id);b.name=String(b.name||tr('common.customer')).slice(0,80);b.bw=num(b.bw,1);b.rate=num(b.rate,0);if(b.fee!==undefined)b.fee=num(b.fee,0);if(b.start!==undefined)b.start=num(b.start,0);if(b.dur!==undefined)b.dur=num(b.dur,1);if(b.slots!==undefined)b.slots=num(b.slots,0);if(b.what!==undefined)b.what=String(b.what).slice(0,200);if(b.broker!==undefined)b.broker=!!b.broker;if(!Array.isArray(b.reqs))b.reqs=[];b.reqs=b.reqs.filter(r=>own(REQS,r));if(b.mood!==undefined)b.mood=num(b.mood,100);if(b.pm!==undefined)b.pm=num(b.pm,b.mood||100);if(b.exp!==undefined)b.exp=num(b.exp,0);if(b.latMax!=null)b.latMax=num(b.latMax,10);if(b.route&&!own(RT,b.route))b.route='normal';if(b.due!==undefined)b.due=num(b.due,0);if(b.win!==undefined)b.win=num(b.win,180);if(b.live!==undefined)b.live=!!b.live;if(b.link!==undefined&&typeof b.link!=='string')delete b.link;return b;}; - {const ids=new Map(s.links.map(l=>[l.id,l]));s.biz=s.biz.filter(okBiz).map(b=>unpackBiz(fixBiz(b),ids));}s.offers=s.offers.filter(okBiz).map(fixBiz); + {const ids=new Map(s.links.map(l=>[l.id,l]));s.biz=s.biz.filter(okBiz).map(b=>clFix(s,unpackBiz(fixBiz(b),ids)));}s.offers=s.offers.filter(okBiz).map(fixBiz); + // Contracts (#178): the bandwidth market an offer was priced in, who referred it, and the month-by-month tally. + for(const o of s.offers){if(!(typeof o.mk==='number'&&o.mk>0&&o.mk<=5))delete o.mk;if(typeof o.ref!=='string')delete o.ref;if(o.refN!==undefined)o.refN=String(o.refN).slice(0,80);}clFixState(s); // Sponsorships and capacity conferences (#168): registrations are true or 'sp', the glow and the pending deals are checked. for(const k of Object.keys(s.confReg))s.confReg[k]=s.confReg[k]==='sp'?'sp':!!s.confReg[k]; if(s.conf){const c=s.conf;if(typeof c!=='object'||!own(REG,c.reg))s.conf=null;else s.conf={until:num(c.until,0),reg:c.reg,name:String(c.name||'').slice(0,40),sp:!!c.sp};} diff --git a/src/game/80-simulation/75-customer-lifecycle.js b/src/game/80-simulation/75-customer-lifecycle.js new file mode 100644 index 0000000..30e8625 --- /dev/null +++ b/src/game/80-simulation/75-customer-lifecycle.js @@ -0,0 +1,148 @@ +/* ---------- Customers come and go (#178) ---------- + Every customer signs for a term. When it ends, most renew at today's market price, happy ones often grow, a few haggle + for a discount, and some leave for reasons that are not your fault (or, when they were unhappy, because they were). + Nothing changes during a customer's first term. Every roll is a hash of the customer and its term, never + Math.random, so seeded games and tests keep their random stream. */ + +/* The bandwidth market: what a Gbps sells for, 1 when you start. Flat for the first six months, then about 10% cheaper + a year (transit really does fall: 11–17% a year in the big hubs), slowed by dearer hardware, moving up and down in a + slow three-year cycle, and pushed up while a shortage lasts. Without the market rule it stays at 1. */ +const MK_YR=0.10,MK_FREE=180,MK_FLOOR=0.3,MK_SHOCK={opt:1.15,rt:1.1,build:1.08}; +function mktBase(d){if(d<=MK_FREE)return 1;const y=(d-MK_FREE)/365; + return Math.max(MK_FLOOR,Math.pow(1-MK_YR,y)*Math.sqrt(hwTrend(d))*(1+0.06*Math.sin(2*Math.PI*y/3)));} +function mkt(){if(!S||!rule('market'))return 1;const s=hwShock();return mktBase(S.day)*(s?MK_SHOCK[s.k]||1:1);} + +// Terms in months: enterprise and hosting 1–3 years, wholesale and circuits 2–5, IRUs and fiber pairs 10–20. +const CL_TERMS={ip:[12,24,36],whole:[24,36,48,60],iru:[120,180,240]}; +// Events, capacity deals and scripted scenario customers have their own endings. +const clKind=t=>{const T=BIZ_T[t];if(!T||T.event||T.cap)return null;if(t==='dfpair'||t==='pairs')return 'iru';return T.l2||T.fiber||t==='isp'||t==='gpu'?'whole':'ip';}; +const clOn=b=>!!b&&!b.scripted&&!!clKind(b.type); +// A stable roll in [0,1) for this customer, this term and this question. +const clR=(b,q)=>(hstr(((S&&S.asn)||0)+'|'+b.id+'|'+b.te+'|'+q)%100000)/100000; +const clPick=(a,b,q)=>a[Math.floor(clR(b,q)*a.length)]; +function clTerm(b,from){const m=clPick(CL_TERMS[clKind(b.type)],{id:b.id,te:from},'term');return from+Math.round(m*365/12);} +// What this customer's contract would be priced at today: its price moved by the market since it was signed. +// A renewal moves at most 25% down or 10% up at once, so an old save is not repriced in one go. +const clFair=b=>rule('market')&&b.mk>0?Math.round(b.rate*clamp(mkt()/b.mk,0.75,1.1)):b.rate; +// Competition where the customer is: carriers selling transit there (a fiber or circuit customer counts both ends). +const clComp=b=>{const cs=bCities(b);let n=0;for(const n2 of NETS)if(cs.some(c=>sellsAt(n2,c)))n++;return n;}; + +// Why they leave when it is not your fault: which reasons fit which customers. Moved and multihomed may keep them. +const CL_WHY={ + acq:{l:N_('lifecycle.why_acquired'),left:N_('lifecycle.left_acquired'),ok:()=>true}, + bust:{l:N_('lifecycle.why_bust'),left:N_('lifecycle.left_bust'),ok:t=>['gpu','stream','game','cgame','metav','ai','agi','hft','provedor','dia','host','mars'].includes(t)}, + insrc:{l:N_('lifecycle.why_insourced'),left:N_('lifecycle.left_insourced'),ok:t=>['isp','hyper','onramp','provedor','edu','sov','aiwan','stream'].includes(t)}, + moved:{l:N_('lifecycle.why_moved'),left:N_('lifecycle.left_moved'),ok:t=>{const T=BIZ_T[t];return !T.l2&&!T.fiber&&!T.nni;}}, + multi:{l:N_('lifecycle.why_multihomed'),left:N_('lifecycle.left_multihomed'),ok:t=>{const T=BIZ_T[t];return !T.l2&&!T.fiber;}}, + ended:{l:N_('lifecycle.why_project_ended'),left:N_('lifecycle.left_project_ended'),ok:t=>{const T=BIZ_T[t];return T.l2||T.fiber||t==='bulk';}}, + cheap:{l:N_('lifecycle.why_cheaper_bid'),left:N_('lifecycle.left_cheaper'),ok:()=>true}, + sad:{l:N_('lifecycle.why_unhappy'),ok:()=>false}, + odd:{l:N_('lifecycle.why_other'),ok:()=>false}, +}; +// The other reasons: now and then (never more than once every two months) a customer leaves for one of these. +const CL_ODD=[N_('lifecycle.odd_asn_six'),N_('lifecycle.odd_bad_holiday'),N_('lifecycle.odd_rdns'),N_('lifecycle.odd_too_many_feet'),N_('lifecycle.odd_dead_beef'),N_('lifecycle.odd_looking_glass'), + N_('lifecycle.odd_communities'),N_('lifecycle.odd_quadrant'),N_('lifecycle.odd_spreadsheet_cell'),N_('lifecycle.odd_fewer_vendors'),N_('lifecycle.odd_the_cloud'),N_('lifecycle.odd_bought_thrice'), + N_('lifecycle.odd_alphabetical'),N_('lifecycle.odd_goat_farmer'),N_('lifecycle.odd_mate'),N_('lifecycle.odd_95th'),N_('lifecycle.odd_holiday_card'),N_('lifecycle.odd_raccoon'),N_('lifecycle.odd_espresso'), + N_('lifecycle.odd_landlord'),N_('lifecycle.odd_wrong_blue'),N_('lifecycle.odd_space'),N_('lifecycle.odd_4g_dongle'),N_('lifecycle.odd_center'),N_('lifecycle.odd_wireguard')]; +const CL_ODD_GAP=60,CL_HAG_MAX=3,CL_MONTHS=24; + +// The month's tally for the dashboard: won, renewed, grew, haggled and who left why. +function clNote(k,why){const C=S.cl||(S.cl={odd:-1e9,mo:[]}),c=cal(S.day),m=c.y*12+c.m;let e=C.mo[C.mo.length-1]; + if(!e||e.m!==m){e={m,won:0,ren:0,grew:0,hag:0,lost:{}};C.mo.push(e);if(C.mo.length>CL_MONTHS)C.mo.shift();} + if(k==='lost')e.lost[why]=(e.lost[why]||0)+1;else e[k]=(e[k]||0)+1;} +// A new customer: its first term and the market it signed in. +function clSign(b){if(!clOn(b))return b;b.mk=b.mk>0?b.mk:mkt();b.te=clTerm(b,S.day);clNote('won');return b;} +function clRenew(b,rate){b.rate=Math.max(0,Math.round(rate));b.mk=mkt();delete b.hag;delete b.hr;b.te=clTerm(b,b.te);} +function clGone(b,why){S.biz=S.biz.filter(x=>x!==b);clNote('lost',why);} +const clWhere=b=>bCities(b).map(c=>CITY[c].name).join(' ⇄ '); + +// Growing: the next size up their type sells, or twice the bandwidth past the top one. Fiber grows by renewing. +function clGrow(b){const T=BIZ_T[b.type];if(T.fiber)return false;const up=(T.opts||[]).find(x=>x>b.bw);b.bw=up||b.bw*2;return true;} +// Leaving, or one of the not-your-fault turns that keeps them. Returns what the log says. +function clLeave(b,d,out){const T=BIZ_T[b.type],v={name:esc(b.name),city:esc(clWhere(b))}; + if(b.mood<50){clGone(b,'sad');out.lost.push(tr('lifecycle.left_unhappy',v));return;} + const C=S.cl;if(d-C.odd>=CL_ODD_GAP&&clR(b,'odd')<0.25){C.odd=d;clGone(b,'odd');out.lost.push(tr('lifecycle.left_odd',{...v,why:tr(clPick(CL_ODD,b,'oddline'))}));return;} + const ks=Object.keys(CL_WHY).filter(k=>CL_WHY[k].ok(b.type)),k=clPick(ks,b,'why'); + if(k==='acq'&&clR(b,'acqbig')<0.3&&clGrow(b)){clRenew(b,clFair(b));clNote('grew');out.ok.push(tr('lifecycle.acquired_stays_bigger',{...v,bw:fmtG(b.bw)}));return;} + if(k==='moved'){const reg=CITY[b.city].reg,to=Object.keys(S.pops).filter(c=>c!==b.city&&CITY[c].reg===reg&&bizCity(c)).sort(); + const c2=to.length&&clR(b,'stay')<0.5?clPick(to,b,'to'):null; + if(c2){const from=CITY[b.city].name;b.city=c2;clRenew(b,clFair(b));clNote('ren');out.ok.push(tr('lifecycle.moved_stays',{name:v.name,from:esc(from),to:esc(CITY[c2].name)}));return;}} + if(k==='multi'&&b.bw>=2){const keep=(T.opts||[]).filter(x=>x<=b.bw/2).pop()||b.bw/2;b.bw=keep;clRenew(b,clFair(b));clNote('ren');out.ok.push(tr('lifecycle.multihomed_keeps',{...v,bw:fmtG(b.bw)}));return;} + clGone(b,k);out.lost.push(tr(CL_WHY[k].left,v));} + +/* A day of contracts, after the moods. 30 days before a term ends a customer with competitors around may ask for a + discount (at most three open at a time); at the end, the rest renew, grow or leave. An unanswered haggle renews at + the asked price. */ +function clDay(d){if(!S.cl)S.cl={odd:-1e9,mo:[]};const out={ren:0,grew:0,ok:[],lost:[],hag:[]};let open=S.biz.reduce((a,b)=>a+(b.hag?1:0),0); + const pat=rule('moods')==='patient'?0.5:1; + for(const b of S.biz.slice()){if(!b.te||!clOn(b))continue; + if(b.hag){if(d>=b.hag.until){clRenew(b,b.hag.rate);clNote('ren');out.ren++;}continue;} + if(d=2&&b.mood>=40&&clR(b,'hag')<(0.05+0.15*cf)*pat){const fair=clFair(b),ask=Math.round(fair*(0.8+0.12*clR(b,'ask'))); + if(ask>0&&ask=80&&g<0.3)||(b.mood>=60&&g<0.12)){if(clGrow(b)){clRenew(b,clFair(b));clNote('grew');out.grew++;out.ok.push(tr('lifecycle.renewed_and_grew',{name:esc(b.name),city:esc(clWhere(b)),bw:fmtG(b.bw)}));continue;}} + clRenew(b,clFair(b));clNote('ren');out.ren++;} + clNews(out);clReferral(d);} +// What the day says: haggles one by one (they want an answer), the rest in a few lines so a big network is not a wall of toasts. +function clNews(out){ + for(const b of out.hag){const was=bizMo(b),now=BIZ_T[b.type].fiber?b.hag.rate:b.bw*b.hag.rate; + toast(tr('lifecycle.haggle',{name:esc(b.name),city:esc(clWhere(b)),price:fmt$(now),p:pct(1-now/Math.max(1,was)),n:b.hag.until-S.day}),'',[{l:tr('common.deals'),act:'leftTab',args:{t:'deals'}}],{a:'cust',v:b.id});} + const few=(list,kind)=>{for(const t of list.slice(0,3))toast(t,kind);if(list.length>3)toast(trn('lifecycle.n_more',list.length-3),kind);}; + few(out.ok,'good');few(out.lost,''); + if(out.ren)toast(trn('lifecycle.n_renewed',out.ren,{p:mktTxt()}),'');} +const mktTxt=()=>{const m=mkt();return Math.abs(m-1)<0.005?tr('lifecycle.market_as_start'):m<1?tr('lifecycle.market_below',{p:pct(1-m)}):tr('lifecycle.market_above',{p:pct(m-1)});}; + +/* Growth by word of mouth: about every six weeks the happiest long-standing customer (a year or more, 90%+ happy) + tells someone like them, who shows up in Deals asking for the smallest size at today's price. */ +const CL_REF=['dia','game','host','isp','stream','edu','scrub','provedor','gpu','cgame','metav']; +function clReferral(d){if(d%45!==0||S.offers.length>=6)return; + const b=S.biz.filter(x=>clOn(x)&&CL_REF.includes(x.type)&&x.mood>=90&&d-(x.since||0)>=365&&bizCity(x.city)&&lvl()>=(BIZ_T[x.type].lv||1)).sort((a,c)=>c.mood-a.mood||(a.since||0)-(c.since||0)||(a.ido.ref===b.id))return;const T=BIZ_T[b.type],list=(T.names||BIZ_N).filter(n=>!S.usedNames.includes(n));if(!list.length)return; + const name=clPick(list,{id:b.id,te:d},'refname');useName(name); + S.offers.push({id:uid(),city:b.city,city2:null,name,type:b.type,bw:(T.opts||[1])[0],rate:Math.round((CITY[b.city].au?T.rate*AU_ARPU:T.rate)*mkt()),mk:mkt(),reqs:[],exp:d+40,ref:b.id,refN:b.name});} +// New offers are priced at today's market (spawnOffer and friends price at 1; this moves them). +function mktPrice(from){const m=mkt();for(let i=from;iS?S.biz.reduce((a,b)=>a+(b.hag?1:0),0):0; +// The renewals waiting for an answer, at the top of Deals. +function clDealsHtml(){const hs=S.biz.filter(b=>b.hag).sort((a,b)=>a.hag.until-b.hag.until);if(!hs.length)return ''; + return `

${tr('lifecycle.renewals')}

${tr('lifecycle.unanswered_matches')}

`+hs.map(b=>{const now=BIZ_T[b.type].fiber?b.hag.rate:b.bw*b.hag.rate,was=bizMo(b); + return `
${esc(b.name)}
${esc(BIZ_T[b.type].l)} · ${esc(clWhere(b))} · ${tr('ui.n_d_left',{n:b.hag.until-S.day})}
+
${tr('lifecycle.wants_price',{was:fmt$(was),price:fmt$(now),p:pct(1-now/Math.max(1,was))})}
+
${btn(tr('lifecycle.match'),'renewMatch',{id:b.id},'green sm')}${btn(tr('lifecycle.meet_halfway'),'renewMeet',{id:b.id},'sm')}${btn(tr('lifecycle.let_them_go'),'renewLet',{id:b.id},'ghost sm')}
`;}).join('');} +// The contract line on a customer row. +const clTermTxt=b=>clOn(b)&&b.te?(b.hag?tr('lifecycle.renewal_haggle',{date:dateStr(b.te)}):tr('lifecycle.contract_until',{date:dateStr(b.te)})):''; + +/* Dashboard: customers won and lost per month (and why), renewals coming up, and the bandwidth market. */ +function clPanel(){const C=S.cl||{mo:[]},mo=C.mo.slice(-12);const soon=S.biz.filter(b=>clOn(b)&&b.te&&b.te-S.day<=30&&b.te>=S.day).length; + const sum=k=>mo.reduce((a,e)=>a+(k==='lost'?Object.values(e.lost).reduce((x,y)=>x+y,0):e[k]||0),0),why={};for(const e of mo)for(const k in e.lost)why[k]=(why[k]||0)+e.lost[k]; + let h=`

${tr('lifecycle.won_and_lost')}

${tr('lifecycle.won_and_lost_note')}

+
${tr('lifecycle.won')}
${sum('won')}
${tr('lifecycle.last_12_months')}
+
${tr('lifecycle.lost')}
${sum('lost')}
${trn('lifecycle.n_grew',sum('grew'))}
+
${tr('lifecycle.renewals_soon')}
${soon}
${tr('lifecycle.next_30_days')}
+
${tr('lifecycle.bandwidth_market')}
${Math.round(mkt()*100)}
${mktTxt()}
`; + if(mo.length){const max=Math.max(1,...mo.map(e=>Math.max(e.won,Object.values(e.lost).reduce((x,y)=>x+y,0)))),W=600,H=120,mid=H/2,bw=W/12; + let g=``; + mo.forEach((e,i)=>{const lost=Object.values(e.lost).reduce((x,y)=>x+y,0),x=(i+12-mo.length)*bw+bw*0.2,w=bw*0.6,hw=(mid-12)*e.won/max,hl=(mid-12)*lost/max; + g+=`${MONTHS[e.m%12]} · ${tr('lifecycle.won')} ${e.won}${MONTHS[e.m%12]} · ${tr('lifecycle.lost')} ${lost}${MONTHS[e.m%12]}`;}); + h+=`${g}`;} + const ks=Object.keys(why).sort((a,b)=>why[b]-why[a]); + h+=ks.length?`

${tr('lifecycle.why_they_left')}

`+ks.map(k=>`
${tr(CL_WHY[k]?CL_WHY[k].l:CL_WHY.odd.l)}${why[k]}
`).join(''):`

${tr('lifecycle.nobody_left_yet')}

`; + return h+`
`;} + +/* Saves from before contracts: renewals spread over the next year (from the customer's id, so they do not all fall on + one day), and the market they signed in from the day they signed. */ +function clFix(s,b){if(b.scripted||!clKind(b.type)){delete b.te;delete b.mk;delete b.hag;delete b.hr;return b;} + const day=Math.max(0,Math.floor(+s.day||0)),ok=v=>typeof v==='number'&&isFinite(v); + if(!ok(b.te)||b.teday+365*21)b.te=day+30+hstr('te|'+b.id)%335;b.te=Math.floor(b.te); + if(!ok(b.mk)||b.mk<=0||b.mk>5)b.mk=mktBase(Math.max(0,Math.floor(+b.since||0))); + if(b.hag&&(typeof b.hag!=='object'||!ok(b.hag.rate)||b.hag.rate<0||!ok(b.hag.until)))delete b.hag;else if(b.hag)b.hag={rate:Math.round(b.hag.rate),until:Math.floor(Math.min(b.hag.until,b.te))}; + if(b.hr!==undefined&&b.hr!==b.te)delete b.hr;return b;} +function clFixState(s){const C=s.cl&&typeof s.cl==='object'&&!Array.isArray(s.cl)?s.cl:{},o={odd:typeof C.odd==='number'&&isFinite(C.odd)?C.odd:-1e9,mo:[]}; + if(Array.isArray(C.mo))for(const e of C.mo.slice(-CL_MONTHS)){if(!e||typeof e!=='object'||!Number.isInteger(e.m))continue;const n=v=>Math.max(0,Math.min(1e7,Math.floor(+v)||0)),lost={}; + if(e.lost&&typeof e.lost==='object')for(const k in e.lost)if(own(CL_WHY,k))lost[k]=n(e.lost[k]);o.mo.push({m:e.m,won:n(e.won),ren:n(e.ren),grew:n(e.grew),hag:n(e.hag),lost});} + s.cl=o;} diff --git a/src/game/88-days/10-day-tick.js b/src/game/88-days/10-day-tick.js index 945c8bb..f421ab8 100644 --- a/src/game/88-days/10-day-tick.js +++ b/src/game/88-days/10-day-tick.js @@ -57,6 +57,8 @@ function dayPost(d){ toast(tr('day_tick.name_is_furious_fix_service_in',{name:esc(b.name),city:CITY[b.city].name})+(why?`
${esc(why)}`:'')+(paused?`
${tr('common.game_paused')}`:''),'bad',[{l:tr('common.show_me'),act:'custGo',args:{id:b.id}}].concat(paused?[resumeAct()]:[]));sfx('err');} else if(b.mood<60&&!b.warn60&&pref('warnUnhappy')){b.warn60=true;const why=bizWhy(b)[0];toast(tr('day_tick.name_is_getting_unhappy_happiness_p',{name:esc(b.name),p:Math.round(b.mood),city:CITY[b.city].name})+(why?`
${esc(why)}`:''),'',[{l:tr('common.show_me'),act:'custGo',args:{id:b.id}}]);}} if(b.mood>60)b.warned=false;if(b.mood>75)b.warn60=false;} + // contracts: renewals, growth, haggles and leaving (75-customer-lifecycle.js) + clDay(d); // own IX members join for(const c in S.myIx){const m=S.myIx[c];if(d>=m.next&&m.members.lengthn.type!=='t1'&&!m.members.includes(n.id)&&(n.pops.includes(c)||n.pops.some(p=>CITY[p].reg===CITY[c].reg))); @@ -67,7 +69,7 @@ function dayPost(d){ // offers S.offers=S.offers.filter(o=>o.exp>d); brTick(); - if(S.offers.length<5&&Math.random()<(0.05+0.01*(S.lvl||1))*(ppol()==='closed'?0.6:1)*(confSpOn()?SP_OFFERS:1))spawnOffer(); + if(S.offers.length<5&&Math.random()<(0.05+0.01*(S.lvl||1))*(ppol()==='closed'?0.6:1)*(confSpOn()?SP_OFFERS:1)){const n0=S.offers.length;spawnOffer();mktPrice(n0);} // failures & events // Chaos (the rules) scales how often: calm waits about three times as long, spicy comes almost twice as often, none never. let dirty=false;const cm=chaosMul(); diff --git a/src/game/90-actions/50-customers.js b/src/game/90-actions/50-customers.js index 53d9aee..87b7d94 100644 --- a/src/game/90-actions/50-customers.js +++ b/src/game/90-actions/50-customers.js @@ -12,8 +12,18 @@ Object.assign(ACT,{ const more=o.type==='wwave'&&S.biz.find(b=>b.type==='wwave'&&b.link===o.link&&b.name===o.name); if(more){const l=S.links.find(x=>x.id===o.link);S.offers=S.offers.filter(x=>x!==o);more.slots=(more.slots||0)+(o.slots||0);more.rate+=o.rate;if(l)more.what=wwWhat(l,more.slots); floater(CITY[o.city].x,CITY[o.city].y-30,tr('common.signed'),'#16A866');sfx('coin');after();return;} - S.offers=S.offers.filter(x=>x!==o);S.biz.push(customer); + S.offers=S.offers.filter(x=>x!==o);if(o.mk)customer.mk=o.mk;S.biz.push(clSign(customer)); floater(CITY[o.city].x,CITY[o.city].y-30,tr('common.signed'),'#16A866');sfx('coin');after();}, decline:({id})=>{S.offers=S.offers.filter(x=>x.id!==id);after();}, dropBiz:({id})=>{const b0=S.biz.find(x=>x.id===id);if(!b0)return;if(BIZ_T[b0.type].event&&S.day>=b0.start){toast(tr('customers.the_event_is_already_running_the'),'bad');sfx('err');return;}if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.biz=S.biz.filter(b=>b.id!==id);UI.confirm=null;after();}, }); +/* The renewal haggle (#178, 75-customer-lifecycle.js): match their price, meet halfway (they take it about two times + in three), or let them go. */ +function clHagOf(id){const b=S.biz.find(x=>x.id===id);return b&&b.hag?b:null;} +Object.assign(ACT,{ + renewMatch:({id})=>{const b=clHagOf(id);if(!b)return;clRenew(b,b.hag.rate);clNote('ren');toast(tr('lifecycle.matched',{name:esc(b.name)}),'good');sfx('coin');after();}, + renewMeet:({id})=>{const b=clHagOf(id);if(!b)return;const mid=Math.round((b.hag.rate+clFair(b))/2); + if(clR(b,'meet')<0.65){clRenew(b,mid);clNote('ren');toast(tr('lifecycle.meet_yes',{name:esc(b.name),price:fmt$(BIZ_T[b.type].fiber?b.rate:b.bw*b.rate)}),'good');sfx('coin');} + else{clGone(b,'cheap');toast(tr('lifecycle.meet_no',{name:esc(b.name)}),'bad');sfx('err');}after();}, + renewLet:({id})=>{const b=clHagOf(id);if(!b)return;clGone(b,'cheap');toast(tr('lifecycle.let_go',{name:esc(b.name)}),'');after();}, +}); diff --git a/src/game/93-ui/40-hud-and-panels.js b/src/game/93-ui/40-hud-and-panels.js index 70042c6..9408436 100644 --- a/src/game/93-ui/40-hud-and-panels.js +++ b/src/game/93-ui/40-hud-and-panels.js @@ -32,7 +32,7 @@ function renderLeft(){checkLayer(); renderTabbar(); if(!S||pzOn()){L.hidden=true;return;}L.hidden=false; const ndone=GOALS.filter(g=>S.done[g.id]!==undefined).length; - const tabs=[['goals',`${tr('common.goals')}${ndone}/${GOALS.length}`],['deals',`${tr('common.deals')}${S.offers.length?`${S.offers.length}`:''}`],['noc',`NOC${S.inc.length?``:''}`],['nets',`${tr('common.networks')}`]]; + const tabs=[['goals',`${tr('common.goals')}${ndone}/${GOALS.length}`],['deals',`${tr('common.deals')}${S.offers.length+clHags()?`${S.offers.length+clHags()}`:''}`],['noc',`NOC${S.inc.length?``:''}`],['nets',`${tr('common.networks')}`]]; $('leftTabs').innerHTML=tabs.map(([k,l])=>``).join('')+(innerWidth<760?``:''); let h=''; if(UI.left==='goals'){ @@ -42,11 +42,11 @@ function renderLeft(){checkLayer(); h+=badgeGrid(); }else if(UI.left==='deals'){ {const st=custStats();if(st.n)h+=`
${tr('common.your_customers')} ${st.n} · ${tr('hud_and_panels.happiness_p',{p:Math.round(st.avg)})}
${st.unhappy?`
${trn('hud_and_panels.n_unhappy_customer_price_mo_at',st.unhappy,{price:fmt$(st.risk)})}
`:''}
${btn(st.unhappy?tr('common.see_who'):tr('common.all_customers'),'custOpen',{sad:st.unhappy?1:0},st.unhappy?'pink sm':'ghost sm')}
`;} - h+=confSection()+seatSection(); + h+=clDealsHtml()+confSection()+seatSection(); {const lv=S.lvl||1,nx=LEVELS[lv];h+=`
${tr('hud_and_panels.customer_level_lv_name',{lv,name:LEVELS[lv-1].n})}
${nx?tr('hud_and_panels.next_req_unlocks_what',{req:nx.req,what:lc1(nx.unlock)}):tr('common.every_customer_type_is_unlocked_go')}
`;} if(!S.offers.length)h+=`

${tr('hud_and_panels.no_open_offers_right_now_businesses')}

`; for(const o of S.offers.slice().sort((a,b)=>a.exp-b.exp)){const has=bHas(o); - h+=`
${esc(o.name)}
${esc(BIZ_T[o.type].l)} · ${CITY[o.city].name}${o.city2?' ⇄ '+CITY[o.city2].name:''} · ${bTerms(o)} · ${tr('ui.n_d_left',{n:o.exp-S.day})}${(o.reqs||[]).length?` · ${trn('hud_and_panels.n_special_requirement',o.reqs.length)}`:''}
${spotWhy(o)}${bRisk(o)}${reqList(o)} + h+=`
${esc(o.name)}
${esc(BIZ_T[o.type].l)} · ${CITY[o.city].name}${o.city2?' ⇄ '+CITY[o.city2].name:''} · ${bTerms(o)} · ${tr('ui.n_d_left',{n:o.exp-S.day})}${(o.reqs||[]).length?` · ${trn('hud_and_panels.n_special_requirement',o.reqs.length)}`:''}
${o.refN?`
${tr('lifecycle.referred_by',{name:esc(o.refN)})}
`:''}${spotWhy(o)}${bRisk(o)}${reqList(o)}
${has?btn(tr('common.accept'),'accept',{id:o.id},'green sm'):btn(tr('common.go_there'),'focusCity',{city:bCities(o).find(c=>!S.pops[c])},'ghost sm')}${btn(tr('common.decline'),'decline',{id:o.id},'ghost sm')}
${has?'':`
${tr('hud_and_panels.needs_a_pop_in_cities',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}
`}
`;} }else if(UI.left==='noc'){ h+=`
${btn(tr('hud_and_panels.open_noc_dashboard'),'dash',{},'pink')}${btn(tr('common.connections'),'connOpen',{},'')}${btn(tr('common.traceroute'),'trace',{},'')}${btn(`⚙️ ${tr('routing.routing_and_ddos')}${S.te&&!coreTE()?'':''}`,'routingOpen',{},'')}
`; diff --git a/src/game/93-ui/50-city-panel.js b/src/game/93-ui/50-city-panel.js index b12a20b..4452395 100644 --- a/src/game/93-ui/50-city-panel.js +++ b/src/game/93-ui/50-city-panel.js @@ -37,7 +37,7 @@ function cityPanel(c){ h+=`

${tr('common.business_customers')}

`; const bz=S.biz.filter(b=>bCities(b).includes(c)); if(!bz.length)h+=`

${tr('city_panel.no_businesses_yet_offers_pop_up')}

`; - for(const b of bz)h+=`
${esc(b.name)}
${esc(BIZ_T[b.type].l)}${b.city2?` ${CITY[b.city].name} ⇄ ${CITY[b.city2].name}`:''} · ${bTerms(b)}${BIZ_T[b.type].l2?` · ${b.sites?tr('city_panel.carrying_g_per_site',{g:fmtG(R.l2[b.id]||0)}):tr('city_panel.carrying_g',{g:fmtG(R.l2[b.id]||0)})}`:''}${BIZ_T[b.type].fiber&&!fiberOk(b)?' · '+tr('city_panel.fiber_is_down')+'':''}${BIZ_T[b.type].event&&eventLive(b)?` · ${tr('city_panel.serving_v',{v:pct(sfOf(R,b.city))})}`:''}${b.type==='scrub'&&!hasScrub()?' · '+tr('common.needs_a_scrubbing_center')+'':''}${S.day-(b.since||0)<15?` · ${tr('common.provisioning_n_d_grace',{n:15-(S.day-(b.since||0))})}`:''}
${bRisk(b)}${reqList(b)}${BIZ_T[b.type].l2?routeCtl(b):''}
${tr('common.happiness_p',{p:Math.round(b.mood)})}
${btn(UI.confirm===b.id?tr('common.really_drop'):tr('common.drop'),'dropBiz',{id:b.id},'ghost sm')}
`; + for(const b of bz)h+=`
${esc(b.name)}
${esc(BIZ_T[b.type].l)}${b.city2?` ${CITY[b.city].name} ⇄ ${CITY[b.city2].name}`:''} · ${bTerms(b)}${clTermTxt(b)?' · '+clTermTxt(b):''}${BIZ_T[b.type].l2?` · ${b.sites?tr('city_panel.carrying_g_per_site',{g:fmtG(R.l2[b.id]||0)}):tr('city_panel.carrying_g',{g:fmtG(R.l2[b.id]||0)})}`:''}${BIZ_T[b.type].fiber&&!fiberOk(b)?' · '+tr('city_panel.fiber_is_down')+'':''}${BIZ_T[b.type].event&&eventLive(b)?` · ${tr('city_panel.serving_v',{v:pct(sfOf(R,b.city))})}`:''}${b.type==='scrub'&&!hasScrub()?' · '+tr('common.needs_a_scrubbing_center')+'':''}${S.day-(b.since||0)<15?` · ${tr('common.provisioning_n_d_grace',{n:15-(S.day-(b.since||0))})}`:''}
${bRisk(b)}${reqList(b)}${BIZ_T[b.type].l2?routeCtl(b):''}
${tr('common.happiness_p',{p:Math.round(b.mood)})}
${btn(UI.confirm===b.id?tr('common.really_drop'):tr('common.drop'),'dropBiz',{id:b.id},'ghost sm')}
`; h+=`
`+offersHere(c); }else if(UI.tab==='up'){ h+=portNote(c)+latNote(c); diff --git a/src/game/94-dashboard/30-customers.js b/src/game/94-dashboard/30-customers.js index 8ff718e..600820a 100644 --- a/src/game/94-dashboard/30-customers.js +++ b/src/game/94-dashboard/30-customers.js @@ -30,5 +30,5 @@ function custSection(){const F=UI.kf||{};let h=`
b.pm===undefined||Math.abs(b.mood-b.pm)<0.05?'':b.mood>b.pm?' ▲':' ▼'; const sorts=[['mood',tr('common.happiness')],['mo',tr('common.per_month')],['name',tr('common.name')],['city',tr('common.where')]]; h+=`
${sorts.map(([k,l])=>btn(l+(sk===k?(dir>0?' ▲':' ▼'):''),'custSort',{k},sk===k?'pink sm':'ghost sm')).join('')}
`; - h+=rows.slice(0,listN('cust')).map(b=>{const why=bizWhy(b),grace=S.day-(b.since||0)<15;return `
${esc(b.name)} ${esc(BIZ_T[b.type].l)}
${esc(where(b))} · ${BIZ_T[b.type].event?esc(bTerms(b)):tr('common.price_mo',{price:fmt$(bizMo(b))})}${grace?` · ${tr('common.provisioning_n_d_grace',{n:15-(S.day-(b.since||0))})}`:''}
${bRisk(b)}${why.length?`
${why.map(esc).join(' · ')}
`:''}
${tr('common.happiness_p',{p:Math.round(b.mood)})}${trend(b)}
${btn(tr('common.open'),'custGo',{id:b.id},'ghost sm')}
`;}).join(''); + h+=rows.slice(0,listN('cust')).map(b=>{const why=bizWhy(b),grace=S.day-(b.since||0)<15;return `
${esc(b.name)} ${esc(BIZ_T[b.type].l)}
${esc(where(b))} · ${BIZ_T[b.type].event?esc(bTerms(b)):tr('common.price_mo',{price:fmt$(bizMo(b))})}${grace?` · ${tr('common.provisioning_n_d_grace',{n:15-(S.day-(b.since||0))})}`:''}${clTermTxt(b)?' · '+clTermTxt(b):''}
${bRisk(b)}${why.length?`
${why.map(esc).join(' · ')}
`:''}
${tr('common.happiness_p',{p:Math.round(b.mood)})}${trend(b)}
${btn(tr('common.open'),'custGo',{id:b.id},'ghost sm')}
`;}).join(''); return h+listMore('cust',rows.length,n=>trn('customers.n_more_customer',n))+`
`;} diff --git a/src/game/94-dashboard/60-dashboard.js b/src/game/94-dashboard/60-dashboard.js index 4ea4fae..16aecdb 100644 --- a/src/game/94-dashboard/60-dashboard.js +++ b/src/game/94-dashboard/60-dashboard.js @@ -18,7 +18,7 @@ function renderDash(){checkLayer(); {const e={c:0,p:0,ix:0,t:0};let w=0;for(const n of NETS)if(n.tail){const x=R.netEg[n.id];if(x)for(const k in e)e[k]+=x[k]||0;w+=R.demTo[n.id]||0;}nets.push(row({id:'_tail',name:tr('dashboard.the_long_tail_n_small_networks',{n:NETS.filter(n=>n.tail).length}),asn:'many',type:'eye',col:'#8A93B8'},e,w));} for(let i=nets.length-1;i>=0;i--)if(!(nets[i].t>0.01||(!filt&&nets[i].want>0.01)))nets.splice(i,1); {const k=UI.dashSort||'traffic',dir=UI.dashDir||-1,val=x=>k==='name'?x.n.name.toLowerCase():k==='asn'?x.n.asn:k==='type'?x.n.type:k==='cost'?x.cost:k==='lost'?x.lost:x.t;nets.sort((a,b)=>{const A=val(a),B=val(b);return (AB?1:0)*dir||b.t-a.t;});} - if(DT==='cust')h+=custSection(); + if(DT==='cust')h+=clPanel()+custSection(); if(DT==='conn')h+=connSection(); if(DT==='traffic')h+=`
${btn(tr('ops.standing_orders'),'opsOpen',{},'sm')}
`; if(DT==='traffic')h+=`

${tr('dashboard.traffic_by_network_asn')}

${tr('dashboard.where_your_users_traffic_comes_from')}

${chartLegend('mix')}
${[['name',tr('common.network_6974'),''],['asn','AS',''],['type',tr('common.type'),''],['traffic',tr('common.traffic'),'r'],['mix',tr('dashboard.how_it_arrives'),''],['cost',tr('common.transit_cost'),'r'],['lost',tr('common.lost'),'r']].map(([k,l,c])=>``).join('')} diff --git a/src/i18n/en.js b/src/i18n/en.js index ad8a9de..cd6de57 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -2604,6 +2604,84 @@ "lease_swaps.your_fiber_here_has_room_for":"Your fiber here has room for {free} more channels, and moving these leases needs {n}. Light another fiber pair or upgrade the line system first.", "lease_swaps.your_own_cable_up_up_front":"Your own cable: {up} up front, {mo}/mo, about {n} days to build.", "lease_swaps.your_own_fiber_up_up_front":"Your own fiber: {up} up front, {mo}/mo, about {n} days to build.", +"lifecycle.acquired_stays_bigger":"{name} was acquired and stays with you, bigger: now {bw}.", +"lifecycle.bandwidth_market":"Bandwidth market", +"lifecycle.bandwidth_prices":"Bandwidth prices", +"lifecycle.contract_until":"contract until {date}", +"lifecycle.haggle":"{name} ({city}) wants {price}/mo to renew, {p} less. Competitors are bidding. Answer in Deals within {n} days.", +"lifecycle.last_12_months":"last 12 months", +"lifecycle.left_acquired":"{name} was acquired, and the buyer moves everything onto its own network.", +"lifecycle.left_bust":"{name} went bust. The hype moved on without them.", +"lifecycle.left_cheaper":"{name} took a cheaper bid from a competitor in {city}.", +"lifecycle.left_insourced":"{name} got big enough to build its own backbone, and will peer with you instead of buying.", +"lifecycle.left_moved":"{name} moved away from {city}, somewhere you have no POP.", +"lifecycle.left_multihomed":"{name} moved all its traffic to a second provider.", +"lifecycle.left_odd":"{name} did not renew. {why}", +"lifecycle.left_project_ended":"{name}'s project is over, and the circuit goes with it.", +"lifecycle.left_unhappy":"{name} did not renew: the service let them down too often.", +"lifecycle.let_go":"{name} is gone. Their contract was up anyway.", +"lifecycle.let_them_go":"Let them go", +"lifecycle.lost":"Lost", +"lifecycle.market_above":"{p} above when you started", +"lifecycle.market_as_start":"as when you started", +"lifecycle.market_below":"{p} below when you started", +"lifecycle.match":"Match", +"lifecycle.matched":"{name} renewed at the price they asked.", +"lifecycle.meet_halfway":"Meet halfway", +"lifecycle.meet_no":"{name} took the competitor's bid and left.", +"lifecycle.meet_yes":"{name} took your offer and renewed at {price}/mo.", +"lifecycle.moved_stays":"{name} moved from {from} to {to}, where you have a POP, so it stays.", +"lifecycle.multihomed_keeps":"{name} moved half its traffic to a second provider. You keep {bw}.", +"lifecycle.n_grew":{"one":"1 grew","other":"{n} grew"}, +"lifecycle.n_more":{"one":"…and 1 more.","other":"…and {n} more."}, +"lifecycle.n_renewed":{"one":"1 contract renewed at today's prices ({p}).","other":"{n} contracts renewed at today's prices ({p})."}, +"lifecycle.next_30_days":"next 30 days", +"lifecycle.nobody_left_yet":"Nobody has left yet.", +"lifecycle.odd_4g_dongle":"Their whole company now runs on one SaaS app over a 4G dongle. It works fine, which is the worst part.", +"lifecycle.odd_95th":"Their CFO saw 95th percentile on the invoice and thinks you charge for the 95 worst days.", +"lifecycle.odd_alphabetical":"Their rebrand budget ran out, so they are cutting costs alphabetically, and you came up first.", +"lifecycle.odd_asn_six":"Their new CTO only trusts ASNs with exactly three 7s in them.", +"lifecycle.odd_bad_holiday":"They found out you route their packets through a city they once had a bad holiday in.", +"lifecycle.odd_bought_thrice":"They were bought by a company that was bought by a company that already has a network. Nobody knows who is in charge.", +"lifecycle.odd_center":"They read that latency matters, so they are moving closer to the center of the internet. They think it is in a field in the countryside.", +"lifecycle.odd_communities":"They switched to a provider whose BGP communities are better documented. There are two of them.", +"lifecycle.odd_dead_beef":"They wanted an IPv6 address that spells their name in hex. :dead:beef was taken.", +"lifecycle.odd_espresso":"The office's new espresso machine trips the breaker. They blame the router, so they blame you.", +"lifecycle.odd_fewer_vendors":"The new CEO wants fewer vendors. You were the only one. They now have none, and are delighted.", +"lifecycle.odd_goat_farmer":"The person who signed with you left to become a goat farmer, and their replacement is doing things differently.", +"lifecycle.odd_holiday_card":"Your holiday card arrived on time. That made them suspicious.", +"lifecycle.odd_landlord":"Their landlord charges per cable through the wall, and yours is thick and showy.", +"lifecycle.odd_looking_glass":"Your looking glass was down for an hour, and their NOC lead took it personally.", +"lifecycle.odd_mate":"Your account manager called their account manager mate in an email. They are not mates.", +"lifecycle.odd_quadrant":"A consultant made a slide with a quadrant, and you were in the wrong one.", +"lifecycle.odd_raccoon":"A raccoon moved into their only cabinet, and it seems happier with another carrier's cross-connect.", +"lifecycle.odd_rdns":"Your reverse DNS for their IP says customer-cheapskate-04. Someone on their team noticed.", +"lifecycle.odd_space":"They pivoted to an AI-native, blockchain-backed, satellite-first strategy, and your fiber is not in space.", +"lifecycle.odd_spreadsheet_cell":"Procurement's new rule: every vendor's name must fit in one spreadsheet cell without wrapping.", +"lifecycle.odd_the_cloud":"They are moving everything to the cloud. The cloud is a rack two streets away, connected by you. They haven't noticed yet.", +"lifecycle.odd_too_many_feet":"Their intern ran a traceroute to show off, saw 14 hops and declared it too many feet.", +"lifecycle.odd_wireguard":"They are going fully remote. All 40 staff will run WireGuard from their kitchens, and the office line is just for the plants.", +"lifecycle.odd_wrong_blue":"The new office manager wants every cable the same colour, and yours is the wrong blue.", +"lifecycle.referred_by":"Referred by {name}, one of your happiest customers.", +"lifecycle.renewal_haggle":"renewal on {date}: haggling", +"lifecycle.renewals":"Renewals", +"lifecycle.renewals_soon":"Renewals", +"lifecycle.renewed_and_grew":"{name} renewed and grew to {bw} ({city}).", +"lifecycle.unanswered_matches":"No answer by the end of the contract means you match their price.", +"lifecycle.wants_price":"Pays {was}/mo, wants {price}/mo ({p} less) to renew.", +"lifecycle.why_acquired":"Acquired", +"lifecycle.why_bust":"Went bust", +"lifecycle.why_cheaper_bid":"Took a cheaper bid", +"lifecycle.why_insourced":"Built their own network", +"lifecycle.why_moved":"Moved away", +"lifecycle.why_multihomed":"Went to a second provider", +"lifecycle.why_other":"Other reasons", +"lifecycle.why_project_ended":"Project ended", +"lifecycle.why_they_left":"Why they left", +"lifecycle.why_unhappy":"Unhappy with the service", +"lifecycle.won":"Won", +"lifecycle.won_and_lost":"Customers won and lost", +"lifecycle.won_and_lost_note":"Contracts run one to five years, fiber pairs ten to twenty. When one ends, most customers renew at today's market price and happy ones often grow. Some leave, and not always because of you.", "link_modal.building_into_mainland_china_needs_a":"Building into mainland China needs a joint venture and an operating license. Open {city} to apply.", "link_modal.cross_border_circuits_into_mainland":"Cross-border circuits into mainland China are sold only by licensed carriers, at 3× the price. Regular ones lose about 20% of traffic at the border.", "link_modal.diverse_route_40_survives_cuts_alone":"Diverse route +40% · survives cuts alone", diff --git a/tests/customer-lifecycle.test.js b/tests/customer-lifecycle.test.js new file mode 100644 index 0000000..8fef686 --- /dev/null +++ b/tests/customer-lifecycle.test.js @@ -0,0 +1,190 @@ +// Customers come and go (#178): contract terms, renewals at the market price, growth, haggles, leaving for reasons that +// are not your fault, referrals, the bandwidth market, and old saves. Every roll is a hash of the customer and its +// term, so these tests pick ids that land where they need to and never depend on luck. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +const start = "ACT.start({});S.cash=1e9;S.nextFail=1e9;S.nextEvent=1e9;for(const g of GOALS)S.done[g.id]=0;for(const c of ['ams','lon','par'])ACT.buildPop({city:c});compute()"; +// A signed customer, as an accepted offer makes it. +const sign = (ev, o) => ev(`(()=>{const b=clSign(offerCustomer(Object.assign({id:'c'+Math.random().toString(36).slice(2),city:'ams',city2:null,name:'Test Co',type:'dia',bw:5,rate:600,reqs:[],exp:S.day+40},${JSON.stringify(o || {})})));S.biz.push(b);return b.id;})()`); +const B = (ev, id, k) => ev(`S.biz.find(b=>b.id===${JSON.stringify(id)})${k ? '.' + k : ''}`); +// An id whose roll for question q (at term end te) is below p, or at least p when above is true. +const idFor = (ev, q, p, te, above = false) => ev(`(()=>{for(let i=0;i<20000;i++){const id='x'+i,r=clR({id,te:${te}},'${q}');if(${above ? 'r>=' : 'r<'}${p})return id;}})()`); + +test('every customer signs for a term that fits what it buys; events and scripted customers have none', () => { + const { ev, errors } = load(); + ev(start); + const months = (type) => { const id = sign(ev, { type, bw: 1, rate: 100 }); return Math.round((B(ev, id, 'te') - ev('S.day')) * 12 / 365); }; + for (const t of ['dia', 'host', 'game']) assert.ok([12, 24, 36].includes(months(t)), `${t}: one to three years`); + for (const t of ['l2vpn', 'isp']) assert.ok([24, 36, 48, 60].includes(months(t)), `${t}: two to five years`); + assert.ok([120, 180, 240].includes(months('dfpair')), 'fiber pairs: ten to twenty years'); + const ev1 = sign(ev, { type: 'event', start: ev('S.day') + 20, dur: 4, fee: 1000 }); + assert.equal(B(ev, ev1, 'te'), undefined, 'an event has its own ending'); + assert.equal(B(ev, sign(ev, {}), 'mk'), 1, 'signed in the market of the day'); + assert.equal(ev("S.cl.mo[S.cl.mo.length-1].won"), 7, 'and counted as won this month'); + assert.deepEqual(errors, []); +}); + +test('nothing happens during a first term, and a renewal reprices to the market at most 25% at once', () => { + const { ev, errors } = load(); + ev(start); + const te = ev('S.day') + 365; + const id = idFor(ev, 'leave', 0.9, te, true); + ev(`S.biz.push({id:'${id}',city:'ams',city2:null,name:'Steady Co',type:'dia',bw:5,rate:600,reqs:[],mood:100,since:S.day,te:${te},mk:2})`); + ev(`for(let i=0;i<364;i++)clDay(S.day+i)`); + assert.equal(B(ev, id, 'rate'), 600, 'first term: same price, still here'); + ev(`S.biz.find(b=>b.id==='${id}').mood=100;clDay(${te})`); + assert.ok(B(ev, id), 'renewed'); + const rate = B(ev, id, 'rate'); + assert.ok(rate === 450 || B(ev, id, 'bw') > 5, `the market halved, but one renewal moves the price 25% at most (${rate})`); + assert.ok(B(ev, id, 'te') > te, 'a new term starts where the old one ended'); + assert.deepEqual(errors, []); +}); + +test('the lifecycle never draws from Math.random, so seeded games keep their stream', () => { + const { ev, errors } = load(); + ev(start); + for (let i = 0; i < 40; i++) sign(ev, { name: 'Co ' + i, type: i % 3 ? 'dia' : 'l2vpn', city2: i % 3 ? null : 'lon' }); + ev('for(const b of S.biz)b.te=S.day+31'); + ev('window.__r=0;const r0=Math.random;Math.random=()=>{__r++;return r0();};for(let i=0;i<40;i++)clDay(S.day+i);Math.random=r0'); + assert.equal(ev('__r'), 0); + assert.ok(ev("S.cl.mo.reduce((a,e)=>a+e.ren+e.grew+Object.values(e.lost).reduce((x,y)=>x+y,0),0)") > 0, 'contracts did end'); + assert.deepEqual(errors, []); +}); + +test('happy customers renew or grow; an unhappy one leaves, and says it was the service', () => { + const { ev, errors } = load(); + ev(start); + const te = ev('S.day') + 10; + const stay = idFor(ev, 'leave', 0.5, te, true), grow = ev(`(()=>{for(let i=0;i<20000;i++){const id='g'+i;if(clR({id,te:${te}},'leave')>=0.5&&clR({id,te:${te}},'grow')<0.3)return id;}})()`); + const sad = idFor(ev, 'leave', 0.3, te); + for (const [id, mood] of [[stay, 100], [grow, 100], [sad, 20]]) ev(`S.biz.push({id:'${id}',city:'ams',city2:null,name:'${id}',type:'dia',bw:2,rate:600,reqs:[],mood:${mood},since:S.day-400,te:${te},mk:1})`); + ev(`clDay(${te})`); + assert.ok(B(ev, stay), 'renewed'); + assert.equal(B(ev, grow, 'bw'), 5, 'grew to the next size their type sells'); + assert.equal(B(ev, sad), undefined, 'the unhappy one left'); + assert.equal(ev("S.cl.mo[S.cl.mo.length-1].lost.sad"), 1); + assert.match(ev('S.log[0].t+S.log[1].t+S.log[2].t'), /did not renew: the service let them down/); + assert.deepEqual(errors, []); +}); + +test('leaving that is not your fault: only reasons that fit the customer, and the odd ones at most every two months', () => { + const { ev, errors } = load(); + ev(start); + const r = JSON.parse(ev(`(()=>{const seen={};S.day=1000;S.cl={odd:-1e9,mo:[]}; + for(let i=0;i<3000;i++){const t=['dia','l2vpn','dfpair','isp','gpu'][i%5],b={id:'q'+i,city:'ams',city2:BIZ_T[t].l2||BIZ_T[t].fiber?'lon':null,name:'Q'+i,type:t,bw:4,rate:100,reqs:[],mood:90,since:0,te:S.day,mk:1}; + if(clR(b,'leave')>=(0.04+0.08*Math.min(1,clComp(b)/6)+0.35*0.01))continue;S.biz=[b];const before=JSON.stringify(S.cl.mo);clDay(S.day); + const e=S.cl.mo[S.cl.mo.length-1];for(const k in e.lost)(seen[k]=seen[k]||new Set()).add(t);S.cl.mo=[];S.day+=7;} + const out={};for(const k in seen)out[k]=[...seen[k]];return JSON.stringify(out);})()`)); + for (const k of Object.keys(r)) assert.ok(['acq', 'bust', 'insrc', 'moved', 'multi', 'ended', 'cheap', 'odd'].includes(k), k); + assert.ok(!(r.ended || []).includes('dia'), 'an internet customer has no project circuit to end'); + assert.ok(!(r.moved || []).some(t => t === 'l2vpn' || t === 'dfpair'), 'circuits and fiber do not move away'); + assert.ok(!(r.bust || []).includes('dfpair')); + // The odd reasons: never twice within 60 days. + const gaps = JSON.parse(ev(`(()=>{S.day=5000;S.cl={odd:-1e9,mo:[]};const days=[];for(let d=0;d<400;d++){for(let i=0;i<6;i++){const b={id:'o'+d+'_'+i,city:'ams',city2:null,name:'O',type:'dia',bw:1,rate:100,reqs:[],mood:90,since:0,te:S.day,mk:1};S.biz=[b];const o=S.cl.odd;clDay(S.day);if(S.cl.odd!==o)days.push(S.day);}S.day++;}return JSON.stringify(days);})()`)); + assert.ok(gaps.length >= 3, `odd reasons do come (${gaps.length} in 400 days)`); + assert.ok(gaps.every((d, i) => !i || d - gaps[i - 1] >= 60), 'at most one every 60 days'); + assert.deepEqual(errors, []); +}); + +test('a haggle: 30 days ahead, in Deals; match, meet halfway, let go, or no answer matches their price', () => { + const { ev, errors } = load(); + ev(start); + const te = ev('S.day') + 30; + const id = idFor(ev, 'hag', 0.05, te); + ev(`S.biz.push({id:'${id}',city:'ams',city2:null,name:'Haggle Co',type:'dia',bw:5,rate:600,reqs:[],mood:90,since:S.day-800,te:${te},mk:1})`); + ev(`clDay(S.day)`); + const hag = JSON.parse(ev(`JSON.stringify(S.biz.find(b=>b.id==='${id}').hag)`)); + assert.ok(hag && hag.rate < 600 && hag.rate >= 480 && hag.until === te, `asks 8–20% off until the term ends (${JSON.stringify(hag)})`); + ev("UI.left='deals';renderLeft()"); + const deals = ev("document.getElementById('leftBody')?document.getElementById('leftBody').innerHTML:document.getElementById('left').innerHTML"); + assert.match(deals, /data-act="renewMatch"/); + assert.match(deals, /data-act="renewMeet"/); + assert.match(deals, /data-act="renewLet"/); + assert.match(ev("document.getElementById('leftTabs').innerHTML"), /cnt">\d/, 'counted on the Deals tab'); + ev(`ACT.renewMatch({id:'${id}'})`); + assert.equal(B(ev, id, 'rate'), hag.rate, 'matched'); + assert.equal(B(ev, id, 'hag'), undefined); + // No answer: renews at the asked price when the term ends. + ev(`(()=>{const b=S.biz.find(b=>b.id==='${id}');b.hag={rate:500,until:S.day+5};})()`); + ev(`for(let i=0;i<6;i++)clDay(S.day+i)`); + assert.equal(B(ev, id, 'rate'), 500); + ev(`(()=>{const b=S.biz.find(b=>b.id==='${id}');b.hag={rate:400,until:S.day+5};})()`); + ev(`ACT.renewLet({id:'${id}'})`); + assert.equal(B(ev, id), undefined, 'let go'); + assert.deepEqual(errors, []); +}); + +test('the bandwidth market: flat for six months, then cheaper each year, up in a shortage, 1 without the market rule', () => { + const { ev, errors } = load(); + ev(start); + assert.equal(ev('mktBase(0)'), 1); + assert.equal(ev('mktBase(180)'), 1); + const y1 = ev('mktBase(180+365)'), y3 = ev('mktBase(180+3*365)'); + assert.ok(y1 < 0.97 && y1 > 0.85, `a year on: ${y1}`); + assert.ok(y3 < y1 && y3 > 0.6, `three years on: ${y3}`); + assert.ok(ev('mktBase(180+40*365)') >= 0.3, 'never below the floor'); + ev('S.day=900'); + const calm = ev('mkt()'); + ev("S.hw={shock:{k:'opt',until:S.day+30,mul:1.5}}"); + assert.ok(ev('mkt()') > calm * 1.1, 'a laser shortage pushes bandwidth prices up'); + ev("S.rules=Object.assign({},S.rules||RULE_DEF,{market:false})"); + assert.equal(ev('mkt()'), 1); + assert.deepEqual(errors, []); +}); + +test('word of mouth: a happy customer of a year or more brings a referral at the smallest size and today\'s price', () => { + const { ev, errors } = load(); + ev(start); + ev("S.day=900;S.offers=[];S.biz.push({id:'fan',city:'ams',city2:null,name:'Big Fan Ltd',type:'host',bw:40,rate:60,reqs:[],mood:100,since:100,te:2000,mk:1})"); + ev('clReferral(899)'); + assert.equal(ev('S.offers.length'), 0, 'about every six weeks, not every day'); + ev('clReferral(900)'); + const o = JSON.parse(ev('JSON.stringify(S.offers[0])')); + assert.equal(o.type, 'host'); + assert.equal(o.bw, 10, 'the smallest size'); + assert.equal(o.refN, 'Big Fan Ltd'); + assert.equal(o.rate, Math.round(60 * ev('mkt()'))); + ev("UI.left='deals';renderLeft()"); + assert.match(ev("document.getElementById('left').innerHTML"), /Referred by Big Fan Ltd/); + assert.deepEqual(errors, []); +}); + +test('old saves: renewals spread over the next year, the market from the signing day, broken fields repaired', () => { + const { ev, errors } = load(); + ev(start); + const s = JSON.parse(ev('JSON.stringify(packSave(S))')); + s.day = 1500; + s.biz = []; + for (let i = 0; i < 200; i++) s.biz.push({ id: 'old' + i, city: 'ams', name: 'Old ' + i, type: i % 2 ? 'dia' : 'host', bw: 5, rate: 600, mood: 90, since: 200 }); + s.biz.push({ id: 'bad', city: 'ams', name: 'Bad', type: 'dia', bw: 5, rate: 600, mood: 90, since: 200, te: 'soon', mk: -3, hag: { rate: 'x' } }); + s.cl = { odd: 'never', mo: [{ m: 30, won: 3, lost: { acq: 1, nonsense: 5 } }, 'junk'] }; + const out = JSON.parse(ev(`JSON.stringify(sanitize(JSON.parse(${JSON.stringify(JSON.stringify(s))})))`)); + const tes = out.biz.map(b => b.te - 1500); + assert.ok(tes.every(t => t >= 30 && t <= 365), 'within the next year, never on day one'); + assert.ok(new Set(tes).size > 100, 'spread out, not one wave'); + const bad = out.biz.find(b => b.id === 'bad'); + assert.equal(bad.hag, undefined); + assert.ok(bad.mk > 0 && bad.mk === ev('mktBase(200)'), 'the market of the day it signed'); + assert.deepEqual(out.cl, { odd: -1e9, mo: [{ m: 30, won: 3, ren: 0, grew: 0, hag: 0, lost: { acq: 1 } }] }); + assert.deepEqual(errors, []); +}); + +test('the dashboard shows customers won and lost, why, renewals coming up and the market; rows show the contract', () => { + const { ev, errors } = load(); + ev(start); + const id = sign(ev, {}); + ev("clNote('lost','bust');clNote('lost','odd');clNote('grew')"); + ev("ACT.dash({});UI.dtab='cust';renderDash()"); + const h = ev("document.getElementById('dash').innerHTML"); + assert.match(h, /Customers won and lost/); + assert.match(h, /Went bust/); + assert.match(h, /Other reasons/); + assert.match(h, /Bandwidth market/); + assert.match(h, /contract until/); + ev(`selectCity('ams');UI.tab='cust';renderPanel()`); + assert.match(ev("document.getElementById('panel').innerHTML"), /contract until/); + assert.ok(B(ev, id)); + assert.deepEqual(errors, []); +}); diff --git a/tests/save-size.test.js b/tests/save-size.test.js index 4f4c544..1607493 100644 --- a/tests/save-size.test.js +++ b/tests/save-size.test.js @@ -39,7 +39,9 @@ const bigBiz = "ACT.start({});S.cash=1e9;ACT.launchBB({city:'fra'});ACT.buildPop "S.links.push({id:'df1',a:'fra',b:'ams',kind:'df',own:true,km:450,sys:'roadm',ch:[],ready:0,mo:500,day:0,cut:0});" + "for(let i=0;i<300;i++){const slots=1+i%4;S.biz.push({id:'w'+i,city:'fra',city2:'ams',reqs:[],latMax:null,route:'normal',name:'Carrier '+i,type:'wwave',bw:1,rate:4000,mood:100-i%9*1.37,since:i,sites:null,link:'df1',slots,what:wwWhat(S.links.find(l=>l.id==='df1'),slots),pm:i%2?100:99,warned:i%5===0,warn60:false});}" + "S.biz.push({id:'l2',city:'fra',city2:'ams',reqs:['diverse'],latMax:3.2,route:'fast',name:'Fast Co',type:'hft',bw:5,rate:900,mood:80,since:0,sites:null,slots:0,pm:81,warned:false,warn60:true});" + - "S.biz.push({id:'d1',city:'fra',city2:null,reqs:[],latMax:null,route:'normal',name:'Plain Co',type:'dia',bw:5,rate:600,mood:100,since:0,sites:null,slots:0});compute()"; + "S.biz.push({id:'d1',city:'fra',city2:null,reqs:[],latMax:null,route:'normal',name:'Plain Co',type:'dia',bw:5,rate:600,mood:100,since:0,sites:null,slots:0});" + + // Signed customers carry a contract (#178): when the term ends and the market it was priced in. + "for(const b of S.biz)if(clOn(b)){b.te=400;b.mk=1;}compute()"; const sorted = "JSON.stringify(S.biz.map(b=>Object.keys(b).sort().map(k=>[k,b[k]])))"; test('#176 saves leave customer defaults out, and loading puts them back exactly', () => {
${k==='mix'?l:``}