fix: preserve planning booster reservations and map tile geometry

This commit is contained in:
coyotte508 2026-11-05 13:34:00 +00:00
commit b2286fa32e
24 changed files with 790 additions and 57 deletions

View file

@ -260,6 +260,11 @@ happen lazily, mid-replay, at the exact point the clone first reaches round 1's
`|| turnOrderAfterSetupAuction` fallback never triggers, rather than shrinking `setup` and risking
the same leech-adjacency breakage for round 1 itself.
**Booster reservation correction:** keep already-passed opponents in `passedPlayers` while shrinking
`turnOrder`, so their new boosters stay reserved for the upcoming round (§4.5). At the next boundary,
`beginRoundStartPhase` selects only the analysis seat for income/Gaia/turns and clears `passedPlayers`
as usual. This preserves solo flow and naturally expires those reservations without extra saved state.
### 2.6 Setup already does what decision #7 wants — if you leave it alone
`beginSetupBuildingPhase` (`phase.ts:366`) builds the setup turn order including Lost Fleet expansion
@ -471,6 +476,15 @@ opponents frozen, analysis shows all of them available, so a line built on the 7
assumes nobody takes it first. This is deliberately out of scope. State it in the panel's help text so
the number is not over-trusted.
For boosters, this assumption applies only to future **undecided** choices: the pool contains only
this game's drawn tiles, excludes your current booster, and excludes the new boosters already chosen
by opponents who passed in the current real round. Opponents still playing may return their old
boosters before your planned pass, so those remain selectable. Existing reservations expire once
the simulation enters the next round; its next pass chooses for a later round, not the one already
reserved. Entering after your own real pass starts in that next round too. Setup still uses actual
availability. Reanchoring or reloading derives reservations from the current real position, without
adding metadata to saved plans.
---
## 5. Visual design

View file

@ -1,6 +1,6 @@
{
"name": "@gaia-project/engine",
"version": "4.17.4",
"version": "4.17.5",
"description": "Javascript engine for project gaia",
"main": "dist/index.js",
"types": "index.ts",

View file

@ -1,6 +1,6 @@
import { expect } from "chai";
import Engine from "../engine";
import { Booster, Phase, Player as PlayerEnum } from "../enums";
import { Booster, Command, Phase, Player as PlayerEnum } from "../enums";
import { possibleRoundBoosters } from "./round";
describe("possibleRoundBoosters", () => {
@ -29,7 +29,7 @@ describe("possibleRoundBoosters", () => {
expect(command.data.boosters.length).to.be.greaterThan(0);
});
it("in analysis mode, offers only this game’s boosters except the one currently held", () => {
it("before anyone has passed, offers this game's boosters except the planning seat's current one", () => {
const engine = game();
engine.player(PlayerEnum.Player1).data.analysis = true;
@ -37,8 +37,8 @@ describe("possibleRoundBoosters", () => {
// Player1 (terrans) is holding booster3 - can't pick the one you just had.
expect(command.data.boosters).to.not.include(Booster.Booster3);
// booster7 is off the table in a real game (held by the other player), but analysis assumes
// it's still pickable since opponents are frozen and might not really have taken it.
// booster7 is currently held by the other player, who has not passed yet. Planning allows
// for that player returning it before our future pass.
expect(command.data.boosters).to.include(Booster.Booster7);
expect(command.data.boosters).to.have.members(
Object.keys(engine.tiles.boosters).filter((booster) => booster !== Booster.Booster3)
@ -48,6 +48,38 @@ describe("possibleRoundBoosters", () => {
expect(command.data.boosters).to.not.include.members(unused);
});
it("respects an opponent's completed pass when generating and validating a planning pass", () => {
const real = new Engine([...SETUP, "terrans pass booster4"]);
const original = JSON.stringify(real);
const engine = Engine.fromData(JSON.parse(original));
engine.player(PlayerEnum.Player2).data.analysis = true;
engine.clearAvailableCommands();
engine.generateAvailableCommands();
const command = engine.findAvailableCommand(PlayerEnum.Player2, Command.Pass);
expect(command.data.boosters).to.have.members(
Object.keys(real.tiles.boosters).filter((booster) => real.tiles.boosters[booster])
);
// The old booster was returned; the new one is already reserved for round 2.
expect(command.data.boosters).to.include(Booster.Booster3);
expect(command.data.boosters).to.not.include(Booster.Booster4);
expect(command.data.boosters).to.not.include(Booster.Booster7);
expect(() => engine.move("nevlas pass booster4")).to.throw("booster4 is not in the available boosters");
expect(JSON.stringify(real)).to.equal(original);
});
it("keeps real pass order and booster ownership intact across the next round", () => {
const engine = new Engine([...SETUP, "terrans pass booster4", "nevlas pass booster5"]);
expect(engine.round).to.equal(2);
expect(engine.turnOrder).to.deep.equal([PlayerEnum.Player1, PlayerEnum.Player2]);
expect(engine.passedPlayers).to.deep.equal([]);
const command = engine.findAvailableCommand(PlayerEnum.Player1, Command.Pass);
expect(command.data.boosters).to.include(Booster.Booster3);
expect(command.data.boosters).to.include(Booster.Booster7);
expect(command.data.boosters).to.not.include(Booster.Booster4);
expect(command.data.boosters).to.not.include(Booster.Booster5);
});
it("during setup, excludes unused boosters and those already picked by opponents", () => {
const engine = new Engine(SETUP.slice(0, -1));
engine.player(PlayerEnum.Player1).data.analysis = true;

View file

@ -4,13 +4,18 @@ import { Booster, Command, Phase, Player } from "../enums";
export function possibleRoundBoosters(engine: Engine, player: Player) {
const commands = [];
const pl = engine.player(player);
// Future rounds may assume an opponent returns a booster, but only tiles drawn for this game
// exist. During setup, already chosen boosters cannot become available before our first pick.
// An opponent still playing may return their old booster before our planned pass. An opponent
// who already passed has reserved their NEW booster for next round; that choice is no longer
// hypothetical. passedPlayers resets at the round boundary, so this is not a permanent ban.
// During setup, already chosen boosters cannot become available before our first pick.
const reserved = (engine.passedPlayers ?? []).map((seat) => engine.player(seat).data.tiles.booster);
const boosters = engine.isLastRound
? []
: Booster.values(engine.expansions).filter((booster) =>
pl?.data.analysis && engine.phase !== Phase.SetupBooster
? engine.tiles.boosters[booster] !== undefined && booster !== pl.data.tiles.booster
? engine.tiles.boosters[booster] !== undefined &&
booster !== pl.data.tiles.booster &&
!reserved.includes(booster)
: engine.tiles.boosters[booster]
);

View file

@ -477,6 +477,11 @@ function beginRoundStartPhase(engine: Engine) {
startAutomaRound(engine);
engine.addAdvancedLog({ round: engine.round });
engine.turnOrder = engine.passedPlayers || engine.turnOrderAfterSetupAuction;
// Solo planning preserves real passedPlayers until this boundary to reserve their next-round
// boosters. Do not bring those opponents back into the clone's income/Gaia/turn order. The
// analysis flag is never serialized in real player data; ordinary games keep the full order.
const analysisPlayers = engine.turnOrder.filter((seat) => engine.player(seat).data.analysis);
if (analysisPlayers.length) engine.turnOrder = analysisPlayers;
engine.passedPlayers = [];
engine.currentPlayer = engine.turnOrder[0];

View file

@ -1,6 +1,6 @@
{
"name": "@gaia-project/old-ui",
"version": "1.2.25",
"version": "1.2.26",
"scripts": {
"serve": "vite --port 5193",
"build": "vite build",

View file

@ -29,7 +29,11 @@
<use
v-if="mapModeHighlight !== null"
xlink:href="#space-hex"
:class="['space-hex-federation', 'planet', 'planet-fill', playerPlanet(mapModeHighlight)]"
:class="[
'planet-fill',
playerPlanet(mapModeHighlight),
sectorMapMode ? 'space-hex-sector-highlight' : 'space-hex-federation planet',
]"
/>
<use

View file

@ -14,7 +14,7 @@
:key="hex.toString()"
:hex="hex"
:isCenter="false"
:transform="`translate(${hexCenter(hex).x * spread},${hexCenter(hex).y * spread})`"
:transform="`translate(${displayedHexCenter(hex).x},${displayedHexCenter(hex).y})`"
/>
<use
v-for="ring in powerRings"

View file

@ -1,6 +1,6 @@
{
"name": "@gaia-project/viewer",
"version": "5.22.25",
"version": "5.22.26",
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
"contributors": [
"coyotte508",

View file

@ -180,7 +180,11 @@ export default class FinalScoringTile extends Vue {
}
toggleMapMode(mode: MapModeType, player: Player) {
this.$store.commit("toggleMapMode", { type: mode, player: player.player } as MapMode);
this.$store.commit("toggleMapMode", {
type: mode,
player: player.player,
...(mode === MapModeType.sectors ? { spaceSectorsOnly: true } : {}),
} as MapMode);
}
get content() {

View file

@ -924,6 +924,79 @@ describe("Game", () => {
vm.$destroy();
});
it("renders only unreserved booster choices after the first planned move and inspecting it", async () => {
const real = new Engine([...SETUP_MOVES, "terrans pass booster4"]);
const original = JSON.stringify(real);
const vm = mountAsSeat(1, Engine.fromData(JSON.parse(original)));
vm.enterAnalysisMode();
vm.applyAnalysisMove("nevlas up nav.");
vm.inspectAnalysisMove(0);
expect(vm.engine.findAvailableCommand(1, Command.Pass).data.boosters).to.have.members([
"booster3",
"booster5",
"booster8",
]);
vm.cancelAnalysisMoveEdit();
await Vue.nextTick();
const pass = Array.from(vm.$el.querySelectorAll("#move-buttons button")).find(
(button: HTMLButtonElement) => button.textContent.trim() === "Pass"
);
expect(pass).not.to.equal(undefined);
await fireEvent.click(pass as HTMLElement);
const offered = Array.from(vm.$el.querySelectorAll("#move-buttons .booster")).map(
(element: any) => element.__vue__.booster
);
expect(offered).to.have.members(["booster3", "booster5", "booster8"]);
expect(vm.engine.passedPlayers).to.deep.equal([0]);
vm.exitAnalysisMode();
expect(JSON.parse(JSON.stringify(vm.engine))).to.deep.equal(JSON.parse(original));
vm.$el.remove();
vm.$destroy();
});
it("refreshes booster reservations on real progress and reload without losing a blocked saved pass", async () => {
const real = new Engine(SETUP_MOVES);
const vm = mountAsSeat(1, real);
vm.enterAnalysisMode(); // Off turn: Terrans has not passed yet.
vm.applyAnalysisMove("nevlas up nav.");
vm.applyAnalysisMove("nevlas pass booster4");
const entries = JSON.parse(JSON.stringify(vm.analysisEntries));
expect(vm.analysisAppliedCount).to.equal(2);
const arrived = bgsMove(JSON.parse(JSON.stringify(real)), "terrans pass booster4", 0);
const original = JSON.stringify(arrived);
await vm.$store.dispatch("externalData", arrived);
expect(vm.analysisMode).to.equal(true);
expect(vm.analysisEntries).to.deep.equal(entries);
expect(vm.analysisAppliedCount).to.equal(1);
expect(vm.analysisBlockedReason).to.contain("booster4 is not in the available boosters");
expect(vm.engine.findAvailableCommand(1, Command.Pass).data.boosters).to.have.members([
"booster3",
"booster5",
"booster8",
]);
expect(loadAnalysisLines(1).lines[0]).to.deep.equal(entries);
vm.$el.remove();
vm.$destroy();
const reloaded = mountAsSeat(1, Engine.fromData(JSON.parse(original)));
reloaded.enterAnalysisMode();
expect(reloaded.analysisEntries).to.deep.equal(entries);
expect(reloaded.analysisAppliedCount).to.equal(1);
expect(reloaded.analysisBlockedReason).to.contain("booster4 is not in the available boosters");
expect(reloaded.engine.findAvailableCommand(1, Command.Pass).data.boosters).not.to.include("booster4");
reloaded.startAnalysisMoveEdit(1);
reloaded.applyAnalysisMove("nevlas pass booster3");
expect(reloaded.engine.round).to.equal(2);
expect(reloaded.engine.turnOrder).to.deep.equal([1]);
// A round-2 pass chooses for round 3; Terrans' round-2 reservation has expired.
expect(reloaded.engine.findAvailableCommand(1, Command.Pass).data.boosters).to.include("booster4");
expect(reloaded.engine.findAvailableCommand(1, Command.Pass).data.boosters).not.to.include("booster3");
reloaded.exitAnalysisMode();
expect(JSON.parse(JSON.stringify(reloaded.engine))).to.deep.equal(JSON.parse(original));
reloaded.$el.remove();
reloaded.$destroy();
});
it("rolls a seat that has already passed into the next round, and commits nothing from it", () => {
// applySoloRoundFlow used to wipe passedPlayers outright, handing back a full turn - Pass button
// and all - in a round this seat is out of, and reporting those moves as committable.
@ -938,6 +1011,14 @@ describe("Game", () => {
vm.applyAnalysisMove("terrans up nav.");
expect(vm.analysisEntries).to.have.length(1);
expect(vm.analysisCommittableMoves).to.deep.equal([]);
vm.inspectAnalysisMove(0);
expect(vm.engine.round).to.equal(2);
expect(vm.engine.findAvailableCommand(0, Command.Pass).data.boosters).to.have.members([
"booster3",
"booster5",
"booster7",
"booster8",
]);
vm.$el.remove();
vm.$destroy();

View file

@ -49,7 +49,11 @@
<use
v-if="mapModeHighlight !== null"
xlink:href="#space-hex"
:class="['space-hex-federation', 'planet', 'planet-fill', playerPlanet(mapModeHighlight)]"
:class="[
'planet-fill',
playerPlanet(mapModeHighlight),
sectorMapMode ? 'space-hex-sector-highlight' : 'space-hex-federation planet',
]"
/>
<!-- Lost Fleet spaceship hex: fill the entire hex with the ship's identity color (rulebook
page 7 - Twilight purple / Rebellion brown / T F Mars grey / Eclipse yellow). Drawn here,
@ -169,6 +173,7 @@ import { spaceshipColors } from "../data/spaceships";
import { isWarningEnabled } from "../data/warnings";
import type { FederationLine } from "../graphics/hex";
import { corners, playerFederationLines } from "../graphics/hex";
import { isColonizedSector } from "../graphics/sectors";
import { hexStarField } from "../graphics/stars";
import { factionPiecePlanet } from "../graphics/utils";
import { isFree } from "../logic/buttons/utils";
@ -438,18 +443,25 @@ export default class SpaceHex extends Vue {
}
}
get mapModeHighlight(): PlayerEnum | null {
if (this.planet === "e") {
const sec = this.playerMapMode(MapModeType.sectors);
if (
sec &&
this.player(sec.player).data.occupied.some(
(hex) => hex.colonizedBy(sec.player) && hex.data.sector === this.hex.data.sector
)
) {
return sec.player;
}
get sectorMapMode(): MapMode | null {
return this.playerMapMode(MapModeType.sectors);
}
get mapModeHighlight(): PlayerEnum | null {
const sec = this.sectorMapMode;
// Deep Space's three per-hex IDs share one sector; Interspace is never a sector. Tint every
// DS background (even a tile with three planets must remain visible), underneath its content.
// Keep ordinary sectors' existing empty-cell highlighting unchanged.
if (
sec &&
(this.planet === PlanetEnum.Empty || this.sectorType === LostFleetSectorType.DeepSpace) &&
(!sec.spaceSectorsOnly || this.sectorType === LostFleetSectorType.Space) &&
isColonizedSector(this.hex, this.player(sec.player))
) {
return sec.player;
}
if (this.planet === "e") {
const fed = this.playerMapMode(MapModeType.federations);
if (fed && this.hex.federations.some((f) => f === fed.player)) {
return fed.player;
@ -649,6 +661,14 @@ svg {
}
}
// Sector tint must stop at the SAME hex outline as the normal map. Reusing the federation/
// planet stroke expands the fill into the existing 1% inter-sector gap, merging neighbouring
// highlighted tiles. Fill only: no new borders, spacing, or changes to federation highlights.
.space-hex-sector-highlight {
stroke: none;
pointer-events: none;
}
.space-hex-federation {
stroke-width: 0.1;
fill: none;

View file

@ -0,0 +1,201 @@
import Engine, {
Building,
classifySectorId,
Condition,
FinalTile,
GaiaHex,
LostFleetSectorType,
Planet,
PlayerEnum,
} from "@gaia-project/engine";
import { lostFleetSectorKey } from "@gaia-project/engine/src/lost-fleet-map";
import { cleanup, fireEvent, render } from "@testing-library/vue";
import { expect } from "chai";
import fs from "fs";
import Vue from "vue";
import AlternateSpaceMap from "../../../old-ui/src/components/SpaceMap.vue";
import { MapModeType } from "../data/actions";
import { sectors as sectorCount } from "../data/stats";
import { makeStore } from "../store";
import FinalScoringTile from "./FinalScoringTile.vue";
import SpaceMap from "./SpaceMap.vue";
function position(lostFleet: boolean) {
const engine = new Engine(["init 2 sector-map-regression", "p1 faction firaks", "p2 faction lantids"], {
lostFleet,
});
const hexes = [...engine.map.grid.values()];
const ordinary = hexes.filter((hex) => classifySectorId(hex.data.sector) === LostFleetSectorType.Space);
const first = ordinary[0];
const adjacent = ordinary.find(
(hex) =>
hex.data.sector !== first.data.sector &&
engine.map.grid.neighbours(hex).some((other) => other.data.sector === first.data.sector)
);
expect(adjacent, "fixture needs two adjacent regular sectors").not.to.equal(undefined);
const regularKeys = [first.data.sector, adjacent.data.sector];
const otherKeys = [...new Set(ordinary.map((hex) => hex.data.sector))].filter((key) => !regularKeys.includes(key));
function occupy(hex: GaiaHex, player = PlayerEnum.Player1, building = Building.Mine) {
hex.data.player = player;
hex.data.building = building;
if (building !== Building.SpaceStation) hex.data.planet = Planet.Titanium;
engine.players[player].data.occupied.push(hex);
return hex;
}
const mines = regularKeys.map((key) => occupy(ordinary.find((hex) => hex.data.sector === key && hex.hasPlanet())));
mines[0].data.additionalMine = PlayerEnum.Player2;
engine.players[1].data.occupied.push(mines[0]);
occupy(
ordinary.find((hex) => hex.data.sector === otherKeys[0] && hex.hasPlanet()),
PlayerEnum.Player2
);
occupy(
ordinary.find((hex) => hex.data.sector === otherKeys[1] && hex.hasPlanet()),
PlayerEnum.Player1,
Building.GaiaFormer
);
occupy(
ordinary.find((hex) => hex.data.sector === otherKeys[2] && !hex.hasPlanet()),
PlayerEnum.Player1,
Building.SpaceStation
);
// Sector tint must stay below the existing top-layer Power Ring.
mines[0].data.powerRing = PlayerEnum.Player1;
const deep = hexes.filter((hex) => classifySectorId(hex.data.sector) === LostFleetSectorType.DeepSpace);
const deepKey = deep.length ? lostFleetSectorKey(deep[0]) : undefined;
if (lostFleet) {
const tile = deep.filter((hex) => lostFleetSectorKey(hex) === deepKey);
// An empty-cell-only highlight would be completely invisible on this planet-filled tile.
tile.forEach((hex) => {
hex.data.planet = Planet.Asteroid;
});
occupy(tile[1]);
tile[1].data.additionalMine = PlayerEnum.Player2;
engine.players[1].data.occupied.push(tile[1]);
occupy(
hexes.find((hex) => classifySectorId(hex.data.sector) === LostFleetSectorType.Interspace && hex.hasPlanet())
);
}
return { engine, regularKeys, otherKeys, deepKey, mines };
}
function highlightedKeys(container: HTMLElement, engine: Engine): Set<string> {
const ids = [...container.querySelectorAll(".space-hex-cell > .space-hex-sector-highlight")].map(
(node) => node.parentElement.id
);
return new Set(ids.map((id) => lostFleetSectorKey(engine.map.getS(id))));
}
for (const [name, component] of [
["primary", SpaceMap],
["alternate", AlternateSpaceMap],
] as const) {
describe(`${name} Sectors map mode`, () => {
for (const lostFleet of [false, true]) {
it(`separates adjacent highlighted tiles and follows the selected player (${lostFleet ? "Lost Fleet" : "base"})`, async () => {
const { engine, regularKeys, otherKeys, deepKey, mines } = position(lostFleet);
const store = makeStore();
store.commit("receiveData", engine);
// Exercise setup rotation as well as primary Lost Fleet's whole-board rotation.
store.commit("rotate", mines[0]);
store.commit("rotate", mines[0]);
const { container } = render(component, { store });
const geometry = () =>
[...container.querySelectorAll(".sector, .space-hex-cell")].map((node) => ({
id: node.id,
transform: node.getAttribute("transform"),
style: node.getAttribute("style"),
}));
const defaultGeometry = geometry();
expect(container.querySelector(".sector-boundaries")).to.equal(null);
expect(highlightedKeys(container, engine).size).to.equal(0);
store.commit("toggleMapMode", { type: MapModeType.sectors, player: PlayerEnum.Player1 });
await Vue.nextTick();
expect([...highlightedKeys(container, engine)]).to.have.members([
...regularKeys,
...(lostFleet ? [deepKey] : []),
]);
// Exactly the normal positions and polygons: no extra spacing, boundary layer, or strokes
// expanding into the normal 1% inter-sector gap. The old .planet + .space-hex-federation
// classes brought a 0.1-unit faction stroke, wider than the gap between adjacent sectors.
expect(geometry()).to.deep.equal(defaultGeometry);
expect(container.querySelector(".sector-boundaries, .sector-boundary")).to.equal(null);
const highlights = [...container.querySelectorAll(".space-hex-sector-highlight")];
expect(highlights.length).to.be.greaterThan(0);
for (const highlight of highlights) {
expect(highlight.classList.contains("space-hex-federation")).to.equal(false);
expect(highlight.classList.contains("planet")).to.equal(false);
const polygon = highlight.parentElement.querySelector("use.space-hex");
expect(highlight.getAttribute("href") ?? highlight.getAttribute("xlink:href")).to.equal(
polygon.getAttribute("href") ?? polygon.getAttribute("xlink:href")
);
expect(highlight.getAttribute("transform")).to.equal(null);
const content = highlight.parentElement.querySelector("g");
expect(highlight.compareDocumentPosition(content) & Node.DOCUMENT_POSITION_FOLLOWING).not.to.equal(0);
}
if (lostFleet) {
const deepHighlights = highlights.filter((node) => node.parentElement.id.startsWith(`${deepKey}_`));
expect(deepHighlights.length).to.equal(3);
// All three have planets: background tint must not depend on an empty hex being available.
expect(deepHighlights.every((node) => engine.map.getS(node.parentElement.id).hasPlanet())).to.equal(true);
const deep = deepHighlights[0].parentElement;
expect(deep.parentElement.getAttribute("transform")).to.equal(name === "primary" ? "rotate(60)" : null);
}
const ring = container.querySelector(".space-hex-power-ring");
expect(
highlights.every((node) => !!(node.compareDocumentPosition(ring) & Node.DOCUMENT_POSITION_FOLLOWING))
).to.equal(true);
expect(container.querySelectorAll("defs").length).to.equal(3);
// The visual request must NOT change base sector scoring or the player-board statistic.
expect(engine.players[0].eventConditionCount(Condition.Sector)).to.equal(2);
expect(sectorCount(engine.players[0])).to.equal(2);
store.commit("toggleMapMode", { type: MapModeType.sectors, player: PlayerEnum.Player2 });
await Vue.nextTick();
expect([...highlightedKeys(container, engine)]).to.have.members([
regularKeys[0],
otherKeys[0],
...(lostFleet ? [deepKey] : []),
]);
store.commit("toggleMapMode", { type: MapModeType.default, player: PlayerEnum.Player2 });
await Vue.nextTick();
expect(container.querySelector(".sector-boundaries")).to.equal(null);
expect(highlightedKeys(container, engine).size).to.equal(0);
cleanup();
});
}
});
}
describe("base final sector-scoring map shortcut", () => {
it("excludes Deep Space from its scoring explanation without narrowing the player dropdown view", async () => {
const { engine, regularKeys, deepKey } = position(true);
engine.tiles.scorings.final[0] = FinalTile.Sector;
const store = makeStore();
store.commit("receiveData", engine);
const map = render(SpaceMap, { store });
const tile = render(FinalScoringTile, { store, props: { index: 0 } });
await fireEvent.click(tile.container.querySelector('circle[role="button"]'));
expect(store.getters.mapModes).to.deep.equal([
{ type: MapModeType.sectors, player: PlayerEnum.Player1, spaceSectorsOnly: true },
]);
expect([...highlightedKeys(map.container, engine)]).to.have.members(regularKeys);
// Switching back to the ordinary player dropdown restores Deep Space to the visual selection.
store.commit("toggleMapMode", { type: MapModeType.sectors, player: PlayerEnum.Player1 });
await Vue.nextTick();
expect([...highlightedKeys(map.container, engine)]).to.have.members([...regularKeys, deepKey]);
expect(engine.players[0].progress(FinalTile.Sector)).to.equal(2);
});
});
// jsdom does not apply compiled SFC styles; assert the shared rule explicitly as well as the
// rendered class/placement contract above. Both UIs import this same SpaceHex stylesheet.
it("keeps sector highlights fill-only and noninteractive without changing federation strokes", () => {
const source = fs.readFileSync("src/components/SpaceHex.vue", "utf8");
const sectorStyle = /\.space-hex-sector-highlight\s*\{([^}]+)\}/.exec(source)[1];
expect(sectorStyle).to.include("stroke: none;");
expect(sectorStyle).to.include("pointer-events: none;");
const federationStyle = /\.space-hex-federation\s*\{([^}]+)\}/.exec(source)[1];
expect(federationStyle).to.include("stroke-width: 0.1;");
});

View file

@ -11,7 +11,7 @@ import Engine, {
import { cleanup, render } from "@testing-library/vue";
import { expect } from "chai";
import fs from "fs";
import { hexCenter } from "../graphics/hex";
import { displayedHexCenter, hexCenter } from "../graphics/hex";
import { makeStore } from "../store";
import SpaceMap from "./SpaceMap.vue";
@ -316,6 +316,9 @@ describe("SpaceMap", () => {
expect(labelForId, `expected a label for ${id}`).to.not.equal(undefined);
const transform = labelForId.getAttribute("transform");
const [tx, ty] = /translate\((-?[\d.]+),\s*(-?[\d.]+)\)/.exec(transform).slice(1).map(Number);
const centers = hexes.map((hex) => displayedHexCenter(hex, engine.map.grid));
expect(tx).to.be.closeTo(centers.reduce((sum, c) => sum + c.x, 0) / 3, 1e-9);
expect(ty).to.be.closeTo(centers.reduce((sum, c) => sum + c.y, 0) / 3, 1e-9);
// the centroid must not coincide with any single one of the tile's 3 hex centers (that was
// the old per-hex-badge bug this replaces) - it should sit roughly between all 3.
for (const hex of hexes) {
@ -534,6 +537,20 @@ describe("SpaceMap", () => {
matrixOf(ring.getAttribute("transform")).forEach((value, i) => expect(value).to.be.closeTo(expected[i], 1e-9));
});
it("keeps a Deep Space Power Ring aligned with its translated tile", () => {
const engine = new Engine(["init 2 deep-ring", "p1 faction moweyds", "p2 faction terrans"], { lostFleet: true });
const hex = [...engine.map.grid.values()].find(
(h) => classifySectorId(h.data.sector) === LostFleetSectorType.DeepSpace
);
hex.data.powerRing = engine.players[0].player;
const store = makeStore();
store.commit("receiveData", engine);
const { container } = render(SpaceMap, { store });
const cell = container.querySelector(`g.space-hex-cell[id="${hex}"]`);
const ring = container.querySelector(".space-hex-power-ring");
expect(matrixOf(ring.getAttribute("transform"))).to.deep.equal(matrixOf(cell.getAttribute("transform")));
});
it("does not render final scoring on the map itself (it lives in ResearchBoard's 7th column instead)", () => {
const engine = new Engine(["init 2 lost-fleet-space-map"], { lostFleet: true });
const store = makeStore();

View file

@ -25,7 +25,7 @@
<SpaceHex
v-for="hex in looseHexes"
:key="hex.toString()"
:transform="`translate(${hexCenter(hex).x * spread}, ${hexCenter(hex).y * spread})`"
:transform="`translate(${displayedHexCenter(hex).x}, ${displayedHexCenter(hex).y})`"
:hex="hex"
:isCenter="false"
:contentRotation="mapRotationDeg"
@ -130,7 +130,7 @@ import Vue from "vue";
import { Component } from "vue-property-decorator";
import type { MapMode } from "../data/actions";
import { MapModeType } from "../data/actions";
import { HEX_SPREAD, hexCenter } from "../graphics/hex";
import { deepSpaceOffset, displayedHexCenter, HEX_SPREAD, hexCenter } from "../graphics/hex";
import { factionPiecePlanet } from "../graphics/utils";
import { gameSeed, isBeforeRound1 } from "../logic/utils";
import FactionWheel from "./FactionWheel.vue";
@ -217,6 +217,10 @@ export default class SpaceMap extends Vue {
return hexCenter(hex);
}
displayedHexCenter(hex: GaiaHex) {
return displayedHexCenter(hex, this.map.grid);
}
/** Exposed for the template, which places sectors and loose hexes at the same 1% spread. */
get spread(): number {
return HEX_SPREAD;
@ -249,7 +253,8 @@ export default class SpaceMap extends Vue {
private hexTransform(hex: GaiaHex): string {
const spread = (point: Point) => `translate(${point.x * HEX_SPREAD}, ${point.y * HEX_SPREAD})`;
if (classifySectorId(hex.data.sector) !== LostFleetSectorType.Space) {
return spread(hexCenter(hex));
const point = this.displayedHexCenter(hex);
return `translate(${point.x}, ${point.y})`;
}
const center = this.sectors.find((sector) => this.map.distance(sector, hex) <= 2);
if (!center) {
@ -304,9 +309,9 @@ export default class SpaceMap extends Vue {
}
}
return Array.from(groups.entries()).map(([id, hexes]) => {
const centers = hexes.map((h) => hexCenter(h));
const x = (centers.reduce((sum, c) => sum + c.x, 0) / centers.length) * HEX_SPREAD;
const y = (centers.reduce((sum, c) => sum + c.y, 0) / centers.length) * HEX_SPREAD;
const centers = hexes.map((h) => this.displayedHexCenter(h));
const x = centers.reduce((sum, c) => sum + c.x, 0) / centers.length;
const y = centers.reduce((sum, c) => sum + c.y, 0) / centers.length;
return { id, x, y };
});
}
@ -477,7 +482,10 @@ export default class SpaceMap extends Vue {
const points: Point[] = [];
for (const hex of [...this.map.grid.values(), ...this.draftSlots]) {
const c = hexCenter(hex);
points.push({ x: (c.x * cos - c.y * sin) * 1.01, y: (c.x * sin + c.y * cos) * 1.01 });
const offset = "data" in hex ? deepSpaceOffset(hex as GaiaHex, this.map.grid) : { x: 0, y: 0 };
const x = c.x * HEX_SPREAD + offset.x;
const y = c.y * HEX_SPREAD + offset.y;
points.push({ x: x * cos - y * sin, y: x * sin + y * cos });
}
return points;
}

View file

@ -0,0 +1,42 @@
import Engine from "@gaia-project/engine";
import { mount } from "@vue/test-utils";
import { expect } from "chai";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { makeStore } from "../../store";
import Buildings from "./Buildings.vue";
describe("research-lab artwork", () => {
it("keeps the original art and size without an image viewport that clips its outline", () => {
const engine = new Engine(["init 2 lab-artwork", "p1 faction hadsch-hallas", "p2 faction terrans"]);
const store = makeStore();
store.commit("receiveData", engine);
const wrapper = mount(Buildings, { store });
const original = new DOMParser().parseFromString(
readFileSync(resolve(__dirname, "../../assets/buildings/research-lab.svg"), "utf8"),
"image/svg+xml"
);
const originalPath = original.querySelector("path");
const originalGradient = original.querySelector("linearGradient");
const gradient = wrapper.find("#research-lab-shading");
for (const attribute of ["x1", "y1", "x2", "y2", "gradientUnits"]) {
expect(gradient.attributes(attribute)).to.equal(originalGradient.getAttribute(attribute));
}
expect(gradient.findAll("stop").wrappers.map((stop) => stop.attributes("stop-color"))).to.deep.equal([
"#F2F2F7",
"#B6B6B6",
]);
for (const faction of ["hadsch-hallas", "terrans", "gen"]) {
const lab = wrapper.find(`#lab-${faction}`);
expect(lab.attributes("filter")).to.equal(`url(#color-${faction})`);
expect(lab.find("image, svg, clipPath").exists(), "no per-image boundary may trim the stroke").to.equal(false);
const path = lab.find("path");
for (const attribute of ["d", "stroke", "stroke-width", "stroke-miterlimit"]) {
expect(path.attributes(attribute)).to.equal(originalPath.getAttribute(attribute));
}
expect(path.attributes("fill")).to.equal("url(#research-lab-shading)");
expect(path.attributes("transform")).to.equal(`scale(${80 / 522}) translate(-255.5, -261)`);
}
wrapper.destroy();
});
});

View file

@ -1,5 +1,16 @@
<template>
<defs>
<linearGradient
id="research-lab-shading"
x1="336"
y1="149.153"
x2="39.0306"
y2="438.797"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#F2F2F7" />
<stop offset="1" stop-color="#B6B6B6" />
</linearGradient>
<template v-for="faction in factions">
<g :key="'ac-' + faction" :id="'ac-' + faction">
<image
@ -41,14 +52,17 @@
y="-55"
/>
</g>
<g :key="'rl-' + faction" :id="'lab-' + faction">
<image
xlink:href="../../assets/buildings/research-lab.svg"
:filter="faction ? `url(#color-${faction})` : ''"
width="80"
height="80"
x="-40"
y="-40"
<g :key="'rl-' + faction" :id="'lab-' + faction" :filter="faction ? `url(#color-${faction})` : ''">
<!-- Keep the original artwork as a vector, not an SVG image: its 12-unit stroke extends
beyond the 511×522 image viewport and gets cut off at small/subpixel board scales.
Match the old 80×80 image's centered "meet" scaling without a clipping viewport. -->
<path
:transform="`scale(${80 / 522}) translate(-255.5, -261)`"
d="M506 331.328C506 351.779 504.52 371.738 501.756 391.205C500.275 401.726 495.34 411.46 487.839 419.03C427.534 479.989 345.712 517.45 255.5 517.45C165.288 517.45 83.3676 479.989 23.1608 419.03C15.5609 411.263 10.6259 401.332 9.14539 390.615C6.48049 371.443 5 351.582 5 331.426C5 151.105 117.123 5.00005 255.5 5.00005C393.877 4.90173 506 151.007 506 331.328Z"
fill="url(#research-lab-shading)"
stroke="#010101"
stroke-width="12"
stroke-miterlimit="10"
/>
</g>
<g :key="'sp-' + faction" :id="'sp-' + faction">

View file

@ -37,6 +37,9 @@ export type MapMode = {
type: MapModeType;
player?: PlayerEnum;
planet?: Planet;
/** The base final-scoring shortcut explains Condition.Sector, which excludes Deep Space.
* Player-board Sectors mode leaves this unset to show all physical sector tiles instead. */
spaceSectorsOnly?: boolean;
};
export const freeActionShortcuts: { [key in FreeAction]: { shortcut: string; fast: FastConversion } } = {

View file

@ -0,0 +1,51 @@
import Engine, { classifySectorId, LostFleetSectorType } from "@gaia-project/engine";
import { lostFleetSectorKey } from "@gaia-project/engine/src/lost-fleet-map";
import { expect } from "chai";
import { displayedHexCenter, hexCenter } from "./hex";
for (const players of [2, 3, 4]) {
describe(`${players}p Deep Space visual clearance`, () => {
it("widens every regular-sector boundary with a tiny rigid tile translation, leaving other positions intact", () => {
const engine = new Engine([`init ${players} deep-space-clearance`], { lostFleet: true });
const grid = engine.map.grid;
const coordinates = [...grid.values()].map((hex) => hex.toString());
const tiles = new Map<string, { x: number; y: number }[]>();
let boundaries = 0;
for (const hex of grid.values()) {
const before = displayedHexCenter(hex);
const after = displayedHexCenter(hex, grid);
if (classifySectorId(hex.data.sector) !== LostFleetSectorType.DeepSpace) {
expect(after).to.deep.equal(before);
continue;
}
const delta = { x: after.x - before.x, y: after.y - before.y };
expect(Math.hypot(delta.x, delta.y)).to.be.closeTo(0.035, 1e-12);
const key = lostFleetSectorKey(hex);
if (!tiles.has(key)) tiles.set(key, []);
tiles.get(key).push(delta);
for (const neighbour of grid.neighbours(hex)) {
if (classifySectorId(neighbour.data.sector) !== LostFleetSectorType.Space) continue;
// Project onto the shared edge's normal: this measures edge clearance, not
// just center distance (which could increase while sliding along the edge).
const a = hexCenter(hex);
const b = hexCenter(neighbour);
expect(delta.x * (a.x - b.x) + delta.y * (a.y - b.y)).to.be.at.least(-1e-12);
const other = displayedHexCenter(neighbour, grid);
expect(Math.hypot(after.x - other.x, after.y - other.y)).to.be.greaterThan(
Math.hypot(before.x - other.x, before.y - other.y)
);
boundaries++;
}
}
expect([...grid.values()].map((hex) => hex.toString())).to.deep.equal(coordinates);
expect(boundaries).to.be.greaterThan(0);
for (const shifts of tiles.values()) {
expect(shifts).to.have.length(3);
for (const shift of shifts) {
expect(shift.x).to.be.closeTo(shifts[0].x, 1e-12);
expect(shift.y).to.be.closeTo(shifts[0].y, 1e-12);
}
}
});
});
}

View file

@ -1,4 +1,5 @@
import { classifySectorId, GaiaHex, LostFleetSectorType, Player } from "@gaia-project/engine";
import { lostFleetSectorKey } from "@gaia-project/engine/src/lost-fleet-map";
import { Direction, Grid } from "hexagrid";
import { CubeCoordinatesPartial } from "hexagrid/src/cubecoordinates";
import { factionColor, lightenDarkenColor } from "./utils";
@ -21,11 +22,36 @@ export function hexCenter(hex: CubeCoordinatesPartial, radius = 1) {
};
}
/** A tiny rigid translation of each physical Deep Space tile away from its neighbouring
* regular sectors. Derive the outward direction from the local notch, not the board origin:
* the asymmetric 3/4-player boards also have notches along their sides. */
export function deepSpaceOffset(hex: GaiaHex, grid?: Grid<GaiaHex>) {
if (!grid || classifySectorId(hex.data.sector) !== LostFleetSectorType.DeepSpace) return { x: 0, y: 0 };
const tile = [...grid.values()].filter((other) => lostFleetSectorKey(other) === lostFleetSectorKey(hex));
// Sum distinct boundary normals rather than weighting by the number of touching
// cells. The notch has opposing side walls: their normals cancel, leaving the
// opening direction (so sliding outward never narrows either side wall).
const normals = new Map<string, { x: number; y: number }>();
for (const cell of tile) {
for (const neighbour of grid.neighbours(cell)) {
if (classifySectorId(neighbour.data.sector) !== LostFleetSectorType.Space) continue;
const q = cell.q - neighbour.q;
const r = cell.r - neighbour.r;
normals.set(`${q},${r}`, hexCenter({ q, r }));
}
}
const dx = [...normals.values()].reduce((sum, p) => sum + p.x, 0);
const dy = [...normals.values()].reduce((sum, p) => sum + p.y, 0);
const length = Math.hypot(dx, dy);
return length ? { x: (dx / length) * 0.035, y: (dy / length) * 0.035 } : { x: 0, y: 0 };
}
/** Sectors are spread apart as whole tiles; their internal hex spacing stays unchanged. */
export function displayedHexCenter(hex: GaiaHex) {
export function displayedHexCenter(hex: GaiaHex, grid?: Grid<GaiaHex>) {
const point = hexCenter(hex);
if (classifySectorId(hex.data.sector) !== LostFleetSectorType.Space) {
return { x: point.x * HEX_SPREAD, y: point.y * HEX_SPREAD };
const offset = deepSpaceOffset(hex, grid);
return { x: point.x * HEX_SPREAD + offset.x, y: point.y * HEX_SPREAD + offset.y };
}
const relative = hex.relativeCoordinates;
const center = hexCenter({ q: hex.q - relative.q, r: hex.r - relative.r });
@ -52,10 +78,10 @@ function rotateRight(d: Direction, times: number): Direction {
export function playerFederationLines(grid: Grid<GaiaHex>, hex: GaiaHex, player: Player): FederationLine[] {
const directions = Direction.list().filter((d) => grid.neighbour(hex, d)?.federations?.includes(player.player));
const center = displayedHexCenter(hex);
const center = displayedHexCenter(hex, grid);
const color = lightenDarkenColor(factionColor(player.faction), 30);
const midpoint = (direction: Direction) => {
const neighbour = displayedHexCenter(grid.neighbour(hex, direction));
const neighbour = displayedHexCenter(grid.neighbour(hex, direction), grid);
return `${(neighbour.x - center.x) / 2} ${(neighbour.y - center.y) / 2}`;
};

View file

@ -0,0 +1,67 @@
import Engine, { Building, GaiaHex, Planet, PlayerEnum } from "@gaia-project/engine";
import { expect } from "chai";
import { isColonizedSector } from "./sectors";
function cell(sector: string, q = 0, r = 0): GaiaHex {
return new GaiaHex(q, r, { sector, planet: Planet.Empty });
}
describe("physical sector map highlights", () => {
it("preserves whole ordinary IDs (including alternate faces) instead of grouping by a prefix", () => {
const engine = new Engine(["init 2 visual-sectors", "p1 faction firaks", "p2 faction lantids"]);
const player = engine.players[0];
for (const id of ["1", "10", "5B", "s1", "s10", "s5B"]) {
const mine = cell(id);
mine.data.planet = Planet.Titanium;
mine.data.player = player.player;
mine.data.building = Building.Mine;
player.data.occupied = [mine];
for (const otherId of ["1", "10", "5B", "s1", "s10", "s5B"]) {
expect(isColonizedSector(cell(otherId), player), `${id} vs ${otherId}`).to.equal(id === otherId);
}
}
});
it("groups all three DS cells regardless of which contains a colony, but never groups IS", () => {
const engine = new Engine(["init 2 visual-sectors", "p1 faction firaks", "p2 faction lantids"]);
const player = engine.players[0];
const deep = [0, 1, 2].map((index) => cell(`DS11_${index}`));
for (const mine of deep) {
mine.data.planet = Planet.Asteroid;
mine.data.player = player.player;
mine.data.building = Building.Mine;
player.data.occupied = [mine];
expect(deep.every((hex) => isColonizedSector(hex, player))).to.equal(true);
expect(isColonizedSector(cell("DS12_0"), player)).to.equal(false);
}
const interspace = cell("IS1");
interspace.data.planet = Planet.Terra;
interspace.data.player = player.player;
interspace.data.building = Building.Mine;
player.data.occupied = [interspace];
expect(isColonizedSector(interspace, player)).to.equal(false);
expect(isColonizedSector(cell("IS2"), player)).to.equal(false);
});
it("includes a selected Lantids shared mine, but not a station or Gaiaformer", () => {
const engine = new Engine(["init 2 visual-sectors", "p1 faction firaks", "p2 faction lantids"]);
const [owner, lantids] = engine.players;
const shared = cell("DS11_0");
Object.assign(shared.data, {
planet: Planet.Titanium,
building: Building.Mine,
player: owner.player,
additionalMine: lantids.player,
});
owner.data.occupied = [shared];
lantids.data.occupied = [shared];
expect(isColonizedSector(cell("DS11_2"), lantids)).to.equal(true);
delete shared.data.additionalMine;
expect(isColonizedSector(cell("DS11_2"), lantids)).to.equal(false);
for (const building of [Building.GaiaFormer, Building.SpaceStation]) {
shared.data.building = building;
expect(isColonizedSector(cell("DS11_2"), owner)).to.equal(false);
}
expect(shared.data.player).to.equal(PlayerEnum.Player1);
});
});

View file

@ -0,0 +1,13 @@
import { GaiaHex, Player } from "@gaia-project/engine";
import { lostFleetSectorKey } from "@gaia-project/engine/src/lost-fleet-map";
/** Visual map mode, NOT Condition.Sector scoring: include physical Deep Space tiles as well as
* regular sectors. Interspace has no sector key. colonizedBy includes Lantids' shared mines but
* excludes Gaiaformers and Space Stations. Keep ordinary sector IDs (including variants) intact. */
export function isColonizedSector(hex: GaiaHex, player: Player): boolean {
const sector = lostFleetSectorKey(hex);
return (
sector !== undefined &&
player.data.occupied.some((other) => other.colonizedBy(player.player) && lostFleetSectorKey(other) === sector)
);
}

View file

@ -851,6 +851,133 @@ describe("settleAnalysisClone", () => {
});
});
describe("analysis booster reservations", () => {
function game() {
return new Engine([
"init 4 concurrent-charge-test",
"p1 faction terrans",
"p2 faction nevlas",
"p3 faction firaks",
"p4 faction hadsch-hallas",
"p1 build m 8A2",
"p2 build m 8B1",
"p3 build m 8B3",
"p4 build m 7B5",
"p4 build m 1A2",
"p3 build m 7A4",
"p2 build m 5A2",
"p1 build m 4A4",
"p4 booster booster2",
"p3 booster booster4",
"p2 booster booster5",
"p1 booster booster6",
"hadsch-hallas income 2t",
"terrans pass booster9",
"nevlas pass booster8",
]);
}
function preview(real: Engine, seat: number) {
const engine = markAnalysisSeat(Engine.fromData(JSON.parse(JSON.stringify(real))), seat);
advancePastOwnPass(engine, seat);
settleAnalysisClone(engine, seat);
return engine;
}
function passBoosters(engine: Engine, seat: number) {
return engine.findAvailableCommand(seat, Command.Pass).data.boosters;
}
for (const seat of [2, 3]) {
it(`keeps already-passed opponents' next boosters out of the pass menu ${seat === 2 ? "on turn" : "off turn"}`, () => {
const real = game();
const original = JSON.stringify(real);
expect(real.playerToMove).to.equal(2);
expect(real.passedPlayers).to.deep.equal([0, 1]);
const origin = preview(real, seat);
const { engine, applied, blockedReason } = replayAnalysisLine(
origin,
[{ kind: "move", move: `${real.players[seat].faction} up nav.` }],
seat
);
expect(applied).to.equal(1);
expect(blockedReason).to.equal(undefined);
expect(engine.turnOrder).to.deep.equal([seat]);
expect(engine.round).to.equal(1);
expect(passBoosters(engine, seat)).to.have.members(
Object.keys(real.tiles.boosters).filter(
(booster) => !["booster8", "booster9", real.players[seat].data.tiles.booster].includes(booster)
)
);
// Still assume a not-yet-passed opponent can return their old booster before our pass.
expect(passBoosters(engine, seat)).to.include(seat === 2 ? "booster2" : "booster4");
expect(passBoosters(engine, seat)).to.include("booster6"); // actually returned by Terrans
expect(passBoosters(engine, seat)).to.include("booster5"); // actually returned by Nevlas
expect(JSON.stringify(real)).to.equal(original);
});
}
it("rejects a reserved selection during replay without mutating the real game, origin or saved line", () => {
const real = game();
const origin = preview(real, 2);
const original = JSON.stringify(real);
const base = JSON.stringify(origin);
const entries: AnalysisEntry[] = [
{ kind: "move", move: "firaks up nav." },
{ kind: "move", move: "firaks pass booster8" },
];
const saved = JSON.stringify(entries);
const result = replayAnalysisLine(origin, entries, 2);
expect(result.applied).to.equal(1);
expect(result.blockedReason).to.contain("booster8 is not in the available boosters");
expect(result.engine.round).to.equal(1);
expect(result.engine.players[2].data.tiles.booster).to.equal("booster4");
expect(JSON.stringify(real)).to.equal(original);
expect(JSON.stringify(origin)).to.equal(base);
expect(JSON.stringify(entries)).to.equal(saved);
});
it("expires reservations at the round boundary, keeps solo flow, and returns our old booster", () => {
const real = game();
const original = JSON.stringify(real);
const origin = preview(real, 2);
const first = replayAnalysisLine(origin, [{ kind: "move", move: "firaks pass booster5" }], 2);
expect(first.blockedReason).to.equal(undefined);
expect(first.applied).to.equal(1);
expect(first.engine.round).to.equal(2);
expect(first.engine.turnOrder).to.deep.equal([2]);
expect(first.engine.passedPlayers).to.deep.equal([]);
expect(first.engine.playerToMove).to.equal(2);
expect(passBoosters(first.engine, 2)).to.include.members(["booster8", "booster9", "booster4"]);
expect(passBoosters(first.engine, 2)).to.not.include("booster5");
// The choice now targets round 3, not the round 2 those real opponents reserved.
const later = replayAnalysisLine(first.engine, [{ kind: "move", move: "firaks pass booster8" }], 2);
expect(later.blockedReason).to.equal(undefined);
expect(later.applied).to.equal(1);
expect(later.engine.round).to.equal(3);
expect(later.engine.turnOrder).to.deep.equal([2]);
expect(passBoosters(later.engine, 2)).to.include.members(["booster5", "booster9"]);
expect(passBoosters(later.engine, 2)).to.not.include("booster8");
expect(JSON.stringify(real)).to.equal(original);
});
it("does not extend already-passed opponents' reservations after entering with our own seat passed", () => {
const real = game();
real.move("firaks pass booster5");
const original = JSON.stringify(real);
expect(real.passedPlayers).to.deep.equal([0, 1, 2]);
const engine = preview(real, 2);
expect(engine.round).to.equal(2);
expect(engine.turnOrder).to.deep.equal([2]);
expect(engine.playerToMove).to.equal(2);
expect(engine.players[2].data.tiles.booster).to.equal("booster5");
expect(passBoosters(engine, 2)).to.include.members(["booster8", "booster9", "booster4", "booster2"]);
expect(passBoosters(engine, 2)).to.not.include("booster5");
expect(JSON.stringify(real)).to.equal(original);
});
});
describe("markAnalysisSeat", () => {
it("sets the analysis flag on the given seat's player data", () => {
const engine = new Engine(SETUP_MOVES);

View file

@ -370,14 +370,13 @@ export function clearAnalysisLine(seat: number, scope?: string): void {
* `[seat, seat]` the moment it happens.
* 2. If `engine` is already sitting in `Phase.RoundMove` (entry landed mid-round, or the setup ->
* round 1 transition above already ran), `turnOrder` is still the real multiplayer list for the
* round in progress - shrink it directly, and reset `passedPlayers` to a fresh `[]` so this
* seat's own future pass accumulates cleanly (mirrors what `beginRoundStartPhase` itself already
* does at every ordinary round boundary).
* round in progress - shrink it directly. Keep opponents in `passedPlayers`: their new boosters
* are already reserved for the next round, unlike old boosters held by opponents still playing.
* Remove only this seat so its own future pass accumulates once.
*
* Either way, the loop is self-sustaining from here: `beginRoundStartPhase`'s
* `turnOrder = passedPlayers` at every later boundary reads back exactly `[seat]`, since only this
* seat ever passes again - this function only ever needs to run once (from `enterAnalysisMode`),
* never on every replay step.
* At the next boundary `beginRoundStartPhase` selects only the analysis seat from `passedPlayers`
* for the new turn order, then clears that accumulator normally. This expires the reservations at
* exactly the right round and keeps future rounds solo without extra state to persist or reanchor.
*
* Deliberately does NOT touch `engine.setup` (the array backing the `turnOrderAfterSetupAuction`
* getter, which has no setter - the fallback above can only be steered via `passedPlayers`).
@ -397,7 +396,7 @@ export function applySoloRoundFlow(engine: Engine, seat: number): void {
return;
}
engine.turnOrder = [seat];
engine.passedPlayers = [];
engine.passedPlayers = engine.passedPlayers.filter((passed) => passed !== seat);
engine.currentPlayer = seat;
engine.tempCurrentPlayer = undefined;
engine.clearAvailableCommands();
@ -412,11 +411,11 @@ export function applySoloRoundFlow(engine: Engine, seat: number): void {
*
* So roll the clone forward instead: every opponent still in `turnOrder` passes, through real engine
* code, which runs the ordinary end-of-round machinery (scoring, income, Gaia) and lands in the next
* round with `beginRoundStartPhase` reading `turnOrder = passedPlayers` - i.e. this seat, alone,
* exactly as the solo flow wants it. Opponents pass rather than being auto-played, because the
* sandbox's premise is that they never take a turn; their booster is handed straight back for the
* same reason `resolveOpponentDecisions` hands back the round-0 one (the pool must show every tile
* free except the one the sandbox seat itself holds).
* round with `beginRoundStartPhase` selecting only the analysis seat for the next turn order.
* Opponents pass rather than being auto-played, because the sandbox's premise is that they never
* take a turn; their fictitious booster pick is handed straight back. Real earlier picks remain
* on their boards, but the round boundary expires those reservations too: our next pass will
* choose a booster for the round AFTER the one they already reserved.
*
* Returns whether the clone actually moved to a later round - `Game.vue` blocks Commit on that, since
* a line played in round N+1 describes moves the real game, still sitting in round N, cannot accept.