feat(viewer): restore old UI with Lost Fleet support

This commit is contained in:
coyotte508 2026-09-11 15:33:28 +02:00
commit 3644919458
45 changed files with 1455 additions and 1419 deletions

View file

@ -4,12 +4,18 @@ on:
paths:
- ".github/workflows/viewer-test.yml"
- "viewer/**"
- "old-ui/**"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
branches:
- master
pull_request:
paths:
- ".github/workflows/viewer-test.yml"
- "viewer/**"
- "old-ui/**"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
defaults:
run:
@ -31,3 +37,7 @@ jobs:
env:
NODE_OPTIONS: --max-old-space-size=12288
- run: pnpm build
- run: pnpm --dir ../old-ui test
env:
NODE_OPTIONS: --max-old-space-size=12288
- run: pnpm --dir ../old-ui package

View file

@ -1,15 +1,24 @@
# gaia-viewer
# Gaia Project old UI
A Vue.js / SVG UI for Gaia Project
The original map, text-based research board and player-card arrangement run on
Vue 2.7 and Vite. The game controller, engine, action controls, chat and journal
are shared with `viewer`; this package has its own renderer and build.
**OLD UI — ARCHIVED**
Lost Fleet adds loose map tiles and spaceships, the scoring extension, ship actions,
ship technology/federation tiles, artifacts, and updated faction boards and abilities.
This package is no longer part of the pnpm workspace and is no longer built or
tested in CI. It is kept in the repository for reference only. The active UI is
[`viewer`](../viewer). Its legacy toolchain (`@vue/cli-service` 4 +
`fork-ts-checker-webpack-plugin` 1.6) is incompatible with the current
dependency versions.
From the repository root:
## Demo
```sh
pnpm install
pnpm --dir old-ui serve # http://localhost:5193/
pnpm --dir old-ui test
pnpm --dir old-ui package
```
Check out [boardgamers.space](https://www.boardgamers.space)!
Use `?lostFleet=1` for expansion setup or `?scenario=lost-fleet-overview` for a
playable test position. The local test tools also load the other expansion positions.
For BGS, publish `dist/package/old-ui.umd.js` and `old-ui.css` as the alternate
viewer. Its API is `gaiaViewer.launch`, with the same events as the normal viewer.
Vue and BootstrapVue remain supplied by the host; game assets and sounds are bundled.

12
old-ui/index.html Normal file
View file

@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Gaia Project · Old UI</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

View file

@ -1,63 +1,52 @@
{
"name": "@gaia-project/old-ui",
"version": "1.0.1",
"version": "1.0.2",
"scripts": {
"serve": "vue-cli-service serve --port 8080",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"package": "vue-cli-service build --target lib src/wrapper.ts",
"prepublishOnly": "npm run package",
"test": "vue-cli-service lint"
"serve": "vite --port 5193",
"build": "vite build",
"package": "vite build",
"test": "vitest run",
"prepublishOnly": "npm run package"
},
"repository": "git@github.com:boardgamers/gaia-project.git",
"publishConfig": {
"access": "public"
},
"unpkg": "dist/package/old-ui.umd.min.js",
"unpkg": "dist/package/old-ui.umd.js",
"files": [
"index.ts",
"tsconfig.json",
"src",
"README.md",
"public",
"dist/package/old-ui.umd.min.js",
"dist/package/old-ui.umd.js",
"dist/package/old-ui.css"
],
"dependencies": {
"@gaia-project/engine": "workspace:../engine",
"bootstrap": "^4.4.1",
"bootstrap-vue": "^2.12.0",
"vue": "^2.6.11",
"vuex": "^3.0.1"
"events": "^3.3.0",
"hexagrid": "^2.1.1",
"lodash": "^4.17.15",
"vue": "^2.7.16",
"vuex": "^3.0.1",
"@gaia-project/viewer": "workspace:../viewer"
},
"devDependencies": {
"@types/jquery": "^3.3.1",
"@types/node": "^10.5.2",
"@typescript-eslint/eslint-plugin": "^2.26.0",
"@typescript-eslint/parser": "^2.26.0",
"@vue/cli-plugin-eslint": "~4.5.13",
"@vue/cli-plugin-typescript": "~4.2.3",
"@vue/cli-service": "~4.2.3",
"@vue/eslint-config-standard": "^5.1.2",
"@vue/eslint-config-typescript": "^5.0.2",
"eslint": "^7.26.0",
"eslint-plugin-import": "^2.23.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-vue": "^7.9.0",
"hexagrid": "^2.0.1",
"popper.js": "^1.16.1",
"@testing-library/vue": "^5.9.0",
"@vitejs/plugin-vue2": "^2.3.4",
"@vue/test-utils": "^1.1.3",
"chai": "^4.3.0",
"jsdom": "^30.0.1",
"sass": "^1.32.8",
"sass-loader": "^8.0.2",
"typescript": "^4.2.4",
"typescript": "^3.8.3",
"vite": "^8.2.2",
"vitest": "^4.1.11",
"vue-class-component": "^7.2.6",
"vue-property-decorator": "^9.1.2",
"vue-template-compiler": "^2.6.11",
"webpack": "^4.16.1"
"vue-template-compiler": "^2.7.16"
},
"peerDependencies": {
"bootstrap-vue": "^2.12.0",
"vue": "^2.6.11"
"vue": "^2.7.16"
},
"browserslist": [
"> 1%",

View file

@ -0,0 +1,265 @@
import Engine, { Building, Command, Faction, Phase, Planet, PlayerEnum } from "@gaia-project/engine";
import { fireEvent } from "@testing-library/vue";
import BootstrapVue from "bootstrap-vue";
import { expect } from "chai";
import Vue from "vue";
import { makeStore } from "../../viewer/src/store";
import Game from "./components/Game.vue";
import ResearchTile from "./components/ResearchTile.vue";
import TechTile from "./components/TechTile.vue";
Vue.use(BootstrapVue);
describe("old UI move compatibility", () => {
it("sends current controller commands from the old technology and research tiles", () => {
const store = makeStore();
store.state.context.highlighted.techs.add("terra" as any);
store.state.context.highlighted.researchTiles.add("terra-1");
const dispatch = vi.spyOn(store, "dispatch").mockResolvedValue(undefined);
const tech = new TechTile({ store, propsData: { pos: "terra" } });
const research = new ResearchTile({ store, propsData: { field: "terra", level: 1 } });
try {
tech.onClick();
research.onClick();
expect(dispatch.mock.calls).to.deep.equal([
["techClick", { command: "terra" }],
["researchClick", { command: "terra" }],
]);
} finally {
tech.$destroy();
research.$destroy();
dispatch.mockRestore();
}
});
function createMoweydsPiUpgradeState(withLeech = false) {
const persisted = new Engine(["init 2 lf-moweyds-pi-endturn"], { lostFleet: true });
persisted.players.forEach((pl, index) => {
pl.faction = [Faction.Moweyds, Faction.Terrans][index];
pl.loadFaction(null, persisted.expansions);
pl.data.victoryPoints = 30;
pl.data.qics = 10;
pl.data.credits = 20;
pl.data.knowledge = 10;
pl.data.ores = 10;
});
persisted.phase = Phase.RoundMove;
persisted.round = 3;
persisted.turnOrder = persisted.players.map((pl) => pl.player);
persisted.currentPlayer = PlayerEnum.Player1;
const hex = [...persisted.map.grid.values()].find(
(space) =>
space.hasPlanet() &&
space.data.planet !== Planet.Transdim &&
space.data.planet !== Planet.Gaia &&
space.data.spaceship === undefined &&
!space.occupied()
);
expect(hex, "expected an available Trading Station location").to.not.equal(undefined);
hex!.data.player = PlayerEnum.Player1;
hex!.data.building = Building.TradingStation;
persisted.player(PlayerEnum.Player1).data.occupied.push(hex!);
persisted.player(PlayerEnum.Player1).data.buildings[Building.TradingStation] = 1;
persisted.clearAvailableCommands();
persisted.generateAvailableCommands();
const build = persisted.findAvailableCommand(PlayerEnum.Player1, Command.Build);
const upgrade = build?.data.buildings.find((entry) => entry.building === Building.PlanetaryInstitute);
expect(upgrade, "expected a Planetary Institute upgrade").to.not.equal(undefined);
if (withLeech) {
const upgradeHex = persisted.map.getS(upgrade!.coordinates);
const leechHex = [...persisted.map.grid.values()].find(
(space) =>
space !== upgradeHex &&
space.hasPlanet() &&
space.data.planet !== Planet.Transdim &&
space.data.planet !== Planet.Gaia &&
space.data.spaceship === undefined &&
!space.occupied() &&
persisted.map.distance(upgradeHex, space) <= 2
);
expect(leechHex, "expected an adjacent opponent mine for leeching").to.not.equal(undefined);
leechHex!.data.player = PlayerEnum.Player2;
leechHex!.data.building = Building.Mine;
persisted.player(PlayerEnum.Player2).data.occupied.push(leechHex!);
persisted.player(PlayerEnum.Player2).data.buildings[Building.Mine] = 1;
}
const partial = Engine.fromData(JSON.parse(JSON.stringify(persisted)));
partial.move(`moweyds build PI ${upgrade!.coordinates}`);
partial.generateAvailableCommandsIfNeeded();
return { persisted, partial, coordinates: upgrade!.coordinates };
}
it("keeps the raw partial move after Tinkeroids income selection", () => {
const base = new Engine(
[
"init 2 lf-freeze-28",
"p1 faction tinkeroids",
"p2 faction terrans",
"terrans build m 3A11",
"terrans build m 4A6",
"tinkeroids build PI IS1",
"terrans booster booster10",
"tinkeroids booster booster2",
],
{ lostFleet: true }
);
const partial = Engine.fromData(JSON.parse(JSON.stringify(base)));
partial.move("tinkeroids chooseTinkeringTile tinkering-power4. income t");
partial.generateAvailableCommandsIfNeeded();
const restored = Engine.fromData(JSON.parse(JSON.stringify(partial)));
const store = makeStore();
const vm = new (Vue.extend(Game as any))({ store }) as any;
vm.handleData(restored);
expect(vm.currentMove).to.equal("tinkeroids chooseTinkeringTile tinkering-power4. income t");
expect(vm.currentMove).to.not.contain("⇒");
expect(store.state.data.moveHistory[store.state.data.moveHistory.length - 1]).to.equal(
"tinkeroids booster booster2"
);
vm.$destroy();
});
it("keeps the remaining setup-income choices clickable after Tinkeroids picks the first 4 power income", async () => {
let persisted = new Engine(
[
"init 2 lf-freeze-28",
"p1 faction tinkeroids",
"p2 faction terrans",
"terrans build m 3A11",
"terrans build m 4A6",
"tinkeroids build PI IS1",
"terrans booster booster10",
"tinkeroids booster booster9",
],
{ lostFleet: true }
);
persisted.generateAvailableCommandsIfNeeded();
const store = makeStore();
const vm = new (Vue.extend(Game as any))({ store }) as any;
vm.$mount();
document.body.appendChild(vm.$el);
const unsub = store.subscribeAction(({ type, payload }) => {
if (type !== "move") {
return;
}
const copy = Engine.fromData(JSON.parse(JSON.stringify(persisted)));
copy.move(payload as string);
copy.generateAvailableCommandsIfNeeded();
if (copy.newTurn) {
persisted = copy;
}
vm.handleData(Engine.fromData(JSON.parse(JSON.stringify(copy))));
});
const buttons = () =>
Array.from(vm.$el.querySelectorAll<HTMLButtonElement>("#move-buttons button.move-button")).filter(
(button) => !button.classList.contains("d-none")
);
const labels = () => buttons().map((button) => button.textContent?.trim() ?? "");
const buttonWithText = (text: string, occurrence = 0) =>
buttons().filter((button) => button.textContent?.includes(text))[occurrence] ?? null;
vm.handleData(Engine.fromData(JSON.parse(JSON.stringify(persisted))));
await Vue.nextTick();
await fireEvent.click(buttonWithText("Choose Tinkering Tile")!);
await Vue.nextTick();
await fireEvent.click(buttonWithText("Charge 4 Power")!);
await Vue.nextTick();
expect(labels().filter((label) => label.includes("Income 4pw"))).to.have.length(2);
expect(labels()).to.include("1: Income t");
await fireEvent.click(buttonWithText("Income 4pw")!);
await Vue.nextTick();
expect(labels().filter((label) => label.includes("Income 4pw"))).to.have.length(1);
expect(labels()).to.include("1: Income t");
expect(vm.currentMove).to.equal("tinkeroids chooseTinkeringTile tinkering-power4. income 4pw");
await fireEvent.click(buttonWithText("Income 4pw")!);
await Vue.nextTick();
expect(vm.currentMove).to.equal("");
expect(store.state.data.availableCommands.map((command) => command.name)).to.include.members(["build", "explore"]);
expect(labels().length).to.be.greaterThan(0);
expect(labels().some((label) => label.includes("Income"))).to.equal(false);
unsub();
vm.$el.remove();
vm.$destroy();
});
it("replays Moweyds' PI upgrade cleanly when confirming End Turn in self-contained mode", async () => {
const moweydsState = createMoweydsPiUpgradeState();
let { persisted } = moweydsState;
const { partial, coordinates } = moweydsState;
const store = makeStore();
const vm = new (Vue.extend(Game as any))({ store }) as any;
vm.$mount();
document.body.appendChild(vm.$el);
const unsub = store.subscribeAction(({ type, payload }) => {
if (type !== "move") {
return;
}
const copy = Engine.fromData(JSON.parse(JSON.stringify(persisted)));
copy.move(payload as string);
copy.generateAvailableCommandsIfNeeded();
if (copy.newTurn) {
persisted = copy;
}
vm.handleData(Engine.fromData(JSON.parse(JSON.stringify(copy))));
});
const buttons = () =>
Array.from(vm.$el.querySelectorAll<HTMLButtonElement>("#move-buttons button.move-button")).filter(
(button) => !button.classList.contains("d-none")
);
const buttonWithText = (text: string, occurrence = 0) =>
buttons().filter((button) => button.textContent?.includes(text))[occurrence] ?? null;
vm.handleData(Engine.fromData(JSON.parse(JSON.stringify(partial))));
await Vue.nextTick();
expect(vm.currentMove).to.equal(`moweyds build PI ${coordinates}`);
expect(buttonWithText("End Turn")).to.not.equal(null);
await fireEvent.click(buttonWithText("End Turn")!);
await Vue.nextTick();
await fireEvent.click(buttonWithText("Confirm End Turn")!);
await Vue.nextTick();
expect(vm.currentMove).to.equal("");
expect(store.state.data.currentPlayer).to.equal(PlayerEnum.Player2);
expect(store.state.data.map.getS(coordinates).data.building).to.equal(Building.PlanetaryInstitute);
unsub();
vm.$el.remove();
vm.$destroy();
});
});

View file

@ -0,0 +1,40 @@
<template>
<span class="old-artifact" v-b-tooltip :title="tooltip">{{ notation }}</span>
</template>
<script lang="ts">
import { ArtifactToken } from "@gaia-project/engine";
import { Component } from "vue-property-decorator";
import CurrentArtifact from "../../../viewer/src/components/ArtifactIcon.vue";
@Component
export default class ArtifactIcon extends CurrentArtifact {
get notation(): string {
return {
[ArtifactToken.KnowledgeOre]: "+k,o",
[ArtifactToken.Credit]: "3c,3o",
[ArtifactToken.KnowledgeQic]: "3k,q",
[ArtifactToken.CreditLarge]: "5c,2o",
[ArtifactToken.Power]: "+2ta3",
[ArtifactToken.Asteroid]: "asteroid: 7vp",
[ArtifactToken.Protoplanet]: "protoplanet: 7vp",
[ArtifactToken.ResearchLevel]: "sci > 3vp",
[ArtifactToken.ResearchTracks]: "tracks ≥3 > 3vp",
[ArtifactToken.Federation]: ">fed",
[ArtifactToken.GaiaProject]: "gaia > 3vp",
[ArtifactToken.PlanetTypes]: "3vp,pt > vp",
[ArtifactToken.DeepSpace]: "ds > 3vp",
}[this.artifact];
}
}
</script>
<style scoped>
.old-artifact {
display: inline-block;
max-width: 150px;
border: 1px solid #444;
padding: 4px;
background: #fff;
color: #212529;
font-size: 11px;
line-height: 1.3;
}
</style>

View file

@ -1,5 +1,5 @@
<template>
<g :class="['boardAction', kind, { highlighted, faded }]" v-b-tooltip :title="tooltip">
<g :transform="transform" :class="['old-board-action', kind, { highlighted, faded }]" v-b-tooltip :title="tooltip">
<polygon
points="-1,0.5 -0.5,1 0.5,1 1,0.5 1,-0.5 0.5,-1 -0.5,-1 -1,-0.5"
:transform="`scale(${scale})`"
@ -19,17 +19,22 @@
</template>
<script lang="ts">
import { BoardAction as BoardActionEnum, boardActions, Event } from "@gaia-project/engine";
import Vue from "vue";
import { boardActions, Event } from "@gaia-project/engine";
import { Component, Prop } from "vue-property-decorator";
import { eventDesc } from "../data/event";
import CurrentBoardAction from "../../../viewer/src/components/BoardAction.vue";
import { eventDesc } from "../../../viewer/src/data/event";
@Component<BoardAction>({
computed: {
tooltip() {
const costDesc = "Spend " + this.cost + "\n";
return costDesc + boardActions[this.action].income.map((x) => eventDesc(new Event(x))).join("\n");
return (
costDesc +
boardActions[this.action].income
.map((x) => eventDesc(new Event(x), this.$store.state.data.expansions, true))
.join("\n")
);
},
faded() {
@ -56,29 +61,15 @@ import { eventDesc } from "../data/event";
},
},
})
export default class BoardAction extends Vue {
export default class BoardAction extends CurrentBoardAction {
@Prop()
scale: number;
@Prop()
action: BoardActionEnum;
onClick() {
if (!this.highlighted) {
return;
}
this.$store.dispatch("actionClick", this.action);
}
get highlighted() {
return this.$store.state.context.highlighted.actions.has(this.action);
}
}
</script>
<style lang="scss">
g {
&.boardAction {
&.old-board-action {
polygon {
stroke: #333;
stroke-width: 0.02;

View file

@ -1,72 +1,43 @@
<template>
<svg
:class="['booster', { highlighted, disabled }]"
:class="['old-booster', { highlighted, disabled }]"
v-b-tooltip
:title="tooltip"
@click="onClick"
width="76"
:width="tileWidth"
height="50"
viewBox="0 0 76 50"
:viewBox="`0 0 ${tileWidth} 50`"
>
<rect x="1" y="1" width="74" height="48" rx="5" ry="5" />
<rect x="1" y="1" :width="tileWidth - 2" height="48" rx="5" ry="5" />
<text class="title" x="6" y="12">{{ title }}</text>
<text class="event1" x="6" y="30">{{ event1 }}</text>
<text class="event1" x="6" y="44">{{ event2 }}</text>
<text class="event1" x="6" y="30">{{ event1 && event1.toString() }}</text>
<text class="event1" x="6" y="44">{{ event2 && event2.toString() }}</text>
</svg>
</template>
<script lang="ts">
import { Event } from "@gaia-project/engine";
import { boosterEvents } from "@gaia-project/engine/src/tiles/boosters";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { eventDesc } from "../data/event";
@Component<Booster>({
computed: {
tileObject() {
return boosterEvents(this.booster).map((e) => e.spec);
},
event1() {
return this.tileObject[0];
},
event2() {
return this.tileObject[1];
},
title() {
return this.booster;
},
tooltip() {
return `- ${eventDesc(new Event(this.event1))}\n- ${eventDesc(new Event(this.event2))}`;
},
},
})
export default class Booster extends Vue {
@Prop()
booster: Booster;
@Prop()
disabled: boolean;
onClick() {
if (this.highlighted) {
this.$store.dispatch("boosterClick", this.booster);
}
import { Component } from "vue-property-decorator";
import CurrentBooster from "../../../viewer/src/components/Booster.vue";
@Component
export default class Booster extends CurrentBooster {
get title() {
return this.booster.replace("booster-lostfleet-", "LF ").replace("booster", "Booster ");
}
get highlighted() {
return this.$store.state.context.highlighted.boosters.has(this.booster);
get tileWidth() {
return Math.max(
76,
...[this.title, this.event1?.toString() ?? "", this.event2?.toString() ?? ""].map((text) => text.length * 6 + 12)
);
}
onClick() {
this.$emit("click");
}
}
</script>
<style lang="scss">
svg {
&.booster {
&.old-booster {
rect {
stroke: #333;
stroke-width: 1px;
@ -75,6 +46,8 @@ svg {
.title {
font-size: 10px;
font-weight: bold;
text-anchor: start;
fill: #212529;
pointer-events: none;
}
.event1,

View file

@ -1,5 +1,5 @@
<template>
<g :class="['building', 'planet-fill', planet]">
<g :class="['old-building', 'planet-fill', planet]">
<rect v-if="mine" x="-0.2" y="-0.2" width="0.4" height="0.4" />
<rect v-else-if="planetaryInstitute" x="-0.375" y="-0.375" width="0.75" height="0.75" />
<polygon v-else-if="gaiaFormer" :points="hexCorners" />
@ -15,9 +15,10 @@
</template>
<script lang="ts">
import { Building as BuildingEnum, Faction, Planet, factionPlanet } from "@gaia-project/engine";
import { Building as BuildingEnum, Faction, Planet } from "@gaia-project/engine";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { planetClass } from "../../../viewer/src/graphics/utils";
import { corners } from "../graphics/hex";
import Token from "./Token.vue";
@ -34,7 +35,7 @@ export default class Building extends Vue {
building: BuildingEnum;
get planet() {
return (this.faction as any) === "wild" ? Planet.Transdim : factionPlanet(this.faction);
return (this.faction as any) === "wild" ? Planet.Transdim : planetClass(this.faction);
}
get hexCorners() {
@ -79,7 +80,7 @@ export default class Building extends Vue {
<style lang="scss">
svg {
.building {
.old-building {
stroke-width: 0.1;
pointer-events: none;
stroke: #111;

View file

@ -1,6 +1,6 @@
<template>
<svg viewBox="-25 -25 50 50" width="50" height="50">
<g :class="['federationTile', { highlighted, disabled }]">
<svg v-b-tooltip :title="tooltip" viewBox="-25 -25 50 50" width="50" height="50">
<g :class="['old-federation-tile', { highlighted, disabled }]">
<polygon
points="-1,0.5 -0.5,1 0.5,1 1,0.5 1,-0.7 0.5,-1 -0.5,-1 -1,-0.7"
transform="scale(24)"
@ -20,49 +20,23 @@
</template>
<script lang="ts">
import { Federation as FederationEnum } from "@gaia-project/engine";
import { federationRewards } from "@gaia-project/engine/src/tiles/federations";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
@Component<FederationTile>({
computed: {
income() {
const [first, ...others] = federationRewards(this.federation).map((r) => r.toString());
return others.length > 0 ? [first, others.join(", ")] : first.split("-");
},
disabled() {
return this.used || this.federation === FederationEnum.Fed1;
},
},
})
export default class FederationTile extends Vue {
@Prop()
federation: FederationEnum;
@Prop()
used: boolean;
@Prop()
numTiles: number;
onClick() {
if (!this.highlighted) {
return;
}
this.$store.dispatch("federationClick", this.federation);
import { Component } from "vue-property-decorator";
import CurrentFederationTile from "../../../viewer/src/components/FederationTile.vue";
@Component
export default class FederationTile extends CurrentFederationTile {
get income() {
return this.rewards.map((r) => r.toString());
}
get highlighted() {
return this.$store.state.context.highlighted.federations.has(this.federation);
return false;
}
onClick() {}
}
</script>
<style lang="scss">
g {
&.federationTile {
&.old-federation-tile {
polygon {
stroke: #333;
stroke-width: 0.02;

View file

@ -1,5 +1,5 @@
<template>
<g :class="['finalScoringTile', { highlighted }]" v-b-tooltip :title="tooltip">
<g :class="['old-final-scoring-tile', { highlighted }]" v-b-tooltip :title="tooltip">
<rect x="1" y="1" width="75" height="55" />
<text class="title" x="5" y="12">{{ content }}</text>
<Token
@ -24,7 +24,7 @@
import { Faction, Phase, Player, finalScorings } from "@gaia-project/engine";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { factionName } from "../data/factions";
import { factionName } from "../../../viewer/src/data/factions";
import Token from "./Token.vue";
@Component<FinalScoringTile>({
@ -91,7 +91,7 @@ export default class FinalScoringTile extends Vue {
<style lang="scss">
g {
&.finalScoringTile {
&.old-final-scoring-tile {
rect {
stroke: #333;
stroke-width: 1px;
@ -100,6 +100,8 @@ g {
.title {
font-size: 10px;
font-weight: bold;
text-anchor: start;
fill: #212529;
pointer-events: none;
}
.score {

View file

@ -0,0 +1,33 @@
<template>
<g v-if="isLostFleet" :transform="`translate(${fields.length * 60}, 0)`">
<g v-if="hasScoringExtension" v-b-tooltip :title="extensionTooltip">
<rect x="1" y="2" width="75" height="42" fill="white" stroke="#333" />
<text x="5" y="17" fill="#212529">Requirement</text>
<text x="5" y="33" fill="#212529">{{ gateOnShips ? "3 ships" : "25 VP" }}</text>
<TechTile pos="adv-ext" x="1" y="53" width="75" height="48" />
</g>
<ScoringTile
v-for="i in scorings"
:round="i"
:key="i"
:transform="`translate(0, ${scoringTileY(i)}) scale(0.82)`"
/>
<g v-if="hasFinalScoring" :transform="`translate(0, ${finalScoringY}) scale(0.82)`">
<FinalScoringTile
v-for="i in finalScoringCount"
:index="i - 1"
:key="i"
:transform="`translate(0, ${(i - 1) * 74})`"
/>
</g>
</g>
</template>
<script lang="ts">
import { Component } from "vue-property-decorator";
import CurrentResearchBoard from "../../../viewer/src/components/ResearchBoard.vue";
import FinalScoringTile from "./FinalScoringTile.vue";
import ScoringTile from "./ScoringTile.vue";
import TechTile from "./TechTile.vue";
@Component({ components: { TechTile, ScoringTile, FinalScoringTile } })
export default class FleetScoringColumn extends CurrentResearchBoard {}
</script>

View file

@ -1,287 +1,273 @@
<template>
<div
:class="{
['no-faction-fill']: $store.state.preferences && $store.state.preferences.noFactionFill,
}"
>
<div
:class="['row', 'no-gutters', 'justify-content-center', engine.players.length > 2 ? 'medium-map' : 'small-map']"
v-if="hasMap"
>
<SpaceMap :class="['mb-1', 'space-map']" />
<svg class="scoring-research-board" :viewBox="`0 0 ${scoringX + 90} 450`">
<ResearchBoard :height="450" ref="researchBoard" />
<ScoringBoard class="ml-4" height="450" width="90" :x="scoringX" />
</svg>
</div>
<div class="row mt-2">
<TurnOrder v-if="!ended && engine.players.length > 0" class="col-md-4 order-4 order-md-1" />
<div class="col-md-8 order-1 order-md-2">
<Commands @command="handleCommand" @undo="undoMove" v-if="canPlay" />
</div>
<template v-if="sessionPlayer === undefined">
<PlayerInfo v-for="player in orderedPlayers" :player="player" :key="player.player" class="col-md-6 order-6" />
</template>
<template v-else>
<PlayerInfo :player="sessionPlayer" class="col-md-6 order-3" />
<PlayerInfo
v-for="player in orderedPlayers.filter((pl) => pl !== sessionPlayer)"
:player="player"
:key="player.player"
class="col-md-6 order-6"
<div :class="[...classes, 'old-ui-game']" id="root">
<b-modal id="chart-button" title="Victory Points, Resources, and more" size="xl">
<Charts />
</b-modal>
<Rules id="rules" />
<div v-if="analysisNotice || analysisPendingRestore" class="row">
<div class="col-12">
<AnalysisPanel
:active="analysisMode"
:notice="analysisNotice"
:pending-restore="analysisPendingRestore"
@dismiss-notice="dismissAnalysisNotice"
@restore="restoreAnalysisLine"
@discard-restore="discardPendingAnalysisLine"
/>
</template>
<Pool class="col-12 order-10 mt-4" />
<AdvancedLog class="col-12 order-last mt-4" />
</div>
</div>
<template v-if="uiMode === 'graphical'">
<div class="row" v-if="!ended">
<div class="col-12">
<SilentAuctionSummary />
<PreferenceSplitSummary />
<SetupStatus />
<PreferenceSplitBid @command="handleCommand" />
<SilentAuctionBid @command="handleCommand" />
<Commands
v-if="setupActionsAtTop && canPlay"
@command="handleCommand"
:currentMove="currentMove"
:hide-spacer="true"
:analysis-mode="analysisMode"
:analysis-status="analysisStatus"
:analysis-move-count="analysisAppliedEntries.length"
:analysis-committable-moves="analysisCommittableMoves.length"
:analysis-commit-plan="analysisCommitPlan"
:analysis-faction-choices="analysisFactionChoices"
:analysis-line-summaries="analysisLineSummaries"
:analysis-active-line="analysisActiveLine"
@analysis-seed-faction="seedAnalysisFaction"
@analysis-commit="commitAnalysisLine"
@analysis-charge="chargeAnalysisPower"
@analysis-undo-charge="undoAnalysisCharge"
@analysis-select-line="selectAnalysisLine"
@analysis-add-line="addAnalysisLine"
@analysis-close-line="closeAnalysisLine"
@sticky-bar-height="stickyBarHeight = $event"
/>
<FactionBrowser v-if="setupActionsAtTop" :on-turn="canPlay" />
</div>
</div>
<div v-if="hasMap" class="old-board-row">
<SpaceMap class="old-space-map" />
<div class="old-research-panel">
<svg v-if="!engine.options.lostFleet" class="old-research-board" :viewBox="`0 0 ${scoringX + 90} 450`">
<ResearchBoard :height="450" ref="researchBoard" />
<ScoringBoard height="450" width="90" :x="scoringX" />
</svg>
<ResearchBoard v-else class="old-research-board" :height="550" ref="researchBoard" />
</div>
</div>
<LostFleetShips v-if="engine.options.lostFleet" class="old-fleet-ships" />
<div class="row mt-2">
<TurnOrder v-if="!ended && engine.players.length > 0" class="col-md-4 order-4 order-md-1" />
<div :class="commandsColumnClass">
<Commands
@command="handleCommand"
v-if="canPlay && !setupActionsAtTop"
:currentMove="currentMove"
:hide-spacer="true"
:show-premove-cancel="premoveMode || cancelTriggerComposeActive"
:show-premove-confirm="(premoveMode && premoveReady) || (cancelTriggerComposeActive && cancelTriggerReady)"
:premove-confirm-label="
cancelTriggerComposeActive ? 'Continue' : premoveEditSeq !== null ? 'Save changes' : 'Queue now'
"
:premove-context="premoveContext"
:analysis-mode="analysisMode"
:analysis-status="analysisStatus"
:analysis-move-count="analysisAppliedEntries.length"
:analysis-committable-moves="analysisCommittableMoves.length"
:analysis-commit-plan="analysisCommitPlan"
:analysis-faction-choices="analysisFactionChoices"
:analysis-line-summaries="analysisLineSummaries"
:analysis-active-line="analysisActiveLine"
@analysis-seed-faction="seedAnalysisFaction"
@analysis-commit="commitAnalysisLine"
@analysis-charge="chargeAnalysisPower"
@analysis-undo-charge="undoAnalysisCharge"
@analysis-select-line="selectAnalysisLine"
@analysis-add-line="addAnalysisLine"
@analysis-close-line="closeAnalysisLine"
@cancel-premove="cancelTriggerComposeActive ? cancelCancelTriggerCompose() : cancelPremoveMode()"
@confirm-premove="cancelTriggerComposeActive ? confirmCancelTriggerCompose() : queueCurrentPremove()"
@sticky-bar-height="stickyBarHeight = $event"
/>
<div v-else-if="offlineMirrorWaiting" class="text-muted small">
Waiting for {{ turnPlayer.name || "the other player" }}. This is your offline copy of an online game, so you
play only your own seats here; their move arrives the next time you open the game with a connection.
</div>
<div v-if="showPremoveSheet" class="mt-2">
<PremoveBar
:seat="myLockedSeat"
:compose-mode-preference="premoveModePreference"
:sticky-mobile="!canPlay"
:bottom-offset="0"
:stage="cancelTriggerStage"
:watched-seat="cancelTriggerWatchedSeat"
:draft-move="cancelTriggerDraftMove"
:editing-atoms="cancelTriggerEditingAtoms"
:editing-leech-config="cancelTriggerEditingLeechConfig"
:edit-cascade-notice="premoveEditCascadeNotice"
@mode-preference="setPremoveModePreference"
@start-new="onStartNewPremove"
@start-edit="startEditPremove"
@start-cancel-trigger="startCancelTriggerPicker"
@start-edit-cancel-trigger="startEditCancelTrigger"
@pick-opponent="pickCancelTriggerOpponent"
@pick-leech="pickCancelTriggerLeech"
@arm-refine="armCancelTriggerFromRefine"
@arm-leech="armLeechTrigger"
@close-cancel-trigger="closeCancelTriggerStep"
@dismiss-cascade="premoveEditCascadeNotice = null"
@bar-height="premoveBarHeight = $event"
/>
</div>
<FactionBrowser v-if="!setupActionsAtTop" :on-turn="canPlay" />
</div>
</div>
<AdvancedLog
class="col-12 order-last mt-4"
:currentMove="currentMove"
:hideLog.sync="hideLog"
v-if="logPlacement === 'top'"
/>
<div class="row mt-2">
<template v-if="sessionPlayer === undefined">
<PlayerInfo v-for="player in orderedPlayers" :player="player" :key="player.player" class="col-md-6 order-6" />
</template>
<template v-else>
<PlayerInfo :player="sessionPlayer" class="col-md-6 order-3" />
<PlayerInfo
v-for="player in orderedPlayers.filter((pl) => pl !== sessionPlayer)"
:player="player"
:key="player.player"
class="col-md-6 order-6"
/>
</template>
<Pool class="col-12 order-10 mt-4" />
<AdvancedLog
class="col-12 order-last mt-4"
:currentMove="currentMove"
:hideLog.sync="hideLog"
v-if="logPlacement === 'bottom'"
/>
</div>
<div
class="mobile-sticky-actions-spacer"
:style="{ '--sticky-bar-height': totalStickyFooterHeight + 'px' }"
aria-hidden="true"
></div>
<AutoLeechFab
v-if="showOffTurnAutoLeechFab"
:bottom-offset="offTurnAutoLeechBottomOffset"
:show-passed-cap-options="myLockedSeatHasPassed"
/>
</template>
<div v-else class="d-flex flex-column">
<SetupStatus v-if="!ended" />
<SpaceMap
v-if="hasMap"
:class="['mb-1', 'space-map', 'col-md-7']"
:analysis-offered="analysisOffered"
:analysis-active="analysisMode"
:analysis-can-edit="analysisAppliedEntries.length > 0"
@analysis-toggle="toggleAnalysisMode"
@analysis-undo="undoLastAnalysisEntry"
@analysis-reset="resetAnalysisLine"
/>
<AdvancedLog :currentMove="currentMove" :hideLog.sync="hideLog" v-if="logPlacement === 'top'" />
<Commands
@command="handleCommand"
v-if="canPlay"
:currentMove="currentMove"
:analysis-mode="analysisMode"
:analysis-status="analysisStatus"
:analysis-move-count="analysisAppliedEntries.length"
:analysis-committable-moves="analysisCommittableMoves.length"
:analysis-commit-plan="analysisCommitPlan"
:analysis-faction-choices="analysisFactionChoices"
:analysis-line-summaries="analysisLineSummaries"
:analysis-active-line="analysisActiveLine"
@analysis-seed-faction="seedAnalysisFaction"
@analysis-commit="commitAnalysisLine"
@analysis-charge="chargeAnalysisPower"
@analysis-undo-charge="undoAnalysisCharge"
@analysis-select-line="selectAnalysisLine"
@analysis-add-line="addAnalysisLine"
@analysis-close-line="closeAnalysisLine"
/>
<Table />
<AdvancedLog :currentMove="currentMove" :hideLog.sync="hideLog" v-if="logPlacement === 'bottom'" />
</div>
</div>
</template>
<script lang="ts">
import Engine, { Command, EngineOptions, Phase } from "@gaia-project/engine";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import AdvancedLog from "./AdvancedLog.vue";
import Commands from "./Commands.vue";
import { Component } from "vue-property-decorator";
import CurrentGame from "../../../viewer/src/components/Game.vue";
import LostFleetShips from "./LostFleetShips.vue";
import PlayerInfo from "./PlayerInfo.vue";
import Pool from "./Pool.vue";
import ResearchBoard from "./ResearchBoard.vue";
import ScoringBoard from "./ScoringBoard.vue";
import SpaceMap from "./SpaceMap.vue";
import TurnOrder from "./TurnOrder.vue";
@Component<Game>({
created(this: Game) {
const unsub = this.$store.subscribeAction(({ type, payload }) => {
if (type === "externalData") {
this.handleData(Engine.fromData(payload));
return;
}
if (type === "replayStart") {
this.$store.dispatch("replayInfo", {
start: 1,
end: this.engine.moveHistory.length,
current: this.engine.moveHistory.length,
});
this.replayData = {
current: this.engine.moveHistory.length,
backup: JSON.parse(JSON.stringify(this.engine)),
};
return;
}
if (type === "replayEnd") {
const restore = payload || this.replayData?.backup;
this.replayData = null;
this.handleData(Engine.fromData(restore));
return;
}
if (type === "replayTo") {
const dest: number = payload;
const current = this.replayData.current;
this.replayData.current = dest;
this.$store.dispatch("replayInfo", {
start: 1,
end: this.replayData.backup.moveHistory.length,
current: dest,
});
if (dest === current) {
return;
}
if (dest < current) {
this.handleData(
new Engine(this.replayData.backup.moveHistory.slice(0, dest), {
...this.replayData.backup.options,
noFedCheck: true,
})
);
return;
}
for (const move of this.replayData.backup.moveHistory.slice(current, dest)) {
this.engine.move(move);
}
this.handleData(Engine.fromData(JSON.parse(JSON.stringify(this.engine))));
return;
}
});
this.$once("hook:beforeDestroy", unsub);
},
components: {
AdvancedLog,
Commands,
PlayerInfo,
Pool,
ResearchBoard,
ScoringBoard,
SpaceMap,
TurnOrder,
},
})
export default class Game extends Vue {
public currentMove = "";
clearCurrentMove = false;
// When joining a game
name = "";
replayData: { current: number; backup: Engine } = null;
@Prop()
options: EngineOptions;
get engine(): Engine {
return this.$store.state.data;
}
get ended() {
return this.engine.phase === Phase.EndGame;
}
@Component({ components: { Pool, SpaceMap, PlayerInfo, ResearchBoard, ScoringBoard, LostFleetShips } })
export default class Game extends CurrentGame {
get scoringX() {
return this.engine.expansions ? 505 : 385;
}
get orderedPlayers() {
const engine = this.engine;
if (!engine.round || !engine.turnOrder) {
return engine.players;
}
const turnOrder = engine.turnOrder;
// Do not switch boards anymore now that there's two in a row
// if (engine.turnOrder.indexOf(this.player) !== -1) {
// turnOrder = turnOrder.slice(turnOrder.indexOf(this.player)).concat(turnOrder.slice(0, turnOrder.indexOf(this.player)));
// }
return turnOrder.concat(engine.passedPlayers).map((player) => engine.players[player]);
}
get canPlay() {
return !this.ended && (!this.$store.state.player || this.sessionPlayer === this.engine.players[this.player]);
}
get hasMap() {
return !!this.$store.state.data.map;
}
get player() {
return this.engine.availableCommands?.[0]?.player;
}
get sessionPlayer() {
const player = this.$store.state.player;
if (player) {
if (player.index !== undefined) {
return this.engine.players[player.index];
}
}
}
handleData(data: Engine, keepMoveHistory?: boolean) {
console.log("handle data", keepMoveHistory);
for (const sector of document.getElementsByClassName("sector") as any as Element[]) {
sector.classList.add("notransition");
}
this.$store.commit("receiveData", data);
this.clearCurrentMove = false;
if (data.newTurn) {
this.currentMove = "";
} else {
this.currentMove = data.moveHistory.pop();
}
setTimeout(() => {
for (const sector of document.getElementsByClassName("sector") as any as Element[]) {
sector.classList.remove("notransition");
}
});
}
handleCommand(command: string) {
if (command.startsWith(Command.Init) || this.engine.round <= 0) {
this.addMove(command);
return;
}
const move = this.parseMove(command);
if (move.command === Command.EndTurn) {
this.addMove(this.currentMove + ".");
return;
}
if (this.currentMove && !this.clearCurrentMove) {
this.addMove(this.currentMove + `. ${command.slice(move.player.length + 1)}`);
} else {
this.clearCurrentMove = false;
this.addMove(command);
}
}
undoMove() {
if (this.currentMove.includes(".")) {
this.currentMove = this.currentMove.slice(0, this.currentMove.lastIndexOf("."));
} else {
this.currentMove = "";
}
this.addMove(this.currentMove);
}
addMove(command: string) {
this.$store.commit("clearContext");
this.$store.dispatch("move", command);
}
parseMove(command: string): { player: string; command: string; args: string[] } {
command = command.trim();
if (command.includes(".")) {
return this.parseMove(command.slice(0, command.indexOf(".")));
}
const split = command.split(" ");
return {
player: split[0],
command: split[1],
args: split.slice(2),
};
}
}
</script>
<style lang="scss">
@import "../stylesheets/frontend.scss";
.space-map,
.scoring-research-board {
.old-ui-game .old-board-row {
display: flex;
align-items: start;
gap: 8px;
}
.old-ui-game .old-space-map {
flex: 1 1 55%;
width: 55%;
min-width: 0;
height: auto;
max-height: 550px;
}
.old-ui-game .old-research-panel {
flex: 1 1 45%;
width: 45%;
min-width: 0;
touch-action: pan-y pinch-zoom;
}
.old-ui-game .old-research-board {
width: 100%;
// this is needed for Safari
height: intrinsic;
max-height: 550px;
height: auto;
}
.medium-map,
.small-map {
flex-wrap: nowrap;
.old-ui-game .old-fleet-ships .lost-fleet-ships__boards {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
}
@media (max-width: 767px) {
.small-map,
.medium-map {
flex-wrap: wrap;
.old-ui-game .old-board-row {
display: block;
}
.old-ui-game .old-space-map,
.old-ui-game .old-research-panel {
width: 100%;
}
.old-ui-game .old-fleet-ships .lost-fleet-ships__boards {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
</style>

View file

@ -0,0 +1,125 @@
<template>
<div v-if="isLostFleet" class="lost-fleet-ships old-ships">
<section v-for="ship in ships" :key="ship" class="lost-fleet-ship old-ship" :data-ship="ship">
<header :style="{ background: shipColor(ship) }">
<strong>{{ shipFullName(ship) }}</strong>
<span class="old-ship-slots">
<span
v-for="slot in explorationSlots(ship)"
:key="slot.index"
v-b-tooltip
:title="slotTitle(slot)"
:class="{ occupied: !!slot.player }"
>{{ slot.player ? "P" + (slot.player.player + 1) : slot.cost + "pw" }}</span
>
</span>
</header>
<div
v-for="action in shipActions(ship)"
:key="action.type"
class="old-ship-action"
:class="{ used: !!actionUser(ship, action.type) }"
v-b-tooltip
:title="actionTooltip(ship, action)"
>
<b>{{ action.cost }}</b
><span>{{ actionNotation(ship, action.type) }}</span>
</div>
<div class="old-ship-rewards">
<FederationTile
v-if="shipFederation(ship)"
:spaceship-federation="shipFederation(ship)"
:rewards-override="federationDisplayRewards(shipFederation(ship))"
:num-tiles="1"
/>
<TechTile v-if="hasTechSlot(ship)" :pos="ship" />
<template v-else
><ArtifactIcon v-for="artifact in remainingArtifacts" :key="artifact" :artifact="artifact"
/></template>
</div>
</section>
</div>
</template>
<script lang="ts">
import { Spaceship } from "@gaia-project/engine";
import { Component } from "vue-property-decorator";
import CurrentShips from "../../../viewer/src/components/LostFleetShips.vue";
import ArtifactIcon from "./ArtifactIcon.vue";
import FederationTile from "./FederationTile.vue";
import TechTile from "./TechTile.vue";
@Component({ components: { FederationTile, TechTile, ArtifactIcon } })
export default class LostFleetShips extends CurrentShips {
actionNotation(ship: Spaceship, type: string): string {
const effects = this.actionIncome(ship, type as any);
if (effects.length) return effects.join(",");
const otherEffects = {
[Spaceship.Twilight]: { power: "lab" },
[Spaceship.Rebellion]: { power: "ts" },
[Spaceship.TFMars]: { power: "instant-gaia", credit: "1step,mine" },
[Spaceship.Eclipse]: { power: "up-research", credit: "asteroid mine" },
};
return otherEffects[ship][type];
}
}
</script>
<style scoped>
.old-ships {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
}
.old-ship {
min-width: 0;
background: white;
color: #212529;
border: 1px solid #444;
font-size: 12px;
}
.old-ship header {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: 4px;
padding: 4px;
}
.old-ship-slots {
display: flex;
gap: 3px;
}
.old-ship-slots span {
border: 1px solid #444;
background: white;
padding: 0 3px;
}
.old-ship-slots .occupied {
font-weight: bold;
}
.old-ship-action {
display: grid;
grid-template-columns: 42px 1fr;
gap: 4px;
padding: 4px;
border-top: 1px solid #ccc;
}
.old-ship-action.used {
opacity: 0.45;
}
.old-ship-rewards {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 4px;
border-top: 1px solid #ccc;
padding: 4px;
}
@media (max-width: 900px) {
.old-ships {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 480px) {
.old-ships {
grid-template-columns: 1fr;
}
}
</style>

View file

@ -38,7 +38,7 @@
/>
<Building
:building="building"
class="building-in-group"
class="old-building-in-group"
:faction="faction"
:transform="`translate(${isPI ? 0.5 : 0}, 0) scale(1.5)`"
v-if="showBuilding(i)"
@ -55,132 +55,9 @@
</template>
<script lang="ts">
import {
Building as BuildingEnum,
Faction,
FactionBoard,
factionBoard,
Operator,
Resource as ResourceEnum,
Reward,
} from "@gaia-project/engine";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { Component } from "vue-property-decorator";
import CurrentBuildingGroup from "../../../../viewer/src/components/PlayerBoard/BuildingGroup.vue";
import Building from "../Building.vue";
import Resource from "../Resource.vue";
@Component({
components: {
Building,
Resource,
},
watch: {
faction(newVal) {
this.board = factionBoard(newVal);
},
},
})
export default class BuildingGroup extends Vue {
@Prop()
nBuildings: number;
@Prop()
building: BuildingEnum;
@Prop()
faction!: Faction;
@Prop()
placed: number;
@Prop()
resource: ResourceEnum[];
@Prop({ default: false })
ac1: boolean;
@Prop({ default: false })
ac2: boolean;
board: FactionBoard = factionBoard(this.faction || Faction.Terrans);
get buildingList() {
return [0, 1, 2, 3, 4, 5, 6, 7].slice(0, this.nBuildings);
}
get isPI() {
return this.building === BuildingEnum.PlanetaryInstitute;
}
tooltip(i: number) {
return "Income: " + (this.resources(i, true).join(", ") || "~");
}
get offset() {
return 1.4;
}
get buildingSpacing() {
return 2.2;
}
get paddingRight() {
return 0.2;
}
get width() {
return Math.max(this.nBuildings, 2) * this.buildingSpacing + this.offset + this.paddingRight;
}
get factionIncome(): Reward[] {
const income: Reward[] = [].concat(
...this.board.income.filter((ev) => ev.operator === Operator.Income).map((ev) => ev.rewards)
);
return income.filter((rew) => this.resource.includes(rew.type));
}
showBuilding(i: number) {
if (this.ac1 || this.ac2) {
return i === 0 ? !this.ac1 : !this.ac2;
}
return i >= this.placed;
}
resources(i: number, forced = false): Reward[] {
if (this.showBuilding(i) && !forced) {
return [];
}
let building = this.building;
if (this.building === BuildingEnum.Academy1 && i > 0) {
building = BuildingEnum.Academy2;
i = 0;
}
return [].concat(
...this.board.buildings[building].income[i]
.filter((ev) => {
if (ev.operator === Operator.Income) {
return true;
}
const rew = ev.rewards.toString();
return ev.operator === Operator.Activate && (rew === "q" || rew === "4c");
})
.map((ev) => ev.rewards)
);
}
}
@Component({ components: { Building } })
export default class BuildingGroup extends CurrentBuildingGroup {}
</script>
<style lang="scss">
.player-board {
.building-group {
.building-in-group {
stroke-width: 0.05px;
}
}
}
</style>

View file

@ -4,19 +4,20 @@
name
}}</span>
<div class="board mt-2">
<svg viewBox="-0.2 -0.5 38.5 21.4" class="player-board" :style="`background-color: ${factionColor}`">
<svg :viewBox="`-0.2 -0.5 38.5 ${height}`" class="player-board" :style="`background-color: ${factionColor}`">
<rect x="-1" y="-1" width="50" height="50" fill="#ffffff44"></rect>
<PlayerBoardInfo
transform="translate(0.5, 0.5)"
:player="player"
:faction="player.faction"
:data="playerData"
:height="height"
/>
<BuildingGroup
:transform="player.faction !== 'bescods' ? 'translate(2.2, 10)' : 'translate(12, 10)'"
:nBuildings="1"
building="PI"
:faction="player.faction"
:player="player"
:placed="playerData.buildings.PI"
:resource="['pw', 't']"
/>
@ -24,7 +25,7 @@
:transform="player.faction === 'bescods' ? 'translate(2.2, 10)' : 'translate(12, 10)'"
:nBuildings="2"
building="ac1"
:faction="player.faction"
:player="player"
:placed="0"
:ac1="playerData.buildings.ac1"
:ac2="playerData.buildings.ac2"
@ -34,7 +35,7 @@
transform="translate(0, 13)"
:nBuildings="4"
building="ts"
:faction="player.faction"
:player="player"
:placed="playerData.buildings.ts"
:resource="['c']"
/>
@ -42,7 +43,7 @@
transform="translate(11, 13)"
:nBuildings="3"
building="lab"
:faction="player.faction"
:player="player"
:placed="playerData.buildings.lab"
:resource="['k']"
/>
@ -50,7 +51,7 @@
transform="translate(0, 16)"
:nBuildings="8"
building="m"
:faction="player.faction"
:player="player"
:placed="playerData.buildings.m"
:resource="['o']"
/>
@ -62,40 +63,81 @@
<line x1="15.3" x2="15.3" y1="11.2" y2="11.8" stroke="black" stroke-width="0.06" />
<!-- TS to LAB -->
<line x1="10.4" x2="11" y1="13.0" y2="13.0" stroke="black" stroke-width="0.06" />
<PowerBowls transform="translate(29,14.5)" :faction="player.faction" :data="playerData" :player="player" />
<BuildingGroup
transform="translate(21,1.2)"
:nBuildings="playerData.gaiaformers"
building="gf"
:gaia="playerData.gaiaformersInGaia"
:player="player"
:placed="playerData.buildings.gf"
:asteroid-consumed="playerData.gaiaformersUsedForAsteroid"
:resource="[]"
/>
<PowerBowls
:transform="`translate(29,${height - 7})`"
:faction="player.faction"
:data="playerData"
:player="player"
/>
<g transform="translate(29.3, 5)">
<g transform="translate(29.3, 4.7) scale(0.9) translate(0, 1)">
<g v-for="i in [0, 1, 2, 3]" :key="i" :transform="`translate(${(i - 2) * 3.8}, 0)`">
<g
v-for="(planet, index) in planetsWithSteps(i)"
:key="planet"
:transform="`translate(0, ${(i > 0 ? (index > 0 ? 1 : -1) : 0) * 1.4})`"
v-for="marker in terraformingMarkers(i)"
:key="marker.planet"
:data-terraforming-step="i"
:data-planet="marker.planet"
:data-radius="marker.radius"
:transform="`translate(${marker.x}, ${marker.y})`"
>
<circle :r="1" style="stroke-width: 0.06px !important" :class="['player-token', 'planet-fill', planet]" />
<circle
:r="marker.radius"
style="stroke-width: 0.06px !important"
:class="['player-token', 'planet-fill', marker.planet]"
/>
<text
:style="`font-size: 1.2px; text-anchor: middle; dominant-baseline: mathematical; fill: ${planetFill(
planet
)}`"
:style="`font-size: ${
marker.fontSize
}px; text-anchor: middle; dominant-baseline: central; fill: ${planetFill(marker.planet)}`"
>
{{ player.ownedPlanetsCount[planet] }}
{{ player.ownedPlanetsCount[marker.planet] }}
</text>
<circle
:r="marker.radius"
style="cursor: pointer; opacity: 0"
@click="togglePlanetHighlight(marker.planet)"
/>
</g>
<line x1="1.9" x2="1.9" y1="-2.3" y2="2.3" stroke-width="0.06" stroke="black" />
</g>
<g :transform="`translate(7.6, 0)`">
<circle :r="1" style="stroke-width: 0.06px !important" :class="['player-token', 'planet-fill', 'g']" />
<text style="font-size: 1.2px; text-anchor: middle; dominant-baseline: mathematical; fill: white">
{{ player.ownedPlanetsCount["g"] }}
<g v-for="entry in planetCounters" :key="entry.planet" :transform="`translate(7.6, ${entry.y})`">
<circle
:r="planetCounterRadius"
style="stroke-width: 0.06px !important"
:class="['player-token', 'planet-fill', entry.planet]"
/>
<text
:style="`font-size: ${planetCounterFontSize}px; text-anchor: middle; dominant-baseline: central; fill: ${planetFill(
entry.planet
)}`"
>
{{ player.ownedPlanetsCount[entry.planet] }}
</text>
<circle
:r="planetCounterRadius"
style="cursor: pointer; opacity: 0"
@click="togglePlanetHighlight(entry.planet)"
/>
</g>
</g>
<SpecialAction
v-for="(action, i) in player.actions"
:action="action.rewards"
v-for="(action, i) in player.actionsWithoutTile"
:action="[action.rewards]"
:player="player"
:disabled="!action.enabled || passed"
:key="action.action + '-' + i"
y="17.5"
:key="'action-' + i"
:y="height - 4"
width="3.1"
height="3.1"
:x="3.3 * i"
@ -123,6 +165,27 @@
:player="player.player"
:numTiles="1"
/>
<FederationTile
v-for="(fed, i) in playerData.spaceshipFederations"
class="mb-1 mr-1"
:key="'ship-fed-' + i"
:data-ship-federation="fed.tile"
:spaceship-federation="fed.tile"
:rewardsOverride="shipFederationRewards(fed.tile)"
:used="!fed.green"
:player="player.player"
:numTiles="1"
filter="url(#shadow-1)"
/>
<span
v-for="(artifact, i) in playerData.artifacts"
class="mb-1 mr-1 d-inline-flex player-artifact"
:class="{ 'last-move': recentArtifact(artifact) }"
:key="'artifact-' + i"
:data-artifact="artifact"
>
<ArtifactIcon :artifact="artifact" />
</span>
<TechTile
v-for="tech in playerData.tiles.techs"
:covered="!tech.enabled"
@ -132,177 +195,26 @@
:player="player.player"
/>
</div>
<b-modal :id="player.faction" :title="factionName" size="lg">
<div v-html="tooltip"></div>
</b-modal>
<Rules :id="player.faction" :type="player.faction" />
</div>
</template>
<script lang="ts">
import { Planet, Player, factionPlanet } from "@gaia-project/engine";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { factionDesc, planetsWithSteps } from "../data/factions";
import { factionColor } from "../graphics/utils";
import { Component } from "vue-property-decorator";
import CurrentPlayerInfo from "../../../viewer/src/components/PlayerInfo.vue";
import ArtifactIcon from "./ArtifactIcon.vue";
import Booster from "./Booster.vue";
import FederationTile from "./FederationTile.vue";
import BuildingGroup from "./PlayerBoard/BuildingGroup.vue";
import PlayerBoardInfo from "./PlayerBoard/Info.vue";
import PowerBowls from "./PlayerBoard/PowerBowls.vue";
import SpecialAction from "./SpecialAction.vue";
import TechTile from "./TechTile.vue";
@Component({
components: {
TechTile,
Booster,
SpecialAction,
FederationTile,
BuildingGroup,
PowerBowls,
PlayerBoardInfo,
},
})
export default class PlayerInfo extends Vue {
@Prop()
player: Player;
get playerData() {
return this.player ? this.player.data : null;
}
playerClick(player: Player) {
this.$store.dispatch("playerClick", player);
}
get factionColor() {
return factionColor(this.player.faction);
}
get name() {
if (this.player.name) {
return this.player.name;
}
return "Player " + (this.player.player + 1);
}
get tooltip() {
return factionDesc(this.player.faction);
}
get planet() {
return factionPlanet(this.player.faction);
}
get factionName(): string {
return factionPlanet(this.player.faction);
}
planetFill(planet: string) {
if (planet === Planet.Titanium || planet === Planet.Swamp) {
return "white";
}
return "black";
}
planetsWithSteps(steps: number) {
return planetsWithSteps(this.planet, steps);
}
get passed() {
return (this.$store.state.data.passedPlayers || []).includes(this.player.player);
}
get round() {
return this.$store.state.data.round;
}
get hasPlanets() {
return this.player.ownedPlanets.length > 0;
}
}
@Component({ components: { SpecialAction, Booster, TechTile, FederationTile, ArtifactIcon, BuildingGroup } })
export default class PlayerInfo extends CurrentPlayerInfo {}
</script>
<style lang="scss">
.player-token {
stroke: #111;
pointer-events: none;
stroke-width: 1;
}
.content {
font-size: 1rem;
color: #212529;
pointer-events: none;
}
<style scoped>
.player-board {
width: 100%;
height: auto;
border: 1px solid black;
max-width: 700px;
display: block;
// margin-left: auto;
margin-right: auto;
.board-text {
dominant-baseline: mathematical;
font-size: 1.2px;
}
// &::after {
// position: absolute;
// content: " ";
// background: rgba(white, 0.4);
// top: 0; bottom: 0; left: 0; right: 0;
// }
&.bescods::after,
&.firaks::after {
background: rgba(white, 0.7);
}
}
.player-info {
padding-top: 0.5em;
padding-bottom: 0.5em;
border-radius: 5px;
position: relative;
.player-name {
cursor: pointer;
font-weight: bold;
&.dropped {
text-decoration: line-through;
}
}
flex-wrap: nowrap !important;
@media (max-width: 600px) {
flex-wrap: wrap !important;
}
.tiles {
align-content: baseline;
align-items: center;
// justify-content: center;
}
.tiles,
.board {
z-index: 1;
position: relative;
}
.faction-name {
cursor: pointer;
outline: 0;
}
.maxResource {
color: red;
}
}
</style>

View file

@ -1,12 +1,13 @@
<template>
<svg :viewBox="`0 0 ${viewWidth} 440`" :height="height" :width="width">
<svg :viewBox="`0 0 ${viewWidth} ${viewHeight}`" :height="height" :width="width">
<ResearchTrack v-for="(field, index) in fields" :field="field" :x="index * 60" :key="field" />
<text y="186" x="130" style="font-size: 14px">Charge 3 power</text>
<FleetScoringColumn v-if="$store.state.data.options.lostFleet" />
<text y="186" x="130" style="font-size: 14px; fill: currentColor">Charge 3 power</text>
<g v-if="$store.state.data.tiles && $store.state.data.tiles.techs['gaia']">
<TechTile pos="free1" x="70" y="360" />
<TechTile pos="free2" x="150" y="360" />
<TechTile pos="free3" x="230" y="360" />
<TechTile pos="free4" v-if="expansions" x="310" y="360" />
<TechTile pos="free4" v-if="$store.state.data.tiles.techs.free4" x="310" y="360" />
</g>
<BoardAction
:scale="17"
@ -22,7 +23,9 @@
import { BoardAction as BoardActionEnum, ResearchField } from "@gaia-project/engine";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { researchBoardHeight } from "../../../viewer/src/logic/utils";
import BoardAction from "./BoardAction.vue";
import FleetScoringColumn from "./FleetScoringColumn.vue";
import ResearchTrack from "./ResearchTrack.vue";
import TechTile from "./TechTile.vue";
@ -38,13 +41,17 @@ import TechTile from "./TechTile.vue";
return this.$store.state.data.expansions;
},
viewWidth() {
return this.fields.length * 60;
return this.fields.length * 60 + (this.$store.state.data.options.lostFleet ? 80 : 0);
},
viewHeight() {
return researchBoardHeight(this.$store.state.data);
},
width() {
return (this.height / 440) * this.viewWidth;
},
},
components: {
FleetScoringColumn,
ResearchTrack,
TechTile,
BoardAction,

View file

@ -47,7 +47,6 @@
<script lang="ts">
import {
Expansion,
Federation,
Operator,
Planet as PlanetEnum,
@ -59,7 +58,7 @@ import {
} from "@gaia-project/engine";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { descriptions } from "../data/research";
import { researchLevelDesc } from "../../../viewer/src/data/research";
import FederationTile from "./FederationTile.vue";
import Planet from "./Planet.vue";
import Resource from "./Resource.vue";
@ -73,7 +72,7 @@ import Token from "./Token.vue";
);
},
tooltip() {
return `<b>Level ${this.level}:</b> ${descriptions[this.field][this.level]}`;
return `<b>Level ${this.level}:</b> ${researchLevelDesc(this.$store.state.data, this.field, this.level, true).join("<br>")}`;
},
height() {
return this.level === 0 || this.level === 5 ? 46 : 36;
@ -131,7 +130,7 @@ export default class ResearchTile extends Vue {
onClick() {
if (this.highlighted) {
this.$store.dispatch("researchClick", this.field);
this.$store.dispatch("researchClick", { command: this.field });
}
}
@ -158,7 +157,12 @@ export default class ResearchTile extends Vue {
}
get resources() {
const events = researchEvents(this.field, this.level, Expansion.None).slice(0, 1);
const events = researchEvents(
this.field,
this.level,
this.$store.state.data.expansions,
this.$store.state.data.lostFleetEconomySide
).slice(0, 1);
const rewards = Reward.merge(...events.map((ev) => ev.rewards));

View file

@ -1,5 +1,5 @@
<template>
<g :class="['scoringTile', { highlighted, faded }]" v-b-tooltip :title="tooltip">
<g :class="['old-scoring-tile', { highlighted, faded }]" v-b-tooltip :title="tooltip">
<rect x="1" y="1" width="75" height="40" />
<text class="title" x="5" y="12">Round {{ round }}</text>
<text class="content" x="5" y="31">{{ content }}</text>
@ -44,7 +44,7 @@ export default class ScoringTile extends Vue {
<style lang="scss">
g {
&.scoringTile {
&.old-scoring-tile {
rect {
stroke: #333;
stroke-width: 1px;
@ -53,10 +53,13 @@ g {
.title {
font-size: 10px;
font-weight: bold;
text-anchor: start;
fill: #212529;
pointer-events: none;
}
.content {
font-size: 12px;
fill: #212529;
pointer-events: none;
}

View file

@ -1,194 +1,95 @@
<template>
<g :id="`${hex}`">
<title>
Coordinates: {{ hex }}{{ hex.data.planet !== "e" ? `&#10;Planet: ${planetName(hex.data.planet)}` : ""
}}{{ hex.data.building ? `&#10;Building: ${buildingName(hex.data.building)}` : ""
}}{{ cost(hex) ? `&#10;Cost: ${cost(hex)}` : "" }}
</title>
<polygon
:points="hexCorners.map((p) => `${p.x},${p.y}`).join(' ')"
:class="[
'spaceHex',
{
toSelect,
highlighted: highlightedHexes.has(hex),
qic: cost(hex).includes('q'),
power: cost(hex).includes('pw'),
},
]"
@click="hexClick(hex)"
<g :id="`${hex}`" class="space-hex-cell">
<title v-text="tooltip" />
<use xlink:href="#space-hex" :class="polygonClasses(hex)" @click="hexClick(hex)" />
<use
v-if="recentOpponentMove"
xlink:href="#space-hex"
class="recent-opponent-move"
:data-recent-opponent-move="recentOpponentMove.command"
pointer-events="none"
/>
<text class="sector-name" v-if="isCenter">{{
hex.data.sector[0] === "s" ? parseInt(hex.data.sector.slice(1)) : parseInt(hex.data.sector)
}}</text>
<Planet v-if="hex.data.planet !== 'e'" :planet="hex.data.planet" :faction="faction(hex.data.player)" />
<Building v-if="hex.data.building" :building="hex.data.building" :faction="faction(hex.data.player)" />
<Building
v-if="hex.data.additionalMine !== undefined"
:faction="faction(hex.data.additionalMine)"
building="m"
transform="translate(0.58, -0.2) rotate(36) scale(0.9)"
class="additionalMine"
<use
v-for="(l, i) in federationLines"
:key="`fl-${i}`"
:xlink:href="l.id"
:transform="`rotate(${l.rotate})`"
pointer-events="none"
/>
<Building
v-for="(player, index) in tradeTokens"
:key="`${player}-${index}-trade`"
:faction="faction(player)"
building="gf"
:transform="`scale(0.6) translate(${tradeX(6 - index)}, ${tradeY(6 - index)})`"
<use v-if="powerHighlightClass" xlink:href="#space-hex" :class="['space-hex-federation', powerHighlightClass]" />
<use
v-if="mapModeHighlight !== null"
xlink:href="#space-hex"
:class="['space-hex-federation', 'planet', 'planet-fill', playerPlanet(mapModeHighlight)]"
/>
<polygon
v-for="(player, index) in hex.data.federations || []"
:points="hexCorners.map((p) => `${p.x * (1 - (index + 0.5) / 8)},${p.y * (1 - (index + 0.5) / 8)}`).join(' ')"
:class="['spaceHexFederation', 'planet', planet(player)]"
:key="`${player}-${index}`"
<use
v-if="lostFleetSpaceship"
xlink:href="#space-hex"
class="lost-fleet-spaceship__hex"
:data-ship="lostFleetSpaceship"
:style="{ fill: lostFleetSpaceshipColor }"
/>
<g :transform="`rotate(${-contentRotation})`">
<g
v-if="lostFleetSectorBadge && !lostFleetSpaceship"
:class="['lost-fleet-sector-badge', `lost-fleet-sector-badge--${lostFleetSectorBadge.kind}`]"
:data-sector-type="lostFleetSectorBadge.kind"
transform="translate(-0.84,-0.79)"
>
<rect :width="badgeWidth" height="0.34" rx="0.12" ry="0.12" />
<text :x="badgeWidth / 2" y="0.17">{{ lostFleetSectorBadge.label }}</text>
</g>
<text class="sector-name" v-if="isCenter" x="0" y="0" dy="0.35">
{{ hex.data.sector[0] === "s" ? parseInt(hex.data.sector.slice(1)) : parseInt(hex.data.sector) }}
</text>
<g v-if="lostFleetSpaceship" class="lost-fleet-spaceship">
<text class="lost-fleet-spaceship__label" y="0" dy="0.315">{{ lostFleetSpaceshipLabel }}</text>
</g>
<Planet
v-if="showPlanet"
:planet="hex.data.planet"
:faction="faction(hex.data.player)"
:classes="planetClasses(hex)"
/>
<Building
style="stroke-width: 0.1"
v-if="hex.data.building"
:building="hex.data.building"
:faction="faction(hex.data.player)"
outline
:flat="flat"
transform="scale(1)"
/>
<Building
style="stroke-width: 0.1"
v-if="highlightBuilding"
:building="highlightBuilding.building"
:faction="faction(highlightBuilding.player)"
outline
:flat="flat"
transform="scale(1)"
/>
<Building
style="stroke-width: 0.1"
v-if="hex.data.additionalMine !== undefined"
:faction="faction(hex.data.additionalMine)"
building="m"
transform="translate(0.4, 0.2) scale(0.9)"
class="additionalMine"
:flat="flat"
outline
/>
</g>
</g>
</template>
<script lang="ts">
import {
Building as BuildingEnum,
GaiaHex,
SpaceMap as ISpaceMap,
Planet as PlanetEnum,
factionPlanet,
} from "@gaia-project/engine";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { buildingName } from "../data/building";
import { planetNames } from "../data/planets";
import { corners } from "../graphics/hex";
import { Component } from "vue-property-decorator";
import CurrentHex from "../../../viewer/src/components/SpaceHex.vue";
import Building from "./Building.vue";
import Planet from "./Planet.vue";
@Component<SpaceHex>({
components: {
Planet,
Building,
},
})
export default class SpaceHex extends Vue {
@Prop()
hex: GaiaHex;
@Prop()
isCenter: boolean;
get hexCorners() {
return corners();
}
get map(): ISpaceMap {
return this.$store.state.data.map;
}
cost(hex: GaiaHex) {
const data = this.highlightedHexes.get(hex);
return data && data.cost && data.cost !== "~" ? data.cost.replace(/,/g, ", ") : "";
}
hexClick(hex: GaiaHex) {
if (this.highlightedHexes.has(hex) || this.toSelect) {
this.$store.dispatch("hexClick", hex);
}
}
faction(player) {
if (player === undefined || player === "wild") {
return player; // Wild will get recognized as purple, for trade tokens. A bit of a hack
}
return this.$store.state.data.players[player].faction;
}
planet(player) {
return factionPlanet(this.faction(player));
}
buildingName(building: BuildingEnum) {
return buildingName(building);
}
planetName(planet: PlanetEnum) {
return planetNames[planet];
}
get highlightedHexes(): Map<GaiaHex, any> {
return this.$store.state.context.highlighted.hexes;
}
get toSelect() {
return !!this.$store.state.context.hexSelection;
}
shipX(index) {
return SpaceHex.shipXs[index % 7];
}
shipY(index) {
return SpaceHex.shipYs[index % 7];
}
tradeX(index) {
return SpaceHex.tradeXs[index];
}
tradeY(index) {
return SpaceHex.tradeYs[index];
}
static shipXs = [-0.5, 0.5, -1.3, 1.3, -0.5, 0.5, 0];
static shipYs = [-1.3, -1.3, 0, 0, 1.3, 1.3, 0];
static tradeXs = [-0.5, 0.5, -0.9, 0, 0.9, -0.5, 0.5];
static tradeYs = [-0.9, -0.9, 0, 0, 0, 0.9, 0.9];
}
@Component({ components: { Building } })
export default class SpaceHex extends CurrentHex {}
</script>
<style lang="scss">
svg {
.spaceHex {
fill: #172e62;
stroke: #666;
stroke-width: 0.01;
&:hover {
fill-opacity: 0.5;
}
&.highlighted {
fill: white;
cursor: pointer;
&.qic {
fill: lightGreen;
}
&.power {
fill: #d378d3;
}
}
&.toSelect {
cursor: pointer;
opacity: 0.7;
}
}
.spaceHexFederation {
stroke-width: 0.1;
fill: none;
pointer-events: none;
}
.sector-name {
text-anchor: middle;
dominant-baseline: central;
font-size: 1px;
fill: white;
opacity: 0.35;
pointer-events: none;
}
}
</style>

View file

@ -1,5 +1,6 @@
<template>
<svg :viewBox="`-13 -11.5 ${right} 24`">
<svg :viewBox="viewBox" class="old-map-canvas">
<definitions />
<Sector
v-for="center in this.sectors"
:center="center"
@ -8,46 +9,52 @@
rotation(center) * 60
}deg);`"
/>
<FactionWheel transform="translate(-10.5, -8.7) scale(0.5, 0.5)" />
<SpaceHex
v-for="hex in looseHexes"
:key="hex.toString()"
:hex="hex"
:isCenter="false"
:transform="`translate(${hexCenter(hex).x * spread},${hexCenter(hex).y * spread})`"
/>
<use
v-for="ring in powerRings"
:key="ring.key"
xlink:href="#space-hex"
:class="['space-hex-power-ring', ring.planet]"
:transform="ring.transform"
pointer-events="none"
/>
<text v-for="label in deepSpaceLabels" :key="label.id" :x="label.x" :y="label.y" class="sector-name">
{{ label.id }}
</text>
<rect
v-for="(planet, i) in terraformingColors"
:key="planet"
:class="['planet-fill', planet]"
width="0.9"
height="0.9"
:x="bounds.right - 7.5 + i * 1.05"
:y="bounds.top + 0.3"
>
<title>Terraforming board colour {{ i + 1 }}</title>
</rect>
<FactionWheel :transform="`translate(${bounds.left + 3},${bounds.top + 3}) scale(0.5)`" />
</svg>
</template>
<script lang="ts">
import { GaiaHex, SpaceMap as SpaceMapData } from "@gaia-project/engine";
import { CubeCoordinates } from "hexagrid";
import Vue from "vue";
import { Component } from "vue-property-decorator";
import { hexCenter } from "../graphics/hex";
import CurrentMap from "../../../viewer/src/components/SpaceMap.vue";
import FactionWheel from "./FactionWheel.vue";
import Sector from "./Sector.vue";
@Component<SpaceMap>({
components: {
Sector,
FactionWheel,
},
})
export default class SpaceMap extends Vue {
hexCenter(hex: GaiaHex) {
return hexCenter(hex);
import SpaceHex from "./SpaceHex.vue";
@Component({ components: { Sector, SpaceHex, FactionWheel } })
export default class SpaceMap extends CurrentMap {
get mapRotationDeg() {
return 0;
}
get sectors(): CubeCoordinates[] {
return this.map.configuration().centers;
}
rotation(center: CubeCoordinates) {
return this.$store.state.context.rotation.get(`${center.q}x${center.r}`) || 0;
}
get map(): SpaceMapData {
return this.$store.state.data.map;
}
get right() {
return (this.sectors || []).length > 7 ? 33.5 : 26;
get spread() {
return 1.01;
}
}
</script>
<style lang="scss"></style>

View file

@ -1,13 +1,13 @@
<template>
<svg viewBox="-25 -25 50 50" width="50" height="50">
<g :class="['specialAction', { highlighted, disabled }]">
<g :class="['old-special-action', { highlighted: isHighlighted, disabled }]">
<polygon
points="-1,0.5 -0.5,1 0.5,1 1,0.5 1,-0.5 0.5,-1 -0.5,-1 -1,-0.5"
transform="scale(24)"
@click="onClick"
/>
<text>
<tspan x="0" v-for="(line, i) in income" :dy="`${i === 0 ? -0.5 * (income.length - 1) * 11 : 11}px`" :key="i">
<tspan x="0" v-for="(line, i) in lines" :dy="`${i === 0 ? -0.5 * (lines.length - 1) * 11 : 11}px`" :key="i">
{{ line.replace(/ /g, "") }}
</tspan>
</text>
@ -16,39 +16,19 @@
</template>
<script lang="ts">
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
@Component<SpecialAction>({
computed: {
income() {
return this.action.includes(",") ? this.action.split(",") : this.action.split("-");
},
},
})
export default class SpecialAction extends Vue {
@Prop()
disabled: boolean;
@Prop()
action: string;
onClick() {
if (!this.highlighted) {
return;
}
this.$store.dispatch("actionClick", this.action);
}
get highlighted() {
return this.$store.state.context.highlighted.actions.has(this.action);
import { Component } from "vue-property-decorator";
import CurrentAction from "../../../viewer/src/components/SpecialAction.vue";
@Component
export default class SpecialAction extends CurrentAction {
get lines() {
return this.income.split(",");
}
}
</script>
<style lang="scss">
g {
&.specialAction {
&.old-special-action {
polygon {
stroke: #333;
stroke-width: 0.02;

View file

@ -1,6 +1,6 @@
<template>
<svg
:class="['techTile', { highlighted, covered }]"
:class="['old-tech-tile', { highlighted, covered }]"
v-show="this.count"
v-b-tooltip
:title="tooltip"
@ -16,78 +16,30 @@
</template>
<script lang="ts">
import { AdvTechTilePos, Event, PlayerEnum, TechTilePos } from "@gaia-project/engine";
import { techTileEvents } from "@gaia-project/engine/src/tiles/techs";
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { eventDesc } from "../data/event";
@Component<TechTile>({
computed: {
tileObject() {
return this.$store.state.data.tiles.techs[this.pos];
},
tile() {
return this.tileObject.tile;
},
count() {
if (this.player !== undefined) {
return 1;
}
return this.tileObject.count;
},
rawContent() {
return techTileEvents(this.tile)[0].toString();
},
content() {
const val = this.rawContent;
return val.length > 10 && val[0] !== "=" ? val.replace(/ /g, "") : val;
},
title() {
// Only show count if there are more players than tech tiles available
if (this.count > 1 && this.$store.state.data.players.length > 4) {
return `${this.pos} (${this.count})`;
}
return this.pos;
},
tooltip() {
return eventDesc(new Event(this.rawContent));
},
},
})
export default class TechTile extends Vue {
@Prop()
pos: TechTilePos | AdvTechTilePos;
@Prop()
player: PlayerEnum;
@Prop()
covered: boolean;
onClick() {
if (this.highlighted) {
this.$store.dispatch("techClick", this.pos);
}
import { spaceshipTechSpec } from "@gaia-project/engine/src/tiles/spaceship-techs";
import { Component } from "vue-property-decorator";
import CurrentTechTile from "../../../viewer/src/components/TechTile.vue";
import { eventDesc } from "../../../viewer/src/data/event";
@Component
export default class TechTile extends CurrentTechTile {
get rawContent() {
return this.event?.toString() ?? "";
}
get highlighted() {
return this.$store.state.context.highlighted.techs.has(this.pos);
get content() {
return this.isRangeTile ? "+1 range" : this.isTerraformMineTile ? "2step + mine" : this.rawContent;
}
get title() {
return this.pos;
}
get tooltip() {
return spaceshipTechSpec[this.tile] ?? (this.event ? eventDesc(this.event, this.engine.expansions, true) : "");
}
}
</script>
<style lang="scss">
svg {
&.techTile {
&.old-tech-tile {
polygon {
stroke: #333;
stroke-width: 1px;
@ -96,10 +48,13 @@ svg {
.title {
font-size: 10px;
font-weight: bold;
fill: #212529;
text-anchor: start;
pointer-events: none;
}
.content {
font-size: 11px;
fill: #212529;
pointer-events: none;
&.smaller {

View file

@ -1,27 +1,2 @@
import { Planet } from "@gaia-project/engine";
export default {
[Planet.Swamp]: { radius: 0.65, color: "#523A00", borderColor: "#874d12" },
[Planet.Desert]: { radius: 0.65, color: "#F2FF00", borderColor: "#c1a925" },
[Planet.Terra]: { radius: 0.65, color: "#2080f0", borderColor: "#3399ff" },
[Planet.Volcanic]: { radius: 0.65, color: "#ffa135", borderColor: "#ff0000" },
[Planet.Oxide]: { radius: 0.65, color: "#FF160A", borderColor: "#ff8566" },
[Planet.Titanium]: { radius: 0.65, color: "#808080", borderColor: "#d1d1e0" },
[Planet.Ice]: { radius: 0.65, color: "#F8FFF5", borderColor: "#00c2c2" },
[Planet.Gaia]: { radius: 0.65, color: "#009933", borderColor: "#004d1a" },
[Planet.Transdim]: { radius: 0.5, color: "#a64dff", borderColor: "#a64dff" },
[Planet.Lost]: { radius: 0.5, color: "#000033", borderColor: "#ccccff" },
};
export const planetNames = {
[Planet.Swamp]: "Swamp",
[Planet.Desert]: "Desert",
[Planet.Terra]: "Terra",
[Planet.Volcanic]: "Volcanic",
[Planet.Oxide]: "Oxide",
[Planet.Titanium]: "Titanium",
[Planet.Ice]: "Ice",
[Planet.Gaia]: "Gaia",
[Planet.Transdim]: "Transdim",
[Planet.Lost]: "Lost planet",
};
export * from "../../../viewer/src/data/planets";
export { default } from "../../../viewer/src/data/planets";

59
old-ui/src/game.spec.ts Normal file
View file

@ -0,0 +1,59 @@
import Engine from "@gaia-project/engine";
import Vue from "vue";
import { loadScenarioEngine, selfContainedScenarios } from "../../viewer/src/self-contained-scenarios";
import launch from "./launcher";
describe("old UI on the current engine", () => {
beforeAll(() => {
const Observer = class {
observe() {}
disconnect() {}
unobserve() {}
};
vi.stubGlobal("IntersectionObserver", Observer);
vi.stubGlobal("ResizeObserver", Observer);
});
afterAll(() => vi.unstubAllGlobals());
for (const id of ["base", ...selfContainedScenarios.map((s) => s.id)]) {
it(`renders the actual old player/map components and current controls for ${id}`, async () => {
const host = document.createElement("div");
host.id = "old-test";
document.body.append(host);
const viewer = launch("#old-test");
try {
const engine =
id === "base"
? new Engine(["init 3 old-test", "p1 faction terrans", "p2 faction nevlas", "p3 faction firaks"])
: loadScenarioEngine(id);
viewer.emit("state", JSON.parse(JSON.stringify(engine)));
viewer.emit("chat:state", { canSend: true });
viewer.emit("chat:messages", [{ author: "Teammate", text: "Ready to explore" }]);
await Vue.nextTick();
expect(viewer.app.$el.querySelector(".old-ui-game")).not.toBeNull();
expect(viewer.app.$el.querySelector(".old-map-canvas")).not.toBeNull();
expect(viewer.app.$el.querySelector(".old-building")).not.toBeNull();
expect(viewer.app.$el.querySelectorAll(".player-board").length).toBe(engine.players.length);
if (engine.options.lostFleet)
expect(viewer.app.$el.querySelectorAll(".lost-fleet-ship").length).toBe(engine.players.length === 2 ? 3 : 4);
expect(viewer.app.$el.querySelector(".pool .old-booster")).not.toBeNull();
expect(viewer.app.$el.querySelector(".pool .booster")).toBeNull();
expect(viewer.app.$el.querySelector(".old-research-panel .scoringTile")).toBeNull();
if (engine.options.lostFleet) {
expect(viewer.app.$el.querySelectorAll(".old-ship-action").length).toBe(
(engine.players.length === 2 ? 3 : 4) * 3
);
}
const tiles = viewer.app.$el.querySelectorAll(".old-research-panel .old-tech-tile");
expect(tiles.length).toBeGreaterThanOrEqual(15);
expect(tiles[0].textContent.trim().length).toBeGreaterThan(3);
for (const action of viewer.app.$el.querySelectorAll(".old-board-action")) {
expect(action.getAttribute("transform")).toMatch(/^translate\(/);
}
expect(document.querySelector(".bgs-game-chat")?.textContent).toContain("Ready to explore");
} finally {
viewer.app.$destroy();
document.body.replaceChildren();
}
});
}
});

View file

@ -1,6 +1 @@
import { Faction, factionPlanet } from "@gaia-project/engine";
import planets from "../data/planets";
export function factionColor(faction: Faction): string {
return planets[factionPlanet(faction)].color;
}
export { factionColor } from "../../../viewer/src/graphics/utils";

View file

@ -1,97 +1,5 @@
import BootstrapVue from "bootstrap-vue";
import { EventEmitter } from "events";
import Vue from "vue";
import type { VueConstructor } from "vue/types/umd";
import { Store } from "vuex";
import launchCurrent from "../../viewer/src/launcher";
import Game from "./components/Game.vue";
import { makeStore } from "./store";
Vue.use(BootstrapVue);
function launch(selector: string, component: VueConstructor<Vue> = Game) {
const store = makeStore();
const app = new Vue({
store,
render: (h) => h("div", { class: "container-fluid py-2" }, [h(component)]),
}).$mount(selector);
const item: EventEmitter & { store?: Store<unknown>; app?: Vue } = new EventEmitter();
let replaying = false;
item.addListener("state", (data) => {
store.dispatch("externalData", data);
item.emit("replaceLog", data?.moveHistory);
app.$nextTick().then(() => item.emit("ready"));
});
item.addListener("state:updated", () => {
if (!replaying) {
item.emit("fetchState");
}
});
item.addListener("preferences", (data) => store.commit("preferences", data));
item.addListener("player", (data) => store.commit("player", data));
item.addListener("replay:start", () => {
store.dispatch("replayStart");
replaying = true;
});
item.addListener("replay:to", (info) => {
store.dispatch("replayTo", info);
item.emit("replaceLog", store.state.data.moveHistory);
});
item.addListener("replay:end", () => {
store.dispatch("replayEnd");
replaying = false;
item.emit("fetchState");
});
item.addListener("gamelog", (logData) => {
if (replaying) {
//
} else {
store.dispatch("externalData", logData.data.state);
item.emit("replaceLog", logData.data.state?.moveHistory);
}
});
const unsub1 = store.subscribeAction(({ type, payload }) => {
// console.log("spy action", type, payload);
if (type === "move") {
item.emit("move", payload);
return;
}
if (type === "playerClick") {
item.emit("player:clicked", {
name: payload.name,
auth: payload.auth,
index: (store as Store<any>).state.data?.players?.findIndex((pl) => pl === payload),
});
}
if (type === "replayInfo") {
item.emit("replay:info", payload);
}
});
const unsub2 = store.subscribe(({ type, payload }) => {
// console.log("spy mutation", type, payload);
if (type === "info" || type === "error") {
item.emit(type, payload);
}
});
app.$once("hook:beforeDestroy", () => {
unsub1();
unsub2();
});
item.store = store;
item.app = app;
return item;
export default function launch(selector: string) {
return launchCurrent(selector, Game);
}
export default launch;

View file

@ -1,12 +1,2 @@
import launch from "./launcher";
import launchSelfContained from "./self-contained";
console.log(process.env);
if (process.env.VUE_APP_BGIO) {
launch("#app");
} /* if (process.env.VUE_APP_SelfContained || 1) */ else {
launchSelfContained();
} /* else {
launch("#app");
} */
launchSelfContained();

View file

@ -1,39 +1,5 @@
import Engine from "@gaia-project/engine";
import run from "../../viewer/src/self-contained";
import Game from "./components/Game.vue";
import Wrapper from "./components/Wrapper.vue";
import launch from "./launcher";
function launchSelfContained(selector = "#app", debug = true) {
const emitter = launch(selector, debug ? Wrapper : Game);
let engine = new Engine();
const unsub = emitter.store.subscribeAction(({ payload, type }) => {
if (type === "loadFromJSON") {
const egData: Engine = payload;
engine = new Engine(egData.moveHistory, egData.options);
engine.generateAvailableCommandsIfNeeded();
emitter.emit("state", JSON.parse(JSON.stringify(engine)));
}
});
emitter.app.$once("hook:beforeDestroy", unsub);
emitter.on("move", (move: string) => {
console.log("executing move", move);
const copy = Engine.fromData(JSON.parse(JSON.stringify(engine)));
if (move) {
copy.move(move);
copy.generateAvailableCommandsIfNeeded();
// Only save updated version if a full turn was done
if (copy.newTurn) {
engine = copy;
}
}
emitter.emit("state", JSON.parse(JSON.stringify(copy)));
});
export default function launchSelfContained(selector = "#app", debug = true) {
return run(selector, debug, Game);
}
export default launchSelfContained;

View file

@ -1,134 +1 @@
import Engine, {
AdvTechTilePos,
Booster,
Federation,
GaiaHex,
Player,
ResearchField,
TechTilePos,
} from "@gaia-project/engine";
import { CubeCoordinates } from "hexagrid";
import Vue from "vue";
import Vuex from "vuex";
import { GameContext } from "./data";
Vue.use(Vuex);
const gaiaViewer = {
state: {
data: new Engine(),
context: {
highlighted: {
hexes: new Map(),
researchTiles: new Set(),
techs: new Set(),
boosters: new Set(),
actions: new Set(),
federations: new Set(),
},
rotation: new Map(),
hexSelection: false,
activeButton: null,
} as GameContext,
preferences: {
noFactionFill: false,
},
player: null as { index?: number; auth?: string } | null,
},
mutations: {
receiveData(state, data: Engine) {
state.data = data;
state.context.rotation = new Map();
},
highlightHexes(state, hexes: Map<GaiaHex, { cost?: string }>) {
state.context.highlighted.hexes = hexes;
},
highlightResearchTiles(state, tiles: string[]) {
state.context.highlighted.researchTiles = new Set(tiles);
},
highlightTechs(state, techs: Array<TechTilePos | AdvTechTilePos>) {
state.context.highlighted.techs = new Set(techs);
},
highlightBoosters(state, boosters: Booster[]) {
state.context.highlighted.boosters = new Set(boosters);
},
highlightActions(state, actions: string[]) {
state.context.highlighted.actions = new Set(actions);
},
highlightFederations(state, federations: Federation[]) {
state.context.highlighted.federations = new Set(federations);
},
selectHexes(state, defaultHexes) {
state.context.hexSelection = true;
state.context.highlighted.hexes = new Map(defaultHexes || []);
},
rotate(state, coords: CubeCoordinates) {
const coordsStr = `${coords.q}x${coords.r}`;
state.context.rotation.set(coordsStr, (state.context.rotation.get(coordsStr) || 0) + 1);
state.context.rotation = new Map(state.context.rotation.entries());
},
clearContext(state) {
state.context.highlighted.hexes = new Map();
state.context.highlighted.researchTiles = new Set();
state.context.highlighted.techs = new Set();
state.context.highlighted.boosters = new Set();
state.context.highlighted.actions = new Set();
state.context.highlighted.federations = new Set();
// state.context.rotation = new Map();
state.context.hexSelection = false;
state.context.activeButton = null;
},
activeButton(state, button) {
state.context.activeButton = button;
},
preferences(state, preferences) {
state.preferences = preferences;
},
player(state, data) {
state.player = data;
},
},
actions: {
// No body, used for signalling with store.subscribeAction
hexClick(context, hex: GaiaHex) {},
researchClick(context, field: ResearchField) {},
techClick(context, pos: TechTilePos | AdvTechTilePos) {},
boosterClick(context, booster: Booster) {},
actionClick(context, action: string) {},
federationClick(context, federation: Federation) {},
confirmClick(context, action: string) {},
// API COMMUNICATION
playerClick(context, player: Player) {},
move(context, move: string) {},
replayInfo(context, info: { start: number; end: number; current: number }) {},
// ^ up - down v
externalData(context, data: Engine) {},
replayStart(context) {},
replayTo(context, to: number) {},
replayEnd(context, data: Engine) {},
// WRAPPER / DEBUG COMMUNICATION
loadFromJSON(context, data: any) {},
},
getters: {},
};
function makeStore() {
return new Vuex.Store(gaiaViewer);
}
export default makeStore();
export { gaiaViewer, makeStore };
export * from "../../viewer/src/store";

17
old-ui/vite.config.ts Normal file
View file

@ -0,0 +1,17 @@
import { fileURLToPath } from "node:url";
import shared from "../viewer/vite.config";
export default {
...shared,
root: fileURLToPath(new URL(".", import.meta.url)),
build: {
...shared.build,
outDir: "dist/package",
lib: {
entry: fileURLToPath(new URL("src/wrapper.ts", import.meta.url)),
name: "gaiaOldViewerLib",
formats: ["iife"],
fileName: () => "old-ui.umd.js",
cssFileName: "old-ui",
},
},
};

7
old-ui/vitest.config.ts Normal file
View file

@ -0,0 +1,7 @@
import { fileURLToPath } from "node:url";
import shared from "../viewer/vitest.config";
export default {
...shared,
root: fileURLToPath(new URL(".", import.meta.url)),
test: { ...shared.test, setupFiles: [fileURLToPath(new URL("../viewer/vitest.setup.ts", import.meta.url))] },
};

86
pnpm-lock.yaml generated
View file

@ -103,6 +103,73 @@ importers:
specifier: ^4.9.5
version: 4.9.5
old-ui:
dependencies:
'@gaia-project/engine':
specifier: workspace:../engine
version: link:../engine
'@gaia-project/viewer':
specifier: workspace:../viewer
version: link:../viewer
bootstrap:
specifier: ^4.4.1
version: 4.6.2(jquery@3.7.1)(popper.js@1.16.1)
bootstrap-vue:
specifier: ^2.12.0
version: 2.23.1(jquery@3.7.1)(vue@2.7.16)
events:
specifier: ^3.3.0
version: 3.3.0
hexagrid:
specifier: ^2.1.1
version: 2.1.1
lodash:
specifier: ^4.17.15
version: 4.18.1
vue:
specifier: ^2.7.16
version: 2.7.16
vuex:
specifier: ^3.0.1
version: 3.6.2(vue@2.7.16)
devDependencies:
'@testing-library/vue':
specifier: ^5.9.0
version: 5.9.0(vue-template-compiler@2.7.16)(vue@2.7.16)
'@vitejs/plugin-vue2':
specifier: ^2.3.4
version: 2.3.4(vite@8.2.2(esbuild@0.28.2)(sass@1.102.0))(vue@2.7.16)
'@vue/test-utils':
specifier: ^1.1.3
version: 1.3.6(vue-template-compiler@2.7.16)(vue@2.7.16)
chai:
specifier: ^4.3.0
version: 4.5.0
jsdom:
specifier: ^30.0.1
version: 30.0.1
sass:
specifier: ^1.32.8
version: 1.102.0
typescript:
specifier: ^3.8.3
version: 3.9.10
vite:
specifier: ^8.2.2
version: 8.2.2(@types/node@10.17.60)(esbuild@0.28.2)(sass@1.102.0)
vitest:
specifier: ^4.1.11
version: 4.1.11(@types/node@10.17.60)(@vitest/coverage-v8@4.1.11)(jsdom@30.0.1)(vite@8.2.2(@types/node@10.17.60)(esbuild@0.28.2)(sass@1.102.0))
vue-class-component:
specifier: ^7.2.6
version: 7.2.6(vue@2.7.16)
vue-property-decorator:
specifier: ^9.1.2
version: 9.1.2(vue-class-component@7.2.6(vue@2.7.16))(vue@2.7.16)
vue-template-compiler:
specifier: ^2.7.16
version: 2.7.16
viewer:
dependencies:
'@gaia-project/engine':
@ -162,7 +229,7 @@ importers:
version: 2.34.0(eslint@6.8.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@3.9.10)
'@vitejs/plugin-vue2':
specifier: ^2.3.4
version: 2.3.4(vite@8.2.2(@types/node@10.17.60)(esbuild@0.28.2)(sass@1.102.0))(vue@2.7.16)
version: 2.3.4(vite@8.2.2(esbuild@0.28.2)(sass@1.102.0))(vue@2.7.16)
'@vitest/coverage-v8':
specifier: ^4.1.11
version: 4.1.11(vitest@4.1.11)
@ -1095,11 +1162,6 @@ packages:
'@volar/typescript@2.4.15':
resolution: {integrity: sha512-2aZ8i0cqPGjXb4BhkMsPYDkkuc2ZQ6yOpqwAuNwUoncELqoy5fRgOQtLR9gB0g902iS0NAkvpIzs27geVyVdPg==}
peerDependencies:
typescript: '*'
peerDependenciesMeta:
typescript:
optional: true
'@vue/cli-overlay@4.5.19':
resolution: {integrity: sha512-GdxvNSmOw7NHIazCO8gTK+xZbaOmScTtxj6eHVeMbYpDYVPJ+th3VMLWNpw/b6uOjwzzcyKlA5dRQ1DAb+gF/g==}
@ -7544,7 +7606,7 @@ snapshots:
'@ungap/promise-all-settled@1.1.2': {}
'@vitejs/plugin-vue2@2.3.4(vite@8.2.2(@types/node@10.17.60)(esbuild@0.28.2)(sass@1.102.0))(vue@2.7.16)':
'@vitejs/plugin-vue2@2.3.4(vite@8.2.2(esbuild@0.28.2)(sass@1.102.0))(vue@2.7.16)':
dependencies:
vite: 8.2.2(@types/node@10.17.60)(esbuild@0.28.2)(sass@1.102.0)
vue: 2.7.16
@ -7572,7 +7634,7 @@ snapshots:
chai: 6.2.2
tinyrainbow: 3.1.1
'@vitest/mocker@4.1.11(vite@8.2.2(@types/node@10.17.60)(esbuild@0.28.2)(sass@1.102.0))':
'@vitest/mocker@4.1.11(vite@8.2.2(esbuild@0.28.2)(sass@1.102.0))':
dependencies:
'@vitest/spy': 4.1.11
estree-walker: 3.0.3
@ -7610,13 +7672,11 @@ snapshots:
'@volar/source-map@2.4.15': {}
'@volar/typescript@2.4.15(typescript@5.9.3)':
'@volar/typescript@2.4.15':
dependencies:
'@volar/language-core': 2.4.15
path-browserify: 1.0.1
vscode-uri: 3.1.0
optionalDependencies:
typescript: 5.9.3
'@vue/cli-overlay@4.5.19': {}
@ -14377,7 +14437,7 @@ snapshots:
vitest@4.1.11(@types/node@10.17.60)(@vitest/coverage-v8@4.1.11)(jsdom@30.0.1)(vite@8.2.2(@types/node@10.17.60)(esbuild@0.28.2)(sass@1.102.0)):
dependencies:
'@vitest/expect': 4.1.11
'@vitest/mocker': 4.1.11(vite@8.2.2(@types/node@10.17.60)(esbuild@0.28.2)(sass@1.102.0))
'@vitest/mocker': 4.1.11(vite@8.2.2(esbuild@0.28.2)(sass@1.102.0))
'@vitest/pretty-format': 4.1.11
'@vitest/runner': 4.1.11
'@vitest/snapshot': 4.1.11
@ -14519,7 +14579,7 @@ snapshots:
vue-tsc@2.2.12(typescript@5.9.3):
dependencies:
'@volar/typescript': 2.4.15(typescript@5.9.3)
'@volar/typescript': 2.4.15
'@vue/language-core': 2.2.12(typescript@5.9.3)
typescript: 5.9.3

View file

@ -1,6 +1,7 @@
packages:
- "viewer"
- "engine"
- "old-ui"
# pnpm 11 (resolved via corepack in CI) blocks dependency postinstall scripts by default.
# These are all no-op or cosmetic (core-js/ejs banners, an optional native watcher);
# allow them so `pnpm install` exits 0.

View file

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

View file

@ -1,6 +1,7 @@
import Engine, { Expansion, Faction } from "@gaia-project/engine";
import { render } from "@testing-library/vue";
import { expect } from "chai";
import Vue from "vue";
import { makeStore } from "../store";
import FactionInfoCard from "./FactionInfoCard.vue";
@ -84,4 +85,23 @@ describe("FactionInfoCard", () => {
expect(container.textContent).to.include("build a mine on a planet colonized by an opponent");
});
it("refreshes both the modal costs and its player board when another faction is chosen", async () => {
const engine = new Engine(["init 3 live-terraform-preview"], { lostFleet: true });
const store = makeStore();
store.commit("receiveData", engine);
const { container } = render(FactionInfoCard, {
props: { faction: Faction.Moweyds, variant: null, expansion: Expansion.LostFleet },
store,
});
const before = container.querySelector(".player-board")!.outerHTML;
const next = Engine.fromData(JSON.parse(JSON.stringify(engine)));
next.move("p1 faction nevlas");
store.commit("receiveData", next);
await Vue.nextTick();
await Vue.nextTick();
expect(container.querySelectorAll(".faction-info-card__swatch--cost3").length).to.equal(3);
const white = next.lostFleetTerraformingRow.indexOf("i" as any);
expect(container.querySelectorAll(".faction-info-card__swatch")[white].textContent!.trim()).to.equal("3");
expect(container.querySelector(".player-board")!.outerHTML).not.to.equal(before);
});
});

View file

@ -138,7 +138,7 @@ import Engine, {
import type { FactionBoardRaw } from "@gaia-project/engine/src/faction-boards";
import { lostFleetTerraformingBoard } from "@gaia-project/engine/src/factions";
import Vue, { markRaw } from "vue";
import { Component, Prop } from "vue-property-decorator";
import { Component, Prop, Watch } from "vue-property-decorator";
import type { BuildingSpecialAction, Conversion, TinkeringRound } from "../data/faction-overview";
import {
baseFactionLostFleetChanges,
@ -194,6 +194,11 @@ class FactionBoardPreview extends Vue {
@Prop()
player: Player;
@Watch("engine")
updatePreview(engine: Engine) {
this.$store.commit("receiveData", engine);
}
beforeCreate() {
const store = makeStore();
const engine = (this.$options.propsData as { engine?: Engine })?.engine;
@ -224,10 +229,6 @@ export default class FactionInfoCard extends Vue {
@Prop()
expansion: Expansion;
// Built once and shared between the board and every supplemental getter. markRaw keeps Vue from
// deep-observing the large engine graph (it is read-only display data that never mutates here).
private engineInstance: Engine | null = null;
get PI(): BuildingEnum {
return BuildingEnum.PlanetaryInstitute;
}
@ -235,17 +236,11 @@ export default class FactionInfoCard extends Vue {
// A self-contained preview engine (round-1, no buildings placed) read purely as data - the source
// for the reused board and for all supplemental costs below.
get previewEngine(): Engine {
if (!this.engineInstance) {
const engine = markRaw(factionPreviewEngine(this.faction));
// The preview's own cost-3 terraforming set is computed against a throwaway filler opponent and
// the preview seed, so it would contradict the real 7-colour row we show. Replace it with the
// set computed from the live game's board + opponents so the board markers and swatches agree.
if (terraformCostDependsOnFactions(this.faction)) {
engine.players[0].data.lostFleetCost3Planets = this.cost3Set;
}
this.engineInstance = engine;
const engine = markRaw(factionPreviewEngine(this.faction));
if (terraformCostDependsOnFactions(this.faction)) {
engine.players[0].data.lostFleetCost3Planets = this.cost3Set;
}
return this.engineInstance;
return engine;
}
// Live-game terraforming row (the 7 swatches) and the cost-3 subset for this faction.
@ -342,7 +337,7 @@ export default class FactionInfoCard extends Vue {
}
const engine = this.$store.state.data as Engine;
const seed = engine ? gameSeed(engine) : undefined;
return seed ? lostFleetTerraformingBoard(seed) : [];
return engine?.lostFleetTerraformingRow ?? (seed ? lostFleetTerraformingBoard(seed) : []);
}
get terraformNote(): string | null {

View file

@ -455,7 +455,7 @@ export default class PlayerInfo extends Vue {
if (!this.isLostFleet) {
return [];
}
return lostFleetTerraformingBoard(gameSeed(this.engine));
return this.engine.lostFleetTerraformingRow ?? lostFleetTerraformingBoard(gameSeed(this.engine));
}
planetsWithSteps(steps: number) {

View file

@ -0,0 +1,49 @@
import Engine, { AuctionVariant, Faction, Planet } from "@gaia-project/engine";
import { expect } from "chai";
import { terraformCost3Set } from "./faction-overview";
const row = [Planet.Volcanic, Planet.Ice, Planet.Titanium, Planet.Desert, Planet.Oxide, Planet.Terra, Planet.Swamp];
describe("auction terraforming previews", () => {
it("counts Nevlas while temporarily unowned and agrees with completed setup", () => {
const engine = new Engine(
[
"init 4 Foreign-gecko-8667",
"p1 faction lantids",
"p2 faction nevlas",
"p3 faction firaks",
"p4 faction moweyds",
"p1 bid lantids 8",
"p2 bid firaks 0",
"p3 bid firaks 1",
"p4 bid lantids 9",
"p1 bid lantids 10",
"p2 bid moweyds 0",
"p4 bid firaks 2",
"p3 bid moweyds 1",
],
{ lostFleet: true, auction: AuctionVariant.ChooseBid }
);
expect(engine.players.some((pl) => pl.faction === Faction.Nevlas)).to.equal(false);
const costs = terraformCost3Set(engine, Faction.Moweyds, row);
expect(costs).to.have.members([Planet.Terra, Planet.Ice, Planet.Titanium]);
expect(costs).not.to.include(Planet.Volcanic);
engine.move("p2 bid nevlas 0");
expect(engine.players.find((pl) => pl.faction === Faction.Moweyds).data.lostFleetCost3Planets).to.have.members(
costs
);
});
it("keeps both special factions in setup order even when seat ownership is reversed", () => {
const engine = new Engine(["init 3 preview-order"], { lostFleet: true });
engine.setup = [Faction.Tinkeroids, Faction.Nevlas, Faction.Moweyds];
engine.players[0].faction = Faction.Moweyds;
engine.players[2].faction = Faction.Tinkeroids;
expect(terraformCost3Set(engine, Faction.Tinkeroids, row)).to.have.members([
Planet.Ice,
Planet.Volcanic,
Planet.Titanium,
]);
expect(terraformCost3Set(engine, Faction.Moweyds, row)).to.have.members([Planet.Ice, Planet.Desert, Planet.Oxide]);
});
});

View file

@ -172,12 +172,11 @@ export function terraformCost3Set(engine: Engine, faction: Faction, board: Plane
return existing.data.lostFleetCost3Planets;
}
const opponents = engine.players
.filter((pl) => pl.faction && pl.faction !== faction)
.map((pl) => ({ player: pl.player, faction: pl.faction }));
const specialId = engine.players.length as PlayerEnum;
const players = [...opponents, { player: specialId, faction }];
const turnOrder = [...opponents.map((pl) => pl.player), specialId];
// Auction bids change ownership, not the chosen lineup or its terraforming order.
const lineup = [...new Set([...engine.setup, ...engine.players.map((pl) => pl.faction), faction])].filter(Boolean);
const players = lineup.map((faction, player) => ({ player: player as PlayerEnum, faction }));
const specialId = lineup.indexOf(faction) as PlayerEnum;
const turnOrder = players.map((pl) => pl.player);
const map = lostFleetTerraformingCost3Planets(players, turnOrder, board);
return map[specialId] ?? [];

View file

@ -7,6 +7,7 @@ import Game from "./components/Game.vue";
import Resource from "./components/Resource.vue";
import TechContent from "./components/TechContent.vue";
import { mountGameChat } from "./game-chat";
import { installBoardTouch } from "./logic/board-touch";
import { installActionSounds } from "./sounds";
import { makeStore } from "./store";
@ -15,22 +16,6 @@ Vue.component("Condition", Condition);
Vue.component("TechContent", TechContent);
Vue.component("Resource", Resource);
// iOS Safari (and older mobile Chrome) only emits `mouseenter`/`:hover` on the first tap of a
// session if some element on the page already has a click listener bound - otherwise the first
// tap on any `.hover`-triggered tooltip (v-b-tooltip) is swallowed and only the *second* tap
// (after tapping something else first) shows it. Binding a no-op touchstart listener up front
// arms hover emulation immediately, so the very first tap on any tooltip target works.
if (typeof document !== "undefined") {
// The lib may be loaded from <head> (e.g. the platform's iframe wrapper), where document.body
// does not exist yet at module evaluation time.
const armHoverEmulation = () => document.body.addEventListener("touchstart", () => undefined, true);
if (document.body) {
armHoverEmulation();
} else {
document.addEventListener("DOMContentLoaded", armHoverEmulation);
}
}
// The boardgamers.space host page signals dark mode by toggling the "dark" class on <html>
// (live, via postMessage - see the platform's iframe wrapper). The component styles inherited
// from the fork's theming system read their colors from CSS custom properties scoped under
@ -63,7 +48,7 @@ function launch(selector: string, component: VueConstructor<Vue> = Game) {
render: (h) => h("div", { class: "container-fluid py-2" }, [h(component)]),
}).$mount(selector);
// Tooltips also carry `.click` (see the touchstart-arm comment above this function) so a first
// Touch tooltips open on click, so a first
// tap always shows one, but that means a click-opened tooltip no longer auto-hides on its own
// the way a hover-only one did when the pointer moved elsewhere - tapping a different component
// left the previous one stuck open. A capture-phase listener fires before the newly-tapped
@ -95,6 +80,9 @@ function launch(selector: string, component: VueConstructor<Vue> = Game) {
);
}
const removeBoardTouch = installBoardTouch(app.$el, () => app.$emit("bv::hide::tooltip"));
app.$once("hook:beforeDestroy", removeBoardTouch);
const item: EventEmitter & { store: typeof store; app: Vue } = Object.assign(new EventEmitter(), { store, app });
installActionSounds(item);

View file

@ -0,0 +1,42 @@
import { installBoardTouch } from "./board-touch";
describe("board swipes", () => {
function touch(root: Element, type: string, x = 0, y = 0) {
const event = new Event(type, { bubbles: true, cancelable: true });
Object.defineProperty(event, "touches", { value: [{ clientX: x, clientY: y }] });
root.dispatchEvent(event);
return event;
}
it("dismisses a tooltip once per swipe without cancelling native scrolling", () => {
const root = document.createElement("div");
const dismiss = vi.fn();
const listen = vi.spyOn(root, "addEventListener");
const remove = installBoardTouch(root, dismiss);
expect(listen.mock.calls.every((call) => (call[2] as AddEventListenerOptions).passive)).toBe(true);
touch(root, "touchstart", 20, 50);
expect(touch(root, "touchmove", 20, 55).defaultPrevented).toBe(false);
expect(dismiss).not.toHaveBeenCalled();
expect(touch(root, "touchmove", 20, 80).defaultPrevented).toBe(false);
touch(root, "touchmove", 20, 100);
expect(dismiss).toHaveBeenCalledTimes(1);
remove();
touch(root, "touchstart");
touch(root, "touchmove", 0, 100);
expect(dismiss).toHaveBeenCalledTimes(1);
});
it("leaves tap tooltips alone and resets after a cancelled gesture", () => {
const root = document.createElement("div");
const dismiss = vi.fn();
const remove = installBoardTouch(root, dismiss);
touch(root, "touchstart");
touch(root, "touchend");
touch(root, "touchmove", 0, 100);
touch(root, "touchstart");
touch(root, "touchcancel");
touch(root, "touchmove", 0, 100);
expect(dismiss).not.toHaveBeenCalled();
remove();
});
});

View file

@ -0,0 +1,29 @@
// Tooltips must not sit over a board while a finger is scrolling it.
export function installBoardTouch(root: Element, dismiss: () => void): () => void {
let start: { x: number; y: number } | undefined;
const onStart = (event: TouchEvent) => {
const touch = event.touches[0];
start = touch ? { x: touch.clientX, y: touch.clientY } : undefined;
};
const onMove = (event: TouchEvent) => {
const touch = event.touches[0];
if (start && touch && Math.hypot(touch.clientX - start.x, touch.clientY - start.y) > 8) {
start = undefined;
dismiss();
}
};
const onEnd = () => {
start = undefined;
};
const options = { capture: true, passive: true };
root.addEventListener("touchstart", onStart, options);
root.addEventListener("touchmove", onMove, options);
root.addEventListener("touchend", onEnd, options);
root.addEventListener("touchcancel", onEnd, options);
return () => {
root.removeEventListener("touchstart", onStart, true);
root.removeEventListener("touchmove", onMove, true);
root.removeEventListener("touchend", onEnd, true);
root.removeEventListener("touchcancel", onEnd, true);
};
}

View file

@ -124,8 +124,9 @@ function returnToOfflineLobby(reason: string): void {
window.location.replace(url.toString());
}
function launchSelfContained(selector = "#app", debug = true) {
const emitter = launch(selector, debug ? Wrapper : Game);
function launchSelfContained(selector = "#app", debug = true, gameComponent = Game) {
const localWrapper = Wrapper.extend({ components: { Game: gameComponent } });
const emitter = launch(selector, debug ? localWrapper : gameComponent);
mountSoundTests(emitter);
installLocalChat(emitter);

View file

@ -168,3 +168,15 @@ body {
display: none !important;
}
}
@media (pointer: coarse) {
.gaia-viewer-game svg {
touch-action: pan-y pinch-zoom;
user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none;
}
.tooltip {
pointer-events: none;
}
}