BlueGit

projects-timfalken-com meteors

Merge branch 'feature/t1137-exit-only-arcs'

timfa Grok Bot · pushed by timfa

Authored 2026-11-13 · 4 days ago

Hash
fc85b610e61a6855771ca54b5e824fba0c874cba
Pipeline
Passed
7 files changed +255 −60
build/game.js +35 −13
@@ -5079,7 +5079,7 @@ Online.spawnFlights = function (results, locals)
5079 5079 else if (kind === 'player-to-enemy' || kind === 'player-miss')
5080 5080 { start = this._flightStart(startCol, startY); }
5081 5081 else if (startCol != null || startY != null)
5082 { start = this.miniCellViewport(fromId, startCol, startY != null ? startY : 12); }
5082 { start = this.miniCellViewport(fromId, startCol, startY != null ? startY : 13); }
5083 5083 else
5084 5084 { start = this._miniAnchor(fromId, 'out'); }
5085 5085
@@ -5199,7 +5199,7 @@ Online.rememberFlightLocal = function (shot, startX, startY)
5199 5199 Online._flightStart = function (col, y)
5200 5200 {
5201 5201 if (y == null || !isFinite(y))
5202 { y = 12; }
5202 { y = 13; }
5203 5203 return this.cellViewport(col == null ? 4.5 : col, y);
5204 5204 };
5205 5205
@@ -5258,16 +5258,30 @@ Online._findFlight = function (sid)
5258 5258 };
5259 5259
5260 5260 /**
5261 * Early visual takeover: a flying rocket near the top of a field
5262 * becomes a flight sprite at its exact cell, so it is seen flying
5263 * *out* rather than popping in above the canvas (t1134). When the
5264 * shot is later dispatched, `retargetFlight` picks up from the
5265 * current pose and aims at the real landing column.
5261 * True once a block has really left the field, matching cullOffTop
5262 * (y ≥ height, default 13). Used so an arc never starts for a
5263 * rocket that only peaked near the top and fell back (t1137).
5264 */
5265 Online.EXIT_Y = 13;
5266 Online.hasLeftTheField = function (y, height)
5267 {
5268 height = height == null ? this.EXIT_Y : height;
5269 return y != null && isFinite(y) && y >= height - 1e-9;
5270 };
5271
5272 /**
5273 * Start a flight only at the true exit (y ≥ 13). Callers that pass
5274 * a rocket still on the field are ignored, so a fallback never
5275 * shows a phantom arc (t1137). The start pose is the exit cell,
5276 * continuing upward; retargetFlight aims it at the real target
5277 * if a preview was used in the same frame as cull.
5266 5278 */
5267 5279 Online.previewExit = function (info)
5268 5280 {
5269 5281 if (!info || info.id == null)
5270 { return; }
5282 { return null; }
5283 if (!this.hasLeftTheField(info.y))
5284 { return null; }
5271 5285 var sid = String(info.id);
5272 5286 if (!this._flights)
5273 5287 { this._flights = []; }
@@ -6966,7 +6980,6 @@ function tickView (dt)
6966 6980 placeTile(app.cells[i], col, row);
6967 6981 }
6968 6982
6969 previewOutgoingFlights();
6970 6983 app.core.tick(dt);
6971 6984 if (app.offline && app.battle)
6972 6985 { tickOffline(dt); }
@@ -7812,12 +7825,16 @@ function updateColumnWarn (dt)
7812 7825 }
7813 7826
7814 7827 /**
7815 * Take over a rocket that is about to leave the top of a field (the
7816 * player's, or a bot's) so the flight starts at the real cell and
7817 * continues its upward motion (t1134). Shared by offline and online.
7828 * A flight starts only when a block has actually left the field
7829 * (y ≥ height, the same threshold as cullOffTop). Rockets that
7830 * peak below the top and fall back must never get an arc (t1137).
7831 * Shared by the player's field, enemy minis, offline and online.
7818 7832 */
7819 7833 function previewOutgoingFlights ()
7820 7834 {
7835 // Intentionally not called before core.tick: a block still on
7836 // the field (y < 13) is not a shot yet. Flights are spawned
7837 // from consumeOutgoingShots after cull, at the exit pose.
7821 7838 if (typeof Online === 'undefined' || !Online.previewExit)
7822 7839 { return; }
7823 7840 if (app.core)
@@ -7838,11 +7855,16 @@ function previewCoreExits (core, fromId)
7838 7855 {
7839 7856 if (!core || !core.blocks)
7840 7857 { return; }
7858 var height = core.height != null ? core.height : 13;
7841 7859 var blocks = core.blocks;
7842 7860 for (var i = 0; i < blocks.length; i++)
7843 7861 {
7844 7862 var b = blocks[i];
7845 if (b.y < 11.6)
7863 if (b.state === 'manual')
7864 { continue; }
7865 if (typeof Online.hasLeftTheField === 'function'
7866 ? !Online.hasLeftTheField(b.y, height)
7867 : !(b.y >= height - 1e-9))
7846 7868 { continue; }
7847 7869 if (!(b.vy > 0))
7848 7870 { continue; }
@@ -5079,7 +5079,7 @@ Online.spawnFlights = function (results, locals)
5079 else if (kind === 'player-to-enemy' || kind === 'player-miss')
5079 else if (kind === 'player-to-enemy' || kind === 'player-miss')
5080 { start = this._flightStart(startCol, startY); }
5080 { start = this._flightStart(startCol, startY); }
5081 else if (startCol != null || startY != null)
5081 else if (startCol != null || startY != null)
5082 { start = this.miniCellViewport(fromId, startCol, startY != null ? startY : 12); }
5082 { start = this.miniCellViewport(fromId, startCol, startY != null ? startY : 13); }
5083 else
5083 else
5084 { start = this._miniAnchor(fromId, 'out'); }
5084 { start = this._miniAnchor(fromId, 'out'); }
5085
5085
@@ -5199,7 +5199,7 @@ Online.rememberFlightLocal = function (shot, startX, startY)
5199Online._flightStart = function (col, y)
5199Online._flightStart = function (col, y)
5200{
5200{
5201 if (y == null || !isFinite(y))
5201 if (y == null || !isFinite(y))
5202 { y = 12; }
5202 { y = 13; }
5203 return this.cellViewport(col == null ? 4.5 : col, y);
5203 return this.cellViewport(col == null ? 4.5 : col, y);
5204};
5204};
5205
5205
@@ -5258,16 +5258,30 @@ Online._findFlight = function (sid)
5258};
5258};
5259
5259
5260/**
5260/**
5261 * Early visual takeover: a flying rocket near the top of a field
5261 * True once a block has really left the field, matching cullOffTop
5262 * becomes a flight sprite at its exact cell, so it is seen flying
5262 * (y ≥ height, default 13). Used so an arc never starts for a
5263 * *out* rather than popping in above the canvas (t1134). When the
5263 * rocket that only peaked near the top and fell back (t1137).
5264 * shot is later dispatched, `retargetFlight` picks up from the
5264 */
5265 * current pose and aims at the real landing column.
5265Online.EXIT_Y = 13;
5266Online.hasLeftTheField = function (y, height)
5267{
5268 height = height == null ? this.EXIT_Y : height;
5269 return y != null && isFinite(y) && y >= height - 1e-9;
5270};
5271
5272/**
5273 * Start a flight only at the true exit (y ≥ 13). Callers that pass
5274 * a rocket still on the field are ignored, so a fallback never
5275 * shows a phantom arc (t1137). The start pose is the exit cell,
5276 * continuing upward; retargetFlight aims it at the real target
5277 * if a preview was used in the same frame as cull.
5266 */
5278 */
5267Online.previewExit = function (info)
5279Online.previewExit = function (info)
5268{
5280{
5269 if (!info || info.id == null)
5281 if (!info || info.id == null)
5270 { return; }
5282 { return null; }
5283 if (!this.hasLeftTheField(info.y))
5284 { return null; }
5271 var sid = String(info.id);
5285 var sid = String(info.id);
5272 if (!this._flights)
5286 if (!this._flights)
5273 { this._flights = []; }
5287 { this._flights = []; }
@@ -6966,7 +6980,6 @@ function tickView (dt)
6966 placeTile(app.cells[i], col, row);
6980 placeTile(app.cells[i], col, row);
6967 }
6981 }
6968
6982
6969 previewOutgoingFlights();
6970 app.core.tick(dt);
6983 app.core.tick(dt);
6971 if (app.offline && app.battle)
6984 if (app.offline && app.battle)
6972 { tickOffline(dt); }
6985 { tickOffline(dt); }
@@ -7812,12 +7825,16 @@ function updateColumnWarn (dt)
7812}
7825}
7813
7826
7814/**
7827/**
7815 * Take over a rocket that is about to leave the top of a field (the
7828 * A flight starts only when a block has actually left the field
7816 * player's, or a bot's) so the flight starts at the real cell and
7829 * (y ≥ height, the same threshold as cullOffTop). Rockets that
7817 * continues its upward motion (t1134). Shared by offline and online.
7830 * peak below the top and fall back must never get an arc (t1137).
7831 * Shared by the player's field, enemy minis, offline and online.
7818 */
7832 */
7819function previewOutgoingFlights ()
7833function previewOutgoingFlights ()
7820{
7834{
7835 // Intentionally not called before core.tick: a block still on
7836 // the field (y < 13) is not a shot yet. Flights are spawned
7837 // from consumeOutgoingShots after cull, at the exit pose.
7821 if (typeof Online === 'undefined' || !Online.previewExit)
7838 if (typeof Online === 'undefined' || !Online.previewExit)
7822 { return; }
7839 { return; }
7823 if (app.core)
7840 if (app.core)
@@ -7838,11 +7855,16 @@ function previewCoreExits (core, fromId)
7838{
7855{
7839 if (!core || !core.blocks)
7856 if (!core || !core.blocks)
7840 { return; }
7857 { return; }
7858 var height = core.height != null ? core.height : 13;
7841 var blocks = core.blocks;
7859 var blocks = core.blocks;
7842 for (var i = 0; i < blocks.length; i++)
7860 for (var i = 0; i < blocks.length; i++)
7843 {
7861 {
7844 var b = blocks[i];
7862 var b = blocks[i];
7845 if (b.y < 11.6)
7863 if (b.state === 'manual')
7864 { continue; }
7865 if (typeof Online.hasLeftTheField === 'function'
7866 ? !Online.hasLeftTheField(b.y, height)
7867 : !(b.y >= height - 1e-9))
7846 { continue; }
7868 { continue; }
7847 if (!(b.vy > 0))
7869 if (!(b.vy > 0))
7848 { continue; }
7870 { continue; }
docs/ASSUMPTIONS.md +23 −9
@@ -680,14 +680,11 @@ Aanname:
680 680 - Speler↔vijand gaat nog steeds om het veld heen en mag alleen de
681 681 **lanceer- en landingskolom** gebruiken, niet het binnenveld.
682 682 Vijand→vijand blijft een kleine soepele boog achter het veld.
683 - Een uitgaand schot start op de **echte cel** van de raket (zelfde
684 positie en formaat als de sprite, `fieldToViewport` met het
685 +0,5-tegel-midden). Zodra een vliegende raket bij de bovenste
686 rij komt (`y ≳ 11,6`, `vy > 0`) neemt een vlucht-sprite het
687 visueel over (de veld-sprite verdwijnt) en vliegt omhoog verder;
688 bij het echte schot wordt de boog vanaf de huidige pose op het
689 echte doel gericht, zonder sprong. Zo ontstaan blokjes niet meer
690 „erbovenop” het veld.
683 - Een uitgaand schot start op de **echte exit-pose** van de raket
684 (zelfde positie en formaat, `fieldToViewport` met het
685 +0,5-tegel-midden, `y ≥ 13`). De boog gaat vanaf daar omhoog
686 verder, zonder pop-in boven het veld. (De vroege overname bij
687 `y ≳ 11,6` is in t1137 teruggedraaid.)
691 688
692 689 ## t1135 — soepel het veld invliegen, naadloze overdracht
693 690
@@ -710,7 +707,8 @@ Aanname:
710 707 `Online.spawnFlights` / `tickFlights` (C¹-bogen om het veld,
711 708 `land_col`, grijze raak-schoten, uitvliegen vanuit de cel,
712 709 invliegen naar de spawn-pose, vijand→vijand achter het veld) en
713 `previewOutgoingFlights` voor de lokale raket.
710 dezelfde startregel voor de lokale raket (pas bij het echte
711 schot, `y ≥ 13`).
714 712 - De server bewaart nu ook de **lanceercel** (`from_col`, `from_y`)
715 713 en stuurt die mee op `shot_results` en `shot_flights`, zodat een
716 714 andere client het blokje uit de juiste cel van de mini ziet
@@ -722,3 +720,19 @@ Aanname:
722 720 `Online._handleTransitions` (het echte poll-pad) op 1920×1080
723 721 en 1024×532, plus dezelfde bogen in Offline Strijd (early/mid/
724 722 late en een korte webm).
723
724 ## t1137 — pas een boogje als het blok echt het veld verlaat
725
726 - Tim zag raketten die net niet hoog genoeg gingen een boogje
727 maken, het veld uit en weer in, omdat de visuele overname al bij
728 `y ≳ 11,6` (met `vy > 0`) begon. Een raket die daar piekt en
729 terugvalt is nog van het veld en mag geen boog krijgen.
730 - Een vlucht start **alleen** bij het echte schot, hetzelfde moment
731 als `cullOffTop`: `y ≥ 13` (hoogte van het veld). Dat geldt voor
732 het spelersveld, vijand-mini's, offline en online.
733 `Online.hasLeftTheField` en `previewExit` weigeren alles daaronder.
734 De overdracht blijft naadloos: start op de exit-pose, volle
735 grootte, raaklijn omhoog, daarna de soepele boog naar het doel.
736 - Een raket die onder de rand piekt produceert geen `outgoingShot`
737 en geen vlucht; een raket die `y ≥ 13` kruist precies één schot
738 en één vlucht, beginnend op die exit-pose.
@@ -680,14 +680,11 @@ Aanname:
680- Speler↔vijand gaat nog steeds om het veld heen en mag alleen de
680- Speler↔vijand gaat nog steeds om het veld heen en mag alleen de
681 **lanceer- en landingskolom** gebruiken, niet het binnenveld.
681 **lanceer- en landingskolom** gebruiken, niet het binnenveld.
682 Vijand→vijand blijft een kleine soepele boog achter het veld.
682 Vijand→vijand blijft een kleine soepele boog achter het veld.
683- Een uitgaand schot start op de **echte cel** van de raket (zelfde
683- Een uitgaand schot start op de **echte exit-pose** van de raket
684 positie en formaat als de sprite, `fieldToViewport` met het
684 (zelfde positie en formaat, `fieldToViewport` met het
685 +0,5-tegel-midden). Zodra een vliegende raket bij de bovenste
685 +0,5-tegel-midden, `y ≥ 13`). De boog gaat vanaf daar omhoog
686 rij komt (`y ≳ 11,6`, `vy > 0`) neemt een vlucht-sprite het
686 verder, zonder pop-in boven het veld. (De vroege overname bij
687 visueel over (de veld-sprite verdwijnt) en vliegt omhoog verder;
687 `y ≳ 11,6` is in t1137 teruggedraaid.)
688 bij het echte schot wordt de boog vanaf de huidige pose op het
689 echte doel gericht, zonder sprong. Zo ontstaan blokjes niet meer
690 „erbovenop” het veld.
691
688
692## t1135 — soepel het veld invliegen, naadloze overdracht
689## t1135 — soepel het veld invliegen, naadloze overdracht
693
690
@@ -710,7 +707,8 @@ Aanname:
710 `Online.spawnFlights` / `tickFlights` (C¹-bogen om het veld,
707 `Online.spawnFlights` / `tickFlights` (C¹-bogen om het veld,
711 `land_col`, grijze raak-schoten, uitvliegen vanuit de cel,
708 `land_col`, grijze raak-schoten, uitvliegen vanuit de cel,
712 invliegen naar de spawn-pose, vijand→vijand achter het veld) en
709 invliegen naar de spawn-pose, vijand→vijand achter het veld) en
713 `previewOutgoingFlights` voor de lokale raket.
710 dezelfde startregel voor de lokale raket (pas bij het echte
711 schot, `y ≥ 13`).
714- De server bewaart nu ook de **lanceercel** (`from_col`, `from_y`)
712- De server bewaart nu ook de **lanceercel** (`from_col`, `from_y`)
715 en stuurt die mee op `shot_results` en `shot_flights`, zodat een
713 en stuurt die mee op `shot_results` en `shot_flights`, zodat een
716 andere client het blokje uit de juiste cel van de mini ziet
714 andere client het blokje uit de juiste cel van de mini ziet
@@ -722,3 +720,19 @@ Aanname:
722 `Online._handleTransitions` (het echte poll-pad) op 1920×1080
720 `Online._handleTransitions` (het echte poll-pad) op 1920×1080
723 en 1024×532, plus dezelfde bogen in Offline Strijd (early/mid/
721 en 1024×532, plus dezelfde bogen in Offline Strijd (early/mid/
724 late en een korte webm).
722 late en een korte webm).
723
724## t1137 — pas een boogje als het blok echt het veld verlaat
725
726- Tim zag raketten die net niet hoog genoeg gingen een boogje
727 maken, het veld uit en weer in, omdat de visuele overname al bij
728 `y ≳ 11,6` (met `vy > 0`) begon. Een raket die daar piekt en
729 terugvalt is nog van het veld en mag geen boog krijgen.
730- Een vlucht start **alleen** bij het echte schot, hetzelfde moment
731 als `cullOffTop`: `y ≥ 13` (hoogte van het veld). Dat geldt voor
732 het spelersveld, vijand-mini's, offline en online.
733 `Online.hasLeftTheField` en `previewExit` weigeren alles daaronder.
734 De overdracht blijft naadloos: start op de exit-pose, volle
735 grootte, raaklijn omhoog, daarna de soepele boog naar het doel.
736- Een raket die onder de rand piekt produceert geen `outgoingShot`
737 en geen vlucht; een raket die `y ≥ 13` kruist precies één schot
738 en één vlucht, beginnend op die exit-pose.
src/main.js +13 −5
@@ -761,7 +761,6 @@ function tickView (dt)
761 761 placeTile(app.cells[i], col, row);
762 762 }
763 763
764 previewOutgoingFlights();
765 764 app.core.tick(dt);
766 765 if (app.offline && app.battle)
767 766 { tickOffline(dt); }
@@ -1607,12 +1606,16 @@ function updateColumnWarn (dt)
1607 1606 }
1608 1607
1609 1608 /**
1610 * Take over a rocket that is about to leave the top of a field (the
1611 * player's, or a bot's) so the flight starts at the real cell and
1612 * continues its upward motion (t1134). Shared by offline and online.
1609 * A flight starts only when a block has actually left the field
1610 * (y ≥ height, the same threshold as cullOffTop). Rockets that
1611 * peak below the top and fall back must never get an arc (t1137).
1612 * Shared by the player's field, enemy minis, offline and online.
1613 1613 */
1614 1614 function previewOutgoingFlights ()
1615 1615 {
1616 // Intentionally not called before core.tick: a block still on
1617 // the field (y < 13) is not a shot yet. Flights are spawned
1618 // from consumeOutgoingShots after cull, at the exit pose.
1616 1619 if (typeof Online === 'undefined' || !Online.previewExit)
1617 1620 { return; }
1618 1621 if (app.core)
@@ -1633,11 +1636,16 @@ function previewCoreExits (core, fromId)
1633 1636 {
1634 1637 if (!core || !core.blocks)
1635 1638 { return; }
1639 var height = core.height != null ? core.height : 13;
1636 1640 var blocks = core.blocks;
1637 1641 for (var i = 0; i < blocks.length; i++)
1638 1642 {
1639 1643 var b = blocks[i];
1640 if (b.y < 11.6)
1644 if (b.state === 'manual')
1645 { continue; }
1646 if (typeof Online.hasLeftTheField === 'function'
1647 ? !Online.hasLeftTheField(b.y, height)
1648 : !(b.y >= height - 1e-9))
1641 1649 { continue; }
1642 1650 if (!(b.vy > 0))
1643 1651 { continue; }
@@ -761,7 +761,6 @@ function tickView (dt)
761 placeTile(app.cells[i], col, row);
761 placeTile(app.cells[i], col, row);
762 }
762 }
763
763
764 previewOutgoingFlights();
765 app.core.tick(dt);
764 app.core.tick(dt);
766 if (app.offline && app.battle)
765 if (app.offline && app.battle)
767 { tickOffline(dt); }
766 { tickOffline(dt); }
@@ -1607,12 +1606,16 @@ function updateColumnWarn (dt)
1607}
1606}
1608
1607
1609/**
1608/**
1610 * Take over a rocket that is about to leave the top of a field (the
1609 * A flight starts only when a block has actually left the field
1611 * player's, or a bot's) so the flight starts at the real cell and
1610 * (y ≥ height, the same threshold as cullOffTop). Rockets that
1612 * continues its upward motion (t1134). Shared by offline and online.
1611 * peak below the top and fall back must never get an arc (t1137).
1612 * Shared by the player's field, enemy minis, offline and online.
1613 */
1613 */
1614function previewOutgoingFlights ()
1614function previewOutgoingFlights ()
1615{
1615{
1616 // Intentionally not called before core.tick: a block still on
1617 // the field (y < 13) is not a shot yet. Flights are spawned
1618 // from consumeOutgoingShots after cull, at the exit pose.
1616 if (typeof Online === 'undefined' || !Online.previewExit)
1619 if (typeof Online === 'undefined' || !Online.previewExit)
1617 { return; }
1620 { return; }
1618 if (app.core)
1621 if (app.core)
@@ -1633,11 +1636,16 @@ function previewCoreExits (core, fromId)
1633{
1636{
1634 if (!core || !core.blocks)
1637 if (!core || !core.blocks)
1635 { return; }
1638 { return; }
1639 var height = core.height != null ? core.height : 13;
1636 var blocks = core.blocks;
1640 var blocks = core.blocks;
1637 for (var i = 0; i < blocks.length; i++)
1641 for (var i = 0; i < blocks.length; i++)
1638 {
1642 {
1639 var b = blocks[i];
1643 var b = blocks[i];
1640 if (b.y < 11.6)
1644 if (b.state === 'manual')
1645 { continue; }
1646 if (typeof Online.hasLeftTheField === 'function'
1647 ? !Online.hasLeftTheField(b.y, height)
1648 : !(b.y >= height - 1e-9))
1641 { continue; }
1649 { continue; }
1642 if (!(b.vy > 0))
1650 if (!(b.vy > 0))
1643 { continue; }
1651 { continue; }
src/online.js +22 −8
@@ -1019,7 +1019,7 @@ Online.spawnFlights = function (results, locals)
1019 1019 else if (kind === 'player-to-enemy' || kind === 'player-miss')
1020 1020 { start = this._flightStart(startCol, startY); }
1021 1021 else if (startCol != null || startY != null)
1022 { start = this.miniCellViewport(fromId, startCol, startY != null ? startY : 12); }
1022 { start = this.miniCellViewport(fromId, startCol, startY != null ? startY : 13); }
1023 1023 else
1024 1024 { start = this._miniAnchor(fromId, 'out'); }
1025 1025
@@ -1139,7 +1139,7 @@ Online.rememberFlightLocal = function (shot, startX, startY)
1139 1139 Online._flightStart = function (col, y)
1140 1140 {
1141 1141 if (y == null || !isFinite(y))
1142 { y = 12; }
1142 { y = 13; }
1143 1143 return this.cellViewport(col == null ? 4.5 : col, y);
1144 1144 };
1145 1145
@@ -1198,16 +1198,30 @@ Online._findFlight = function (sid)
1198 1198 };
1199 1199
1200 1200 /**
1201 * Early visual takeover: a flying rocket near the top of a field
1202 * becomes a flight sprite at its exact cell, so it is seen flying
1203 * *out* rather than popping in above the canvas (t1134). When the
1204 * shot is later dispatched, `retargetFlight` picks up from the
1205 * current pose and aims at the real landing column.
1201 * True once a block has really left the field, matching cullOffTop
1202 * (y ≥ height, default 13). Used so an arc never starts for a
1203 * rocket that only peaked near the top and fell back (t1137).
1204 */
1205 Online.EXIT_Y = 13;
1206 Online.hasLeftTheField = function (y, height)
1207 {
1208 height = height == null ? this.EXIT_Y : height;
1209 return y != null && isFinite(y) && y >= height - 1e-9;
1210 };
1211
1212 /**
1213 * Start a flight only at the true exit (y ≥ 13). Callers that pass
1214 * a rocket still on the field are ignored, so a fallback never
1215 * shows a phantom arc (t1137). The start pose is the exit cell,
1216 * continuing upward; retargetFlight aims it at the real target
1217 * if a preview was used in the same frame as cull.
1206 1218 */
1207 1219 Online.previewExit = function (info)
1208 1220 {
1209 1221 if (!info || info.id == null)
1210 { return; }
1222 { return null; }
1223 if (!this.hasLeftTheField(info.y))
1224 { return null; }
1211 1225 var sid = String(info.id);
1212 1226 if (!this._flights)
1213 1227 { this._flights = []; }
@@ -1019,7 +1019,7 @@ Online.spawnFlights = function (results, locals)
1019 else if (kind === 'player-to-enemy' || kind === 'player-miss')
1019 else if (kind === 'player-to-enemy' || kind === 'player-miss')
1020 { start = this._flightStart(startCol, startY); }
1020 { start = this._flightStart(startCol, startY); }
1021 else if (startCol != null || startY != null)
1021 else if (startCol != null || startY != null)
1022 { start = this.miniCellViewport(fromId, startCol, startY != null ? startY : 12); }
1022 { start = this.miniCellViewport(fromId, startCol, startY != null ? startY : 13); }
1023 else
1023 else
1024 { start = this._miniAnchor(fromId, 'out'); }
1024 { start = this._miniAnchor(fromId, 'out'); }
1025
1025
@@ -1139,7 +1139,7 @@ Online.rememberFlightLocal = function (shot, startX, startY)
1139Online._flightStart = function (col, y)
1139Online._flightStart = function (col, y)
1140{
1140{
1141 if (y == null || !isFinite(y))
1141 if (y == null || !isFinite(y))
1142 { y = 12; }
1142 { y = 13; }
1143 return this.cellViewport(col == null ? 4.5 : col, y);
1143 return this.cellViewport(col == null ? 4.5 : col, y);
1144};
1144};
1145
1145
@@ -1198,16 +1198,30 @@ Online._findFlight = function (sid)
1198};
1198};
1199
1199
1200/**
1200/**
1201 * Early visual takeover: a flying rocket near the top of a field
1201 * True once a block has really left the field, matching cullOffTop
1202 * becomes a flight sprite at its exact cell, so it is seen flying
1202 * (y ≥ height, default 13). Used so an arc never starts for a
1203 * *out* rather than popping in above the canvas (t1134). When the
1203 * rocket that only peaked near the top and fell back (t1137).
1204 * shot is later dispatched, `retargetFlight` picks up from the
1204 */
1205 * current pose and aims at the real landing column.
1205Online.EXIT_Y = 13;
1206Online.hasLeftTheField = function (y, height)
1207{
1208 height = height == null ? this.EXIT_Y : height;
1209 return y != null && isFinite(y) && y >= height - 1e-9;
1210};
1211
1212/**
1213 * Start a flight only at the true exit (y ≥ 13). Callers that pass
1214 * a rocket still on the field are ignored, so a fallback never
1215 * shows a phantom arc (t1137). The start pose is the exit cell,
1216 * continuing upward; retargetFlight aims it at the real target
1217 * if a preview was used in the same frame as cull.
1206 */
1218 */
1207Online.previewExit = function (info)
1219Online.previewExit = function (info)
1208{
1220{
1209 if (!info || info.id == null)
1221 if (!info || info.id == null)
1210 { return; }
1222 { return null; }
1223 if (!this.hasLeftTheField(info.y))
1224 { return null; }
1211 var sid = String(info.id);
1225 var sid = String(info.id);
1212 if (!this._flights)
1226 if (!this._flights)
1213 { this._flights = []; }
1227 { this._flights = []; }
test/flight-path.test.js +137 −0
@@ -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
275describe('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});
test/minis-flights-playwright.py +15 −15
@@ -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,
test/online-presentation-playwright.py +10 −10
@@ -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();