From 856ecfbb37eb85c65ec42a9b93dc37e8bae418f8 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Sun, 25 Oct 2026 14:48:49 +0100 Subject: [PATCH] Stop loan offers once you have half a billion in the bank Fixes #52 --- site/i18n/it.js | 1 + site/index.html | 3 +++ tests/game.test.js | 13 +++++++++++++ 3 files changed, 17 insertions(+) diff --git a/site/i18n/it.js b/site/i18n/it.js index a73b83c..636adef 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2219,4 +2219,5 @@ "Fiber pair {n} is lit: {a}–{b}.
Another ROADMaster 9000 and a fresh chain of amplifiers. Room for {m} more channels.":"Coppia di fibre {n} accesa: {a}–{b}.
Un altro ROADMaster 9000 e una nuova catena di amplificatori. Spazio per altri {m} canali.", "{n} fiber pairs lit, the trench is full":"{n} coppie di fibre accese, il cavidotto è pieno", "Light fiber pair {n} {price} + {mo}/mo":"Accendi la coppia {n} {price} + {mo}/mese", +"The banks have stopped calling.
You have more money than most of them. Loan offers come back if your cash ever drops below {cash}.":"Le banche hanno smesso di chiamare.
Hai più soldi della maggior parte di loro. Le offerte di prestito tornano se la tua cassa scende sotto {cash}.", }; diff --git a/site/index.html b/site/index.html index 0e8108c..a74d20e 100644 --- a/site/index.html +++ b/site/index.html @@ -1270,8 +1270,11 @@ function loanTick(d){ // offers: now and then, and much more often when you are in trouble S.loanOffers=S.loanOffers.filter(o=>o.exp>d); const broke=S.cash<0; + // With half a billion in the vault, loan offers are just noise (#52): banks stop calling, open offers lapse. + if(S.cash>=RICH_NO_LOANS){if(S.loanOffers.length||!S.richTold){S.loanOffers=[];if(!S.richTold&&S.mode!=='sandbox'){S.richTold=1;toast(tr('The banks have stopped calling.
You have more money than most of them. Loan offers come back if your cash ever drops below {cash}.',{cash:fmt$(RICH_NO_LOANS)}),'good');}}return;} if(S.loanOffers.length<4&&(broke?Math.random()<0.25:(d>20&&Math.random()<1/40)))spawnLoanOffer(broke); } +const RICH_NO_LOANS=5e8; /* Seeded games (scenarios, weekly challenge) draw every random number from S.rng, so the same seed gives the same world. Free play keeps using the browser's Math.random. */ const _rand=Math.random; diff --git a/tests/game.test.js b/tests/game.test.js index d27433a..9ecbae6 100644 --- a/tests/game.test.js +++ b/tests/game.test.js @@ -299,3 +299,16 @@ test('DDoS goal and badges unlock from the right state', () => { assert.equal(ev("R.served=999999;BADGES.find(b=>b.id==='petabit').ok()"), false, 'just under a petabit is not enough'); assert.equal(ev("R.served=1e6;BADGES.find(b=>b.id==='petabit').ok()"), true, 'a petabit per second earns it'); }); + +test('#52 loan offers stop once you have half a billion in the bank, and come back if you lose it', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.day=100;S.cash=6e8;S.loanOffers=[{id:'x',bank:Object.keys(BANKS)[0],amount:1e5,exp:200}]"); + for (let i = 0; i < 60; i++) ev('S.day++;loanTick(S.day)'); + assert.equal(ev('S.loanOffers.length'), 0, 'no offers while rich'); + assert.match(ev("document.getElementById('toasts').textContent"), /stopped calling/); + ev('S.cash=-5e4'); + let seen = 0; + for (let i = 0; i < 40; i++) seen += ev('S.day++;loanTick(S.day);S.loanOffers.length') > 0 ? 1 : 0; + assert.ok(seen > 0, 'broke again: the banks are back'); + assert.deepEqual(errors, []); +});