The sales desk answers renewal haggles, each salesperson their way

With the new switch at the sales desk, whoever runs sales answers a
renewal haggle three days after it opens, unless the player did first.
The engineer gives business customers their discount and keeps nerdy
ones at the market price (nobody leaves); the shark holds the old price,
often with a fresh promise, bills a month of the saving, and loses some
(nerds most); the CEO gives 10% more off for a double term, says yes, or
picks a fight. Every answer is a hash of the contract. The switch is
stored only when on, so existing saves are unchanged.
This commit is contained in:
Frederic Jung 2026-11-06 20:56:50 +01:00
parent d7aad7d965
commit 74e8611f8e
No known key found for this signature in database
17 changed files with 238 additions and 6 deletions

View file

@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows
## [Unreleased] ## [Unreleased]
- Whoever runs sales can now answer renewal haggles for you, each in their own way: switch it on at the sales desk. The engineer keeps nerdy customers at the market price and gives everyone else their discount, the shark refuses discounts and some customers walk, and the CEO settles it on the golf course, for better or worse.
- Your intern can upgrade optical transport: a new standing order moves full, busy fiber to a bigger line system, or trades its smallest channels for bigger optics. Pick a line system, and every fiber on a smaller one is moved up to it. A line system swap takes the fiber down for a day, so the intern only does it where the traffic gets around it and no customer rides it, one a night. - Your intern can upgrade optical transport: a new standing order moves full, busy fiber to a bigger line system, or trades its smallest channels for bigger optics. Pick a line system, and every fiber on a smaller one is moved up to it. A line system swap takes the fiber down for a day, so the intern only does it where the traffic gets around it and no customer rides it, one a night.
- Your intern can standardize your routers on a model you choose: pick it in Keep routers ahead, and every POP on a smaller model is swapped to it, the busiest first, within the monthly budget. Every setting in the Standing orders sheet is now a list to pick from instead of a button to tap through. - Your intern can standardize your routers on a model you choose: pick it in Keep routers ahead, and every POP on a smaller model is swapped to it, the busiest first, within the monthly budget. Every setting in the Standing orders sheet is now a list to pick from instead of a button to tap through.
- France gets seven more cities: Lyon, Toulouse, Lille, Bordeaux, Strasbourg, Rennes and Nantes, all but Nantes with an exchange of their own (#288). SF-Error Telecom and Boy-Egg Telecom bring home broadband and mobile, Ov-Hatch Cloud and Scale-Away bring French clouds, Tangerine Telecom and Free as in Beer reach the new cities, Cogentle reaches Toulouse, Lille, Bordeaux and Strasbourg, and Andorable Telecom comes up to Toulouse. The Atlantic cables now come ashore where they really do: Ami-Tea at Bordeaux and Dunno-ant at Nantes, and Dunno-ant starts at Virginia Beach. - France gets seven more cities: Lyon, Toulouse, Lille, Bordeaux, Strasbourg, Rennes and Nantes, all but Nantes with an exchange of their own (#288). SF-Error Telecom and Boy-Egg Telecom bring home broadband and mobile, Ov-Hatch Cloud and Scale-Away bring French clouds, Tangerine Telecom and Free as in Beer reach the new cities, Cogentle reaches Toulouse, Lille, Bordeaux and Strasbourg, and Andorable Telecom comes up to Toulouse. The Atlantic cables now come ashore where they really do: Ami-Tea at Bordeaux and Dunno-ant at Nantes, and Dunno-ant starts at Virginia Beach.

View file

@ -31,7 +31,7 @@ hoisted across files, and top-level statements run in path order. Find code by n
| `30-networks/` | Other ASes (`NETS`), rival exchanges (`XIX`), the long tail, traffic shares (`NSH`) | | `30-networks/` | Other ASes (`NETS`), rival exchanges (`XIX`), the long tail, traffic shares (`NSH`) |
| `40-progress/` | Customer types (`BIZ_T`), `LEVELS` and their requirements, `GOALS`; the per-save ruleset (`S.rules`, `rule()`, `PRESETS`, `chaosMul()`, `leadDays()`) | | `40-progress/` | Customer types (`BIZ_T`), `LEVELS` and their requirements, `GOALS`; the per-save ruleset (`S.rules`, `rule()`, `PRESETS`, `chaosMul()`, `leadDays()`) |
| `50-state.js` | The globals `S`, `R`, `UI`; `emptyR()` | | `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()`), the sales desk (`S.sales`, `salesDay()`, `salesShape()` on new offers, orbit ones through `pieSlShape()`; signing for you: `S.slAuto`, `slAutoDay()`) | | `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()`), the sales desk (`S.sales`, `salesDay()`, `salesShape()` on new offers, orbit ones through `pieSlShape()`; signing for you: `S.slAuto`, `slAutoDay()`; renewal haggles: `S.slAuto.ren`, `slRenDay()`) |
| `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 | | `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, the customer lifecycle (contracts, renewals, the bandwidth market, why customers leave), 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`) | | `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`) |

View file

@ -4331,8 +4331,22 @@
"sales.locked":"Der Vertrieb öffnet ab Kundenstufe {lv}.", "sales.locked":"Der Vertrieb öffnet ab Kundenstufe {lv}.",
"sales.never":"nie", "sales.never":"nie",
"sales.one_at_a_time":"Immer nur eine Person: Lass sie gehen, um jemand anderen einzustellen.", "sales.one_at_a_time":"Immer nur eine Person: Lass sie gehen, um jemand anderen einzustellen.",
"sales.p_ren":"Nachverhandeln",
"sales.p_sign":"Deals unterschreiben", "sales.p_sign":"Deals unterschreiben",
"sales.pitch":"Eine Person im Vertrieb holt Deals auf ihre eigene Art. Such sie aus.", "sales.pitch":"Eine Person im Vertrieb holt Deals auf ihre eigene Art. Such sie aus.",
"sales.ren":"Nachverhandlungen",
"sales.ren_ceo":"{name} antwortet drei Tage nach Beginn auf die Nachverhandlung eines Kunden, auf dem Golfplatz: mehr Rabatt als verlangt für einen doppelt so langen Vertrag, ein schnelles Ja oder ein Streit, nach dem der Kunde weg ist.",
"sales.ren_ceo_fight":"{name} hat {cust} erklärt, dass mit ihm niemand verhandelt. Sie sind weg.",
"sales.ren_ceo_golf":"{name} hat {cust} auf dem Golfplatz geregelt: {price}/Monat, noch weniger als verlangt, fest bis {date}.",
"sales.ren_ceo_yes":"{name} hat {cust} zugesagt, bevor jemand nachrechnen konnte: {price}/Monat.",
"sales.ren_eng":"{name} antwortet drei Tage nach Beginn auf die Nachverhandlung eines Kunden. Nerdige Kunden bekommen einen Nachmittag mit den Netzplänen und verlängern meist zum Marktpreis; alle anderen bekommen den Rabatt, den sie wollten. Niemand geht.",
"sales.ren_eng_cave":"{name} hat {cust} den gewünschten Rabatt gegeben: {price}/Monat. Sie bleiben.",
"sales.ren_eng_tech":"{name} hat den Engineers von {cust} einen Nachmittag lang das Netz gezeigt. Sie verlängern zu {price}/Monat, ganz ohne Rabatt.",
"sales.ren_mid":"{name} hat sich mit {cust} in der Mitte getroffen: {price}/Monat.",
"sales.ren_shark":"{name} antwortet drei Tage nach Beginn auf die Nachverhandlung eines Kunden und schenkt nichts her: die meisten verlängern zum alten Preis, oft mit einem neuen Versprechen, und er stellt dir einen Monat der Ersparnis in Rechnung. Manche gehen, nerdige am ehesten.",
"sales.ren_shark_hold":"{name} hat {cust} gesagt, der Preis ist der Preis. Sie verlängern zu {price}/Monat, und er stellt dir {fee} für die Rettung in Rechnung.",
"sales.ren_shark_walk":"{name} hat bei {cust} auf hart gemacht, und sie sind gegangen.",
"sales.ren_when":"{name} antwortet am {date}, falls du es nicht vorher tust.",
"sales.shark_d":"Holt die größten Deals zu einem Viertel mehr und kassiert einen Monat jedes Deals als Provision. Verkauft zu viel: Die Hälfte kommt mit einem Versprechen, das dein Netz noch nicht hält, und diese Kunden gehen früher. Ignoriert die Nerds: keine technischen Kunden, keine Meetings, und Peering-Desks wollen ein Viertel mehr Verkehr von dir. Gewinnt die meisten Verhandlungen.", "sales.shark_d":"Holt die größten Deals zu einem Viertel mehr und kassiert einen Monat jedes Deals als Provision. Verkauft zu viel: Die Hälfte kommt mit einem Versprechen, das dein Netz noch nicht hält, und diese Kunden gehen früher. Ignoriert die Nerds: keine technischen Kunden, keine Meetings, und Peering-Desks wollen ein Viertel mehr Verkehr von dir. Gewinnt die meisten Verhandlungen.",
"sales.shark_n":"Der Hai", "sales.shark_n":"Der Hai",
"sales.shark_s":"Chad", "sales.shark_s":"Chad",

View file

@ -4329,8 +4329,22 @@
"sales.locked":"Ventas se abre en el nivel de clientes {lv}.", "sales.locked":"Ventas se abre en el nivel de clientes {lv}.",
"sales.never":"nunca", "sales.never":"nunca",
"sales.one_at_a_time":"Solo una a la vez: despídela para contratar a otra.", "sales.one_at_a_time":"Solo una a la vez: despídela para contratar a otra.",
"sales.p_ren":"Renegociar",
"sales.p_sign":"Firmar tratos", "sales.p_sign":"Firmar tratos",
"sales.pitch":"Una persona de ventas trae tratos a su manera. Elige quién.", "sales.pitch":"Una persona de ventas trae tratos a su manera. Elige quién.",
"sales.ren":"Renegociaciones",
"sales.ren_ceo":"{name} responde a la renegociación de un cliente tres días después de que empiece, en el campo de golf: más descuento del pedido a cambio de un contrato el doble de largo, un sí rápido o una pelea tras la que el cliente se va.",
"sales.ren_ceo_fight":"{name} le dijo a {cust} que con él nadie regatea. Se han ido.",
"sales.ren_ceo_golf":"{name} arregló lo de {cust} en el campo de golf: {price}/mes, aún menos de lo pedido, cerrado hasta el {date}.",
"sales.ren_ceo_yes":"{name} le dijo que sí a {cust} antes de que nadie pudiera comprobarlo: {price}/mes.",
"sales.ren_eng":"{name} responde a la renegociación de un cliente tres días después de que empiece. Los clientes frikis reciben una tarde con los diagramas de la red y suelen renovar a precio de mercado; los demás reciben el descuento que pidieron. Nadie se va.",
"sales.ren_eng_cave":"{name} le dio a {cust} el descuento que pidió: {price}/mes. Se quedan.",
"sales.ren_eng_tech":"{name} pasó una tarde enseñando la red a los ingenieros de {cust}. Renuevan a {price}/mes, sin descuento.",
"sales.ren_mid":"{name} y {cust} se encontraron a medio camino: {price}/mes.",
"sales.ren_shark":"{name} responde a la renegociación de un cliente tres días después de que empiece, y no regala nada: la mayoría renueva al precio antiguo, a menudo con una promesa nueva, y te cobra un mes de lo que te ahorró. Algunos se van, sobre todo los frikis.",
"sales.ren_shark_hold":"{name} le dijo a {cust} que el precio es el precio. Renuevan a {price}/mes, y te cobra {fee} por salvarlo.",
"sales.ren_shark_walk":"{name} se puso duro con {cust}, y se fueron.",
"sales.ren_when":"{name} responde el {date}, salvo que lo hagas tú antes.",
"sales.shark_d":"Consigue los tratos más grandes a un cuarto más, y se lleva un mes de cada trato de comisión. Vende de más: la mitad llega con una promesa que tu red aún no cumple, y esos clientes se van antes. Ignora a los nerds: nada de clientes técnicos ni de reuniones, y los equipos de peering te piden un cuarto más de tráfico. Gana casi todas las negociaciones.", "sales.shark_d":"Consigue los tratos más grandes a un cuarto más, y se lleva un mes de cada trato de comisión. Vende de más: la mitad llega con una promesa que tu red aún no cumple, y esos clientes se van antes. Ignora a los nerds: nada de clientes técnicos ni de reuniones, y los equipos de peering te piden un cuarto más de tráfico. Gana casi todas las negociaciones.",
"sales.shark_n":"El tiburón", "sales.shark_n":"El tiburón",
"sales.shark_s":"Chad", "sales.shark_s":"Chad",

View file

@ -4329,8 +4329,22 @@
"sales.locked":"Le service commercial ouvre au niveau clients {lv}.", "sales.locked":"Le service commercial ouvre au niveau clients {lv}.",
"sales.never":"jamais", "sales.never":"jamais",
"sales.one_at_a_time":"Une seule à la fois : laissez-la partir pour en recruter une autre.", "sales.one_at_a_time":"Une seule à la fois : laissez-la partir pour en recruter une autre.",
"sales.p_ren":"Renégocier",
"sales.p_sign":"Signer les contrats", "sales.p_sign":"Signer les contrats",
"sales.pitch":"Un commercial apporte des contrats à sa façon. Choisissez qui.", "sales.pitch":"Un commercial apporte des contrats à sa façon. Choisissez qui.",
"sales.ren":"Renégociations",
"sales.ren_ceo":"{name} répond à la renégociation d'un client trois jours après son début, sur le terrain de golf : une remise plus forte que demandé contre un contrat deux fois plus long, un oui rapide, ou une dispute après laquelle le client s'en va.",
"sales.ren_ceo_fight":"{name} a dit à {cust} que personne ne négocie avec lui. Ils sont partis.",
"sales.ren_ceo_golf":"{name} a réglé le cas de {cust} sur le terrain de golf : {price}/mois, encore moins que demandé, bloqué jusqu'au {date}.",
"sales.ren_ceo_yes":"{name} a dit oui à {cust} avant que quiconque puisse vérifier : {price}/mois.",
"sales.ren_eng":"{name} répond à la renégociation d'un client trois jours après son début. Les clients geeks ont droit à un après-midi avec les schémas du réseau et renouvellent le plus souvent au prix du marché ; les autres obtiennent la remise demandée. Personne ne part.",
"sales.ren_eng_cave":"{name} a accordé à {cust} la remise demandée : {price}/mois. Ils restent.",
"sales.ren_eng_tech":"{name} a passé un après-midi à montrer le réseau aux ingénieurs de {cust}. Ils renouvellent à {price}/mois, sans remise.",
"sales.ren_mid":"{name} a coupé la poire en deux avec {cust} : {price}/mois.",
"sales.ren_shark":"{name} répond à la renégociation d'un client trois jours après son début, et ne lâche rien : la plupart renouvellent à l'ancien prix, souvent avec une nouvelle promesse, et il vous facture un mois de ce qu'il vous a fait gagner. Certains partent, surtout les geeks.",
"sales.ren_shark_hold":"{name} a dit à {cust} que le prix, c'est le prix. Ils renouvellent à {price}/mois, et il vous facture {fee} pour l'avoir sauvé.",
"sales.ren_shark_walk":"{name} a joué les durs avec {cust}, et ils sont partis.",
"sales.ren_when":"{name} répond le {date}, sauf si vous le faites avant.",
"sales.shark_d":"Décroche les plus gros contrats un quart plus cher, et prend un mois de chaque contrat en commission. Survend : la moitié arrive avec une promesse que votre réseau ne tient pas encore, et ces clients partent plus tôt. Ignore les geeks : pas de clients techniques, pas de NOG, et les équipes peering vous demandent un quart de trafic en plus. Gagne la plupart des négociations.", "sales.shark_d":"Décroche les plus gros contrats un quart plus cher, et prend un mois de chaque contrat en commission. Survend : la moitié arrive avec une promesse que votre réseau ne tient pas encore, et ces clients partent plus tôt. Ignore les geeks : pas de clients techniques, pas de NOG, et les équipes peering vous demandent un quart de trafic en plus. Gagne la plupart des négociations.",
"sales.shark_n":"Le requin", "sales.shark_n":"Le requin",
"sales.shark_s":"Chad", "sales.shark_s":"Chad",

View file

@ -4329,8 +4329,22 @@
"sales.locked":"L'ufficio vendite apre al livello clienti {lv}.", "sales.locked":"L'ufficio vendite apre al livello clienti {lv}.",
"sales.never":"mai", "sales.never":"mai",
"sales.one_at_a_time":"Uno alla volta: lascialo andare per assumerne un altro.", "sales.one_at_a_time":"Uno alla volta: lascialo andare per assumerne un altro.",
"sales.p_ren":"Rinegoziare",
"sales.p_sign":"Firma contratti", "sales.p_sign":"Firma contratti",
"sales.pitch":"Un venditore porta contratti a modo suo. Scegli chi.", "sales.pitch":"Un venditore porta contratti a modo suo. Scegli chi.",
"sales.ren":"Rinegoziazioni",
"sales.ren_ceo":"{name} risponde alla rinegoziazione di un cliente tre giorni dopo l'inizio, sul campo da golf: più sconto di quanto chiesto in cambio di un contratto lungo il doppio, un sì veloce, o una lite dopo cui il cliente se ne va.",
"sales.ren_ceo_fight":"{name} ha detto a {cust} che con lui nessuno tratta. Se ne sono andati.",
"sales.ren_ceo_golf":"{name} ha sistemato {cust} sul campo da golf: {price}/mese, ancora meno di quanto chiesto, bloccato fino al {date}.",
"sales.ren_ceo_yes":"{name} ha detto sì a {cust} prima che qualcuno potesse controllare: {price}/mese.",
"sales.ren_eng":"{name} risponde alla rinegoziazione di un cliente tre giorni dopo l'inizio. I clienti nerd passano un pomeriggio con gli schemi della rete e di solito rinnovano a prezzo di mercato; gli altri ottengono lo sconto che chiedevano. Nessuno se ne va.",
"sales.ren_eng_cave":"{name} ha dato a {cust} lo sconto che chiedeva: {price}/mese. Restano.",
"sales.ren_eng_tech":"{name} ha passato un pomeriggio a mostrare la rete agli ingegneri di {cust}. Rinnovano a {price}/mese, senza sconto.",
"sales.ren_mid":"{name} è venuto incontro a {cust}: {price}/mese.",
"sales.ren_shark":"{name} risponde alla rinegoziazione di un cliente tre giorni dopo l'inizio, e non regala niente: quasi tutti rinnovano al vecchio prezzo, spesso con una nuova promessa, e ti fattura un mese di quanto ti ha fatto risparmiare. Alcuni se ne vanno, soprattutto i nerd.",
"sales.ren_shark_hold":"{name} ha detto a {cust} che il prezzo è il prezzo. Rinnovano a {price}/mese, e lui ti fattura {fee} per averli salvati.",
"sales.ren_shark_walk":"{name} ha fatto il duro con {cust}, e se ne sono andati.",
"sales.ren_when":"{name} risponde il {date}, a meno che tu non lo faccia prima.",
"sales.shark_d":"Porta i contratti più grandi a un quarto in più, e si prende un mese di ogni contratto come provvigione. Vende troppo: metà arriva con una promessa che la tua rete non mantiene ancora, e quei clienti se ne vanno prima. Ignora i nerd: niente clienti tecnici, niente incontri, e i peering desk ti chiedono un quarto di traffico in più. Vince quasi tutte le trattative.", "sales.shark_d":"Porta i contratti più grandi a un quarto in più, e si prende un mese di ogni contratto come provvigione. Vende troppo: metà arriva con una promessa che la tua rete non mantiene ancora, e quei clienti se ne vanno prima. Ignora i nerd: niente clienti tecnici, niente incontri, e i peering desk ti chiedono un quarto di traffico in più. Vince quasi tutte le trattative.",
"sales.shark_n":"Lo squalo", "sales.shark_n":"Lo squalo",
"sales.shark_s":"Chad", "sales.shark_s":"Chad",

View file

@ -4329,8 +4329,22 @@
"sales.locked":"Vendas abre no nível de clientes {lv}.", "sales.locked":"Vendas abre no nível de clientes {lv}.",
"sales.never":"nunca", "sales.never":"nunca",
"sales.one_at_a_time":"Uma por vez: dispense para contratar outra.", "sales.one_at_a_time":"Uma por vez: dispense para contratar outra.",
"sales.p_ren":"Renegociar",
"sales.p_sign":"Assinar contratos", "sales.p_sign":"Assinar contratos",
"sales.pitch":"Uma pessoa de vendas traz negócios do jeito dela. Escolha quem.", "sales.pitch":"Uma pessoa de vendas traz negócios do jeito dela. Escolha quem.",
"sales.ren":"Renegociações",
"sales.ren_ceo":"{name} responde à renegociação de um cliente três dias depois de começar, no campo de golfe: mais desconto do que pediram em troca de um contrato com o dobro da duração, um sim rápido, ou uma briga que termina com o cliente indo embora.",
"sales.ren_ceo_fight":"{name} disse a {cust} que ninguém pechincha com ele. Foram embora.",
"sales.ren_ceo_golf":"{name} resolveu {cust} no campo de golfe: {price}/mês, ainda menos do que pediram, fechado até {date}.",
"sales.ren_ceo_yes":"{name} disse sim a {cust} antes que alguém pudesse conferir: {price}/mês.",
"sales.ren_eng":"{name} responde à renegociação de um cliente três dias depois de começar. Clientes nerds ganham uma tarde com os diagramas da rede e quase sempre renovam a preço de mercado; os outros recebem o desconto que pediram. Ninguém sai.",
"sales.ren_eng_cave":"{name} deu a {cust} o desconto que pediram: {price}/mês. Eles ficam.",
"sales.ren_eng_tech":"{name} passou uma tarde mostrando a rede aos engenheiros da {cust}. Renovam a {price}/mês, sem desconto.",
"sales.ren_mid":"{name} e {cust} chegaram a um meio-termo: {price}/mês.",
"sales.ren_shark":"{name} responde à renegociação de um cliente três dias depois de começar, e não cede nada: a maioria renova ao preço antigo, muitas vezes com uma nova promessa, e ele te cobra um mês do que economizou. Alguns vão embora, principalmente os nerds.",
"sales.ren_shark_hold":"{name} disse a {cust} que preço é preço. Renovam a {price}/mês, e ele te cobra {fee} pelo resgate.",
"sales.ren_shark_walk":"{name} jogou duro com {cust}, e eles foram embora.",
"sales.ren_when":"{name} responde em {date}, a não ser que você responda antes.",
"sales.shark_d":"Fecha os maiores negócios por um quarto a mais, e leva um mês de cada contrato de comissão. Vende demais: metade chega com uma promessa que sua rede ainda não cumpre, e esses clientes saem mais cedo. Ignora os nerds: nada de clientes técnicos nem de encontros, e as equipes de peering pedem um quarto a mais de tráfego. Ganha quase todas as negociações.", "sales.shark_d":"Fecha os maiores negócios por um quarto a mais, e leva um mês de cada contrato de comissão. Vende demais: metade chega com uma promessa que sua rede ainda não cumpre, e esses clientes saem mais cedo. Ignora os nerds: nada de clientes técnicos nem de encontros, e as equipes de peering pedem um quarto a mais de tráfego. Ganha quase todas as negociações.",
"sales.shark_n":"O tubarão", "sales.shark_n":"O tubarão",
"sales.shark_s":"Chad", "sales.shark_s":"Chad",

View file

@ -243,6 +243,8 @@ const API_CMD={
doc:'With the CEO running sales: pay for a board meeting that brings a VP of Sales, who frees the desk a month later.'}, doc:'With the CEO running sales: pay for a board meeting that brings a VP of Sales, who frees the desk a month later.'},
salesAuto:{args:[],watch:['slAuto'], salesAuto:{args:[],watch:['slAuto'],
doc:'With someone at the sales desk: switch automatic signing on or off. Once a game day they sign the offers that fit, in their own style: eng and ceo after a routing trial (one a day; an offer that did not fit waits a week), shark every offer whose POPs are up, promises and all, while the cash covers the commission. Orbit offers sign where the landing dish has room (the shark ignores that). Nobody at the desk: nothing is signed for you.'}, doc:'With someone at the sales desk: switch automatic signing on or off. Once a game day they sign the offers that fit, in their own style: eng and ceo after a routing trial (one a day; an offer that did not fit waits a week), shark every offer whose POPs are up, promises and all, while the cash covers the commission. Orbit offers sign where the landing dish has room (the shark ignores that). Nobody at the desk: nothing is signed for you.'},
salesRen:{args:[],watch:['slAuto'],
doc:'Switch whether the sales desk answers renewal haggles for you, 3 days after each opens (only while someone runs sales). The engineer gives business customers their discount and keeps nerdy ones at the market price; the shark holds the old price (sometimes with a new promise, billing a month of the saving) but some walk; the CEO gives 10% more off for a double term, says yes, or picks a fight and loses them.'},
salesMin:{args:[],watch:['slAuto'], salesMin:{args:[],watch:['slAuto'],
doc:'Step the minimum monthly value under which the sales desk declines offers: never, 2k, 5k, 10k, 25k, 50k. With the CEO, about one decline in three is signed anyway.'}, doc:'Step the minimum monthly value under which the sales desk declines offers: never, 2k, 5k, 10k, 25k, 50k. With the CEO, about one decline in three is signed anyway.'},
renewMatch:{args:[['id','entityId']],watch:['biz.#id'], renewMatch:{args:[['id','entityId']],watch:['biz.#id'],

View file

@ -36,7 +36,7 @@ const API_STATE_DOC={
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}).'}, 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).'}, 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).'},
sales:{type:'map',doc:'The sales desk: p (eng, shark, ceo or null), hired (day), vp (the day a VP of Sales takes over from the CEO), golf and say (the CEO\'s next golf deal and opinion). Offers and customers carry by: who brought or signed them, orbit ones too (the shark\'s may carry the skyfull promise).'}, sales:{type:'map',doc:'The sales desk: p (eng, shark, ceo or null), hired (day), vp (the day a VP of Sales takes over from the CEO), golf and say (the CEO\'s next golf deal and opinion). Offers and customers carry by: who brought or signed them, orbit ones too (the shark\'s may carry the skyfull promise).'},
slAuto:{type:'map',doc:'Deals the sales desk signs for you (only while someone runs sales): on (sign offers that fit), min (decline offers paying less a month; 0 never), wk (this week: w, p who was at the desk, n signed, rev their monthly revenue, x declined, y declined but signed anyway by the CEO) and rep (last week, the same).'}, slAuto:{type:'map',doc:'Deals the sales desk signs for you (only while someone runs sales): on (sign offers that fit), min (decline offers paying less a month; 0 never), ren (answer renewal haggles), wk (this week: w, p who was at the desk, n signed, rev their monthly revenue, x declined, y declined but signed anyway by the CEO) and rep (last week, the same).'},
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.'}, 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.'}, done:{type:'map',doc:'Goals landed, by goal id → day.'},
ach:{type:'map',doc:'Badges earned this game, by badge id → day.'}, ach:{type:'map',doc:'Badges earned this game, by badge id → day.'},

View file

@ -16,7 +16,7 @@ const slAutoOn=()=>!!(S&&S.slAuto&&slP()&&(S.slAuto.on||S.slAuto.min));
function slWkOk(x){if(!x||typeof x!=='object'||Array.isArray(x)||!own(SALES,x.p))return null;const n=v=>int(v,0,1e6,0);return {w:n(x.w),p:x.p,n:n(x.n),rev:int(x.rev,0,1e10,0),x:n(x.x),y:n(x.y)};} function slWkOk(x){if(!x||typeof x!=='object'||Array.isArray(x)||!own(SALES,x.p))return null;const n=v=>int(v,0,1e6,0);return {w:n(x.w),p:x.p,n:n(x.n),rev:int(x.rev,0,1e10,0),x:n(x.x),y:n(x.y)};}
const slWkAny=x=>!!x&&(x.n>0||x.x>0); const slWkAny=x=>!!x&&(x.n>0||x.x>0);
function slAutoFix(s){const a=s.slAuto&&typeof s.slAuto==='object'&&!Array.isArray(s.slAuto)?s.slAuto:{}; function slAutoFix(s){const a=s.slAuto&&typeof s.slAuto==='object'&&!Array.isArray(s.slAuto)?s.slAuto:{};
s.slAuto={on:a.on===true,min:SL_MINS.includes(a.min)?a.min:0,wk:slWkOk(a.wk),rep:slWkOk(a.rep)};} s.slAuto={on:a.on===true,min:SL_MINS.includes(a.min)?a.min:0,wk:slWkOk(a.wk),rep:slWkOk(a.rep)};if(a.ren===true)s.slAuto.ren=true;}
// An old save whose intern ran the sales order: the same switch and minimum, now at the sales desk (they run once someone is there). // An old save whose intern ran the sales order: the same switch and minimum, now at the sales desk (they run once someone is there).
function slAutoFrom(s,on,p){if(!on||(s.slAuto&&typeof s.slAuto==='object'))return;s.slAuto={on:p.acc!==false,min:SL_MINS.includes(p.min)?p.min:0,wk:null,rep:null};} function slAutoFrom(s,on,p){if(!on||(s.slAuto&&typeof s.slAuto==='object'))return;s.slAuto={on:p.acc!==false,min:SL_MINS.includes(p.min)?p.min:0,wk:null,rep:null};}
// "This week Dave signed 3 customers (+$41k/mo), declined 17 tiny offers." // "This week Dave signed 3 customers (+$41k/mo), declined 17 tiny offers."

View file

@ -0,0 +1,36 @@
/* ---------- The sales desk answers renewal haggles ----------
A customer near the end of its term may ask for a discount (#178, 75-customer-lifecycle.js). With S.slAuto.ren on,
whoever runs sales answers it SL_REN_WAIT days after it opens, so the player can still answer first. Each in their way:
- the engineer talks technology, not price: nerdy customers get an afternoon with the network diagrams and renew at
the market price, now and then halfway; everyone else gets the discount they asked for. Nobody leaves.
- the shark gives nothing away: most renew at the old price, often with a fresh promise, and he bills a month of what
he saved you. Some walk, nerdy ones most of all.
- the CEO settles it on the golf course: a deeper discount than asked for a contract twice as long, a quick yes, or
a fight that ends with the customer gone.
Each answer is a hash of the contract (clR), so no random numbers are drawn. */
const SL_REN_WAIT=3;
const slRenOn=()=>!!(S&&S.slAuto&&S.slAuto.ren&&slP());
// The day the desk answers this haggle: a few days after it opened (30 days before the term ends), today at the earliest.
const slRenAt=b=>b.hag.until-30+SL_REN_WAIT;
function slRenDay(d){if(!slRenOn())return;const p=slP();let any=false;
for(const b of S.biz.slice())if(b.hag&&d>=slRenAt(b)&&d<b.hag.until){slRenOne(b,p);any=true;}
if(any)compute();}
// One haggle: returns what happened (for the tests): 'tech', 'mid', 'cave', 'hold', 'walk', 'golf', 'yes', 'fight'.
function slRenOne(b,p){const ask=b.hag.rate,was=b.rate,mid=clMid(b),nerd=SALES_NERDS.includes(b.type),r=clR(b,'sl|'+p);
const v=x=>({name:esc(slCap()),cust:esc(b.name),...x}),bill=rate=>fmt$(clBill(b,rate));
const keep=(rate,how,key,x,s)=>{clRenew(b,rate);clNote('ren');toast(tr(key,v({price:bill(b.rate),...x})),s===undefined?'good':s,[{l:tr('common.show_me'),act:'custGo',args:{id:b.id}}]);return how;};
const gone=(how,key)=>{clGone(b,'cheap');toast(tr(key,v({})),'bad');sfx('err');return how;};
if(p==='eng'){if(!nerd)return keep(ask,'cave','sales.ren_eng_cave');
return r<0.7?keep(Math.max(ask,Math.min(was,clFair(b))),'tech','sales.ren_eng_tech'):keep(mid,'mid','sales.ren_mid');}
if(p==='shark'){const walk=nerd?0.4:0.12;if(r<walk)return gone('walk','sales.ren_shark_walk');
if(r<walk+0.5){const fee=Math.round(clBill(b,was-ask)),k=clR(b,'slp')<0.5?salesPromise(b):null;
if(k)b.reqs=(b.reqs||[]).concat(k);S.cash-=fee;
const req=k?' '+tr('sales.ceo_promised',{req:esc(typeof REQS[k].l==='function'?REQS[k].l(b):REQS[k].l)}):'';
clRenew(b,was);clNote('ren');toast(tr('sales.ren_shark_hold',v({price:bill(b.rate),fee:fmt$(fee)}))+req,'',[{l:tr('common.show_me'),act:'custGo',args:{id:b.id}}]);return 'hold';}
return keep(mid,'mid','sales.ren_mid');}
if(r<0.25)return gone('fight','sales.ren_ceo_fight');
if(r<0.6){clRenew(b,Math.round(ask*0.9));b.te=clTerm(b,b.te);clNote('ren');
toast(tr('sales.ren_ceo_golf',v({price:bill(b.rate),date:dateStr(b.te)})),'',[{l:tr('common.show_me'),act:'custGo',args:{id:b.id}}]);return 'golf';}
return keep(ask,'yes','sales.ren_ceo_yes',{},'');}
// Under a haggle in Deals: when the desk will answer it.
const slRenRow=b=>slRenOn()&&b.hag.until>S.day?`<div class="meta">${tr('sales.ren_when',{name:esc(slCap()),date:dateStr(Math.max(S.day+1,slRenAt(b)))})}</div>`:'';

View file

@ -117,7 +117,7 @@ const clHags=()=>S?S.biz.reduce((a,b)=>a+(b.hag?1:0),0):0;
function clDealsHtml(){const hs=S.biz.filter(b=>b.hag).sort((a,b)=>a.hag.until-b.hag.until);if(!hs.length)return ''; function clDealsHtml(){const hs=S.biz.filter(b=>b.hag).sort((a,b)=>a.hag.until-b.hag.until);if(!hs.length)return '';
return `<h3 class="sub4">${tr('lifecycle.renewals')}</h3><p class="meta" style="margin:0 0 6px">${tr('lifecycle.unanswered_matches')}</p>`+hs.map(b=>{const now=BIZ_T[b.type].fiber?b.hag.rate:b.bw*b.hag.rate,was=bizMo(b); return `<h3 class="sub4">${tr('lifecycle.renewals')}</h3><p class="meta" style="margin:0 0 6px">${tr('lifecycle.unanswered_matches')}</p>`+hs.map(b=>{const now=BIZ_T[b.type].fiber?b.hag.rate:b.bw*b.hag.rate,was=bizMo(b);
return `<div class="row"><div class="grow"><div class="nm">${esc(b.name)}</div><div class="meta">${esc(BIZ_T[b.type].l)} · ${esc(clWhere(b))} · ${tr('ui.n_d_left',{n:b.hag.until-S.day})}</div> return `<div class="row"><div class="grow"><div class="nm">${esc(b.name)}</div><div class="meta">${esc(BIZ_T[b.type].l)} · ${esc(clWhere(b))} · ${tr('ui.n_d_left',{n:b.hag.until-S.day})}</div>
<div class="meta">${tr('lifecycle.wants_price',{was:fmt$(was),price:fmt$(now),p:pct(1-now/Math.max(1,was))})}</div> <div class="meta">${tr('lifecycle.wants_price',{was:fmt$(was),price:fmt$(now),p:pct(1-now/Math.max(1,was))})}</div>${slRenRow(b)}
<div class="btns">${btn(tr('lifecycle.match'),'renewMatch',{id:b.id},'green sm')}${btn(tr('lifecycle.meet_halfway',{price:fmt$(clBill(b,clMid(b)))}),'renewMeet',{id:b.id},'sm')}${btn(tr('lifecycle.let_them_go'),'renewLet',{id:b.id},'ghost sm')}</div></div></div>`;}).join('');} <div class="btns">${btn(tr('lifecycle.match'),'renewMatch',{id:b.id},'green sm')}${btn(tr('lifecycle.meet_halfway',{price:fmt$(clBill(b,clMid(b)))}),'renewMeet',{id:b.id},'sm')}${btn(tr('lifecycle.let_them_go'),'renewLet',{id:b.id},'ghost sm')}</div></div></div>`;}).join('');}
// The contract line on a customer row. // 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)})):''; 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)})):'';

View file

@ -62,7 +62,7 @@ function dayPost(d){
// contracts: renewals, growth, haggles and leaving (75-customer-lifecycle.js) // contracts: renewals, growth, haggles and leaving (75-customer-lifecycle.js)
clDay(d); clDay(d);
// the sales desk: meetings booked, golf played (38-sales-desk.js) // the sales desk: meetings booked, golf played (38-sales-desk.js)
salesDay(d); salesDay(d);slRenDay(d);
// own IX members join // own IX members join
for(const c in S.myIx){const m=S.myIx[c];if(d>=m.next&&m.members.length<myFab(c).max){ for(const c in S.myIx){const m=S.myIx[c];if(d>=m.next&&m.members.length<myFab(c).max){
const cands=NETS.filter(n=>n.type!=='t1'&&!m.members.includes(n.id)&&(n.pops.includes(c)||n.pops.some(p=>CITY[p].reg===CITY[c].reg))); const cands=NETS.filter(n=>n.type!=='t1'&&!m.members.includes(n.id)&&(n.pops.includes(c)||n.pops.some(p=>CITY[p].reg===CITY[c].reg)));

View file

@ -10,6 +10,7 @@ Object.assign(ACT,{
// The CEO cannot be fired. A board meeting (and its catering) can get you a VP of Sales, who takes over a month later. // The CEO cannot be fired. A board meeting (and its catering) can get you a VP of Sales, who takes over a month later.
// Signing for you (39-sales-auto.js): on or off, and the minimum under which offers are declined. // Signing for you (39-sales-auto.js): on or off, and the minimum under which offers are declined.
salesAuto:()=>{if(!slP())return;const A=S.slAuto||(S.slAuto=slAutoNew());A.on=!A.on;sfx('click');after();salesModal();}, salesAuto:()=>{if(!slP())return;const A=S.slAuto||(S.slAuto=slAutoNew());A.on=!A.on;sfx('click');after();salesModal();},
salesRen:()=>{if(!slP())return;const A=S.slAuto||(S.slAuto=slAutoNew());if(A.ren)delete A.ren;else A.ren=true;sfx('click');after();salesModal();},
salesMin:()=>{if(!slP())return;const A=S.slAuto||(S.slAuto=slAutoNew());A.min=opsCycle(SL_MINS,A.min);sfx('click');after();salesModal();}, salesMin:()=>{if(!slP())return;const A=S.slAuto||(S.slAuto=slAutoNew());A.min=opsCycle(SL_MINS,A.min);sfx('click');after();salesModal();},
salesVp:()=>{if(slP()!=='ceo'||S.sales.vp)return;if(!spend(SALES_VP))return;S.sales.vp=S.day+SALES_VP_DAYS;toast(tr('sales.vp_asked',{n:SALES_VP_DAYS}),'');after();salesModal();}, salesVp:()=>{if(slP()!=='ceo'||S.sales.vp)return;if(!spend(SALES_VP))return;S.sales.vp=S.day+SALES_VP_DAYS;toast(tr('sales.vp_asked',{n:SALES_VP_DAYS}),'');after();salesModal();},
}); });

View file

@ -19,12 +19,15 @@ function salesModal(){if(!S)return;const p=slP(),L=S.sales||{};
// What each of them does in orbit, shown once there is a rocket company to sell for (99-pie-sales.js). // What each of them does in orbit, shown once there is a rocket company to sell for (99-pie-sales.js).
const SL_SKY={eng:N_('sales.eng_sky'),shark:N_('sales.shark_sky'),ceo:N_('sales.ceo_sky')}; const SL_SKY={eng:N_('sales.eng_sky'),shark:N_('sales.shark_sky'),ceo:N_('sales.ceo_sky')};
const SL_AUTO={eng:N_('sales.auto_eng'),shark:N_('sales.auto_shark'),ceo:N_('sales.auto_ceo')}; const SL_AUTO={eng:N_('sales.auto_eng'),shark:N_('sales.auto_shark'),ceo:N_('sales.auto_ceo')};
const SL_REN={eng:N_('sales.ren_eng'),shark:N_('sales.ren_shark'),ceo:N_('sales.ren_ceo')};
// Signing for you (39-sales-auto.js): the switch, the minimum, and this week's and last week's tally. // Signing for you (39-sales-auto.js): the switch, the minimum, and this week's and last week's tally.
function slAutoHtml(p){const A=S.slAuto||slAutoNew(),w=Math.floor(S.day/7),cur=A.wk&&A.wk.w===w&&slWkAny(A.wk)?A.wk:null,rep=A.rep&&A.rep.w===w-1?A.rep:null; function slAutoHtml(p){const A=S.slAuto||slAutoNew(),w=Math.floor(S.day/7),cur=A.wk&&A.wk.w===w&&slWkAny(A.wk)?A.wk:null,rep=A.rep&&A.rep.w===w-1?A.rep:null;
const row=(x,last)=>`<div class="ops-rep">${esc(slWeekLine(x,last))}</div>`; const row=(x,last)=>`<div class="ops-rep">${esc(slWeekLine(x,last))}</div>`;
return `<section class="sl-auto"><h3>${tr('sales.auto')}</h3><p class="meta">${tr(SL_AUTO[p],{name:esc(slCap())})}</p> return `<section class="sl-auto"><h3>${tr('sales.auto')}</h3><p class="meta">${tr(SL_AUTO[p],{name:esc(slCap())})}</p>
<div class="ops-p"><button class="b sm ${A.on?'green':'ghost'}" data-act="salesAuto" data-args='{}' aria-pressed="${A.on}">${tr('sales.p_sign')}: <b>${A.on?tr('common.on'):tr('common.off')}</b></button> <div class="ops-p"><button class="b sm ${A.on?'green':'ghost'}" data-act="salesAuto" data-args='{}' aria-pressed="${A.on}">${tr('sales.p_sign')}: <b>${A.on?tr('common.on'):tr('common.off')}</b></button>
${btn(`${tr('sales.decline_below')}: <b>${A.min?tr('common.price_mo',{price:fmt$(A.min)}):tr('sales.never')}</b>`,'salesMin',{},'ghost sm')}</div> ${btn(`${tr('sales.decline_below')}: <b>${A.min?tr('common.price_mo',{price:fmt$(A.min)}):tr('sales.never')}</b>`,'salesMin',{},'ghost sm')}</div>
${rep?row(rep,true):''}${cur?row(cur,false):''}</section>`;} ${rep?row(rep,true):''}${cur?row(cur,false):''}</section>
<section class="sl-auto"><h3>${tr('sales.ren')}</h3><p class="meta">${tr(SL_REN[p],{name:esc(slCap())})}</p>
<div class="ops-p"><button class="b sm ${A.ren?'green':'ghost'}" data-act="salesRen" data-args='{}' aria-pressed="${!!A.ren}">${tr('sales.p_ren')}: <b>${A.ren?tr('common.on'):tr('common.off')}</b></button></div></section>`;}
// On the card in Deals: this week's tally, once there is one. // On the card in Deals: this week's tally, once there is one.
function slCardLine(){if(!slAutoOn())return '';const A=S.slAuto,x=A.wk&&A.wk.w===Math.floor(S.day/7)&&slWkAny(A.wk)?A.wk:null;return x?esc(slWeekLine(x,false)):'';} function slCardLine(){if(!slAutoOn())return '';const A=S.slAuto,x=A.wk&&A.wk.w===Math.floor(S.day/7)&&slWkAny(A.wk)?A.wk:null;return x?esc(slWeekLine(x,false)):'';}

View file

@ -4330,8 +4330,22 @@
"sales.locked":"The sales desk opens at customer level {lv}.", "sales.locked":"The sales desk opens at customer level {lv}.",
"sales.never":"never", "sales.never":"never",
"sales.one_at_a_time":"One at a time: let them go to hire someone else.", "sales.one_at_a_time":"One at a time: let them go to hire someone else.",
"sales.p_ren":"Answer haggles",
"sales.p_sign":"Sign deals", "sales.p_sign":"Sign deals",
"sales.pitch":"One salesperson brings in deals their own way. Pick who.", "sales.pitch":"One salesperson brings in deals their own way. Pick who.",
"sales.ren":"Renewal haggles",
"sales.ren_ceo":"{name} answers a customer's haggle three days after it opens, on the golf course: a deeper discount than they asked for in exchange for a contract twice as long, a quick yes, or a fight that ends with the customer gone.",
"sales.ren_ceo_fight":"{name} told {cust} that nobody haggles with him. They have left.",
"sales.ren_ceo_golf":"{name} sorted out {cust} on the golf course: {price}/mo, even less than they asked, locked in until {date}.",
"sales.ren_ceo_yes":"{name} said yes to {cust} before anyone could check: {price}/mo.",
"sales.ren_eng":"{name} answers a customer's haggle three days after it opens. Nerdy customers get an afternoon with the network diagrams and usually renew at the market price; everyone else gets the discount they asked for. Nobody leaves.",
"sales.ren_eng_cave":"{name} gave {cust} the discount they asked for: {price}/mo. They stay.",
"sales.ren_eng_tech":"{name} walked {cust}'s engineers through the network for an afternoon. They renew at {price}/mo, no discount needed.",
"sales.ren_mid":"{name} met {cust} halfway: {price}/mo.",
"sales.ren_shark":"{name} answers a customer's haggle three days after it opens, and gives nothing away: most renew at the old price, often with a fresh promise, and he bills you a month of what he saved. Some walk, nerdy ones most of all.",
"sales.ren_shark_hold":"{name} told {cust} the price is the price. They renew at {price}/mo, and he bills you {fee} for the save.",
"sales.ren_shark_walk":"{name} played hardball with {cust}, and they walked.",
"sales.ren_when":"{name} answers this on {date}, unless you do first.",
"sales.shark_d":"Lands the biggest deals at a quarter more, and takes a month of each deal as commission. Oversells: half of them come with a promise your network does not keep yet, and those customers leave sooner. Ignores the nerds: no technical customers, no meetings, and peering desks want a quarter more traffic from you. Wins most haggles.", "sales.shark_d":"Lands the biggest deals at a quarter more, and takes a month of each deal as commission. Oversells: half of them come with a promise your network does not keep yet, and those customers leave sooner. Ignores the nerds: no technical customers, no meetings, and peering desks want a quarter more traffic from you. Wins most haggles.",
"sales.shark_n":"The shark", "sales.shark_n":"The shark",
"sales.shark_s":"Chad", "sales.shark_s":"Chad",

View file

@ -0,0 +1,105 @@
// The sales desk answers renewal haggles (39-sales-renewals.js): the engineer talks technology, the shark gives
// nothing away, the CEO settles it on the golf course. Every answer is a hash of the contract, so the tests make
// many customers and look at what each kind of salesperson does with them, 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.lvl=4;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 customer 27 days from the end of its term, asking $700 instead of the $1,000 it pays: the desk answers it today.
const hag = (id, type = 'dia', extra = '') => `{id:'${id}',city:'ams',city2:null,name:'${id}',type:'${type}',bw:5,rate:1000,reqs:[],mood:90,since:S.day-800,te:S.day+27,mk:1,hag:{rate:700,until:S.day+27}${extra}}`;
// What one kind of salesperson does with n customers of a type: the outcome of each, its new rate and term.
const run = (ev, p, type, n = 300) => {
ev(`S.sales.p='${p}';S.biz=S.biz.filter(b=>!b.hag)`);
return JSON.parse(ev(`(()=>{const out=[];for(let i=0;i<${n};i++){const b=${hag('x', type)};b.id=b.name='${p}-${type}-'+i;S.biz.push(b);const te0=b.te,how=slRenOne(b,'${p}');
out.push({how,rate:b.rate,te:b.te-te0,hag:!!b.hag,here:S.biz.includes(b),reqs:b.reqs.length});}return JSON.stringify(out);})()`));
};
const share = (o, how) => o.filter((x) => x.how === how).length / o.length;
test('off until you switch it on; the desk answers three days into the haggle, unless you did first', () => {
const { ev, errors } = load();
ev(start);
ev("S.biz.push(" + hag('early') + ");S.biz.find(b=>b.id==='early').hag.until=S.day+29;S.biz.find(b=>b.id==='early').te=S.day+29");
ev("S.biz.push(" + hag('due') + ")");
ev('slRenDay(S.day)');
assert.ok(ev("S.biz.every(b=>!b.id.match(/early|due/)||b.hag)"), 'nobody at the desk: nothing happens');
ev("ACT.salesHire({id:'eng'})");
ev('slRenDay(S.day)');
assert.ok(ev("S.biz.find(b=>b.id==='due').hag"), 'someone at the desk, but the switch is off');
assert.equal(ev('!!S.slAuto.ren'), false);
ev('ACT.salesOpen()');
assert.match(ev("document.getElementById('modal').innerHTML"), /data-act="salesRen"/, 'the switch is in the sales sheet');
ev('ACT.salesRen()');
assert.equal(ev('S.slAuto.ren'), true);
ev("UI.left='deals';renderLeft()");
assert.match(ev("document.getElementById('left').innerHTML"), /answers this on/, 'the haggle says when the desk answers');
ev('slRenDay(S.day)');
assert.equal(ev("!!S.biz.find(b=>b.id==='due').hag"), false, 'three days in: answered');
assert.equal(ev("!!S.biz.find(b=>b.id==='early').hag"), true, 'one day in: not yet, you can still answer it');
ev("ACT.renewMatch({id:'early'})");
assert.equal(ev("S.biz.find(b=>b.id==='early').rate"), 700, 'and your answer is the one that counts');
assert.deepEqual(errors, []);
});
test('the engineer: business customers get their discount, nerds a tour of the network, and nobody leaves', () => {
const { ev, errors } = load();
ev(start);
ev("ACT.salesHire({id:'eng'})");
const biz = run(ev, 'eng', 'dia');
assert.ok(biz.every((x) => x.how === 'cave' && x.rate === 700 && x.here), 'every business customer renews at what it asked');
const nerds = run(ev, 'eng', 'hft');
assert.ok(nerds.every((x) => x.here && !x.hag), 'nobody leaves');
const tech = share(nerds, 'tech');
assert.ok(tech > 0.6 && tech < 0.8, `most nerds pay the market price (${Math.round(tech * 100)}%)`);
const fair = ev("clFair(" + hag('f', 'hft') + ")");
for (const x of nerds) assert.equal(x.rate, x.how === 'tech' ? Math.max(700, Math.min(1000, fair)) : 850);
assert.deepEqual(errors, []);
});
test('the shark: the old price, a fee for the save and fresh promises; some walk, nerds most of all', () => {
const { ev, errors } = load();
ev(start);
ev("ACT.salesHire({id:'shark'})");
const cash = ev('S.cash');
const o = run(ev, 'shark', 'dia');
const hold = o.filter((x) => x.how === 'hold');
assert.ok(hold.length / o.length > 0.4 && hold.length / o.length < 0.6, `most renew at the old price (${hold.length} of ${o.length})`);
assert.ok(hold.every((x) => x.rate === 1000 && x.here));
assert.equal(cash - ev('S.cash'), hold.length * 5 * 300, 'a month of what he saved you, for each');
assert.ok(hold.some((x) => x.reqs > 0), 'with a promise now and then');
const walk = share(o, 'walk'), nerdWalk = share(run(ev, 'shark', 'hft'), 'walk');
assert.ok(walk > 0.05 && walk < 0.2, `some walk (${Math.round(walk * 100)}%)`);
assert.ok(nerdWalk > walk * 2, `nerds walk more (${Math.round(nerdWalk * 100)}%)`);
assert.ok(o.filter((x) => x.how === 'walk').every((x) => !x.here), 'and are gone');
assert.ok(o.filter((x) => x.how === 'mid').every((x) => x.rate === 850));
assert.deepEqual(errors, []);
});
test('the CEO: a deeper discount for twice the term, a quick yes, or a fight; all from hashes', () => {
const { ev, errors } = load();
ev(start);
ev("ACT.salesHire({id:'ceo'})");
ev('window.__r=0;window.__r0=Math.random;Math.random=()=>{__r++;return __r0();};');
const o = run(ev, 'ceo', 'dia');
ev('Math.random=__r0');
assert.equal(ev('__r'), 0, 'no draws from the game\'s random stream');
const golf = o.filter((x) => x.how === 'golf'), yes = o.filter((x) => x.how === 'yes'), fight = o.filter((x) => x.how === 'fight');
assert.ok(fight.length / o.length > 0.15 && fight.length / o.length < 0.35, `${fight.length} fights`);
assert.ok(golf.length && golf.every((x) => x.rate === 630 && x.here), 'golf: 10% under what they asked');
const term = (l) => l.reduce((a, x) => a + x.te, 0) / l.length;
assert.ok(term(golf) > term(yes) * 1.6, `for a contract about twice as long (${Math.round(term(golf))} vs ${Math.round(term(yes))} days)`);
assert.ok(yes.every((x) => x.rate === 700), 'a quick yes is what they asked');
assert.ok(fight.every((x) => !x.here));
assert.deepEqual(errors, []);
});
test('saves remember the switch, and an old save has it off', () => {
const { ev, errors } = load();
ev(start);
ev("ACT.salesHire({id:'shark'});ACT.salesRen()");
const s = JSON.parse(ev('JSON.stringify(packSave(S))'));
assert.equal(JSON.parse(ev(`JSON.stringify(sanitize(JSON.parse(${JSON.stringify(JSON.stringify(s))})).slAuto)`)).ren, true);
s.slAuto.ren = 'yes please'; assert.equal(JSON.parse(ev(`JSON.stringify(sanitize(JSON.parse(${JSON.stringify(JSON.stringify(s))})).slAuto)`)).ren, undefined);
delete s.slAuto.ren; assert.equal(JSON.parse(ev(`JSON.stringify(sanitize(JSON.parse(${JSON.stringify(JSON.stringify(s))})).slAuto)`)).ren, undefined);
assert.deepEqual(errors, []);
});