🎉 (old-ui) Add old-ui to repo

This commit is contained in:
coyotte508 2021-05-18 00:23:27 +02:00
commit dbd1e840e0
65 changed files with 14630 additions and 53 deletions

39
.github/workflows/old-ui-publish.yml vendored Normal file
View file

@ -0,0 +1,39 @@
name: Old UI - Version and Release
on:
workflow_dispatch:
inputs:
newversion:
description: "Semantic Version Bump Type (major minor patch)"
default: patch
env:
node_version: 14
defaults:
run:
working-directory: old-ui
jobs:
version_and_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.node_version }}
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v1.2.1
with:
version: 5.17.1
- run: pnpm install
- run: git config --global user.name github-actions
- run: git config --global user.email bot@github.com
- run: yarn config set version-git-message "🔖 (old-ui) v%s"
- run: yarn version --${{ github.event.inputs.newversion }}
- run: pnpm publish .
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: git push --follow-tags

32
.github/workflows/old-ui-test.yml vendored Normal file
View file

@ -0,0 +1,32 @@
name: Old UI - Test
on:
push:
paths:
- ".github/workflows/old-ui-test.yml"
- "viewer/**"
branches:
- master
pull_request:
paths:
- ".github/workflows/old-ui-test.yml"
- "viewer/**"
defaults:
run:
working-directory: old-ui
jobs:
test_and_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14"
- uses: pnpm/action-setup@v1.2.1
with:
version: 5.17.1
- run: pnpm install
- run: pnpm lint
# - run: pnpm test
- run: pnpm build

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2018 donkeytech
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -5,7 +5,7 @@
"main": "dist/index.js",
"types": "index.ts",
"source": "index.ts",
"repository": "git@github.com:donkeytech/gaia-engine.git",
"repository": "git@github.com:boardgamers-mono/gaia-project.git",
"publishConfig": {
"access": "public"
},

25
old-ui/.eslintrc.js Normal file
View file

@ -0,0 +1,25 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: ["plugin:vue/essential", "@vue/typescript/recommended"],
parserOptions: {
ecmaVersion: 2020,
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
semi: ["error", "always"],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-return-assign": "off",
"no-lone-blocks": "off",
"no-unmodified-loop-condition": "off",
"no-useless-return": "off",
quotes: "off",
},
};

9
old-ui/README.md Normal file
View file

@ -0,0 +1,9 @@
# gaia-viewer
A Vue.js / SVG UI for Gaia Project
**OLD UI**
## Demo
Check out [boardgamers.space](https://www.boardgamers.space)!

7
old-ui/index.ts Normal file
View file

@ -0,0 +1,7 @@
import Game from "./src/components/Game.vue";
import launch from "./src/launcher";
import launchSelfContained from "./src/self-contained";
import { gaiaViewer, makeStore } from "./src/store";
export { Game, gaiaViewer, makeStore, launchSelfContained };
export default launch;

69
old-ui/package.json Normal file
View file

@ -0,0 +1,69 @@
{
"name": "@gaia-project/old-ui",
"version": "1.0.0",
"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"
},
"repository": "git@github.com:boardgamers-mono/gaia-project.git",
"publishConfig": {
"access": "public"
},
"unpkg": "dist/package/viewer.umd.min.js",
"files": [
"index.ts",
"tsconfig.json",
"src",
"README.md",
"public",
"dist/package/viewer.umd.min.js",
"dist/package/viewer.css"
],
"dependencies": {
"@gaia-project/engine": "workspace:../engine",
"bootstrap": "^4.4.1",
"bootstrap-vue": "^2.12.0",
"vue": "^2.6.11",
"vuex": "^3.0.1"
},
"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": "^1.0.1",
"popper.js": "^1.16.1",
"sass": "^1.32.8",
"sass-loader": "^8.0.2",
"typescript": "^4.2.4",
"vue-property-decorator": "^8.4.1",
"vue-template-compiler": "^2.6.11",
"webpack": "^4.16.1"
},
"peerDependencies": {
"bootstrap-vue": "^2.12.0",
"vue": "^2.6.11"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
],
"license": "MIT",
"source": "index.ts"
}

9615
old-ui/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,020 B

BIN
old-ui/public/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 968 B

16
old-ui/public/index.html Normal file
View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="shortcut icon" type="image/png" id="favicon-gp" href="/favicon.png" />
<title>Gaia Project</title>
</head>
<body>
<noscript>
<strong>We are sorry, javascript is needed for the website.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

4
old-ui/shims.d.ts vendored Normal file
View file

@ -0,0 +1,4 @@
declare module "*.vue" {
import Vue from "vue";
export default Vue;
}

View file

@ -0,0 +1,103 @@
<template>
<div v-if="data.phase !== 'setupInit'">
<table class="table table-hover table-striped table-sm">
<!-- <thead>
<tr>
<th scope="col">Log</th>
<th scope="col">Victory points</th>
</tr>
</thead> -->
<tbody>
<tr class="major-event" v-if="data.phase === 'endGame'">
<td colspan="3">Game Ended</td>
</tr>
<tr v-for="(event, i) in history" :key="history.length - i">
<td v-if="event.entry.round" class="major-event">Round {{ event.entry.round }}</td>
<td v-else-if="event.entry.phase === 'roundIncome'" class="phase-change">Income phase</td>
<td v-else-if="event.entry.phase === 'roundGaia'" class="phase-change">Gaia phase</td>
<td v-else-if="event.entry.phase === 'endGame'" class="phase-change">End scoring</td>
<td v-else>{{ event.move || data.players[event.entry.player].faction }}</td>
<td style="width: 1px; white-space: nowrap">
<div
v-for="(changes, source, i) in event.entry.changes"
v-html="source === 'undefined' ? '&nbsp;' : source"
:key="i"
/>
</td>
<td style="width: 1px; white-space: nowrap">
<div v-for="(changes, source, i) in event.entry.changes" :key="i">
{{
Object.keys(changes)
.map((key) => `${changes[key]}${key}`)
.join(", ")
}}
</div>
</td>
</tr>
<tr class="major-event">
<td colspan="3">Game Started</td>
</tr>
</tbody>
</table>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import Engine, { LogEntry } from '@gaia-project/engine';
@Component({
computed: {
data () {
return this.$store.state.gaiaViewer.data;
},
history (): Array<{move: string; entry: LogEntry}> {
const ret = [];
let advancedLogIndex = 0;
let nextLogEntry = this.data.advancedLog[advancedLogIndex];
const bumpLog = () => {
advancedLogIndex += 1;
nextLogEntry = this.data.advancedLog[advancedLogIndex];
};
this.data.moveHistory.forEach((move, i) => {
while (nextLogEntry && (nextLogEntry.move === undefined || nextLogEntry.move < i)) {
if (nextLogEntry.player === undefined || !!nextLogEntry.changes) {
ret.push({ entry: nextLogEntry });
}
bumpLog();
}
const entry = { move, entry: {} as LogEntry };
if (nextLogEntry && nextLogEntry.move === i) {
entry.entry = nextLogEntry;
bumpLog();
}
ret.push(entry);
while (nextLogEntry && nextLogEntry.move === undefined) {
if (nextLogEntry.player === undefined || !!nextLogEntry.changes) {
ret.push({ entry: nextLogEntry });
}
bumpLog();
}
});
ret.reverse();
return ret;
}
}
})
export default class AdvancedLog extends Vue {
}
</script>
<style lang="scss" scoped>
.major-event {
font-weight: bold;
}
.phase-change {
font-style: italic;
}
</style>

View file

@ -0,0 +1,118 @@
<template>
<g :class="['boardAction', 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})`"
@click="onClick"
/>
<text :transform="`scale(${scale / 17})`">
<tspan
:x="i + 1 < income.length ? 1 : 0"
v-for="(line, i) in income"
:key="i"
:dy="`${i * 1.15 - (income.length - 1) / 4}em`"
>
{{ line.replace(/ /g, "") }}
</tspan>
</text>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, Event, BoardAction as BoardActionEnum, boardActions } from '@gaia-project/engine';
import { eventDesc } from '../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');
},
faded () {
return this.$store.state.gaiaViewer.data.boardActions[this.action] !== null;
},
kind () {
return this.action[0] === 'p' ? 'power' : 'qic';
},
income () {
return [].concat(...boardActions[this.action].income.map(x => {
if (x.includes('+')) {
return [x.slice(0, x.indexOf('+')), x.slice(x.indexOf('+'))];
}
return x.split('-');
}));
},
cost () {
return boardActions[this.action].cost;
}
}
})
export default class BoardAction extends Vue {
@Prop()
scale: number;
@Prop()
action: BoardActionEnum;
onClick () {
if (!this.highlighted) {
return;
}
this.$store.dispatch("gaiaViewer/actionClick", this.action);
}
get highlighted () {
return this.$store.state.gaiaViewer.context.highlighted.actions.has(this.action);
}
}
</script>
<style lang="scss">
g {
&.boardAction {
polygon {
stroke: #333;
stroke-width: 0.02;
fill: white;
}
&.qic {
polygon {
fill: green;
}
}
&.power {
polygon {
fill: purple;
}
}
text {
fill: white;
text-anchor: middle;
dominant-baseline: middle;
font-size: 12px;
pointer-events: none;
}
&.highlighted polygon {
stroke: #2c4;
cursor: pointer;
stroke-width: 0.08;
}
&.faded {
stroke-opacity: 0.5;
fill-opacity: 0.5;
}
}
}
</style>

View file

@ -0,0 +1,96 @@
<template>
<svg
:class="['booster', { highlighted, disabled }]"
v-b-tooltip
:title="tooltip"
@click="onClick"
width="76"
height="50"
viewBox="0 0 76 50"
>
<rect x="1" y="1" width="74" 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>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, Event } from '@gaia-project/engine';
import { eventDesc } from '../data/event';
@Component<Booster>({
computed: {
tileObject () {
return tiles.boosters[this.booster];
},
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("gaiaViewer/boosterClick", this.booster);
}
}
get highlighted () {
return this.$store.state.gaiaViewer.context.highlighted.boosters.has(this.booster);
}
}
</script>
<style lang="scss">
svg {
&.booster {
rect {
stroke: #333;
stroke-width: 1px;
fill: white;
}
.title {
font-size: 10px;
font-weight: bold;
pointer-events: none;
}
.event1,
.event2 {
font-size: 12px;
pointer-events: none;
}
&.highlighted rect {
stroke: #2c4;
cursor: pointer;
}
&.disabled {
stroke-opacity: 0.5;
fill-opacity: 0.7;
}
}
}
</style>

View file

@ -0,0 +1,70 @@
<template>
<g :class="['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" />
<circle v-else-if="lab" r="0.3" />
<circle v-else-if="academy" r="0.5" />
<polygon
v-else-if="tradingStation"
points="-0.2,-0.2 0,-0.38 0.2,-0.2 0.2,0.2 -0.2,0.2"
transform="translate(0, 0.08)"
/>
<Token v-else-if="spaceStation" :faction="faction" :scale="0.3" />
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { factions, Faction, Building as BuildingEnum, Planet } from '@gaia-project/engine';
import { corners } from '../graphics/hex';
import Token from './Token.vue';
@Component({
components: {
Token
}
})
export default class Building extends Vue {
@Prop()
faction: Faction;
@Prop()
building: BuildingEnum;
get planet () {
return (this.faction as any === "wild") ? Planet.Transdim : factions.planet(this.faction);
}
get hexCorners () {
return corners().map(({ x, y }) => `${x * 0.4},${y * 0.4}`).join(" ");
}
get triangleCorners () {
return [{ x: -0.5, y: Math.sqrt(3) / 4 }, { x: 0.5, y: Math.sqrt(3) / 4 }, { x: 0, y: -Math.sqrt(3) / 4 }].map(({ x, y }) => `${x * 0.5},${y * 0.5}`).join(" ");
}
get mine () { return this.building === BuildingEnum.Mine; }
get tradingStation () { return this.building === BuildingEnum.TradingStation; }
get planetaryInstitute () { return this.building === BuildingEnum.PlanetaryInstitute; }
get lab () { return this.building === BuildingEnum.ResearchLab; }
get academy () { return this.building === BuildingEnum.Academy1 || this.building === BuildingEnum.Academy2; }
get gaiaFormer () { return this.building === BuildingEnum.GaiaFormer; }
get spaceStation () { return this.building === BuildingEnum.SpaceStation; }
}
</script>
<style lang="scss">
svg {
.building {
stroke-width: 0.1;
pointer-events: none;
stroke: #111;
}
.additionalMine {
stroke-width: 0.05;
}
}
</style>

View file

@ -0,0 +1,620 @@
<template>
<div id="move">
<div id="move-title">
<h5>
<span v-if="init">Pick the number of players</span>
<span v-else>
{{ [player, ...titles].join(" - ") }}
<a href="#" v-if="commandChain.length > 0" class="smaller small" @click.prevent="back()">(back)</a>
<a href="#" v-else-if="canUndo" class="smaller small" @click.prevent="undo()">(undo)</a>
</span>
</h5>
</div>
<div id="move-buttons">
<div v-if="init">
<MoveButton
v-for="i in [2, 3, 4]"
:button="{ command: `init ${i} randomSeed`, label: `${i} players` }"
@trigger="handleCommand"
:key="i"
></MoveButton>
</div>
<div v-else-if="chooseFaction">
<MoveButton
v-for="faction in command.data"
:button="{
command: `${command.name} ${faction}`,
modal: tooltip(faction),
title: factions[faction].name,
label: `${factions[faction].name} <i class='planet ${factions[faction].planet}'></i>`,
}"
@trigger="handleCommand"
:key="faction"
/>
<MoveButton :button="randomFactionButton" @cancel="updateRandomFaction" @trigger="handleCommand" />
</div>
<div v-else>
<MoveButton
v-for="(button, i) in buttons"
:class="{ 'd-none': button.hide, shown: !button.hide }"
:ref="`button-${i}`"
:data-ref="`button-${i}`"
@trigger="handleCommand"
:button="button"
:key="(button.label || button.command) + '-' + i"
>
{{ button.label || button.command }}
</MoveButton>
</div>
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import Engine, {
AvailableCommand,
Command,
factions,
Building,
GaiaHex,
Booster,
tiles,
Event,
Faction,
SpaceMap,
Expansion,
} from "@gaia-project/engine";
import MoveButton from "./MoveButton.vue";
import { buildingName } from "../data/building";
import { GameContext, ButtonData } from "../data";
import { eventDesc } from "../data/event";
import { factionDesc } from "../data/factions";
@Component<Commands>({
watch: {
availableCommands(this: Commands, val) {
this.loadCommands(val);
},
},
methods: {
tooltip(faction: Faction) {
return factionDesc(faction);
},
},
computed: {
canUndo() {
return !this.$store.state.gaiaViewer.data.newTurn;
},
randomFactionButton() {
this.updater = this.updater + 1;
const command = this.command;
const faction = command.data[Math.floor(Math.random() * command.data.length)];
return {
command: `${command.name} ${faction}`,
label: "Random",
modal: this.tooltip(faction),
title: factions[faction].name,
};
},
},
components: {
MoveButton,
},
})
export default class Commands extends Vue {
@Prop({ default: "" })
remainingTime: string;
updater = 0;
loadCommands(val: AvailableCommand[]) {
this.commandTitles = [];
this.customButtons = [];
this.commandChain = [];
this.buttonChain = [];
for (const command of val) {
if (command.name === Command.ChooseFaction) {
this.title("Choose your faction");
return;
}
}
// Seems to cause problems on mobile
// If there's only one button, save the player the hassle and click it
// setTimeout(() => {
// if ($(".move-button.shown").length === 1) {
// const ref = $(".move-button.shown").attr("data-ref");
// (this.$refs[ref][0] as MoveButton).handleClick();
// }
// });
}
get availableCommands(): AvailableCommand[] {
return this.engine.availableCommands;
}
get command(): AvailableCommand {
return this.availableCommands ? this.availableCommands[0] : null;
}
get player(): string {
if (this.engine.players[this.command.player].faction) {
return factions[this.engine.players[this.command.player].faction].name;
}
if (this.engine.players[this.command.player].name) {
return this.engine.players[this.command.player].name;
}
return "Player " + (this.command.player + 1);
}
get playerSlug(): string {
return this.$store.state.gaiaViewer.data.players[this.command.player].faction || `p${this.command.player + 1}`;
}
get init() {
return (!this.command && this.engine.moveHistory.length === 0) || this.command.name === Command.Init;
}
get commandName() {
return this.command ? this.command.name : null;
}
get chooseFaction() {
return this.commandName === Command.ChooseFaction;
}
get titles() {
return this.commandTitles.length === 0 ? ["Your turn"] : this.commandTitles;
}
get factions() {
return factions;
}
updateRandomFaction() {
this.updater += 1;
}
handleCommand(command: string, source: MoveButton, final: boolean) {
console.log("handle command", command);
// Some users seem to have a bug with repeating commands on mobile, like clicking the income button twice
if (
this.commandChain.length > 0 &&
this.commandChain.slice(-1).pop() === command &&
(command === "income" || command === "booster")
) {
console.log("repeating command, ignoring");
return;
}
if (source.button.buttons && source.button.buttons.length > 0 && !final) {
this.commandTitles.push(source.button.label);
this.commandChain.push(source.button.command);
this.buttonChain.push(source.button);
this.customButtons = source.button.buttons;
// Seems to cause problems on mobile
// setTimeout(() => {
// if ($(".move-button.shown").length <= 1) {
// const ref = $(".move-button.shown").attr("data-ref");
// (this.$refs[ref][0] as MoveButton).handleClick();
// }
// });
return;
}
if (this.init) {
this.$emit("command", command);
} else {
this.$emit("command", `${this.playerSlug} ${[...this.commandChain, command].join(" ")}`);
}
}
undo() {
this.$emit("undo");
}
title(title: string) {
this.commandTitles.push(title);
}
get context(): GameContext {
return this.$store.state.gaiaViewer.context;
}
get engine(): Engine {
return this.$store.state.gaiaViewer.data;
}
get map(): SpaceMap {
return this.engine.map;
}
get buttons(): ButtonData[] {
const ret: ButtonData[] = [];
for (const command of this.availableCommands) {
switch (command.name) {
case Command.RotateSectors: {
ret.push({
label: "Rotate sectors",
command: Command.RotateSectors,
hexes: new Map<GaiaHex, {}>(
this.map.configuration().centers.map((center) => [this.engine.map.grid.get(center), {}] as const)
),
rotation: true,
});
break;
}
case Command.Build: {
for (const building of Object.values(Building)) {
const coordinates = command.data.buildings.filter((bld) => bld.building === building);
if (coordinates.length > 0) {
let label = `Build a ${buildingName(building)}`;
if (coordinates[0].upgrade) {
label = `Upgrade to ${buildingName(building)}`;
} else if (coordinates[0].downgrade) {
label = `Downgrade to ${buildingName(building)}`;
} else if (
coordinates[0].cost === "~" ||
building === Building.SpaceStation ||
building === Building.GaiaFormer
) {
label = `Place a ${buildingName(building)}`;
}
ret.push({
label,
command: `${Command.Build} ${building}`,
automatic: command.data.automatic,
hexes: new Map<GaiaHex, { cost?: string }>(
coordinates.map((coord) => [this.engine.map.getS(coord.coordinates), coord])
),
});
}
}
break;
}
case Command.PISwap: {
ret.push({
label: "Swap Planetary Institute",
command: command.name,
hexes: new Map(command.data.buildings.map((coord) => [this.engine.map.getS(coord.coordinates), coord])),
});
break;
}
case Command.PlaceLostPlanet: {
ret.push({
label: "Place Lost Planet",
command: command.name,
hexes: new Map(command.data.spaces.map((coord) => [this.engine.map.getS(coord.coordinates), coord])),
});
break;
}
case Command.Pass:
case Command.ChooseRoundBooster: {
const buttons: ButtonData[] = [];
Booster.values(Expansion.All).forEach((booster, i) => {
if (command.data.boosters.includes(booster)) {
buttons.push({
command: booster,
label: `Booster ${i + 1}`,
booster,
needConfirm: true,
tooltip: tiles.boosters[booster].map((spec) => eventDesc(new Event(spec))).join("\n"),
});
}
});
// need a Pass confirmation if it's the last round, where Command = PAss but no Boosters
if (command.data.boosters.length === 0) {
ret.push({
label: "Pass",
command: Command.Pass,
needConfirm: true,
buttons: [
{
command: "",
label: `Confirm Pass`,
},
],
});
} else {
ret.push({
label: command.name === Command.Pass ? "Pass" : "Pick booster",
command: command.name,
buttons,
boosters: command.data.boosters,
});
}
break;
}
case Command.UpgradeResearch: {
if (command.data.tracks.length === 1) {
ret.push({
label: "Advance " + command.data.tracks[0].field,
command: `${Command.UpgradeResearch} ${command.data.tracks[0].field}`,
});
} else {
ret.push({
label: "Advance research",
command: command.name,
// track.to contains actual level, to use when implementing research viewer
buttons: command.data.tracks.map((track) => ({ command: track.field })),
researchTiles: command.data.tracks.map((track) => track.field + "-" + track.to),
});
}
break;
}
case Command.ChooseTechTile:
case Command.ChooseCoverTechTile: {
ret.push({
label: command.name === Command.ChooseCoverTechTile ? "Pick tech tile to cover" : "Pick tech tile",
command: command.name,
techs: command.data.tiles.map((tile) => tile.pos),
buttons: command.data.tiles.map((tile) => ({ command: tile.pos })),
});
break;
}
case Command.ChargePower: {
for (const offer of command.data.offers) {
const leech = offer.offer;
const action = leech.includes("pw") ? "Charge" : "Gain";
ret.push({
label: offer.cost && offer.cost !== "~" ? `${action} ${leech} for ${offer.cost}` : `${action} ${leech}`,
command: `${Command.ChargePower} ${leech}`,
});
}
break;
}
case Command.Decline: {
if (command.data.offers) {
ret.push({
label: `Decline ${command.data.offers[0].offer}`,
command: `${Command.Decline} ${command.data.offers[0].offer}`,
});
} else {
// LEGACY CODE
// TODO: Remove when games are updated
ret.push({
label: `Decline ${command.data.offer}`,
command: `${Command.Decline} ${command.data.offer}`,
});
}
break;
}
case Command.BrainStone: {
ret.push(
...command.data.sort().map((area) => ({
label: `Brainstone ${area}`,
command: `${command.name} ${area}`,
}))
);
break;
}
case Command.Spend: {
ret.push({
label: "Free action",
command: Command.Spend,
buttons: command.data.acts.map((act) => ({
label: `Spend ${act.cost} to gain ${act.income}`,
command: `${act.cost} for ${act.income}`,
times: act.range,
})),
});
break;
}
case Command.Action: {
ret.push({
label: "Power/Q.I.C Action",
command: Command.Action,
actions: command.data.poweracts.map((act) => act.name),
buttons: command.data.poweracts.map((act) => ({
command: act.name,
label: `Spend ${act.cost} for ${act.income.join(" / ")}`,
})),
});
break;
}
case Command.Special: {
ret.push({
label: "Special Action",
command: Command.Special,
actions: command.data.specialacts.map((act) => act.income),
buttons: command.data.specialacts.map((act) => ({ command: act.income })),
});
break;
}
case Command.BurnPower: {
ret.push({
label: "Burn power",
command: Command.BurnPower,
buttons: command.data.map((val) => ({ command: val })),
});
break;
}
case Command.EndTurn: {
ret.push({
label: "End Turn",
command: Command.EndTurn,
needConfirm: true,
buttons: [
{
command: Command.EndTurn,
label: `Confirm End Turn`,
},
],
});
break;
}
case Command.ChooseIncome: {
ret.push(
...command.data.map((income) => ({
label: `Income ${income}`,
command: `${Command.ChooseIncome} ${income}`,
}))
);
break;
}
case Command.Bid: {
ret.push(
...command.data.bids.map((pos) => ({
label: `Bid ${pos.bid[0]} for ${pos.faction}`,
command: `${Command.Bid} ${pos.faction} $times`,
times: pos.bid,
}))
);
break;
}
case Command.PickReward: {
ret.push(
...command.data.rewards.map((reward) => ({
label: `Gain ${reward}`,
command: `${Command.PickReward} ${reward}`,
}))
);
break;
}
case Command.FormFederation: {
const tilesButtons = command.data.tiles.map((fed, i) => ({
command: fed,
label: `Federation ${i + 1}: ${tiles.federations[fed]}`,
}));
const locationButtons = command.data.federations.map((fed, i) => ({
command: fed.hexes,
label: `Location ${i + 1}`,
hexes: new Map(fed.hexes.split(",").map((coord) => [this.engine.map.getS(coord), { coordinates: coord }])),
hover: true,
buttons: tilesButtons,
}));
locationButtons.push({
label: "Custom location",
selectHexes: true,
buttons: tilesButtons,
});
ret.push({
label: "Form federation",
command: Command.FormFederation,
buttons: locationButtons,
});
break;
}
case Command.ChooseFederationTile: {
const tilesButtons = command.data.tiles.map((fed, i) => ({
command: fed,
label: `Federation ${i + 1}: ${tiles.federations[fed]}`,
}));
ret.push({
label: "Rescore federation",
command: Command.ChooseFederationTile,
buttons: tilesButtons,
});
break;
}
}
}
if (this.customButtons.length > 0) {
for (const button of ret) {
button.hide = true;
}
ret.push(...this.customButtons);
}
return ret;
}
back() {
this.$store.commit("gaiaViewer/clearContext");
this.commandChain.pop();
this.commandTitles.pop();
this.buttonChain.pop();
if (this.buttonChain.length > 0) {
const [last] = this.buttonChain.slice(-1);
this.customButtons = last.buttons;
for (const button of last.buttons) {
button.hide = false;
}
} else {
this.customButtons = [];
}
}
private commandTitles: string[] = [];
private customButtons: ButtonData[] = [];
private commandChain: string[] = [];
private buttonChain: ButtonData[] = [];
}
</script>
<style lang="scss">
@import "../stylesheets/planets.scss";
i.planet {
&::before {
content: "\25cf";
.player-info &,
.faction-desc & {
font-size: 25px;
}
}
// terra
&.r {
color: $terra;
}
// desert
&.d {
color: $desert;
}
// swamp
&.s {
color: $swamp;
}
// oxide
&.o {
color: $oxide;
}
// titanium
&.t {
color: $titanium;
}
// ice
&.i {
color: $ice;
}
// volcanic
&.v {
color: $volcanic;
}
// gaia
&.g {
color: $gaia;
}
// transdim
&.m {
color: $transdim;
}
// lost planet
&.l {
color: $lost;
}
filter: drop-shadow(0px 0px 1px black);
.player-info & {
filter: drop-shadow(0px 0px 1px black);
&.r,
&.d,
&.i {
filter: drop-shadow(0px 0px 1px black);
}
}
}
</style>

View file

@ -0,0 +1,48 @@
<template>
<g>
<circle :r="r" fill="none" />
<g
v-for="i in [0, 1, 2, 3, 4, 5, 6]"
:key="i"
:transform="`translate(${r * Math.sin(((-180 + i * 51) * Math.PI) / 180)}, ${
r * Math.cos(((-180 + i * 51) * Math.PI) / 180)
})`"
>
<circle :r="1" :class="['player-token', 'planet-fill', planet(i)]" />
</g>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component } from 'vue-property-decorator';
import { Planet } from '@gaia-project/engine';
@Component
export default class FactionWheel extends Vue {
get r () {
return 3;
}
get spacing () {
return 1.1;
}
angle (deg) {
return deg * 180 / Math.PI;
}
planet (pos: number) {
const list = [Planet.Terra, Planet.Oxide, Planet.Volcanic, Planet.Desert, Planet.Swamp, Planet.Titanium, Planet.Ice];
return list[pos];
}
}
</script>
<style lang="scss" scoped>
circle {
stroke-width: 0.05px;
stroke: black;
}
</style>

View file

@ -0,0 +1,92 @@
<template>
<svg viewBox="-25 -25 50 50" width="50" height="50">
<g :class="['federationTile', { 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)"
@click="onClick"
/>
<circle cx="16.5" cy="-16.5" r="8" stroke="black" stroke-width="1" fill="white" v-if="numTiles > 1" />
<text x="16.5" y="-15.5" v-if="numTiles > 1">
{{ numTiles }}
</text>
<text>
<tspan x="0" v-for="(line, i) in income" :key="i" :dy="`${i * 1.5 - (income.length - 1) / 2.2}em`">
{{ line.replace(/ /g, "") }}
</tspan>
</text>
</g>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, Event, Federation as FederationEnum, PlayerEnum } from '@gaia-project/engine';
import { eventDesc } from '../data/event';
@Component<FederationTile>({
computed: {
income () {
const [first, ...others] = tiles.federations[this.federation].split(",");
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("gaiaViewer/federationClick", this.federation);
}
get highlighted () {
return this.$store.state.gaiaViewer.context.highlighted.federations.has(this.federation);
}
}
</script>
<style lang="scss">
g {
&.federationTile {
polygon {
stroke: #333;
stroke-width: 0.02;
fill: #c9ffca;
}
text {
text-anchor: middle;
dominant-baseline: middle;
font-size: 12px;
pointer-events: none;
}
&.highlighted polygon {
stroke: #2c4;
cursor: pointer;
stroke-width: 0.04;
}
&.disabled {
polygon {
fill: #ddd;
}
}
}
}
</style>

View file

@ -0,0 +1,130 @@
<template>
<g :class="['finalScoringTile', { 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
v-for="(player, index) in players"
:faction="player.faction"
:transform="`translate(${tokenX(index)}, ${tokenY(index)})`"
:key="player.faction"
:scale="8"
/>
<text
v-for="(player, index) in players"
:key="player.faction + '-text'"
:transform="`translate(${tokenX(index)}, ${tokenY(index)})`"
:class="['score', player.faction]"
>
{{ progress(player) }}
</text>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, Event, factions, FinalTile, Phase, Player, finalScorings, Faction } from '@gaia-project/engine';
import Token from "./Token.vue";
@Component<FinalScoringTile>({
computed: {
tooltip () {
const tile = this.tile;
const players = this.players;
return players.map(pl => {
const name = pl.faction === "automa" ? "Automa" : factions[pl.faction].name;
const points = this.progress(pl);
return `- ${name}: ${points}`;
}).join('\n');
},
highlighted () {
return this.$store.state.gaiaViewer.data.phase === Phase.EndGame;
}
},
components: {
Token
}
})
export default class FinalScoringTile extends Vue {
@Prop()
index: number;
progress (player: Player) {
return (player.faction as Faction | "automa") === "automa" ? finalScorings[this.tile].neutralPlayer : player.progress(this.tile);
}
get tile () {
return this.$store.state.gaiaViewer.data.tiles.scorings.final[this.index];
}
get content () {
return this.tile;
}
get players () {
const pls = this.$store.state.gaiaViewer.data.players.filter(player => !!player && player.faction);
if (this.$store.state.gaiaViewer.data.players.length === 2) {
pls.push({ faction: "automa" });
}
return pls;
}
tokenX (index: number) {
return (index % 2) * 30 + 23;
}
tokenY (index: number) {
return 25 + (index > 1 ? 17 : 0);
}
}
</script>
<style lang="scss">
g {
&.finalScoringTile {
rect {
stroke: #333;
stroke-width: 1px;
fill: white;
}
.title {
font-size: 10px;
font-weight: bold;
pointer-events: none;
}
.score {
font-size: 12px;
pointer-events: none;
fill: white;
text-anchor: middle;
dominant-baseline: central;
&.automa,
&.gleens,
&.xenos,
&.itars,
&.nevlas {
fill: #333;
}
}
g .player-token {
stroke-width: 0.01;
}
line {
stroke-width: 0.2;
stroke: #111;
}
&.highlighted rect {
stroke: #2c4;
}
}
}
</style>

View file

@ -0,0 +1,275 @@
<template>
<div
:class="{
['no-faction-fill']: $store.state.gaiaViewer.preferences && $store.state.gaiaViewer.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"
/>
</template>
<Pool class="col-12 order-10 mt-4" />
<AdvancedLog class="col-12 order-last mt-4" />
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import Engine, { Command, Phase, factions, Player, EngineOptions, Expansion } from '@gaia-project/engine';
import AdvancedLog from './AdvancedLog.vue';
import Commands from './Commands.vue';
import Pool from './Pool.vue';
import PlayerInfo from './PlayerInfo.vue';
import ResearchBoard from './ResearchBoard.vue';
import ScoringBoard from './ScoringBoard.vue';
import SpaceMap from './SpaceMap.vue';
import TurnOrder from './TurnOrder.vue';
import { resolve } from 'dns';
@Component<Game>({
created (this: Game) {
const unsub = this.$store.subscribeAction(({ type, payload }) => {
if (type === "gaiaViewer/externalData") {
this.handleData(Engine.fromData(payload));
return;
}
if (type === "gaiaViewer/replayStart") {
this.$store.dispatch("gaiaViewer/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 === "gaiaViewer/replayEnd") {
const restore = payload || this.replayData?.backup;
this.replayData = null;
this.handleData(Engine.fromData(restore));
return;
}
if (type === "gaiaViewer/replayTo") {
const dest: number = payload;
const current = this.replayData.current;
this.replayData.current = dest;
this.$store.dispatch("gaiaViewer/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.gaiaViewer.data;
}
get ended () {
return this.engine.phase === Phase.EndGame;
}
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.gaiaViewer.player || this.sessionPlayer === this.engine.players[this.player]);
}
get hasMap () {
return !!this.$store.state.gaiaViewer.data.map;
}
get player () {
return this.engine.availableCommands?.[0]?.player;
}
get sessionPlayer () {
const player = this.$store.state.gaiaViewer.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('gaiaViewer/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("gaiaViewer/clearContext");
this.$store.dispatch("gaiaViewer/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 {
max-height: 550px;
width: 100%;
// this is needed for Safari
height: intrinsic;
}
.medium-map,
.small-map {
flex-wrap: nowrap;
}
@media (max-width: 767px) {
.small-map,
.medium-map {
flex-wrap: wrap;
}
}
</style>

View file

@ -0,0 +1,267 @@
<template>
<div class="move-button">
<Booster v-if="button.booster" class="mb-1 mr-1" @click="handleClick" :booster="button.booster" />
<button
v-else-if="!button.times"
class="btn btn-secondary mr-2 mb-2 move-button"
@click="handleClick"
@mouseenter="hover"
@mouseleave="leave"
:title="button.tooltip"
v-b-tooltip.html
v-html="customLabel || button.label || button.command"
></button>
<b-dropdown
class="mr-2 mb-2 move-button"
v-else
split
right
:text="customLabel || button.label || button.command"
@click="handleRangeClick(button.times[0])"
>
<b-dropdown-item v-for="i in button.times" :key="i" @click="handleRangeClick(i)">{{ i }}</b-dropdown-item>
</b-dropdown>
<b-modal
v-if="button.modal"
v-model="modalShow"
size="lg"
@ok="handleOK"
@hide="modalCancel"
:title="button.title || button.label || button.command"
ok-title="OK, I pick this one!"
>
<div v-html="button.modal"></div>
</b-modal>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { GaiaHex, TechTilePos, AdvTechTilePos, Command, SpaceMap } from '@gaia-project/engine';
import { HighlightHexData, ButtonData } from '../data';
import Booster from './Booster.vue';
@Component({
components: {
Booster
},
destroyed () {
this.unsubscribe();
}
})
export default class MoveButton extends Vue {
@Prop()
public button: ButtonData;
private subscription: () => {} = null;
private modalShow = false;
private customLabel = '';
private startingHex = null; // For range command
modalCancel (arg: string) {
this.$emit("cancel");
}
subscribe (action: string, callback: any) {
action = "gaiaViewer/" + action;
this.unsubscribe();
this.$store.commit("gaiaViewer/activeButton", this.button);
this.subscription = (this.$store as any).subscribeAction(({ type, payload }) => {
if (type !== action) {
return;
}
if (!this.isActiveButton) {
return;
}
callback(payload);
});
}
subscribeFinal (action: string) {
this.subscribe(action, field => this.emitCommand(field, { final: true }));
this.emitCommand(null, { disappear: false });
}
unsubscribe () {
if (this.subscription) {
this.subscription();
}
}
handleClick () {
if (this.button.hide) {
console.log("click on hidden button, ignoring");
return;
}
// Remove highglights caused by another button
if (!this.isActiveButton) {
this.$store.commit("gaiaViewer/clearContext");
}
if (this.button.hexes && !this.button.selectHexes && !this.button.hover && !this.button.rotation && !this.button.range) {
if (this.button.automatic && this.button.hexes.size === 1) {
const hex = this.button.hexes.keys().next().value;
this.emitCommand(hex.toString());
} else {
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
this.subscribe('hexClick', hex => this.emitCommand(hex.toString()));
}
} else if (this.button.researchTiles) {
this.$store.commit("gaiaViewer/highlightResearchTiles", this.button.researchTiles);
this.subscribeFinal('researchClick');
} else if (this.button.techs) {
this.$store.commit("gaiaViewer/highlightTechs", this.button.techs);
this.subscribeFinal('techClick');
} else if (this.button.boosters) {
this.$store.commit("gaiaViewer/highlightBoosters", this.button.boosters);
this.subscribeFinal('boosterClick');
} else if (this.button.actions) {
this.$store.commit("gaiaViewer/highlightActions", this.button.actions);
this.subscribeFinal('actionClick');
} else if (this.button.needConfirm) {
this.subscribeFinal('needConfirmClick');
} else if (this.button.selectHexes) {
// If already the active button, end the selection
if (this.isActiveButton) {
this.button.command = [...this.$store.state.gaiaViewer.context.highlighted.hexes.keys()].map(hex => hex.toString()).join(',');
this.emitCommand();
return;
}
this.$store.commit("gaiaViewer/selectHexes", this.button.hexes);
this.customLabel = "Custom location - End selection";
this.subscribe('hexClick', hex => {
const highlighted = this.$store.state.gaiaViewer.context.highlighted.hexes;
if (highlighted.has(hex)) {
highlighted.delete(hex);
} else {
highlighted.set(hex, null);
}
const keys: GaiaHex[] = [...highlighted.keys()];
this.$store.commit("gaiaViewer/highlightHexes", new Map([...keys.map(key => [key, null])] as any));
});
} else if (this.button.modal) {
this.modalShow = true;
} else if (this.button.rotation) {
if (this.isActiveButton) {
const rotations = [...this.$store.state.gaiaViewer.context.rotation.entries()];
for (const rotation of rotations) {
rotation[1] %= 6;
}
this.emitCommand([].concat(...rotations.filter(r => !!r[1])).join(' '));
return;
}
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
this.subscribe('hexClick', hex => this.$store.commit("gaiaViewer/rotate", hex));
this.customLabel = "Sector rotations finished";
} else if (this.button.range) {
console.log("range click");
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
this.subscribe('hexClick', hex => {
if (this.startingHex) {
this.emitCommand(`${this.startingHex} ${hex}`);
this.startingHex = undefined;
return;
}
this.startingHex = hex;
const map: SpaceMap = this.$store.state.gaiaViewer.data.map;
const { range, costs } = this.button;
const highlighted = new Map();
const withinDistance = map.withinDistance(hex, range);
for (const target of withinDistance) {
highlighted.set(target, { cost: costs?.[map.distance(hex, target)] ?? '~' });
}
this.$store.commit("gaiaViewer/highlightHexes", highlighted);
});
} else {
// Keep hexes highlighted for next command (federation tile)
if (this.button.hexes && this.button.hover) {
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
}
this.emitCommand();
}
}
handleRangeClick (times: number) {
this.emitCommand(null, { times });
}
handleOK () {
this.emitCommand();
}
emitCommand (append?: string, params?: {disappear?: boolean; final?: boolean; times?: number}) {
console.log("emit command", this.button.command, append);
params = Object.assign({}, { disappear: true, final: false, times: 1 }, params);
const { disappear, final, times } = params;
if (disappear) {
this.unsubscribe();
this.$store.commit("gaiaViewer/activeButton", null);
}
let commandBody: string [] = [];
if (final) {
commandBody = append ? [append] : [];
} else {
// Parse numbers, ie the command is executed X times, multiply
// each number by X instead of repeating the command X times.
let command = (this.button.command || "") + "";
if (times && typeof times === "number") {
// the \b is necessary for things like '1t-a3', so the 3 is not caught
command = command.replace(/\b[0-9]+/g, x => ('' + (parseInt(x) * times)));
}
command = command.replace(/\$times\b/g, '' + (times ?? 0));
commandBody = [command, append].filter(x => !!x);
}
this.$emit('trigger', commandBody.join(" "), this, final);
}
hover () {
if (!this.button.hover || this.$store.state.gaiaViewer.context.activeButton !== null) {
return;
}
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
}
leave () {
if (!this.button.hover || this.$store.state.gaiaViewer.context.activeButton !== null) {
return;
}
this.$store.commit("gaiaViewer/clearContext");
}
get isActiveButton () {
return this.$store.state.gaiaViewer.context.activeButton && this.$store.state.gaiaViewer.context.activeButton.label === this.button.label;
}
}
</script>
<style lang="scss">
.move-button {
display: inline-block;
}
</style>

View file

@ -0,0 +1,136 @@
<template>
<g>
<circle :r="radius" :class="['planet-fill', planet]" style="pointer-events: none" />
<circle :r="radius" :class="['planet-fill', 'faction-fill', fill]" v-if="faction" style="pointer-events: none" />
<circle :r="radius" :class="['planet', planet]" />
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import planets from "../data/planets";
import { Component, Prop } from 'vue-property-decorator';
import { Planet as PlanetEnum, factions, Faction } from '@gaia-project/engine';
@Component
export default class Planet extends Vue {
@Prop()
planet: PlanetEnum;
@Prop()
faction: Faction;
get radius () {
return planets[this.planet].radius;
}
get fill () {
// Comment for planet staying planets!
if (this.faction) {
return factions.planet(this.faction);
}
return this.planet;
}
}
</script>
<style lang="scss">
@import "../stylesheets/planets.scss";
svg {
.planet {
stroke-width: 0.04;
fill: none;
pointer-events: none;
// terra
&.r {
stroke: $terra;
}
// desert
&.d {
stroke: $desert;
}
// swamp
&.s {
stroke: $swamp;
}
// oxide
&.o {
stroke: $oxide;
}
// titanium
&.t {
stroke: $titanium;
}
// ice
&.i {
stroke: $ice;
}
// volcanic
&.v {
stroke: $volcanic;
}
// gaia
&.g {
stroke: $gaia;
}
// transdim
&.m {
stroke: $transdim;
}
// lost planet
&.l {
stroke: $lost;
}
}
.planet-fill,
.planet-stroke {
.no-faction-fill &.faction-fill {
display: none;
}
// terra
&.r {
fill: $terra;
}
// desert
&.d {
fill: $desert;
}
// swamp
&.s {
fill: $swamp;
}
// oxide
&.o {
fill: $oxide;
}
// titanium
&.t {
fill: $titanium;
}
// ice
&.i {
fill: $ice;
}
// volcanic
&.v {
fill: $volcanic;
}
// gaia
&.g {
fill: $gaia;
}
// transdim
&.m {
fill: $transdim;
}
// lost planet
&.l {
fill: $lost;
}
}
}
</style>

View file

@ -0,0 +1,172 @@
<template>
<g class="building-group">
<rect
:x="0"
y="-1.2"
:width="width"
height="2.4"
stroke="black"
stroke-width="0.07"
fill="#ffffff44"
rx="0.2"
ry="0.2"
/>
<Resource
v-if="factionIncome.length > 0"
:kind="factionIncome[0].type"
:count="factionIncome[0].count"
transform="translate(0.77, 0) scale(0.07)"
/>
<g
v-for="i in buildingList"
:transform="`translate(${(i + 0.5) * buildingSpacing + offset}, 0)`"
:key="i"
v-b-tooltip
:title="tooltip(i)"
>
<circle stroke="black" stroke-width="0.07" fill="white" r="1" :key="i" v-if="!isPI" />
<rect
stroke="black"
stroke-width="0.07"
fill="white"
:x="-2.2 + offset"
width="4"
y="-1"
height="2"
:key="i"
v-else
/>
<Building
:building="building"
class="building-in-group"
:faction="faction"
:transform="`translate(${isPI ? 0.5 : 0}, 0) scale(1.5)`"
v-if="showBuilding(i)"
/>
<Resource
v-for="(resource, index) in resources(i)"
:key="'field-' + index"
:kind="resource.type"
:count="resource.count"
:transform="`translate(${index * 1.5 + isPI * 0.5}, 0) scale(0.08)`"
/>
</g>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import Building from '../Building.vue';
import Resource from '../Resource.vue';
import { Building as BuildingEnum, Faction, Reward, FactionBoard, factionBoard, Operator, Resource as ResourceEnum } from '@gaia-project/engine';
@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 === "1q" || rew === "4c");
}).map(ev => ev.rewards));
}
}
</script>
<style lang="scss">
.player-board {
.building-group {
.building-in-group {
stroke-width: 0.05px;
}
}
}
</style>

View file

@ -0,0 +1,133 @@
<template>
<g class="board-info">
<rect
x="-0.5"
y="-0.5"
width="19.5"
height="8"
rx="0.1"
ry="0.1"
fill="#ffffff37"
stroke="black"
stroke-width="0.07"
/>
<rect
x="20"
y="-0.5"
width="17.5"
height="2"
rx="0.1"
ry="0.1"
fill="#ffffff37"
stroke="black"
stroke-width="0.07"
/>
<g transform="translate(0, 0.5)">
<text class="board-text">
<tspan class="faction-name" v-b-modal="faction" role="button">{{ factionName }}</tspan>
</text>
<text class="board-text" x="21"> TF: {{ 3 - data.terraformCostDiscount }} </text>
<text class="board-text" x="26"> NAV: {{ data.range }} </text>
<text class="board-text" x="31">
<tspan class="board-text">VP: {{ data.victoryPoints }}</tspan>
<tspan class="board-text" v-if="data.bid > 0"> (-{{ data.bid }})</tspan>
</text>
</g>
<!-- Resources / Income -->
<g transform="translate(0, 3)">
<g>
<text class="board-text">R</text>
<g transform="translate(2.2, 0)">
<Resource kind="c" :count="data.credits" transform="scale(0.1)" />
<text :class="['board-text', { maxResource: data.ores >= 30 }]" transform="translate(1,0) scale(0.7)"
>/30</text
>
</g>
<g transform="translate(5.5, 0)">
<Resource kind="o" :count="data.ores" transform="scale(0.1)" />
<text :class="['board-text', { maxResource: data.ores >= 15 }]" transform="translate(1,0) scale(0.7)"
>/15</text
>
</g>
<g transform="translate(9, 0)">
<Resource kind="k" :count="data.knowledge" transform="scale(0.1)" />
<text :class="['board-text', { maxResource: data.knowledge >= 15 }]" transform="translate(1,0) scale(0.7)"
>/15</text
>
</g>
<Resource kind="q" :count="data.qics" transform="translate(12.5,0) scale(0.1)" />
</g>
<g transform="translate(0, 1.5)">
<text class="board-text" x="0.25">I</text>
<g transform="translate(2.2, 0)" v-if="income('c') > 0">
<text class="board-text" transform="scale(0.7)">+{{ income("c") }}</text>
</g>
<g transform="translate(5.5, 0)" v-if="income('o') > 0">
<text class="board-text" transform="scale(0.7)">+{{ income("o") }}</text>
</g>
<g transform="translate(9, 0)" v-if="income('k') > 0">
<text class="board-text" transform="scale(0.7)">+{{ income("k") }}</text>
</g>
<g transform="translate(12, 0)" v-if="income('q') > 0">
<text class="board-text" transform="scale(0.7)">+{{ income("q") }}</text>
</g>
</g>
<g transform="translate(0,3.5) scale(0.8)">
<text class="board-text">
<tspan>GF: </tspan>
<tspan v-if="data.gaiaformersInGaia > 0">[{{ data.gaiaformersInGaia }}]</tspan>
<tspan>{{ data.buildings.gf }}/{{ data.gaiaformers }}</tspan>
</text>
<text class="board-text" x="6">Sat: {{ data.satellites }}</text>
</g>
</g>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import Resource from '../Resource.vue';
import { Building as BuildingEnum, Faction, Reward, Operator, Resource as ResourceEnum, factions, PlayerData, Player } from '@gaia-project/engine';
@Component({
components: {
Resource
}
})
export default class BuildingGroup extends Vue {
@Prop()
faction: Faction;
@Prop()
data: PlayerData;
@Prop()
player: Player;
get factionName (): string {
return factions[this.faction].name;
}
income (resource: ResourceEnum) {
const index = this.player.income.search(new RegExp('[0-9]+' + resource));
if (index < 0) {
return 0;
}
return parseInt(this.player.income.substr(index));
}
}
</script>
<style lang="scss">
.maxResource {
fill: red;
}
.board-info {
g.resource {
opacity: 1;
}
}
</style>

View file

@ -0,0 +1,105 @@
<template>
<g>
<line
x1="0"
y1="0"
:x2="-r * spacing"
:y2="(isTerran ? -1 : 1) * 2 * r * sin60 * spacing"
stroke="black"
stroke-width="0.06px"
/>
<circle :r="2 * r * spacing" fill="none" />
<g>
<circle :r="r" fill="green" />
<text>{{ power("gaia") }}</text>
<text class="label" y="2.6">G</text>
</g>
<g :transform="`translate(${-r * spacing}, ${2 * r * sin60 * spacing})`">
<circle :r="r" fill="purple" />
<text>{{ power("area1") }}</text>
<text y="1.7" transform="scale(0.7)" v-if="income('t')">+{{ income("t") }}</text>
<text class="label" x="-2.6">I</text>
</g>
<g :transform="`translate(${-r * spacing}, ${-2 * r * sin60 * spacing})`">
<circle :r="r" fill="purple" />
<text>{{ power("area2") }}</text>
<text class="label" x="-2.6">II</text>
</g>
<g :transform="`translate(${2 * r * spacing}, 0)`">
<circle :r="r" fill="purple" />
<text>{{ power("area3") }}</text>
<text class="label" y="2.6" x="0">III</text>
</g>
<text class="label" transform="translate(-3.5, 0) scale(0.75)" v-if="income('pw')">+{{ income("pw") }}</text>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import Resource from '../Resource.vue';
import { Faction, Reward, FactionBoard, Operator, Resource as ResourceEnum, factions, PlayerData, Player } from '@gaia-project/engine';
@Component({
components: {
Resource
}
})
export default class BuildingGroup extends Vue {
@Prop()
faction: Faction;
@Prop()
data: PlayerData;
@Prop()
player: Player;
get r () {
return 2;
}
get spacing () {
return 1.1;
}
get sin60 () {
return 0.86602540378;
}
get isTerran () {
return this.faction === Faction.Terrans;
}
power (area: string) {
return this.data.power[area] + (this.data.brainstone === area ? "(b)" : "");
}
income (resource: ResourceEnum) {
const index = this.player.income.search(new RegExp('[0-9]+' + resource));
if (index < 0) {
return 0;
}
return parseInt(this.player.income.substr(index));
}
}
</script>
<style lang="scss" scoped>
circle {
stroke-width: 0.05px;
stroke: black;
}
text {
fill: white;
font-size: 1.2px;
text-anchor: middle;
dominant-baseline: mathematical;
&.label {
fill: #333;
}
}
</style>

View file

@ -0,0 +1,308 @@
<template>
<div class="player-info no-gutters" v-if="player && player.faction">
<span @click="playerClick(player)" :class="['player-name', { dropped: player.dropped }]" role="button">{{
name
}}</span>
<div class="board mt-2">
<svg viewBox="-0.2 -0.5 38.5 21.4" 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"
/>
<BuildingGroup
:transform="player.faction !== 'bescods' ? 'translate(2.2, 10)' : 'translate(12, 10)'"
:nBuildings="1"
building="PI"
:faction="player.faction"
:placed="playerData.buildings.PI"
:resource="['pw', 't']"
/>
<BuildingGroup
:transform="player.faction === 'bescods' ? 'translate(2.2, 10)' : 'translate(12, 10)'"
:nBuildings="2"
building="ac1"
:faction="player.faction"
:placed="0"
:ac1="playerData.buildings.ac1"
:ac2="playerData.buildings.ac2"
:resource="['q']"
/>
<BuildingGroup
transform="translate(0, 13)"
:nBuildings="4"
building="ts"
:faction="player.faction"
:placed="playerData.buildings.ts"
:resource="['c']"
/>
<BuildingGroup
transform="translate(11, 13)"
:nBuildings="3"
building="lab"
:faction="player.faction"
:placed="playerData.buildings.lab"
:resource="['k']"
/>
<BuildingGroup
transform="translate(0, 16)"
:nBuildings="8"
building="m"
:faction="player.faction"
:placed="playerData.buildings.m"
:resource="['o']"
/>
<!-- M to TS -->
<line x1="5.7" x2="5.7" y1="14.2" y2="14.8" stroke="black" stroke-width="0.06" />
<!-- TS to PI -->
<line x1="5.7" x2="5.7" y1="11.2" y2="11.8" stroke="black" stroke-width="0.06" />
<!-- LAB to AC -->
<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" />
<g transform="translate(29.3, 5)">
<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})`"
>
<circle :r="1" style="stroke-width: 0.06px !important" :class="['player-token', 'planet-fill', planet]" />
<text
:style="`font-size: 1.2px; text-anchor: middle; dominant-baseline: mathematical; fill: ${planetFill(
planet
)}`"
>
{{ player.ownedPlanetsCount[planet] }}
</text>
</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"] }}
</text>
</g>
</g>
<SpecialAction
v-for="(action, i) in player.actions"
:action="action.rewards"
:disabled="!action.enabled || passed"
:key="action.action + '-' + i"
y="17.5"
width="3.1"
height="3.1"
:x="3.3 * i"
/>
</svg>
<span v-if="player.faction === 'ivits'">
Value of structures in federation: {{ player.fedValue }}<br />
Value of other structures: {{ player.structureValue - player.fedValue }}
</span>
</div>
<div class="tiles row no-gutters mt-1">
<Booster
v-if="playerData.tiles.booster"
class="mb-1 mr-1"
:booster="playerData.tiles.booster"
:disabled="passed"
/>
<FederationTile
v-for="(fed, i) in playerData.tiles.federations"
class="mb-1 mr-1"
:key="i"
:federation="fed.tile"
:used="!fed.green"
:player="player.player"
:numTiles="1"
/>
<TechTile
v-for="tech in playerData.tiles.techs"
:covered="!tech.enabled"
class="mb-1 mr-1"
:key="tech.pos"
:pos="tech.pos"
:player="player.player"
/>
</div>
<b-modal :id="player.faction" :title="factionName" size="lg">
<div v-html="tooltip"></div>
</b-modal>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { Player, factions, tiles, PlayerData, Planet, Federation, terraformingStepsRequired, Building, Condition } from '@gaia-project/engine';
import { factionColor } from '../graphics/utils';
import TechTile from './TechTile.vue';
import Booster from './Booster.vue';
import SpecialAction from './SpecialAction.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 { factionDesc, planetsWithSteps } from '../data/factions';
@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("gaiaViewer/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 factions[this.player.faction].planet;
}
get factionName (): string {
return factions[this.player.faction].name;
}
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.gaiaViewer.data.passedPlayers || []).includes(this.player.player);
}
get round () {
return this.$store.state.gaiaViewer.data.round;
}
get hasPlanets () {
return this.player.ownedPlanets.length > 0;
}
}
</script>
<style lang="scss">
.player-token {
stroke: #111;
pointer-events: none;
stroke-width: 1;
}
.content {
font-size: 1rem;
color: #212529;
pointer-events: none;
}
.player-board {
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

@ -0,0 +1,59 @@
<template>
<div class="container-fluid">
<div
class="pool pb-0 mb-1 row no-gutters"
v-if="$store.state.gaiaViewer.data.tiles && $store.state.gaiaViewer.data.tiles.techs['gaia']"
>
<Booster v-for="booster in boosters" :key="booster" :booster="booster" class="mb-2 mr-1" />
<FederationTile
v-for="([tile, numTiles], i) in federations"
:key="`${tile}-${i}`"
:federation="tile"
:numTiles="numTiles"
class="mb-2 mr-1"
/>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import Booster from './Booster.vue';
import FederationTile from "./FederationTile.vue";
import { Booster as BoosterEnum, Expansion } from '@gaia-project/engine';
@Component({
computed: {
boosters () {
return BoosterEnum.values(Expansion.All).filter(key => this.$store.state.gaiaViewer.data.tiles.boosters[key]);
},
federations () {
return Object.entries(this.$store.state.gaiaViewer.data.tiles.federations).filter(([key, value]) => value > 0);
}
},
components: {
Booster,
FederationTile
}
})
export default class Pool extends Vue {
}
</script>
<style lang="scss" scoped>
.pool {
margin-bottom: 1em;
padding-bottom: 0.5em;
padding-left: 0.5em;
padding-top: 0.5em;
border-radius: 5px;
position: relative;
border: 2px solid #333;
background-color: white;
flex-wrap: wrap;
}
</style>

View file

@ -0,0 +1,59 @@
<template>
<svg :viewBox="`0 0 ${viewWidth} 440`" :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>
<g v-if="$store.state.gaiaViewer.data.tiles && $store.state.gaiaViewer.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" />
</g>
<BoardAction
:scale="17"
:transform="`translate(${18 + 36 * Math.min(i, 12)}, ${i == 13 ? 382 : 420})`"
v-for="(action, i) in actions"
:key="action"
:action="action"
/>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { ResearchField, BoardAction as BoardActionEnum } from '@gaia-project/engine';
import ResearchTrack from './ResearchTrack.vue';
import TechTile from './TechTile.vue';
import BoardAction from "./BoardAction.vue";
@Component({
computed: {
fields (): ResearchField[] {
return ResearchField.values(this.expansions);
},
actions (): BoardActionEnum[] {
return BoardActionEnum.values(this.expansions);
},
expansions () {
return this.$store.state.gaiaViewer.data.expansions;
},
viewWidth () {
return this.fields.length * 60;
},
width () {
return this.height / 440 * this.viewWidth;
}
},
components: {
ResearchTrack,
TechTile,
BoardAction
}
})
export default class ResearchBoard extends Vue {
@Prop({ default: 450 })
height: number
}
</script>
<style lang="scss" scoped></style>

View file

@ -0,0 +1,212 @@
<template>
<g :transform="`translate(0, ${y})`" v-b-tooltip.html.left :title="tooltip" :class="field">
<rect
x="2"
y="2"
:class="['researchTile', field, { highlighted }]"
width="56"
:height="height"
rx="5"
ry="5"
@click="onClick"
/>
<Resource
v-for="(resource, i) in resources"
:key="'field-' + i"
:transform="`translate(${2 + 56 / 2 + resourceX(i)}, ${(height / 3) * 2 + 3})`"
:kind="resource.type"
:count="resource.count"
/>
<Token
v-for="player in players"
:faction="player.faction"
:transform="`translate(${tokenX(player.player)}, ${tokenY(player.player)})`"
:key="player.player"
:scale="5.5"
/>
<FederationTile
v-if="this.federation"
:federation="this.federation"
:numTiles="1"
x="5"
y="7"
height="35"
style="pointer-events: none"
/>
<circle
v-if="this.lostPlanet"
:class="['planet-fill', this.lostPlanet]"
cx="30"
cy="18"
r="10"
style="pointer-events: none"
/>
<text x="0" y="0" :transform="`translate(${2 + 56 / 2}, ${height - 10})`" class="levDesc">{{ label() }}</text>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { ResearchField, Player, Federation, Resource as ResourceEnum, researchTracks, Event, Reward, Operator, Planet as PlanetEnum } from '@gaia-project/engine';
import { descriptions } from '../data/research';
import Token from './Token.vue';
import FederationTile from './FederationTile.vue';
import Planet from './Planet.vue';
import Resource from './Resource.vue';
@Component<ResearchTile>({
computed: {
players (): Player[] {
return this.$store.state.gaiaViewer.data.players.filter(player => player.faction && player.data.research[this.field] === this.level);
},
tooltip () {
return `<b>Level ${this.level}:</b> ${descriptions[this.field][this.level]}`;
},
height () {
return (this.level === 0 || this.level === 5) ? 46 : 36;
},
federation (): Federation {
if (this.level === 5) {
if (this.field === ResearchField.Terraforming) {
return this.$store.state.gaiaViewer.data.terraformingFederation;
}
}
},
lostPlanet (): PlanetEnum {
if (this.level === 5 && this.field === ResearchField.Navigation) {
for (const pl of this.players) {
if (pl.data.lostPlanet) { return undefined; }
}
return PlanetEnum.Lost;
}
}
},
components: {
Token,
FederationTile,
Resource,
Planet
}
})
export default class ResearchTile extends Vue {
@Prop()
field: ResearchField;
@Prop()
y: number;
@Prop({ type: Number })
level: number;
resourceX (index: number) {
const res = this.resources;
const l = res.length;
const sep = l <= 2 ? 7 : 6;
return -6 * (l - 1) + index * 2 * sep - (res[0].count as any === '+' ? 2 : 0);
}
tokenX (index: number) {
return 10 + 13 * (index % 4) + 22 * (index > 3 ? 1 : 0);
}
tokenY (index: number) {
return 10 + 13 * (index > 3 ? 1 : 0);
}
onClick () {
if (this.highlighted) {
this.$store.dispatch('gaiaViewer/researchClick', this.field);
}
}
label () {
if (this.field === ResearchField.Terraforming) {
return this.level === 0 ? "cost 3" : this.level === 2 ? "cost 2" : this.level === 3 ? "cost 1" : "";
};
if (this.field === ResearchField.Navigation) {
return this.level === 0 ? "nav 1" : this.level === 2 ? "nav 2" : this.level === 4 ? "nav 3" : this.level === 5 ? "nav 4" : "";
};
if (this.field === ResearchField.GaiaProject) {
return this.level === 5 ? '4vp, g>vp' : "";
};
return '';
}
get resources () {
const events = researchTracks[this.field][this.level].map(s => new Event(s)).slice(0, 1);
const rewards = Reward.merge(...events.map(ev => ev.rewards));
if (events[0] && events[0].operator === Operator.Income) {
rewards.unshift(new Reward('+', ResourceEnum.None));
rewards[0].count = '+' as any;
}
return rewards;
}
get highlighted (): boolean {
return this.$store.state.gaiaViewer.context.highlighted.researchTiles.has(this.field + "-" + this.level);
}
}
</script>
<style lang="scss">
svg {
.researchTile {
fill: none;
stroke: #444;
stroke-width: 1;
&.trade {
fill: orange;
}
&.ship {
fill: gray;
}
&.eco {
fill: #ffd700;
}
&.sci {
fill: #99ccff;
}
&.terra {
fill: #856443;
}
&.nav {
fill: #516372;
}
&.gaia {
fill: #a5589c;
}
&.int {
fill: #508344;
}
&:hover {
fill-opacity: 0.5;
}
&.highlighted {
fill-opacity: 0.3;
cursor: pointer;
}
}
text {
font-family: arial;
font-size: 10px;
fill: black;
&.levDesc {
dominant-baseline: central;
text-anchor: middle;
fill: white;
pointer-events: none;
}
}
}
</style>

View file

@ -0,0 +1,38 @@
<template>
<g :transform="`translate(${x}, 0)`">
<ResearchTile y="270" :level="0" :field="field" />
<ResearchTile y="230" :level="1" :field="field" />
<ResearchTile y="190" :level="2" :field="field" />
<ResearchTile y="133" :level="3" :field="field" />
<ResearchTile y="93" :level="4" :field="field" />
<ResearchTile y="0" :level="5" :field="field" />
<g v-if="$store.state.gaiaViewer.data.tiles && $store.state.gaiaViewer.data.tiles.techs['gaia']">
<TechTile :pos="'adv-' + field" y="53" x="1" />
<TechTile :pos="field" y="321" x="1" />
</g>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { ResearchField } from '@gaia-project/engine';
import ResearchTile from './ResearchTile.vue';
import TechTile from './TechTile.vue';
@Component({
components: {
ResearchTile,
TechTile
}
})
export default class ResearchTrack extends Vue {
@Prop()
field: ResearchField;
@Prop()
x: number;
}
</script>
<style lang="scss" scoped></style>

View file

@ -0,0 +1,115 @@
<template>
<g class="resource">
<rect v-if="kind == 'q'" class="qic" width="14" height="14" x="-7" y="-7" />
<rect v-else-if="kind == 'o'" class="ore" width="14" height="14" x="-7" y="-7" />
<rect v-else-if="kind == 'c'" class="credit" width="16" height="16" ry="8" rx="8" x="-8" y="-8" />
<rect
v-else-if="kind == 'pw' || kind == 't'"
class="power"
width="15"
height="15"
ry="7.5"
rx="7.5"
x="-7.5"
y="-7.5"
/>
<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(7.5)"
v-else-if="kind == 'k'"
class="planet-fill r"
stroke="#333"
stroke-width="0.1"
/>
<Building
v-else-if="kind == 'gf'"
faction="ivits"
building="gf"
transform="translate(0.5, 0) scale(20)"
style="fill: none !important"
/>
<text
x="0"
y="0"
v-if="['o', 'c', 'q', 'k', 'pw', 't', 'ship'].includes(kind) || count === '+'"
:class="{ plus: count === '+' }"
>{{ count }}</text
>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import Building from './Building.vue';
@Component({
components: {
Building,
}
})
export default class Resource extends Vue {
@Prop()
kind: Resource;
@Prop()
count: number;
}
</script>
<style lang="scss">
@import "../stylesheets/planets.scss";
g.resource {
pointer-events: none;
opacity: 0.7;
rect {
stroke: #333;
stroke-width: 0.8px;
}
.qic {
fill: green;
}
.ore {
fill: #bbb;
}
.credit {
fill: $desert;
}
.power {
fill: #a41894;
}
.building {
stroke-width: 0.04px;
}
.ore,
.credit,
.building.r,
.ship {
& + text {
fill: black;
}
}
text {
font-size: 10px;
fill: white;
dominant-baseline: central;
text-anchor: middle;
&.plus {
font-size: 15px;
font-weight: bold;
fill: #333;
}
}
}
</style>

View file

@ -0,0 +1,33 @@
<template>
<svg
viewBox="0 0 80 400"
v-if="$store.state.gaiaViewer.data.tiles && $store.state.gaiaViewer.data.tiles.scorings.final"
>
<FinalScoringTile :index="0" />
<FinalScoringTile :index="1" transform="translate(0, 60)" />
<ScoringTile
v-for="i in [0, 1, 2, 3, 4, 5]"
:round="i + 1"
:transform="`translate(0, ${400 - (i + 1) * 45})`"
:key="i"
/>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component } from 'vue-property-decorator';
import ScoringTile from './ScoringTile.vue';
import FinalScoringTile from './FinalScoringTile.vue';
@Component({
components: {
ScoringTile,
FinalScoringTile
}
})
export default class ScoringBoard extends Vue {
}
</script>
<style lang="scss" scoped></style>

View file

@ -0,0 +1,72 @@
<template>
<g :class="['scoringTile', { 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>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, Event, Phase } from '@gaia-project/engine';
import { eventDesc } from '../data/event';
@Component<ScoringTile>({
computed: {
tile (this: ScoringTile) {
return this.$store.state.gaiaViewer.data.tiles.scorings.round[this.round - 1];
},
content () {
return tiles.roundScorings[this.tile][0];
},
tooltip () {
return eventDesc(new Event(this.content));
},
highlighted () {
return this.$store.state.gaiaViewer.data.round === this.round && !this.faded;
},
faded () {
return this.$store.state.gaiaViewer.data.round > this.round || this.$store.state.gaiaViewer.data.phase === Phase.EndGame;
}
}
})
export default class ScoringTile extends Vue {
@Prop()
round: number;
}
</script>
<style lang="scss">
g {
&.scoringTile {
rect {
stroke: #333;
stroke-width: 1px;
fill: white;
}
.title {
font-size: 10px;
font-weight: bold;
pointer-events: none;
}
.content {
font-size: 12px;
pointer-events: none;
}
&.highlighted rect {
stroke: #2c4;
}
&.faded {
stroke-opacity: 0.5;
fill-opacity: 0.5;
}
}
}
</style>

View file

@ -0,0 +1,59 @@
<template>
<g class="sector">
<SpaceHex
v-for="hex in sector"
:key="`${hex.q}x${hex.r}`"
:transform="`translate(${centerOffset(hex).x}, ${centerOffset(hex).y})`"
:hex="hex"
:isCenter="isCenter(hex)"
/>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { MapData, HighlightHexData } from '../data';
import { GaiaHex, GaiaHexData } from '@gaia-project/engine';
import { hexCenter } from "../graphics/hex";
import SpaceHex from './SpaceHex.vue';
import { CubeCoordinates, Hex } from 'hexagrid';
@Component<Sector>({
components: {
SpaceHex
}
})
export default class Sector extends Vue {
@Prop()
center: CubeCoordinates;
centerOffset (hex: GaiaHex) {
return hexCenter({
q: hex.q - this.center.q,
r: hex.r - this.center.r
});
}
isCenter (hex: GaiaHex) {
return hex.q === this.center.q && hex.r === this.center.r;
}
get map () {
return this.$store.state.gaiaViewer.data.map;
}
get sector (): GaiaHex[] {
const coords = Hex.hexagon(2, { center: this.center });
const ret = coords.map(coord => this.map.grid.get(coord));
return ret;
}
}
</script>
<style lang="scss">
.sector {
transition-duration: 200ms;
}
</style>

View file

@ -0,0 +1,188 @@
<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)"
/>
<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"
/>
<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)})`"
/>
<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}`"
/>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { GaiaHex, factions, Building as BuildingEnum, Planet as PlanetEnum, SpaceMap as ISpaceMap } from '@gaia-project/engine';
import { corners } from "../graphics/hex";
import Planet from './Planet.vue';
import Building from './Building.vue';
import { buildingName } from '../data/building';
import { planetNames } from '../data/planets';
@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.gaiaViewer.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('gaiaViewer/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.gaiaViewer.data.players[player].faction;
}
planet (player) {
return factions.planet(this.faction(player));
}
buildingName (building: BuildingEnum) {
return buildingName(building);
}
planetName (planet: PlanetEnum) {
return planetNames[planet];
}
get highlightedHexes (): Map<GaiaHex, any> {
return this.$store.state.gaiaViewer.context.highlighted.hexes;
}
get toSelect () {
return !!this.$store.state.gaiaViewer.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];
}
</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

@ -0,0 +1,53 @@
<template>
<svg :viewBox="`-13 -11.5 ${right} 24`">
<Sector
v-for="center in this.sectors"
:center="center"
:key="`${center.q}x{center.r}`"
:style="`transform: translate(${hexCenter(center).x * 1.01}px, ${hexCenter(center).y * 1.01}px) rotate(${
rotation(center) * 60
}deg);`"
/>
<FactionWheel transform="translate(-10.5, -8.7) scale(0.5, 0.5)" />
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component } from 'vue-property-decorator';
import { GaiaHex, SpaceMap as SpaceMapData } from '@gaia-project/engine';
import { hexCenter } from "../graphics/hex";
import Sector from './Sector.vue';
import { CubeCoordinates } from 'hexagrid';
import FactionWheel from "./FactionWheel.vue";
@Component<SpaceMap>({
components: {
Sector,
FactionWheel
}
})
export default class SpaceMap extends Vue {
hexCenter (hex: GaiaHex) {
return hexCenter(hex);
}
get sectors (): CubeCoordinates[] {
return this.map.configuration().centers;
}
rotation (center: CubeCoordinates) {
return this.$store.state.gaiaViewer.context.rotation.get(`${center.q}x${center.r}`) || 0;
}
get map (): SpaceMapData {
return this.$store.state.gaiaViewer.data.map;
}
get right () {
return (this.sectors || []).length > 7 ? 33.5 : 26;
}
}
</script>
<style lang="scss"></style>

View file

@ -0,0 +1,84 @@
<template>
<svg viewBox="-25 -25 50 50" width="50" height="50">
<g :class="['specialAction', { highlighted, 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">
{{ line.replace(/ /g, "") }}
</tspan>
</text>
</g>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, Event } from '@gaia-project/engine';
import { eventDesc } from '../data/event';
@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("gaiaViewer/actionClick", this.action);
}
get highlighted () {
return this.$store.state.gaiaViewer.context.highlighted.actions.has(this.action);
}
}
</script>
<style lang="scss">
g {
&.specialAction {
polygon {
stroke: #333;
stroke-width: 0.02;
fill: orange;
}
text {
fill: white;
text-anchor: middle;
dominant-baseline: middle;
font-size: 12px;
pointer-events: none;
}
&.highlighted polygon {
stroke: #2c4;
cursor: pointer;
stroke-width: 0.04;
}
&.disabled {
stroke-opacity: 0.6;
fill-opacity: 0.3;
text {
fill: #000;
}
}
}
}
</style>

View file

@ -0,0 +1,120 @@
<template>
<svg
:class="['techTile', { highlighted, covered }]"
v-show="this.count"
v-b-tooltip
:title="tooltip"
@click="onClick"
width="58"
height="37"
viewBox="0 0 58 37"
>
<polygon points="1,1 48,1 57,11 57,36 1,36" />
<text class="title" x="4" y="12">{{ title }}</text>
<text :class="['content', { smaller: content.length >= 10 }]" x="4" y="30">{{ content }}</text>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, PlayerEnum, Event, TechTilePos, AdvTechTilePos } from '@gaia-project/engine';
import { eventDesc } from '../data/event';
@Component<TechTile>({
computed: {
tileObject () {
return this.$store.state.gaiaViewer.data.tiles.techs[this.pos];
},
tile () {
return this.tileObject.tile;
},
count () {
if (this.player !== undefined) {
return 1;
}
return this.tileObject.count;
},
rawContent () {
return tiles.techs[this.tile][0];
},
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.gaiaViewer.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("gaiaViewer/techClick", this.pos);
}
}
get highlighted () {
return this.$store.state.gaiaViewer.context.highlighted.techs.has(this.pos);
}
}
</script>
<style lang="scss">
svg {
&.techTile {
polygon {
stroke: #333;
stroke-width: 1px;
fill: white;
}
.title {
font-size: 10px;
font-weight: bold;
pointer-events: none;
}
.content {
font-size: 11px;
pointer-events: none;
&.smaller {
font-size: 9px;
}
}
&.highlighted polygon {
stroke: #2c4;
cursor: pointer;
}
&.covered {
stroke-opacity: 0.5;
fill-opacity: 0.7;
}
}
}
</style>

View file

@ -0,0 +1,38 @@
<template>
<g>
<circle cx="0" cy="0" r="1" :transform="`scale(${scale})`" :class="['player-token', 'planet-fill', renderPlanet]" />
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { factions, Faction, Planet } from '@gaia-project/engine';
@Component
export default class PlayerToken extends Vue {
@Prop()
faction: Faction | 'automa';
@Prop()
scale: number;
@Prop()
planet: Planet;
get renderPlanet (): Planet {
if (this.planet) {
return this.planet;
}
return this.faction === 'automa' ? Planet.Lost : factions.planet(this.faction);
}
}
</script>
<style lang="scss">
g .player-token {
stroke: #111;
pointer-events: none;
stroke-width: 0.2;
}
</style>

View file

@ -0,0 +1,142 @@
<template>
<div class="turn-order">
<h5>Turn order</h5>
<svg viewBox="-1.2 -1.2 12.5 4">
<g v-for="(player, index) in turnOrder" :key="index" :transform="`translate(${index * 2.5})`">
<circle :r="1" :style="stroke(player)" :class="['player-token', 'planet-fill', planet(player, index)]" />
<text
:style="`font-size: 1.2px; text-anchor: middle; dominant-baseline: central; fill: ${planetFill(
planet(player, index)
)}`"
>
{{ initial(player, index) }}
</text>
<text :style="`font-size: 1px; text-anchor: middle;`" y="2">{{ name(player, index) }}</text>
</g>
<g
v-for="(player, index) in passedPlayers"
:key="'p-' + index"
:transform="`translate(${(index + 1 + turnOrder.length) * 2.5})`"
style="opacity: 0.5"
>
<circle :r="1" :style="stroke(player)" :class="['player-token', 'planet-fill', planet(player, index)]" />
<text
:style="`font-size: 1.2px; text-anchor: middle; dominant-baseline: central; fill: ${planetFill(
planet(player, index)
)}`"
>
{{ initial(player, index) }}
</text>
<text :style="`font-size: 1px; text-anchor: middle;`" y="2">{{ name(player, index) }}</text>
</g>
</svg>
</div>
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch } from "vue-property-decorator";
import Engine, { factions, Player, Planet, Phase } from "@gaia-project/engine";
@Component
export default class TurnOrder extends Vue {
get gameData (): Engine {
return this.$store.state.gaiaViewer.data;
}
get phaseBeforeSetupBuilding (): boolean {
const data = this.gameData;
return (data.phase === Phase.SetupInit || data.phase === Phase.SetupBoard || data.phase === Phase.SetupFaction || data.phase === Phase.SetupAuction);
}
get turnOrder (): Player[] {
const data = this.gameData;
if (this.phaseBeforeSetupBuilding) {
return data.players;
}
if (data.phase === Phase.SetupBuilding || data.phase === Phase.SetupBooster) {
return data.setup.map(faction => data.players.find(pl => pl.faction === faction));
}
return data.turnOrder.map(player => data.players[player]);
}
get passedPlayers (): Player[] {
return (this.gameData.passedPlayers ?? []).map(player => this.gameData.players[player]);
}
isCurrentPlayer (pl: Player) {
return this.gameData.players[this.gameData.availableCommands?.[0]?.player] === pl && !(this.gameData.phase === Phase.SetupAuction);
}
stroke (pl: Player) {
if (this.gameData.players[this.gameData.currentPlayer] === pl) {
if (this.gameData.players[this.gameData.playerToMove] === pl) {
return "stroke-width: 0.16px !important; stroke: #2c4";
} else {
return "stroke-width: 0.10px !important; stroke: #2c4";
}
}
if (this.gameData.players[this.gameData.tempCurrentPlayer] === pl) {
return "stroke-width: 0.18px !important; stroke: rgb(250, 116, 255)";
}
return "stroke-width: 0.06px !important";
}
planetFill (planet: string) {
if (planet === Planet.Titanium || planet === Planet.Swamp) {
return "white";
}
return "black";
}
planet (player: Player, index: number) {
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
return factions.planet(this.gameData.setup[index]);
}
if (player.faction) { return factions.planet(player.faction); };
return Planet.Lost;
}
initial (player: Player, index: number) {
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
return this.gameData.setup[index][0].toUpperCase();
}
if (player.faction) {
return player.faction[0].toUpperCase();
}
return "?";
}
name (player: Player, index: number) {
if (this.phaseBeforeSetupBuilding) {
if (this.gameData.phase === Phase.SetupAuction) {
player = this.gameData.players.find(pl => pl.faction === this.gameData.setup[index]);
} else {
return "";
}
}
if (player) {
if (player.name) {
return player.name.substring(0, 3);
} else {
return "P" + (player.player + 1);
};
}
return "?";
}
}
</script>
<style lang="scss">
.turn-order {
& > svg {
max-width: 250px;
}
}
</style>

View file

@ -0,0 +1,40 @@
<template>
<div>
<Game />
<b-modal v-model="modalShow" size="lg" @ok="handleOK" title="Load from JSON">
<b-textarea v-model="text" rows="6" />
</b-modal>
<b-avatar
button
style="position: fixed; left: 20px; bottom: 20px; z-index: 100"
size="50"
@click="modalShow = true"
>
LOAD
</b-avatar>
<b-avatar button style="position: fixed; left: 80px; bottom: 20px; z-index: 100" size="50" @click="openExport">
EXPORT
</b-avatar>
</div>
</template>
<script lang="ts">
import { Vue, Prop, Watch, Component } from "vue-property-decorator";
import Game from "./Game.vue";
@Component({
components: { Game }
})
export default class Wrapper extends Vue {
modalShow = false;
text = "";
handleOK () {
this.$store.dispatch("gaiaViewer/loadFromJSON", JSON.parse(this.text));
}
openExport () {
this.text = JSON.stringify(this.$store.state.gaiaViewer.data);
this.modalShow = true;
}
}
</script>

View file

@ -0,0 +1,22 @@
import { Building } from "@gaia-project/engine";
export function buildingName(building: Building): string {
switch (building) {
case Building.Mine:
return "mine";
case Building.Academy1:
return "academy1";
case Building.Academy2:
return "academy2";
case Building.TradingStation:
return "trading station";
case Building.ResearchLab:
return "research lab";
case Building.PlanetaryInstitute:
return "planetary institute";
case Building.GaiaFormer:
return "gaia-former";
case Building.SpaceStation:
return "space station";
}
}

71
old-ui/src/data/event.ts Normal file
View file

@ -0,0 +1,71 @@
import { Condition, Event, Operator, Resource, Reward } from "@gaia-project/engine";
const conditionsCount = {
[Condition.Mine]: "mine",
[Condition.TradingStation]: "trading station",
[Condition.ResearchLab]: "research lab",
[Condition.PlanetaryInstituteOrAcademy]: "planetary institute or academy",
[Condition.Federation]: "federation",
[Condition.Gaia]: "gaia planet colonized",
[Condition.PlanetType]: "type of planet colonized",
[Condition.Sector]: "occupied sector",
[Condition.Structure]: "colonized planet",
[Condition.StructureFed]: "colonized planet in a federation",
[Condition.Satellite]: "satellite or space station",
[Condition.HighestResearchLevel]: "level of your highest research track",
[Condition.AdvanceResearch]: "level reached in any research track",
};
const conditionsTrigger = {
[Condition.Mine]: "building a mine",
[Condition.TradingStation]: "building a trading station",
[Condition.ResearchLab]: "building a research lab",
[Condition.PlanetaryInstituteOrAcademy]: "building a planetary institute or academy",
[Condition.Federation]: "forming a federation",
[Condition.MineOnGaia]: "building a mine on a gaia planet",
[Condition.AdvanceResearch]: "advancing a level in research",
[Condition.TerraformStep]: "terraforming a planet one step",
};
const operators = {
[Operator.Pass]: "After passing,",
[Operator.Activate]: "Once per round, as a special action,",
[Operator.Income]: "During the income phase,",
[Operator.Once]: "Immediately ",
[Operator.Trigger]: "When ",
[Operator.Special]:
"Planetary institutes and academies have a power value of 4, when building federations and charging power.",
};
function rewardDesc(rewards: Reward[]) {
return rewards
.map((reward) => {
switch (reward.type) {
case Resource.TechTile:
return `gain ${reward.count} tech tile${reward.count > 1 ? "s" : ""}`;
case Resource.TemporaryStep:
return `gain ${reward.count} temporary step${reward.count > 1 ? "s" : ""}`;
case Resource.TemporaryRange:
return `gain ${reward.count} temporary range`;
case Resource.RescoreFederation:
return `gain the rewards from one of your federation tokens`;
// case Resource.Range: return `gain ${reward.count} range for the duration of the round`;
case Resource.Turn:
return `play an extra ${reward.count} turn${reward.count > 1 ? "s" : ""} at once`;
default:
return "gain " + reward.toString();
}
})
.join(", ");
}
export function eventDesc(event: Event) {
const operatorString = operators[event.operator];
const conditionString =
event.operator === Operator.Trigger
? conditionsTrigger[event.condition] + ","
: conditionsCount[event.condition] && "for each " + conditionsCount[event.condition] + ",";
const rewardString = event.rewards.length === 0 ? "" : rewardDesc(event.rewards);
return [operatorString, conditionString, rewardString].filter((x) => !!x).join(" ");
}

155
old-ui/src/data/factions.ts Normal file
View file

@ -0,0 +1,155 @@
import {
Building,
Faction,
factionBoard,
factions,
Operator,
Planet,
terraformingStepsRequired,
} from "@gaia-project/engine";
const factionData: { [faction in Faction]: { ability: string; PI: string } } = {
[Faction.Terrans]: {
ability:
"During the Gaia phase, move the power tokens in your Gaia area to area II of your power cycle instead of to area I.",
PI:
"During the Gaia phase, when you move power tokens from your Gaia area to area II of your power cycle, you may gain resources as if you were spending that much power to take free actions.",
},
[Faction.Lantids]: {
ability:
"When you take the Build a Mine action, you may build a mine on a planet colonized by an opponent (including the Lost Planet). Place your mine next to the opponent’s structure. You do not have to pay for terraforming, but you must still pay the mine’s cost. This mine counts as a normal mine in all ways except the following: this mine cannot be upgraded, and it does not count for any effects that relate to how many planet types or Gaia planets you have colonized.",
PI: "Each time you build a mine on a planet colonized by an opponent, gain two knowledge.",
},
[Faction.Xenos]: {
ability: "You place a third starting mine after all other starting mines have been placed.",
PI:
"You can form federations with a total power value of six instead of seven. You gain one Q.I.C. as income instead of one power token.",
},
[Faction.Gleens]: {
ability:
"If you would ever gain Q.I.C., gain that much ore instead; once you have upgraded to the second academy, this effect no longer applies. To make a Gaia Planet habitable, pay one ore instead of one Q.I.C. Each time you build a mine on a Gaia Planet, gain two additional VP.",
PI:
"When you upgrade to the planetary institute, immediately gain the Gleens’ federation token (2 credits, 1 ore, 1 knowledge). Gaining this tile counts as forming a federation. The planetary institute itself can still be part of a federation on the board.",
},
[Faction.Taklons]: {
ability:
"The Brainstone counts as one power token (when starting a Gaia Project, building satellites, etc.), but you can spend it as if it were three power.",
PI:
"Each time you would charge power from “Passive Action: Charge Power,” you gain one power token. You can choose to gain the power before or after charging.",
},
[Faction.Ambas]: {
ability: "-",
PI:
"Once per round, as an action, you can swap your planetary institute with one of your mines on the game board (this can help you form a new federation). This has no impact on existing federations, even if their power value becomes less than seven. The swap does not count as a build or upgrade action; no VP or power can be gained from it.",
},
[Faction.HadschHallas]: {
ability: "-",
PI: "You can spend credits instead of power to take free actions that allow you to gain resources.",
},
[Faction.Ivits]: {
ability: `During setup, do not place mines. Instead, after all other players have placed mines (including the Xenos’ third mine), place your planetary institute on any red planet.
You can have only one federation during the whole game, but unlike other factions, you will be able to grow that federation to gain new federation tokens. After you have formed a federation,
to take the “Form a Federation” action again, you must connect planets to that federation instead of forming a new federation. The power values of the structures on those planets must bring the total power value of that federation to at least to 7X, where X is the number of federation tokens you own plus one (not including the federation token from level 5 of “Terraforming”). All other rules for forming a federation apply, including building satellites and gaining federation tokens. To build a satellite during this action, you must spend one Q.I.C. instead of discarding one power.`,
PI: `As a special action, place a space station on an accessible space that does not contain a planet or another space station.
The accessibility of a space follows the same rules as the “Build a Mine” action. Like planets, a space station can
be connected with satellites; each space station counts as having a power value of one for its federation.
A space station is not a structure, so placing one does not allow opponents to charge power. A space station does not count as a colonized planet,
but it can be used as a “starting point” when determining the accessibility of a planet (i.e., range can be counted from a space station).
Your opponents can place satellites in a space containing a space station.`,
},
[Faction.Geodens]: {
ability: "-",
PI:
"The first time you build a mine on each planet type, gain 3 knowledge. (You do not gain knowledge for planet types you colonized before upgrading to your planetary institute.)",
},
[Faction.BalTaks]: {
ability: `You cannot advance in the “Navigation” research area, even if you take the tech tile below the “Navigation” research area. If you do take that tech tile, no advancement occurs.
As a free action, you can move a Gaiaformer from a Gaiaformer space on your faction board to your Gaia area to gain one Q.I.C. Gaiaformers in your Gaia area are not available until the next Gaia phase. In the next Gaia phase, move any Gaiaformer in your Gaia area back to its Gaiaformer space.`,
PI: "You can now advance in the “Navigation” research area.",
},
[Faction.Firaks]: {
ability: "-",
PI:
"As an action, you can “downgrade” a research lab into a trading station and immediately advance one level in a research area of your choice. This counts as an “Upgrade to a Trading Station” action. You can later upgrade the trading station back into a research lab using the normal rules (including gaining a new tech tile).",
},
[Faction.Bescods]: {
ability: `The positions of your planetary institute and academies are swapped on your faction board, as is the income you gain for trading stations and research labs. As with the other factions, upgrading to an academy or a research lab allows you to gain a tech tile.
Once per round, as an action, you can advance your lowest-level token in a research area (without paying knowledge). If multiple of your tokens are tied for the lowest level, choose which of
the tied tokens to advance. To advance to level 5 this way, you must still flip a federation token as normal. Remember, only one player can reach level 5 of each research area.`,
PI:
"The power value of your structures on gray planets (your home type) is increased by one (in addition to any other effects that increase their power value).",
},
[Faction.Nevlas]: {
ability:
"As a free action, you can move one power token from area III of your power cycle to your Gaia area to gain one knowledge (these power tokens follow the normal Gaia phase rules). This does not count as spending power.",
PI:
"You can spend power tokens in area III of your power cycle as if they were each two power. Otherwise, they count as one power token (when starting a Gaia Project, building satellites, etc.). When paying for a power action with an odd power cost (1, 3, 5, etc.), the unspent power is lost.",
},
[Faction.Itars]: {
ability:
"Each time you discard a power token from area II of your power cycle to move another power token to area III, place the discarded power token in your Gaia area instead of returning it to the supply.",
PI: `During the Gaia phase, you can discard 4 power tokens from your Gaia area to immediately gain a tech tile. You may do this as many times as you can afford to.`,
},
};
export function planetsWithSteps(planet: Planet, steps: number) {
// Planets are ordered the same as in the planet wheel
let list = [Planet.Terra, Planet.Oxide, Planet.Volcanic, Planet.Desert, Planet.Swamp, Planet.Titanium, Planet.Ice];
// Properly rearrange the list for wheel effect
if (list.includes(planet)) {
list = list.slice(list.lastIndexOf(planet)).concat(list.slice(0, list.indexOf(planet)));
}
return list.filter((p) => terraformingStepsRequired(planet, p) === steps);
}
export function factionDesc(faction: Faction) {
const board = factionBoard(faction);
const p = factions[faction].planet;
const buildingDesc =
"<ul>" +
Object.values(Building)
.filter((bld) => bld !== Building.GaiaFormer && bld !== Building.SpaceStation)
.map(
(bld) =>
"<li><b>" +
bld +
"</b> - " +
board.buildings[bld].cost +
" -> " +
(bld !== Building.ResearchLab ? board.buildings[bld].income : board.buildings[bld].income[0]) +
"</li>"
)
.join("\n") +
"</ul>";
const startingIncome = board.income.filter((ev) => ev.operator === Operator.Once);
const roundIncome = board.income.filter((ev) => ev.operator === Operator.Income);
return `
<div class='faction-desc'>
<b>Ability: </b> ${factionData[faction].ability} </br>
<b>Planetary Institute: </b> ${factionData[faction].PI}<br/>
<b>Buildings:</b> ${buildingDesc.replace(/,,/g, ",~,").replace(/,/g, ", ")}
<b>Starting Income:</b> ${startingIncome.toString().replace(/,/g, ", ")} </br>
<b>Round Income:</b> ${roundIncome} </br>
<span style="white-space: nowrap; line-height: 1em">
<b>Steps:</b>
${[0, 1, 2, 3]
.map(
(i) =>
`<span class="ml-2">${planetsWithSteps(p, i)
.map(
(p) =>
`<svg width="15" height="20" viewbox="0 0 15 15" >
<circle cx="7" cy="6" r="6" class="player-token planet-fill ${p}" />
</svg>`
)
.join("")} ${i}</span>`
)
.join("")}
</span>
</div>
`;
}

48
old-ui/src/data/index.ts Normal file
View file

@ -0,0 +1,48 @@
import { AdvTechTilePos, Booster, Federation, GaiaHex, TechTilePos } from "@gaia-project/engine";
export interface ButtonData {
label?: string;
command: string;
tooltip?: string;
// Simple label
title?: string;
times?: number[];
modal?: string;
hexes?: HighlightHexData;
automatic?: boolean; // Should the user have to click on the hex or is it automatic?
hover?: boolean;
researchTiles?: string[];
techs?: Array<TechTilePos | AdvTechTilePos>;
boosters?: Booster[];
selectHexes?: boolean;
actions?: string[];
federations?: Federation[];
range?: number;
costs?: { [range: number]: string };
// Rotate sectors command?
rotation?: boolean;
needConfirm?: boolean;
buttons?: ButtonData[];
hide?: boolean;
booster?: Booster;
}
export type MapData = GaiaHex[];
export type HighlightHexData = Map<GaiaHex, { cost?: string }>;
export interface GameContext {
highlighted: {
hexes: HighlightHexData;
researchTiles: Set<string>;
techs: Set<TechTilePos | AdvTechTilePos>;
boosters: Set<Booster>;
actions: Set<string>;
federations: Set<Federation>;
};
rotation: Map<string, number>;
activeButton: ButtonData;
hexSelection: boolean;
}

View file

@ -0,0 +1,27 @@
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",
};

View file

@ -0,0 +1,52 @@
import { ResearchField } from "@gaia-project/engine";
export const descriptions = {
[ResearchField.Economy]: [
"This level has no effect.",
"During each income phase, gain two credits and charge one power.",
"During each income phase, gain one ore, two credits, and charge two power.",
"During each income phase, gain one ore, three credits, and charge three power.",
"During each income phase, gain two ore, four credits, and charge four power.",
"Immediately gain three ore, six credits, and charge six power. Remember that you no longer receive the income from level 4.",
],
[ResearchField.Science]: [
"This level has no effect.",
"During each income phase, gain one knowledge.",
"During each income phase, gain two knowledge.",
"During each income phase, gain three knowledge.",
"During each income phase, gain four knowledge.",
"Immediately gain nine knowledge. Remember that you no longer receive the income from level 4.",
],
[ResearchField.Terraforming]: [
"Each terraforming step costs you three ore.",
"Each terraforming step costs you three ore. Immediately gain two ore.",
"Each terraforming step costs you two ore.",
"Each terraforming step costs you one ore.",
"Each terraforming step costs you one ore. Immediately gain two ore.",
"Each terraforming step costs you one ore. Immediately gain the federation token placed here. Gaining this federation token counts as “Forming a Federation.” Remember that you must have a previously acquired federation token in order to advance to level 5 of this research area and claim the federation token there.",
],
[ResearchField.Intelligence]: [
"This level has no effect.",
"Immediately gain one Q.I.C.",
"Immediately gain one Q.I.C.",
"Immediately gain two Q.I.C.",
"Immediately gain two Q.I.C.",
"Immediately gain four Q.I.C.",
],
[ResearchField.Navigation]: [
"Your basic range is one.",
"Your basic range is one. Immediately gain one Q.I.C.",
"Your basic range is two.",
"Your basic range is two. Immediately gain one Q.I.C.",
"Your basic range is three.",
"Your basic range is four. Immediately place the Lost Planet token on an accessible space that does not contain a planet, satellite, or space station. The accessibility of a space follows the same rules as the “Build a Mine” action. This counts as a “Build a Mine” action, meaning you can gain VP and your opponents can gain power. Do not place a mine on the Lost Planet token. You are considered to have colonized the planet; place one of your satellites on the Lost Planet token as a reminder. The Lost Planet counts as its own planet type, and as a planet with a mine. You cannot upgrade this mine.",
],
[ResearchField.GaiaProject]: [
"This level has no effect. You cannot start a Gaia Project.",
"To start a Gaia project, you must move six power tokens to your Gaia area. Immediately gain one of your Gaiaformers.",
"To start a Gaia project, you must move six power tokens to your Gaia area. Immediately gain three power tokens.",
"To start a Gaia project, you must move four power tokens to your Gaia area. Immediately gain one of your Gaiaformers.",
"To start a Gaia project, you must move three power tokens to your Gaia area. Immediately gain one of your Gaiaformers.",
"To start a Gaia project, you must move three power tokens to your Gaia area. Immediately gain 4 VP and 1 additional VP for each Gaia Planet with one of your structures on it (you do not gain VP for Gaiaformers on Gaia Planets).",
],
};

View file

@ -0,0 +1,21 @@
import { CubeCoordinatesPartial } from "hexagrid/src/cubecoordinates";
const vSpacing = Math.sqrt(3) / 2;
export function hexCenter(hex: CubeCoordinatesPartial, radius = 1) {
return {
x: hex.r * 1.5 * radius,
y: -(2 * hex.q + hex.r) * vSpacing * radius,
};
}
export function corners(radius = 1) {
return [
{ x: -radius, y: 0 },
{ x: -radius / 2, y: -vSpacing * radius },
{ x: radius / 2, y: -vSpacing * radius },
{ x: radius, y: 0 },
{ x: radius / 2, y: vSpacing * radius },
{ x: -radius / 2, y: vSpacing * radius },
];
}

View file

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

97
old-ui/src/launcher.ts Normal file
View file

@ -0,0 +1,97 @@
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 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("gaiaViewer/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("gaiaViewer/preferences", data));
item.addListener("player", (data) => store.commit("gaiaViewer/player", data));
item.addListener("replay:start", () => {
store.dispatch("gaiaViewer/replayStart");
replaying = true;
});
item.addListener("replay:to", (info) => {
store.dispatch("gaiaViewer/replayTo", info);
item.emit("replaceLog", (store.state as any).gaiaViewer.data.moveHistory);
});
item.addListener("replay:end", () => {
store.dispatch("gaiaViewer/replayEnd");
replaying = false;
item.emit("fetchState");
});
item.addListener("gamelog", (logData) => {
if (replaying) {
//
} else {
store.dispatch("gaiaViewer/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 === "gaiaViewer/move") {
item.emit("move", payload);
return;
}
if (type === "gaiaViewer/playerClick") {
item.emit("player:clicked", {
name: payload.name,
auth: payload.auth,
index: (store as Store<any>).state.gaiaViewer.data?.players?.findIndex((pl) => pl === payload),
});
}
if (type === "gaiaViewer/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 launch;

12
old-ui/src/main.ts Normal file
View file

@ -0,0 +1,12 @@
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");
} */

View file

@ -0,0 +1,39 @@
import Engine from "@gaia-project/engine";
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 === "gaiaViewer/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 launchSelfContained;

4
old-ui/src/shims.d.ts vendored Normal file
View file

@ -0,0 +1,4 @@
declare module "*.vue" {
import Vue from "vue";
export default Vue;
}

139
old-ui/src/store.ts Normal file
View file

@ -0,0 +1,139 @@
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 = {
namespaced: true,
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({
modules: {
gaiaViewer,
},
});
}
export default makeStore();
export { gaiaViewer, makeStore };

View file

@ -0,0 +1,60 @@
// @import "~font-awesome/css/font-awesome.css";
// // Bootstrap settings
// $font-family-sans-serif: $thin-font;
// $body-bg: $color-base;
// $body-color: $color-text;
// $link-color: $color-text;
// $navbar-dark-active-color: $color-primary;
// $list-group-bg: $color-list-item;
// $primary: $color-primary;
// $secondary: $color-text;
// $dark: $color-dark;
// $dropdown-bg: $color-list-item;
// $border-radius: 2px;
// $dropdown-divider-bg: $color-divider;
// $dropdown-link-color: $color-text-faded;
// $dropdown-link-hover-color: $color-text;
// $dropdown-link-hover-bg: transparent;
// $display2-size: 4.5rem;
// $display3-size: 3.5rem;
// $display4-size: 2.5rem;
// $display5-size: 2rem;
// $display6-size: 1.5rem;
@import "~bootstrap/scss/bootstrap.scss";
@import "~bootstrap-vue";
.tooltip {
.tooltip-inner {
max-width: 400px;
text-align: left;
}
}
.notransition {
transition: none !important;
}
.tooltip#tooltip-canvas {
opacity: 1;
display: none;
&.tooltip-show {
display: block;
}
// Center-vertically
.arrow {
top: 0;
bottom: 0;
margin-top: auto;
margin-bottom: auto;
}
.tooltip-inner {
max-width: 400px;
text-align: left;
}
}

View file

@ -0,0 +1,10 @@
$terra: #2080f0;
$desert: #f2ff00;
$swamp: #6f5a3e;
$oxide: #ff160a;
$titanium: #808080;
$ice: #f8fff5;
$volcanic: #ffa135;
$gaia: #093;
$transdim: #a64dff;
$lost: lightgray;

17
old-ui/src/wrapper.ts Normal file
View file

@ -0,0 +1,17 @@
// Import vue component
import launch from "./launcher";
import launchSelfContained from "./self-contained";
let globalItem: any;
if (typeof window !== "undefined") {
globalItem = window;
} else if (typeof global !== "undefined") {
globalItem = global;
}
if (globalItem) {
globalItem.gaiaViewer = { launch, launchSelfContained };
}
export { launchSelfContained };
export default launch;

21
old-ui/tsconfig.json Normal file
View file

@ -0,0 +1,21 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es2019",
"module": "ES2020",
"moduleResolution": "node",
"sourceMap": true,
"outDir": "./dist" /* Redirect output structure to the directory. */,
// "paths": {
// "@/*": [
// "src/*"
// ]
// },
"baseUrl": ".",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true
},
"include": ["src/**/*.ts", "src/**/*.vue", "src/*.ts"],
"exclude": ["node_modules"]
}

20
old-ui/vue.config.js Normal file
View file

@ -0,0 +1,20 @@
/* eslint-disable */
const path = require("path");
if (process.argv.includes("lib")) {
module.exports = {
lintOnSave: false,
outputDir: path.join(__dirname, "dist/package"),
// css: {extract: false}
chainWebpack: (config) => {
config.externals({
"bootstrap-vue": "BootstrapVue",
});
},
};
} else {
module.exports = {
lintOnSave: false,
outputDir: path.join(__dirname, "dist/app"),
};
}

View file

@ -1,3 +1,4 @@
packages:
- "viewer"
- "engine"
- "old-ui"

View file

@ -78,9 +78,9 @@ try {
const gitmoji = gitmojis.find((gm) => msg.startsWith(gm));
assert(gitmoji, "Commit message should start with gitmoji");
assert(msg[gitmoji.length] === " ", "Space should follow gitmoji");
assert(/^[^ ]* \((all|viewer|engine)\)/.test(msg), "Commit scope should be 'all', 'engine' or 'viewer'");
assert(/^[^ ]* \((all|viewer|engine|old-ui)\)/.test(msg), "Commit scope should be 'all', 'engine' or 'viewer'");
assert(
/^[^ ]* \((all|viewer|engine)\) [A-Z]/.test(msg),
/^[^ ]* \((all|viewer|engine|old-ui)\) [A-Z]/.test(msg),
"Commit subject should start with a space and an uppercase letter"
);
} catch (err) {

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2018 donkeytech
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -7,6 +7,10 @@
"rzulian",
"zeitlinger"
],
"repository": "git@github.com:boardgamers-mono/gaia-project.git",
"publishConfig": {
"access": "public"
},
"scripts": {
"serve": "vue-cli-service serve --port 8080",
"build": "vue-cli-service build",
@ -87,14 +91,6 @@
"last 2 versions",
"not dead"
],
"bugs": {
"url": "https://github.com/donkeytech/gaia-viewer/issues"
},
"homepage": "https://github.com/donkeytech/gaia-viewer#readme",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/donkeytech/gaia-viewer.git"
},
"source": "index.ts"
}