fix(map): drop the last network's floaters when another one starts
Floaters ("New POP!", payday money) live in FLOATS and fade on the map's
animation clock, which only runs while the game does. A new network
whose clock stands still (the agent's clock on the development page)
kept the previous network's floaters frozen over its map until a reload:
hundreds of them after a payday on a big network at 8x.
Each floater now records the network that raised it, and the map drops
any that belong to another one (new game, another slot, import, puzzle,
title screen). Same code for the 2D and WebGL maps.
This commit is contained in:
parent
dd6e4f4f8a
commit
fca11b39d2
5 changed files with 24 additions and 4 deletions
|
|
@ -270,7 +270,7 @@ test('the 2D map paints its pictures again for a new pixel density', () => {
|
|||
test('money pop-ups on the 2D map fade out as before', () => {
|
||||
const { ev, errors } = open();
|
||||
const C = 'CITY[S.home]';
|
||||
ev(`cam.x=${C}.x;cam.y=${C}.y;cam.z=1;__T+=16;FLOATS.push({x:${C}.x,y:${C}.y,text:'+$1,234',col:'#16A866',t:__T});`);
|
||||
ev(`cam.x=${C}.x;cam.y=${C}.y;cam.z=1;__T+=16;FLOATS.push({x:${C}.x,y:${C}.y,text:'+$1,234',col:'#16A866',s:S,t:__T});`);
|
||||
// At 0, 40% and 80% of its life: drawn at opacity 1-a².
|
||||
const alphas = [];
|
||||
for (const a of [0, 0.4, 0.8]) {
|
||||
|
|
@ -282,7 +282,7 @@ test('money pop-ups on the 2D map fade out as before', () => {
|
|||
ev(`__M2D.frame(FLOATS[FLOATS.length-1].t+1700)`);
|
||||
assert.equal(ev('FLOATS.length'), 0, 'gone after its life');
|
||||
// The same text in two colours at once: two pictures, each in its own colour.
|
||||
ev(`FLOATS.push({x:${C}.x,y:${C}.y,text:'+$500',col:'#16A866',t:5000},{x:${C}.x+40,y:${C}.y,text:'+$500',col:'#FF4D5E',t:5000});`);
|
||||
ev(`FLOATS.push({x:${C}.x,y:${C}.y,text:'+$500',col:'#16A866',s:S,t:5000},{x:${C}.x+40,y:${C}.y,text:'+$500',col:'#FF4D5E',s:S,t:5000});`);
|
||||
const r = JSON.parse(ev('JSON.stringify(__M2D.pair(5400))'));
|
||||
assert.deepEqual(problems(r, 'two pop-ups'), []);
|
||||
assert.deepEqual(errors, []);
|
||||
|
|
|
|||
|
|
@ -238,6 +238,22 @@ test('payday money floaters fade after a long pause instead of piling up', () =>
|
|||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test("a new network starts without the last one's money floating over its map", () => {
|
||||
const { ev, errors } = load();
|
||||
bigNet(ev);
|
||||
ev("closeModal();ACT.animSet({v:'on'});setPref('pauseFurious',false);setPref('pauseIncident',false);window.__clk=5000;performance.now=()=>__clk;last=__clk;UI.speed=1");
|
||||
const run = (ms) => { for (let t = 0; t < ms; t += 16) ev('__clk+=16;frame(__clk)'); };
|
||||
run(2000);
|
||||
ev('while(cal(S.day+1).d!==1)dayTick();acc=DAY_MS');
|
||||
run(16);
|
||||
assert.ok(ev('FLOATS.length') > 0, 'payday shows the money');
|
||||
// A new game straight away: it waits, paused, for the player's first POP, and the clock of the floaters with it.
|
||||
ev("ACT.newgame();ACT.start({});closeModal();UI.speed=0");
|
||||
run(100);
|
||||
assert.equal(ev('FLOATS.length'), 0, "the old network's floaters are gone");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the map is not drawn while the dashboard covers the whole screen', () => {
|
||||
const { ev, errors } = load();
|
||||
bigNet(ev);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue