Remember each used customer name once
S.usedNames only answers "was this name used?", but every offer pushed its name again, also once all names were taken: a 5,500-day save holds 560,345 entries for 129 names, 11.8 of its 22.4 million characters. Names are now added once (useName), and sanitize() drops duplicates from older saves. Player save, 30 days from load, against main: routing and the whole state except usedNames identical, usedNames identical as a set; save 22.4 -> 10.6 million characters, first save in Firefox 95 -> 55 ms, JSON.stringify 68 -> 42 ms. Still over Firefox's quota on this save.
This commit is contained in:
parent
d7301747f7
commit
22817c83c5
7 changed files with 19 additions and 5 deletions
|
|
@ -52,6 +52,16 @@ test('a save too big for the browser is not retried every few seconds, but leavi
|
|||
assert.equal(a.ev('__tries'), 6, 'another game (a new state) tries at once');
|
||||
});
|
||||
|
||||
test('customer names already used are remembered once each, and old saves shrink on load', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({});S.usedNames=['A','B','A','A',7,'B'];S=migrate(JSON.parse(JSON.stringify(S)))");
|
||||
assert.deepEqual(JSON.parse(ev('JSON.stringify(S.usedNames)')), ['A', 'B']);
|
||||
ev("for(let i=0;i<400;i++)dayTick()");
|
||||
const u = JSON.parse(ev('JSON.stringify(S.usedNames)'));
|
||||
assert.equal(new Set(u).size, u.length, 'no name twice');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('returning players see what is new after an update, once', () => {
|
||||
const { saved } = playedGame();
|
||||
execFileSync(process.execPath, ['scripts/build.js'], { cwd: root, env: { ...process.env, OUT, VERSION: '1.1.0', BUILD_DATE: '2026-10-23' } });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue