test: rockets that peak below the exit get no flight (t1137)
A rocket peaking under y=13 produces no outgoing shot and previewExit starts nothing. One that crosses the exit yields exactly one shot at that pose. Playwright launches from y=13.
@@ -270,3 +270,140 @@ describe('Smooth C1 arcs (t1134)', () =>
270
270
assert.ok(rect.top - spawn.y - 0.5 / 13 * 507 < 0.01);
271
271
});
272
272
});
273
274
275
describe('Exit-only flight start (t1137)', () =>
276
{
277
function flyingCluster (game, col, y, opts)
278
{
279
opts = opts || {};
280
const cluster = {
281
id: game.nextClusterId++,
282
jumpHeight: opts.jumpHeight != null ? opts.jumpHeight : 3,
283
vy: opts.vy != null ? opts.vy : 4,
284
decel: opts.decel != null ? opts.decel : 2,
285
phase: opts.phase || (opts.vy > 0 ? 'up' : 'down'),
286
anchorY: y
287
};
288
game.clusters[cluster.id] = cluster;
289
const b = game.createBlock(col, y, opts.color != null ? opts.color : 0, 'flying');
290
b.clusterId = cluster.id;
291
b.clusterOffset = 0;
292
b.vy = cluster.vy;
293
b.flame = true;
294
return { cluster, block: b };
295
}
296
297
function resetPreview ()
298
{
299
Online._flights = [];
300
Online._flightSeen = Object.create(null);
301
Online._previewIds = Object.create(null);
302
}
303
304
it('hasLeftTheField is true only at y ≥ 13', () =>
305
{
306
assert.equal(Online.hasLeftTheField(11.6), false);
307
assert.equal(Online.hasLeftTheField(12), false);
308
assert.equal(Online.hasLeftTheField(12.99), false);
309
assert.equal(Online.hasLeftTheField(13 - 2e-9), false);
310
assert.equal(Online.hasLeftTheField(13), true);
311
assert.equal(Online.hasLeftTheField(13.01), true);
312
assert.equal(Online.hasLeftTheField(14), true);
313
assert.equal(Online.hasLeftTheField(12, 13), false);
314
assert.equal(Online.hasLeftTheField(13, 13), true);
315
});
316
317
it('a rocket that peaks below the exit produces no shot and no flight', () =>
318
{
319
const g = makeGame({ noSpawn: true, strictInvariants: false });
320
const { block } = flyingCluster(g, 3, 11.6, {
321
vy: 3, decel: 12, jumpHeight: 0.7, phase: 'up'
322
});
323
const id = block.id;
324
resetPreview();
325
let maxY = block.y;
326
for (let i = 0; i < 120; i++)
327
{
328
for (const b of g.blocks)
329
{
330
assert.equal(Online.hasLeftTheField(b.y, g.height), false,
331
'block still on the field reached y=' + b.y);
332
assert.equal(Online.previewExit({
333
id: b.id, y: b.y, col: b.col, vy: b.vy,
334
color: b.color, start: { x: 0, y: 0 }
335
}), null);
336
}
337
g.tick(1 / 60);
338
if (g.blocks.length)
339
{
340
const y = Math.max(...g.blocks.map((b) => b.y));
341
if (y > maxY)
342
{ maxY = y; }
343
}
344
assert.equal(g.outgoingShots.length, 0,
345
'outgoing shot at tick ' + i + ' y=' + (g.blocks[0] && g.blocks[0].y));
346
}
347
assert.ok(maxY < 13, 'peak y=' + maxY + ' should stay below the exit');
348
assert.ok(maxY > 11.6, 'rocket did go up a bit, peak=' + maxY);
349
assert.ok(g.blocks.some((b) => b.id === id), 'the rocket fell back onto the field');
350
assert.equal(Online._flights.length, 0);
351
assert.equal(Object.keys(Online._previewIds).length, 0);
352
assert.equal(g.consumeOutgoingShots().length, 0);
353
});
354
355
it('a rocket that crosses y=13 produces exactly one shot at the exit pose', () =>
356
{
357
const g = makeGame({ noSpawn: true, strictInvariants: false });
358
const { block } = flyingCluster(g, 6, 12.2, {
359
vy: 24, decel: 0, jumpHeight: 8, phase: 'up'
360
});
361
const id = block.id;
362
const col = block.col;
363
resetPreview();
364
// Still on the field before the tick that carries it out:
365
assert.equal(Online.hasLeftTheField(block.y, g.height), false);
366
assert.equal(Online.previewExit({
367
id: block.id, y: block.y, col: block.col, vy: block.vy,
368
color: block.color, start: { x: 1, y: 2 }
369
}), null);
370
assert.equal(Online._flights.length, 0);
371
372
let shots = [];
373
for (let i = 0; i < 30 && shots.length === 0; i++)
374
{
375
g.tick(1 / 60);
376
shots = g.consumeOutgoingShots();
377
}
378
assert.equal(shots.length, 1, 'exactly one outgoing shot');
379
assert.equal(shots[0].id, id);
380
assert.equal(shots[0].col, col);
381
assert.ok(Online.hasLeftTheField(shots[0].y, g.height),
382
'shot is recorded at the exit, y=' + shots[0].y);
383
assert.equal(g.blocks.filter((b) => b.id === id).length, 0, 'block is culled');
384
assert.equal(g.consumeOutgoingShots().length, 0, 'not emitted again');
385
386
const field = { left: 100, top: 80, width: 390, height: 507, right: 490, bottom: 587 };
387
const start = Online.cellViewport(shots[0].col, shots[0].y, field);
388
const at13 = Online.cellViewport(col, 13, field);
389
assert.ok(start.y <= field.top + 0.5,
390
'exit pose is at or above the canvas top, start.y=' + start.y + ' top=' + field.top);
391
assert.ok(Math.abs(start.x - at13.x) < 0.5, 'starts in the launch column');
392
// y ≥ 13 sits at or above the y=13 spawn/exit centre.
393
assert.ok(start.y <= at13.y + 0.5);
394
assert.equal(Online.hasLeftTheField(shots[0].y, g.height), true);
395
});
396
397
it('previewExit ignores a rocket that has not left, even with an upward vy', () =>
398
{
399
resetPreview();
400
const r = Online.previewExit({
401
id: 'phantom', y: 12.4, col: 4, vy: 10, color: 1,
402
start: { x: 50, y: 50 }
403
});
404
assert.equal(r, null);
405
assert.equal(Online._flights.length, 0);
406
assert.ok(!Online._previewIds.phantom);
407
assert.ok(!Online._flightSeen.phantom);
408
});
409
});
@@ -270,3 +270,140 @@ describe('Smooth C1 arcs (t1134)', () =>270
assert.ok(rect.top - spawn.y - 0.5 / 13 * 507 < 0.01);270
assert.ok(rect.top - spawn.y - 0.5 / 13 * 507 < 0.01);271
});271
});272
});272
});273
274
275
describe('Exit-only flight start (t1137)', () =>276
{277
function flyingCluster (game, col, y, opts)278
{279
opts = opts || {};280
const cluster = {281
id: game.nextClusterId++,282
jumpHeight: opts.jumpHeight != null ? opts.jumpHeight : 3,283
vy: opts.vy != null ? opts.vy : 4,284
decel: opts.decel != null ? opts.decel : 2,285
phase: opts.phase || (opts.vy > 0 ? 'up' : 'down'),286
anchorY: y287
};288
game.clusters[cluster.id] = cluster;289
const b = game.createBlock(col, y, opts.color != null ? opts.color : 0, 'flying');290
b.clusterId = cluster.id;291
b.clusterOffset = 0;292
b.vy = cluster.vy;293
b.flame = true;294
return { cluster, block: b };295
}296
297
function resetPreview ()298
{299
Online._flights = [];300
Online._flightSeen = Object.create(null);301
Online._previewIds = Object.create(null);302
}303
304
it('hasLeftTheField is true only at y ≥ 13', () =>305
{306
assert.equal(Online.hasLeftTheField(11.6), false);307
assert.equal(Online.hasLeftTheField(12), false);308
assert.equal(Online.hasLeftTheField(12.99), false);309
assert.equal(Online.hasLeftTheField(13 - 2e-9), false);310
assert.equal(Online.hasLeftTheField(13), true);311
assert.equal(Online.hasLeftTheField(13.01), true);312
assert.equal(Online.hasLeftTheField(14), true);313
assert.equal(Online.hasLeftTheField(12, 13), false);314
assert.equal(Online.hasLeftTheField(13, 13), true);315
});316
317
it('a rocket that peaks below the exit produces no shot and no flight', () =>318
{319
const g = makeGame({ noSpawn: true, strictInvariants: false });320
const { block } = flyingCluster(g, 3, 11.6, {321
vy: 3, decel: 12, jumpHeight: 0.7, phase: 'up'322
});323
const id = block.id;324
resetPreview();325
let maxY = block.y;326
for (let i = 0; i < 120; i++)327
{328
for (const b of g.blocks)329
{330
assert.equal(Online.hasLeftTheField(b.y, g.height), false,331
'block still on the field reached y=' + b.y);332
assert.equal(Online.previewExit({333
id: b.id, y: b.y, col: b.col, vy: b.vy,334
color: b.color, start: { x: 0, y: 0 }335
}), null);336
}337
g.tick(1 / 60);338
if (g.blocks.length)339
{340
const y = Math.max(...g.blocks.map((b) => b.y));341
if (y > maxY)342
{ maxY = y; }343
}344
assert.equal(g.outgoingShots.length, 0,345
'outgoing shot at tick ' + i + ' y=' + (g.blocks[0] && g.blocks[0].y));346
}347
assert.ok(maxY < 13, 'peak y=' + maxY + ' should stay below the exit');348
assert.ok(maxY > 11.6, 'rocket did go up a bit, peak=' + maxY);349
assert.ok(g.blocks.some((b) => b.id === id), 'the rocket fell back onto the field');350
assert.equal(Online._flights.length, 0);351
assert.equal(Object.keys(Online._previewIds).length, 0);352
assert.equal(g.consumeOutgoingShots().length, 0);353
});354
355
it('a rocket that crosses y=13 produces exactly one shot at the exit pose', () =>356
{357
const g = makeGame({ noSpawn: true, strictInvariants: false });358
const { block } = flyingCluster(g, 6, 12.2, {359
vy: 24, decel: 0, jumpHeight: 8, phase: 'up'360
});361
const id = block.id;362
const col = block.col;363
resetPreview();364
// Still on the field before the tick that carries it out:365
assert.equal(Online.hasLeftTheField(block.y, g.height), false);366
assert.equal(Online.previewExit({367
id: block.id, y: block.y, col: block.col, vy: block.vy,368
color: block.color, start: { x: 1, y: 2 }369
}), null);370
assert.equal(Online._flights.length, 0);371
372
let shots = [];373
for (let i = 0; i < 30 && shots.length === 0; i++)374
{375
g.tick(1 / 60);376
shots = g.consumeOutgoingShots();377
}378
assert.equal(shots.length, 1, 'exactly one outgoing shot');379
assert.equal(shots[0].id, id);380
assert.equal(shots[0].col, col);381
assert.ok(Online.hasLeftTheField(shots[0].y, g.height),382
'shot is recorded at the exit, y=' + shots[0].y);383
assert.equal(g.blocks.filter((b) => b.id === id).length, 0, 'block is culled');384
assert.equal(g.consumeOutgoingShots().length, 0, 'not emitted again');385
386
const field = { left: 100, top: 80, width: 390, height: 507, right: 490, bottom: 587 };387
const start = Online.cellViewport(shots[0].col, shots[0].y, field);388
const at13 = Online.cellViewport(col, 13, field);389
assert.ok(start.y <= field.top + 0.5,390
'exit pose is at or above the canvas top, start.y=' + start.y + ' top=' + field.top);391
assert.ok(Math.abs(start.x - at13.x) < 0.5, 'starts in the launch column');392
// y ≥ 13 sits at or above the y=13 spawn/exit centre.393
assert.ok(start.y <= at13.y + 0.5);394
assert.equal(Online.hasLeftTheField(shots[0].y, g.height), true);395
});396
397
it('previewExit ignores a rocket that has not left, even with an upward vy', () =>398
{399
resetPreview();400
const r = Online.previewExit({401
id: 'phantom', y: 12.4, col: 4, vy: 10, color: 1,402
start: { x: 50, y: 50 }403
});404
assert.equal(r, null);405
assert.equal(Online._flights.length, 0);406
assert.ok(!Online._previewIds.phantom);407
assert.ok(!Online._flightSeen.phantom);408
});409
});@@ -137,22 +137,22 @@ INJECT_FLIGHTS = """(age) => {
137
137
const b = bots[1] || bots[0] || 'bot-2';
138
138
const landCol = 3;
139
139
// Launch from the real top-row cell, not from above the canvas (t1134).
140
const pStart = Online.cellViewport(4, 12, field);
140
const pStart = Online.cellViewport(4, 13, field);
141
141
const pEnd = Online.fieldEntry ? Online.fieldEntry(landCol) : Online.cellViewport(landCol, 13, field);
142
142
if (typeof Online.clearFlights === 'function') Online.clearFlights();
143
143
const flights = [
144
{ id: 'vis-p2e', client_id: 'vis-p2e', from_id: 'player', target_id: a, miss: false, color: 0, flight_duration: 1.2, age: age, land_col: landCol, col: 4, y: 12 },
145
{ id: 'vis-e2p', client_id: 'vis-e2p', from_id: a, target_id: 'player', miss: false, color: 1, flight_duration: 1.2, age: age, land_col: landCol, col: 2, y: 12 },
146
{ id: 'vis-e2e', client_id: 'vis-e2e', from_id: a, target_id: b, miss: false, color: 2, flight_duration: 1.2, age: age, land_col: 7, col: 5, y: 12 },
147
{ id: 'vis-emiss', client_id: 'vis-emiss', from_id: b, target_id: null, miss: true, color: 3, flight_duration: 1.2, age: Math.min(age, 0.45), col: 1, y: 12 }
144
{ id: 'vis-p2e', client_id: 'vis-p2e', from_id: 'player', target_id: a, miss: false, color: 0, flight_duration: 1.2, age: age, land_col: landCol, col: 4, y: 13 },
145
{ id: 'vis-e2p', client_id: 'vis-e2p', from_id: a, target_id: 'player', miss: false, color: 1, flight_duration: 1.2, age: age, land_col: landCol, col: 2, y: 13 },
146
{ id: 'vis-e2e', client_id: 'vis-e2e', from_id: a, target_id: b, miss: false, color: 2, flight_duration: 1.2, age: age, land_col: 7, col: 5, y: 13 },
147
{ id: 'vis-emiss', client_id: 'vis-emiss', from_id: b, target_id: null, miss: true, color: 3, flight_duration: 1.2, age: Math.min(age, 0.45), col: 1, y: 13 }
148
148
];
149
const aOut = miniCell(a, 2, 12);
150
const bOut = miniCell(b, 1, 12);
149
const aOut = miniCell(a, 2, 13);
150
const bOut = miniCell(b, 1, 13);
151
151
const locals = {
152
'vis-p2e': { from_id: 'player', color: 0, startX: pStart.x, startY: pStart.y, col: 4, y: 12, land_col: landCol },
153
'vis-e2p': { from_id: a, color: 1, startX: aOut.x, startY: aOut.y, col: 2, y: 12, land_col: landCol },
154
'vis-e2e': { from_id: a, color: 2, startX: aOut.x, startY: aOut.y, col: 5, y: 12, land_col: 7 },
155
'vis-emiss': { from_id: b, color: 3, startX: bOut.x, startY: bOut.y, col: 1, y: 12 }
152
'vis-p2e': { from_id: 'player', color: 0, startX: pStart.x, startY: pStart.y, col: 4, y: 13, land_col: landCol },
153
'vis-e2p': { from_id: a, color: 1, startX: aOut.x, startY: aOut.y, col: 2, y: 13, land_col: landCol },
154
'vis-e2e': { from_id: a, color: 2, startX: aOut.x, startY: aOut.y, col: 5, y: 13, land_col: 7 },
155
'vis-emiss': { from_id: b, color: 3, startX: bOut.x, startY: bOut.y, col: 1, y: 13 }
156
156
};
157
157
Online.spawnFlights(flights, locals);
158
158
Online.tickFlights();
@@ -203,7 +203,7 @@ INJECT_FLIGHTS = """(age) => {
203
203
});
204
204
const expectedEndX = field.left + ((landCol + 0.5) / 10) * field.width;
205
205
const expectedEndY = field.top + (1 - (13.5) / 13) * field.height;
206
const expectedStartY = field.top + (1 - (12.5) / 13) * field.height;
206
const expectedStartY = field.top + (1 - (13.5) / 13) * field.height;
207
207
return {
208
208
front: front.length,
209
209
back: back.length,
@@ -325,11 +325,11 @@ def assert_flights(info, tag, expect_behind=True, expect_around=True):
325
325
check("gray" in (k.get("src") or "").lower() or k.get("color") == -1,
326
326
f"{tag}: player-to-enemy is grey (src={k.get('src')} color={k.get('color')})")
327
327
if k.get("start") and info.get("expectedStartY") is not None:
328
check(k["start"]["y"] > info["field"]["top"],
329
f"{tag}: player-to-enemy starts inside the field "
328
check(k["start"]["y"] <= info["field"]["top"] + 2,
329
f"{tag}: player-to-enemy starts at the exit (at/above the canvas top) "
330
330
f"(start.y={k['start']['y']:.1f} field.top={info['field']['top']:.1f})")
331
331
check(abs(k["start"]["y"] - info["expectedStartY"]) < 8,
332
f"{tag}: player-to-enemy starts at the top-row cell "
332
f"{tag}: player-to-enemy starts at the y=13 exit pose "
333
333
f"(start.y={k['start']['y']:.1f} expected={info['expectedStartY']:.1f})")
334
334
if k.get("d0"):
335
335
check(k["d0"]["y"] < 0,
@@ -137,22 +137,22 @@ INJECT_FLIGHTS = """(age) => {137
const b = bots[1] || bots[0] || 'bot-2';137
const b = bots[1] || bots[0] || 'bot-2';138
const landCol = 3;138
const landCol = 3;139
// Launch from the real top-row cell, not from above the canvas (t1134).139
// Launch from the real top-row cell, not from above the canvas (t1134).140
const pStart = Online.cellViewport(4, 12, field);140
const pStart = Online.cellViewport(4, 13, field);141
const pEnd = Online.fieldEntry ? Online.fieldEntry(landCol) : Online.cellViewport(landCol, 13, field);141
const pEnd = Online.fieldEntry ? Online.fieldEntry(landCol) : Online.cellViewport(landCol, 13, field);142
if (typeof Online.clearFlights === 'function') Online.clearFlights();142
if (typeof Online.clearFlights === 'function') Online.clearFlights();143
const flights = [143
const flights = [144
{ id: 'vis-p2e', client_id: 'vis-p2e', from_id: 'player', target_id: a, miss: false, color: 0, flight_duration: 1.2, age: age, land_col: landCol, col: 4, y: 12 },144
{ id: 'vis-p2e', client_id: 'vis-p2e', from_id: 'player', target_id: a, miss: false, color: 0, flight_duration: 1.2, age: age, land_col: landCol, col: 4, y: 13 },145
{ id: 'vis-e2p', client_id: 'vis-e2p', from_id: a, target_id: 'player', miss: false, color: 1, flight_duration: 1.2, age: age, land_col: landCol, col: 2, y: 12 },145
{ id: 'vis-e2p', client_id: 'vis-e2p', from_id: a, target_id: 'player', miss: false, color: 1, flight_duration: 1.2, age: age, land_col: landCol, col: 2, y: 13 },146
{ id: 'vis-e2e', client_id: 'vis-e2e', from_id: a, target_id: b, miss: false, color: 2, flight_duration: 1.2, age: age, land_col: 7, col: 5, y: 12 },146
{ id: 'vis-e2e', client_id: 'vis-e2e', from_id: a, target_id: b, miss: false, color: 2, flight_duration: 1.2, age: age, land_col: 7, col: 5, y: 13 },147
{ id: 'vis-emiss', client_id: 'vis-emiss', from_id: b, target_id: null, miss: true, color: 3, flight_duration: 1.2, age: Math.min(age, 0.45), col: 1, y: 12 }147
{ id: 'vis-emiss', client_id: 'vis-emiss', from_id: b, target_id: null, miss: true, color: 3, flight_duration: 1.2, age: Math.min(age, 0.45), col: 1, y: 13 }148
];148
];149
const aOut = miniCell(a, 2, 12);149
const aOut = miniCell(a, 2, 13);150
const bOut = miniCell(b, 1, 12);150
const bOut = miniCell(b, 1, 13);151
const locals = {151
const locals = {152
'vis-p2e': { from_id: 'player', color: 0, startX: pStart.x, startY: pStart.y, col: 4, y: 12, land_col: landCol },152
'vis-p2e': { from_id: 'player', color: 0, startX: pStart.x, startY: pStart.y, col: 4, y: 13, land_col: landCol },153
'vis-e2p': { from_id: a, color: 1, startX: aOut.x, startY: aOut.y, col: 2, y: 12, land_col: landCol },153
'vis-e2p': { from_id: a, color: 1, startX: aOut.x, startY: aOut.y, col: 2, y: 13, land_col: landCol },154
'vis-e2e': { from_id: a, color: 2, startX: aOut.x, startY: aOut.y, col: 5, y: 12, land_col: 7 },154
'vis-e2e': { from_id: a, color: 2, startX: aOut.x, startY: aOut.y, col: 5, y: 13, land_col: 7 },155
'vis-emiss': { from_id: b, color: 3, startX: bOut.x, startY: bOut.y, col: 1, y: 12 }155
'vis-emiss': { from_id: b, color: 3, startX: bOut.x, startY: bOut.y, col: 1, y: 13 }156
};156
};157
Online.spawnFlights(flights, locals);157
Online.spawnFlights(flights, locals);158
Online.tickFlights();158
Online.tickFlights();@@ -203,7 +203,7 @@ INJECT_FLIGHTS = """(age) => {203
});203
});204
const expectedEndX = field.left + ((landCol + 0.5) / 10) * field.width;204
const expectedEndX = field.left + ((landCol + 0.5) / 10) * field.width;205
const expectedEndY = field.top + (1 - (13.5) / 13) * field.height;205
const expectedEndY = field.top + (1 - (13.5) / 13) * field.height;206
const expectedStartY = field.top + (1 - (12.5) / 13) * field.height;206
const expectedStartY = field.top + (1 - (13.5) / 13) * field.height;207
return {207
return {208
front: front.length,208
front: front.length,209
back: back.length,209
back: back.length,@@ -325,11 +325,11 @@ def assert_flights(info, tag, expect_behind=True, expect_around=True):325
check("gray" in (k.get("src") or "").lower() or k.get("color") == -1,325
check("gray" in (k.get("src") or "").lower() or k.get("color") == -1,326
f"{tag}: player-to-enemy is grey (src={k.get('src')} color={k.get('color')})")326
f"{tag}: player-to-enemy is grey (src={k.get('src')} color={k.get('color')})")327
if k.get("start") and info.get("expectedStartY") is not None:327
if k.get("start") and info.get("expectedStartY") is not None:328
check(k["start"]["y"] > info["field"]["top"],328
check(k["start"]["y"] <= info["field"]["top"] + 2,329
f"{tag}: player-to-enemy starts inside the field "329
f"{tag}: player-to-enemy starts at the exit (at/above the canvas top) "330
f"(start.y={k['start']['y']:.1f} field.top={info['field']['top']:.1f})")330
f"(start.y={k['start']['y']:.1f} field.top={info['field']['top']:.1f})")331
check(abs(k["start"]["y"] - info["expectedStartY"]) < 8,331
check(abs(k["start"]["y"] - info["expectedStartY"]) < 8,332
f"{tag}: player-to-enemy starts at the top-row cell "332
f"{tag}: player-to-enemy starts at the y=13 exit pose "333
f"(start.y={k['start']['y']:.1f} expected={info['expectedStartY']:.1f})")333
f"(start.y={k['start']['y']:.1f} expected={info['expectedStartY']:.1f})")334
if k.get("d0"):334
if k.get("d0"):335
check(k["d0"]["y"] < 0,335
check(k["d0"]["y"] < 0,@@ -141,22 +141,22 @@ POLL_FLIGHTS = """() => {
141
141
shot_flights: [
142
142
{ id: 601, client_id: 'on-e2p', from_id: a.id, from_user: a.id,
143
143
target_id: me.id, miss: false, color: 1, flight_duration: 1.2,
144
age: 0.5, land_col: 3, col: 6, y: 12 },
144
age: 0.5, land_col: 3, col: 6, y: 13 },
145
145
{ id: 602, client_id: 'on-p2e', from_id: me.id, from_user: me.id,
146
146
target_id: a.id, miss: false, color: 0, flight_duration: 1.2,
147
age: 0.35, land_col: 5, col: 4, y: 12 },
147
age: 0.35, land_col: 5, col: 4, y: 13 },
148
148
{ id: 603, client_id: 'on-e2e', from_id: a.id, from_user: a.id,
149
149
target_id: b.id, miss: false, color: 2, flight_duration: 1.2,
150
age: 0.45, land_col: 7, col: 2, y: 12 },
150
age: 0.45, land_col: 7, col: 2, y: 13 },
151
151
{ id: 604, client_id: 'on-miss', from_id: b.id, from_user: b.id,
152
152
target_id: null, miss: true, color: 3, flight_duration: 1.2,
153
age: 0.3, col: 1, y: 12 }
153
age: 0.3, col: 1, y: 13 }
154
154
]
155
155
});
156
156
Online.tickFlights();
157
157
const expectedEndX = field.left + ((3 + 0.5) / 10) * field.width;
158
158
const expectedEndY = field.top + (1 - 13.5 / 13) * field.height;
159
const expectedStartY = field.top + (1 - 12.5 / 13) * field.height;
159
const expectedStartY = field.top + (1 - 13.5 / 13) * field.height;
160
160
const kinds = (Online._flights || []).map(f => {
161
161
const raw = Math.min(0.999, Math.max(0, (performance.now() - f.t0) / f.duration));
162
162
const u = f.miss ? Online.easeInOutCubic(raw) : Online.smoothParam(raw, 0.85, 0.85);
@@ -238,11 +238,11 @@ def assert_online_flights(info, tag):
238
238
check(k.get("color") == -1 or "gray" in (k.get("src") or "").lower(),
239
239
f"{tag}: p2e is grey")
240
240
if k.get("start") and info.get("expectedStartY") is not None:
241
check(k["start"]["y"] > info["field"]["top"],
242
f"{tag}: p2e launches from inside the field "
241
check(k["start"]["y"] <= info["field"]["top"] + 2,
242
f"{tag}: p2e launches at the exit (at/above the canvas top) "
243
243
f"(y={k['start']['y']:.1f} top={info['field']['top']:.1f})")
244
244
check(abs(k["start"]["y"] - info["expectedStartY"]) < 10,
245
f"{tag}: p2e start at y=12 cell")
245
f"{tag}: p2e start at y=13 exit pose")
246
246
if k.get("d0"):
247
247
check(k["d0"]["y"] < 0, f"{tag}: p2e leaves going up")
248
248
check(k.get("forbidden", 0) == 0, f"{tag}: p2e corridors only")
@@ -404,10 +404,10 @@ def run_viewport(browser, name, width, height, n_players=3):
404
404
shot_flights: [
405
405
{ id: 701, client_id: 'e-'+age, from_id: a.id, target_id: me.id,
406
406
miss: false, color: 1, flight_duration: 1.2, age: age,
407
land_col: 3, col: 6, y: 12 },
407
land_col: 3, col: 6, y: 13 },
408
408
{ id: 702, client_id: 'p-'+age, from_id: me.id, target_id: a.id,
409
409
miss: false, color: 0, flight_duration: 1.2, age: age,
410
land_col: 5, col: 4, y: 12 }
410
land_col: 5, col: 4, y: 13 }
411
411
]
412
412
});
413
413
Online.tickFlights();
@@ -141,22 +141,22 @@ POLL_FLIGHTS = """() => {141
shot_flights: [141
shot_flights: [142
{ id: 601, client_id: 'on-e2p', from_id: a.id, from_user: a.id,142
{ id: 601, client_id: 'on-e2p', from_id: a.id, from_user: a.id,143
target_id: me.id, miss: false, color: 1, flight_duration: 1.2,143
target_id: me.id, miss: false, color: 1, flight_duration: 1.2,144
age: 0.5, land_col: 3, col: 6, y: 12 },144
age: 0.5, land_col: 3, col: 6, y: 13 },145
{ id: 602, client_id: 'on-p2e', from_id: me.id, from_user: me.id,145
{ id: 602, client_id: 'on-p2e', from_id: me.id, from_user: me.id,146
target_id: a.id, miss: false, color: 0, flight_duration: 1.2,146
target_id: a.id, miss: false, color: 0, flight_duration: 1.2,147
age: 0.35, land_col: 5, col: 4, y: 12 },147
age: 0.35, land_col: 5, col: 4, y: 13 },148
{ id: 603, client_id: 'on-e2e', from_id: a.id, from_user: a.id,148
{ id: 603, client_id: 'on-e2e', from_id: a.id, from_user: a.id,149
target_id: b.id, miss: false, color: 2, flight_duration: 1.2,149
target_id: b.id, miss: false, color: 2, flight_duration: 1.2,150
age: 0.45, land_col: 7, col: 2, y: 12 },150
age: 0.45, land_col: 7, col: 2, y: 13 },151
{ id: 604, client_id: 'on-miss', from_id: b.id, from_user: b.id,151
{ id: 604, client_id: 'on-miss', from_id: b.id, from_user: b.id,152
target_id: null, miss: true, color: 3, flight_duration: 1.2,152
target_id: null, miss: true, color: 3, flight_duration: 1.2,153
age: 0.3, col: 1, y: 12 }153
age: 0.3, col: 1, y: 13 }154
]154
]155
});155
});156
Online.tickFlights();156
Online.tickFlights();157
const expectedEndX = field.left + ((3 + 0.5) / 10) * field.width;157
const expectedEndX = field.left + ((3 + 0.5) / 10) * field.width;158
const expectedEndY = field.top + (1 - 13.5 / 13) * field.height;158
const expectedEndY = field.top + (1 - 13.5 / 13) * field.height;159
const expectedStartY = field.top + (1 - 12.5 / 13) * field.height;159
const expectedStartY = field.top + (1 - 13.5 / 13) * field.height;160
const kinds = (Online._flights || []).map(f => {160
const kinds = (Online._flights || []).map(f => {161
const raw = Math.min(0.999, Math.max(0, (performance.now() - f.t0) / f.duration));161
const raw = Math.min(0.999, Math.max(0, (performance.now() - f.t0) / f.duration));162
const u = f.miss ? Online.easeInOutCubic(raw) : Online.smoothParam(raw, 0.85, 0.85);162
const u = f.miss ? Online.easeInOutCubic(raw) : Online.smoothParam(raw, 0.85, 0.85);@@ -238,11 +238,11 @@ def assert_online_flights(info, tag):238
check(k.get("color") == -1 or "gray" in (k.get("src") or "").lower(),238
check(k.get("color") == -1 or "gray" in (k.get("src") or "").lower(),239
f"{tag}: p2e is grey")239
f"{tag}: p2e is grey")240
if k.get("start") and info.get("expectedStartY") is not None:240
if k.get("start") and info.get("expectedStartY") is not None:241
check(k["start"]["y"] > info["field"]["top"],241
check(k["start"]["y"] <= info["field"]["top"] + 2,242
f"{tag}: p2e launches from inside the field "242
f"{tag}: p2e launches at the exit (at/above the canvas top) "243
f"(y={k['start']['y']:.1f} top={info['field']['top']:.1f})")243
f"(y={k['start']['y']:.1f} top={info['field']['top']:.1f})")244
check(abs(k["start"]["y"] - info["expectedStartY"]) < 10,244
check(abs(k["start"]["y"] - info["expectedStartY"]) < 10,245
f"{tag}: p2e start at y=12 cell")245
f"{tag}: p2e start at y=13 exit pose")246
if k.get("d0"):246
if k.get("d0"):247
check(k["d0"]["y"] < 0, f"{tag}: p2e leaves going up")247
check(k["d0"]["y"] < 0, f"{tag}: p2e leaves going up")248
check(k.get("forbidden", 0) == 0, f"{tag}: p2e corridors only")248
check(k.get("forbidden", 0) == 0, f"{tag}: p2e corridors only")@@ -404,10 +404,10 @@ def run_viewport(browser, name, width, height, n_players=3):404
shot_flights: [404
shot_flights: [405
{ id: 701, client_id: 'e-'+age, from_id: a.id, target_id: me.id,405
{ id: 701, client_id: 'e-'+age, from_id: a.id, target_id: me.id,406
miss: false, color: 1, flight_duration: 1.2, age: age,406
miss: false, color: 1, flight_duration: 1.2, age: age,407
land_col: 3, col: 6, y: 12 },407
land_col: 3, col: 6, y: 13 },408
{ id: 702, client_id: 'p-'+age, from_id: me.id, target_id: a.id,408
{ id: 702, client_id: 'p-'+age, from_id: me.id, target_id: a.id,409
miss: false, color: 0, flight_duration: 1.2, age: age,409
miss: false, color: 0, flight_duration: 1.2, age: age,410
land_col: 5, col: 4, y: 12 }410
land_col: 5, col: 4, y: 13 }411
]411
]412
});412
});413
Online.tickFlights();413
Online.tickFlights();