Workers P2: Szene bekommt flush() für die Rückkehr in den Tab

Die Bühne beruhigt die Regie beim Zurückkehren (alles zu Ende gespielt, alle heim, Aufzug und Effekte leer); im Standbild zeichnet flush() ein Bild.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-18 04:20:35 +00:00
1 parent e6bc2d938a
commit 319e731d0e
2 files changed
+53 -3

No files matched your search

+42 -1
View File
@@ -14,7 +14,7 @@ const open = async (o = {}, extra = {}) => {
test('Handle hat die Methoden aus Übersicht §7 und E4; Mount zeichnet sofort', async () => {
const { sb, h } = await open()
for (const m of ['destroy', 'setState', 'pushEvents', 'select', 'setPaused', 'resize', 'zoomBy', 'resetView', 'locate', 'stats', 'debug']) {
for (const m of ['destroy', 'setState', 'pushEvents', 'select', 'setPaused', 'flush', 'resize', 'zoomBy', 'resetView', 'locate', 'stats', 'debug']) {
assert.equal(typeof h[m], 'function', m)
}
assert.ok(sb.counts.fillRect > 100)
@@ -575,3 +575,44 @@ test('debug() und stats(): Form', async () => {
assert.ok(s.frames > 25)
h.destroy()
})
test('flush(): Rückkehr in den Tab beruhigt die Regie (alles heim, Aufzug und Effekte leer) und zeichnet; nach destroy wirkungslos', async () => {
const { sb, h } = await open()
h.setState(makeState())
const arne = () => h.debug().agents.find((a) => a.id === 'arne')
const home = { x: arne().x, y: arne().y, floor: arne().floor }
h.pushEvents([ev('uebergabe', 'arne', { to: 'bea' })])
sb.tick(3)
assert.ok(h.debug().pending > 0)
h.setPaused(true)
const n = sb.counts.fillRect
h.setPaused(false)
h.flush()
assert.ok(sb.counts.fillRect > n)
assert.equal(h.debug().pending, 0)
assert.equal(h.debug().lift, 'idle')
assert.equal(h.debug().fx, 0)
assert.deepEqual({ x: arne().x, y: arne().y, floor: arne().floor }, home)
h.pushEvents([ev('uebergabe', 'arne', { to: 'bea' })])
assert.equal(h.debug().pending, 1)
h.destroy()
const m = sb.counts.fillRect
h.flush()
assert.equal(sb.counts.fillRect, m)
assert.equal(h.debug().pending, 1)
})
test('flush() im Standbild zeichnet ein Standbild ohne Bildrückruf; ohne 2D-Kontext tut es nichts', async () => {
const { sb, h } = await open({}, { reducedMotion: true })
h.setState(makeState())
const n = sb.counts.fillRect
h.flush()
assert.ok(sb.counts.fillRect > n)
assert.equal(sb.rafPending(), 0)
h.destroy()
const bare = await createEngineSandbox()
bare.canvas.getContext = () => null
const g = bare.mountTower(bare.canvas, bare.opts({}))
g.flush()
assert.equal(bare.counts.fillRect, 0)
})