🚚 (viewer) Move to a subfolder

This commit is contained in:
coyotte508 2021-02-19 00:49:52 +01:00
commit af0aeeb518
119 changed files with 2937 additions and 2518 deletions

View file

@ -1,5 +1,13 @@
name: Gaia Engine
on: [push, pull_request]
on:
push:
paths:
- ".github/workflows/engine-test.yml"
- "engine"
pull_request:
paths:
- ".github/workflows/engine-test.yml"
- "engine"
jobs:
lint_and_test:

View file

@ -1,14 +0,0 @@
name: Test
on: [pull_request, push]
jobs:
test_and_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- run: yarn install
- run: yarn test
- run: yarn build

View file

@ -1,4 +1,4 @@
name: Version and Release
name: Viewer - Version and Release
on:
workflow_dispatch:
@ -21,6 +21,7 @@ jobs:
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"
- run: cd viewer
- run: yarn install
- run: git config --global user.name github-action
- run: git config --global user.email hello@github.com

25
.github/workflows/viewer-test.yml vendored Normal file
View file

@ -0,0 +1,25 @@
name: Viewer - Test
on:
push:
paths:
- ".github/workflows/viewer-test.yml"
- "viewer"
branches:
- master
pull_request:
paths:
- ".github/workflows/viewer-test.yml"
- "viewer"
jobs:
test_and_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14"
- run: cd viewer
- run: yarn install
- run: yarn test
- run: yarn build

View file

@ -1,88 +1,24 @@
[![Join the chat at https://gitter.im/gaia-engine](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gaia-engine?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# Gaia Project
# gaia-viewer
A Vue.js / SVG UI for Gaia Project
Mono repo containing the viewer & the engine for Gaia Project
Checkout their READMEs:
- [engine](./engine/README.md)
- [viewer](./viewer/README.md)
## Demo
Check out [boardgamers.space](https://www.boardgamers.space)!
Check out [boardgamers.space](https://www.boardgamers.space)! Reach out to us if you want to contribute.
## Build and Run
## Test locally
```bash
# install deps, do this everytime yarn.lock is modified
You can run the viewer with:
```
cd viewer
yarn install
# run
yarn serve
```
And open localhost:8080 in the browser.
You can change [src/self-contained.ts](src/self-contained.ts) to change the initial setup: number of players, factions...
## Use local engine
Download and install `gaia-engine`.
In `gaia-engine`'s folder:
```
yarn link
```
In `gaia-viewer`'s folder
```
yarn link @gaia-project/engine
```
Now your gaia-viewer will use your local engine, instead of the one on NPM
## Include in other projects
For now there are three ways to include the viewer:
- By importing individual components: If you want to integrate into an existing Vue APP, for example
- Through `index.ts`, the default export is the `launch` function: The viewer will create its own Vue App on the given selector
- Through `unpkg.com/@gaia-project/viewer`, which will set `window.gaiaViewer` or `global.gaiaViewer`. Here is an example:
```html
<script src="//unpkg.com/vue@^2/dist/vue.min.js"></script>
<script src="//unpkg.com/bootstrap-vue@^2/dist/bootstrap-vue.min.js"></script>
<script source="//unpkg.com/@gaia-project/viewer">
<link type="text/css" rel="stylesheet" href="//unpkg.com/@gaia-project/viewer/dist/package/viewer.css">
```
If you want something else, contact us.
### launch function
The default export, and `window.gaiaViewer.launch` / `global.gaiaViewer.launch` when included via a `script` tag, is a function taking a css selector as an argument. When executed, it instantiates a Game on the aformentioned element, and returns an `EventEmitter` that can be communicated with.
The EventEmitter has this interface:
```js
// Give the new game data to the viewer
emitter.emit('state', gameData);
// Update preferences
emitter.emit('preferences', {noFactionFill: true});
// Set player - choose either. If no player is set, then everyone can play
// in the same window
emitter.emit('player', {auth: "xxx"});
emitter.emit('player', {index: 0});
// Listen for move actions
emitter.on('move', (move) => {/* send move to backend and give back result */});
// Signals that a player's name was clicked
emitter.on('player:clicked', ({name, index, auth}) => {/* ... */});
```
If you want a self-contained game which plays in the browser with no interaction with your code, you can do:
```js
// via <script>
window.gaiaViewer.launchSelfContained("#my-selector");
// via import
import {launchSelfContained} from '@gaia-project/viewer';
```
It will use the engine in its sibling folder

View file

@ -1,130 +0,0 @@
<template>
<g :class='["boardAction", kind, {highlighted}]' v-b-tooltip :title="tooltip">
<SpecialAction :class='{faded}' :action="boardActions[action].income" :highlighted=highlighted :board=true x=-20 y=-25 width=40 @click="onClick" />
<g transform=translate(-15,-15)>
<image v-if="kind === 'power'" xlink:href='../assets/resources/power-charge.svg' width=20 :height=133/345*20 transform=" scale(-1,1) translate(-9, -12)" />
<rect x=-8 y=-8 width=16 height=16 :rx="kind === 'power' ? 8 : 0" :ry="kind === 'power' ? 8 : 0" stroke="black" stroke-width="1" :fill="kind === 'power' ? '#984FF1' : 'green'" transform=scale(0.8) v-if="costNumber>1" />
<text x="-3" y="3.5" v-if="costNumber>1" fill="white" style="fill: white !important">
{{costNumber}}
</text>
</g>
<g v-if="faded">
<line y1="-11" y2="11" x1=-11 x2=11 stroke=#333 stroke-width=5 />
<line y1="11" y2="-11" x1=-11 x2=11 stroke=#333 stroke-width=5 />
</g>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, Event, BoardAction as BoardActionEnum, boardActions, Reward } from '@gaia-project/engine';
import { eventDesc } from '../data/event';
import Resource from './Resource.vue';
import SpecialAction from './SpecialAction.vue';
@Component<BoardAction>({
components: {
Resource,
SpecialAction
}
})
export default class BoardAction extends Vue {
@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);
}
get tooltip () {
const costDesc = "Spend " + this.cost + "\n";
return costDesc + boardActions[this.action].income.map(x => eventDesc(new Event(x))).join('\n');
}
get faded () {
return !this.$store.state.gaiaViewer.data.boardActions[this.action];
}
get kind () {
return this.action[0] === 'p' ? 'power' : 'qic';
}
get rewards () {
return boardActions[this.action].income.map(x => new Reward(x));
}
get 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('-');
}));
}
get cost () {
return boardActions[this.action].cost;
}
get costNumber () {
return new Reward(this.cost).count;
}
boardActions=boardActions;
}
</script>
<style lang="scss">
@import '../stylesheets/planets.scss';
g {
&.boardAction {
& > polygon {
stroke: #333;
stroke-width: 0.02;
}
&.qic {
& > polygon {
fill: $res-qic;
}
}
&.power {
& > polygon {
fill: $res-power;
}
}
& > text {
fill: white;
text-anchor: middle;
dominant-baseline: middle;
font-size: 12px;
pointer-events: none;
}
&.highlighted > polygon {
stroke: $highlighted;
cursor: pointer;
stroke-width: 0.08;
}
}
.faded {
opacity: 0.5;
}
}
</style>

View file

@ -1,114 +0,0 @@
<template>
<g :class='["building"]'>
<component :is="buildingComponent" :faction=faction :filter="outline ? 'url(#shadow-5)' : (outlineWhite ? 'url(#white-shadow-5)' : '')" v-if="!flat" />
<g :class='["planet-fill", planetClass]' v-else >
<rect v-if="mine" x="-20" y="-20" width="40" height="40" />
<rect v-else-if="planetaryInstitute" x="-37.5" y="-37.5" width="75" height="75" />
<polygon v-else-if="gaiaFormer" :points='hexCorners' />
<circle v-else-if="lab" r="30" />
<circle v-else-if="academy" r="50" />
<polygon v-else-if="tradingStation" points="-20,-20 0,-38 20,-20 20,20 -20,20" transform="translate(0, 0.08)"/>
<circle v-else-if="spaceStation" r="20" />
</g>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { Faction, Building as BuildingEnum, Planet, factions } from '@gaia-project/engine';
import Academy from './Buildings/Academy.vue';
import GaiaFormer from './Buildings/GaiaFormer.vue';
import Mine from './Buildings/Mine.vue';
import PlanetaryInstitute from './Buildings/PlanetaryInstitute.vue';
import ResearchLab from './Buildings/ResearchLab.vue';
import SpaceStation from './Buildings/SpaceStation.vue';
import TradingStation from './Buildings/TradingStation.vue';
import { corners } from '../graphics/hex';
import { planetClass } from '../graphics/utils';
const components = {
[BuildingEnum.Mine]: "Mine",
[BuildingEnum.TradingStation]: "TradingStation",
[BuildingEnum.GaiaFormer]: "GaiaFormer",
[BuildingEnum.SpaceStation]: "SpaceStation",
[BuildingEnum.Academy1]: "Academy",
[BuildingEnum.Academy2]: "Academy",
[BuildingEnum.PlanetaryInstitute]: "PlanetaryInstitute",
[BuildingEnum.ResearchLab]: "ResearchLab"
};
@Component({
components: {
Academy,
GaiaFormer,
Mine,
PlanetaryInstitute,
ResearchLab,
SpaceStation,
TradingStation
}
})
export default class Building extends Vue {
@Prop()
faction: Faction;
@Prop({ default: false, type: Boolean })
flat: boolean;
@Prop()
building: BuildingEnum;
@Prop({ default: false, type: Boolean })
outline: boolean;
@Prop({ default: false, type: Boolean })
outlineWhite: boolean;
get buildingComponent () {
return components[this.building];
}
// FLAT buildings
get planetClass () {
return planetClass(this.faction);
}
get hexCorners () {
return corners().map(({ x, y }) => `${x * 40},${y * 40}`).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: 3;
pointer-events: none;
stroke: #111;
& > * {
transform: scale(0.1);
}
}
.additionalMine {
stroke-width: 5;
}
}
</style>

View file

@ -1,77 +0,0 @@
<template>
<g class="condition">
<Building v-if="isBuilding" outline-white :building="condition" :flat="flat" faction='gen' transform="translate(0, 0) scale(2.2)" />
<g v-else-if="condition === 'fed'" transform="scale(0.45)">
<Federation width=50 x=-20 y=-30 :used=true filter="url(#white-shadow-1)" />
</g>
<PlanetType v-else-if="condition === 'pt'" transform=scale(1.1) />
<Sector v-else-if="condition === 's'" transform=scale(1.5) />
<g v-else-if="condition === 'g'" transform=scale(0.85) >
<image xlink:href="../assets/conditions/planet.svg" width=25 height=25 x=-12 y=-11.5 transform="scale(-1,1)" />
</g>
<Resource v-else-if="condition === 'step'" kind="step" />
<g v-else-if="condition === 'mg'" >
<image v-if="!flat" xlink:href="../assets/conditions/planet-flat.svg" :height=120/198*30 width=30 x=-12 y=-13.5 transform="translate(-2,0) scale(-1,-1)" />
<circle v-else r="10" :class='["planet-fill", "g" ]' transform="translate(0,0)" />
<Building building="m" outline-white :flat="flat" faction='gen' :transform="`translate(${flat ? 0 : 0}, ${flat ? 0 : 0}) scale(2.2)`" />
</g>
<g v-else-if="condition === 'PA'">
<Building building="PI" outline-white :flat="flat" faction='gen' :transform="`translate(${flat ? -5 : -2}, 1) scale(1.8)`" />
<Building building="ac1" outline-white :flat="flat" faction='gen' :transform="`translate(5, ${flat ? 1 : 2}) scale(1.8)`" />
</g>
<g v-else-if="condition === 'a'">
<line x1="-15" x2="15" stroke ="#666" />
<line x1="-15" x2="15" y1=-10 y2=-10 stroke ="#666" />
<line x1="-15" x2="15" y1=10 y2=10 stroke ="#666" />
<image xlink:href="../assets/operators/trigger.svg" width=15 :height=529/328*15 :transform="`rotate(180), translate(6, -8), scale(0.7)`" />
<!-- <text y=-1 style="font-size: 9px">3</text>
<text y=8.5 style="font-size: 9px">2</text>-->
</g>
</g>
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch } from "vue-property-decorator";
import { Condition as ConditionEnum, Building as BuildingEnum } from "@gaia-project/engine";
import Building from './Building.vue';
import Federation from './FederationTile.vue';
import Planet from './Planet.vue';
import PlanetType from './Conditions/PlanetType.vue';
import Sector from './Conditions/Sector.vue';
@Component({
components: {
Building,
Federation,
Planet,
PlanetType,
Sector
}
})
export default class Condition extends Vue {
@Prop()
condition!: ConditionEnum;
get isBuilding () {
return Object.values(BuildingEnum).includes(this.condition as any);
}
get flat () {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
}
</script>
<style lang="scss">
@import '../stylesheets/planets.scss';
g {
&.condition {
&.gaia {
fill: $gaia;
}
}
}
</style>

View file

@ -1,104 +0,0 @@
<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}
.accessible-space-map &.v {stroke-dasharray:.25; stroke-width: .1;}
// gaia
&.g {stroke: $gaia }
.accessible-space-map &.g {stroke-dasharray:.14; stroke-width: .1;}
// transdim
&.m {stroke: $transdim}
.accessible-space-map &.m {stroke-dasharray:.14; stroke-width: .1;}
// 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}
// generic planet
&.gen {fill: $generic}
//diggable planet
&.dig {fill: $dig}
}
}
</style>

View file

@ -1,140 +0,0 @@
<template>
<g class="power-bowls">
<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="#00aa00" />
<Resource v-if="power('gaia')>0" :kind="'bowl-t'" :count="power('gaia')" :transform="`translate(${xPos('gaia')}, ${yPos('gaia')}) scale(0.11)`"/>
<Resource v-if="brainstone('gaia')==1" :kind="'brainstone'" :transform="`translate(${power('gaia')>0 ? 0.9 : 0}, ${yPos('gaia')}) scale(0.11)`"/>
<Resource v-if="data.gaiaformersInGaia>0" :kind="'gf'" :count="data.gaiaformersInGaia" :faction="faction" :transform="`translate(0, 0.7) scale(0.09)`"/>
</g>
<g :transform="`translate(${-r*spacing}, ${2*r*sin60*spacing})`">
<circle :r=r class="power-bowl" />
<Resource v-if="power('area1')>0" :kind="'bowl-t'" :count="power('area1')" :transform="`translate(${xPos('area1')}, 0) scale(0.11)`"/>
<Resource v-if="brainstone('area1')==1" :kind="'brainstone'" :transform="`translate(${power('area1')>0 ? 0.9 : 0}, 0) scale(0.11)`"/>
<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 class="power-bowl" />
<Resource v-if="power('area2')>0" :kind="'bowl-t'" :count="power('area2')" :transform="`translate(${xPos('area2')}, 0) scale(0.11)`"/>
<Resource v-if="brainstone('area2')==1" :kind="'brainstone'" :transform="`translate(${power('area2')>0 ? 0.9 : 0}, 0) scale(0.11)`"/>
<text class="label" x=-2.6>II</text>
</g>
<g :transform="`translate(${2*r*spacing}, 0)`">
<circle :r=r class="power-bowl" />
<Resource v-if="power('area3')>0" :kind="'bowl-t'" :count="power('area3')" :transform="`translate(${xPos('area3')}, 0) scale(0.11)`"/>
<Resource v-if="brainstone('area3')==1" :kind="'brainstone'" :transform="`translate(${power('area3')>0 ? 0.9 : 0}, 0) scale(0.11)`"/>
<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 Building from '../Building.vue';
import { Faction, Reward, FactionBoard, Operator, Resource as ResourceEnum, factions, PlayerData, Player } from '@gaia-project/engine';
@Component({
components: {
Resource,
Building
}
})
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;
}
xPos (area: string) {
return this.brainstone(area) ? -0.9 : 0;
}
yPos (area: string) {
return this.data.gaiaformersInGaia > 0 ? -0.5 : 0;
}
power (area: string) {
return this.data.power[area];
}
brainstone (area: string) {
return this.data.brainstone === area;
}
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));
}
get flat () {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
}
</script>
<style lang="scss">
@import '../../stylesheets/planets.scss';
.power-bowls {
circle {
stroke-width: 0.05px;
stroke: black;
}
.power-bowl {
fill: purple;
}
.power {
fill: $res-power;
}
.brainstone {
fill: $res-power;
}
text {
fill: white;
font-size: 1.2px;
text-anchor: middle;
dominant-baseline: mathematical;
&.label {
fill: #333;
}
}
}
</style>

View file

@ -1,178 +0,0 @@
<template>
<g class="resource">
<template v-if="kind === 'q'" >
<Qic v-if="!flat" class="qic" :transform="`translate(-0.5,0)`" />
<rect v-else class="qic" width="14" height="14" x="-7" y="-7" />
</template>
<!-- <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="['pw', 'pay-pw', 't', 'bowl-t', 'tg', 'brainstone'].includes(kind)"
:class="kind === 'tg' ? 'gaia': 'power'"
width="15" height="15" ry="7.5" rx="7.5" x="-7.5" y="-7.5" />
<polygon points="-7.5,3 -3,7.5 3,7.5 7.5,3 7.5,-3 3,-7.5 -3,-7.5 -7.5,-3" v-else-if="kind=='k'" class="knowledge" />
<g v-else-if="kind=='vp'" transform="translate(-7.5,-7.5)" class="vp">
<VictoryPoint width="15" height="15" />
</g>
<Building v-else-if="kind=='gf'" building="gf" transform="translate(0.5, 0) scale(2.5)" :flat="flat" :faction="faction"/>
<g v-else-if="kind=='swap-PI'" transform="scale(-1,1)">
<Building faction="ambas" building="m" transform="translate(-8.5, 0) scale(1.5)" :flat="flat"/>
<Building faction="ambas" building="PI" transform="translate(6, 0) scale(1.5)" :flat="flat"/>
<image xlink:href="../assets/resources/swap-arrow.svg" width=15 :height=129/343*15 x=-7.5 y=-14 />
</g>
<g v-else-if="kind=='down-lab'" transform="scale(-1,1)">
<Building faction="firaks" building="lab" transform="translate(-7.5, 0) scale(1.5)" :flat="flat"/>
<Building faction="firaks" building="ts" transform="translate(7.5, 0) scale(-1.5,1.5)" :flat="flat"/>
<image xlink:href="../assets/resources/arrow-charge.svg" width=15 :height=133/346*15 x=-7.5 y=-14 />
</g>
<Building v-else-if="kind=='space-station'" building="sp" transform="translate(0.5, 0) scale(2.5)" faction="ivits" :flat="flat" />
<template v-else-if="kind === 'step'">
<image v-if="!flat" xlink:href='../assets/resources/dig-planet.svg' width=20 height=20 x=-10 y=-10 />
<circle v-else r="10" :class='["planet-fill", "dig" ]' />
<template v-if="count === 1 || !count">
<image xlink:href='../assets/resources/dig-arrow.svg' width=14 :height=325/308*14 x=-11 y=-4 />
</template>
<template v-else-if="count === 2">
<image xlink:href='../assets/resources/dig-arrow.svg' width=14 :height=325/308*14 x=-13 y=-7 />
<image xlink:href='../assets/resources/dig-arrow.svg' width=14 :height=325/308*14 x=-9 y=-2 />
</template>
</template>
<template v-else-if="kind === 'd'">
<g transform=translate(3,0) >
<image v-if="!flat" xlink:href='../assets/resources/dig-planet.svg' width=20 height=20 x=-10 y=-10 />
<circle v-else r="10" :class='["planet-fill", "dig" ]' />
<image xlink:href='../assets/resources/dig-arrow.svg' :height=325/308*14 width=14 x=-11 y=-4 />
</g>
<g transform=translate(-7,-7)>
<rect class="ore" width="12" height="12" x="-6" y="-6" />
<text x="0" y="0">{{4-count}}</text>
</g>
</template>
<image v-else-if="kind === 'tech'" xlink:href='../assets/resources/tech.svg' :height=155/211*22 width=22 x=-11 y=-8 />
<Federation v-else-if="kind === 'fed'" width=22 x=-11 y=-26.5 :used=true />
<template v-else-if="kind === 'range'">
<image xlink:href="../assets/resources/flat-hex.svg" :height=162/328*20 width=15 y=-9 x=-2 />
<image xlink:href="../assets/resources/flat-hex.svg" :height=162/328*20 width=20 y=3 x=-10 />
<image xlink:href="../assets/resources/range-arrow.svg" :height=285/164*9 width=9 y=-8 x=-2 transform="rotate(5)" />
<text v-if="count > 1" x=-7 y=-2.5 stroke="black" stroke-width=0.3 style="font-weight: bold; font-size: 15px; stroke-width: 0.7px" >
{{count}}
</text>
</template>
<template v-else-if="kind === 'r'">
<g transform="scale(1) translate(-13,0)">
<image xlink:href="../assets/resources/flat-hex.svg" :height=162/328*20 width=20 x=-10 y=-4 />
</g>
<g transform="scale(1) translate(13,0)">
<image xlink:href="../assets/resources/flat-hex.svg" :height=162/328*20 width=20 x=-10 y=-4 />
</g>
<g transform="translate(1,0) rotate(70)">
<image xlink:href="../assets/resources/range-arrow.svg" :height=285/164*9 width=10 x=-5 y=-8 />
</g>
<text v-if="count >= 1" x=13 y=1.2 stroke-width=0.3 style="font-weight: bold; font-size: 10px" >
{{count}}
</text>
</template>
<template v-else-if="kind === 'up-lowest'">
<Condition condition="a" transform="scale(0.75)" />
<Token faction="bescods" transform="scale(0.15) translate(50,-24)" />
<Token faction="bescods" transform="scale(0.15) translate(-5,26)" />
</template>
<image v-if="kind === 'pw'" xlink:href='../assets/resources/power-charge.svg' :height=133/346*20 width=20 transform="translate(-9.5, -13.5)" />
<image v-if="kind === 'pay-pw'" xlink:href='../assets/resources/power-charge.svg' :height=133/346*20 width=20 transform="translate(9.5, -13.5) scale(-1,1) " />
<text x="0" y="0" v-if="count >=0 && ['o','c','k','pw','pay-pw','t','bowl-t','tg','vp','q','gf'].includes(kind) || count === '+'" :class="{plus: count === '+'}">{{kind === 't' ? '+' : ''}}{{count}}</text>
<text x="0" y="0" v-if="kind=='brainstone'">B</text>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { Faction } from '@gaia-project/engine';
import Building from './Building.vue';
import Qic from './Resources/Qic.vue';
import VictoryPoint from './Resources/VictoryPoint.vue';
import Federation from './FederationTile.vue';
import Token from './Token.vue';
@Component({
components: {
Building,
Federation,
Qic,
Token,
VictoryPoint
}
})
export default class Resource extends Vue {
@Prop()
kind: Resource | "brainstone";
@Prop()
count: number;
@Prop({ default: false })
centerLeft: boolean;
@Prop({ default: 'gen' })
faction: Faction;
get flat () {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
}
</script>
<style lang="scss">
@import '../stylesheets/planets.scss';
g.resource {
pointer-events: none;
rect, .knowledge {
stroke: #111;
stroke-width: 0.9px;
fill: $res-knowledge;
}
.qic {
fill: $res-qic;
}
.ore {
fill: $res-ore;
}
.credit {
fill: $res-credit;
}
.power {
fill: $res-power
}
.gaia {
fill: $gaia
}
.ore, .credit, .building.r {
& + text {
fill: black
}
}
text {
font-size: 10px;
fill: white;
font-weight: 600;
dominant-baseline: central;
text-anchor: middle;
&.plus {
font-size: 22px;
stroke: #111;
fill: white;
}
}
}
</style>

View file

@ -1,95 +0,0 @@
<template>
<g :class='["scoringTile", {highlighted, faded}]' v-b-tooltip :title="tooltip">
<rect x="1" y="1" width="75" height="40" rx=2 ry=2 stroke="none" fill="white" />
<text class="title" x="58" y="36">R{{round}}</text>
<!-- <text class="content" x="5" y="31">{{content.split(" ")[0]}}</text>-->
<Resource :kind=reward.type :count=reward.count transform="translate(63.7, 13.1) scale(1.5)" />
<Condition :condition=event.condition :transform="`translate(${(event.condition === 'step' || event.condition === 'a' || event.condition === 'PA') ? 27 + (event.condition === 'PA' ? 8 : 0 ) : 34}, ${event.condition === 'step' ? 20 : 22}) scale(1.3)`" />
<Operator :condition=event.condition :operator=event.operator transform="translate(28, 27) scale(1)" />
<rect x="1" y="1" width="75" height="40" rx=2 ry=2 class="contour" />
</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';
import Condition from './Condition.vue';
import Resource from './Resource.vue';
import Operator from './Operator.vue';
@Component<ScoringTile>({
components: {
Condition,
Operator,
Resource
}
})
export default class ScoringTile extends Vue {
@Prop()
round: number;
get tile (this: ScoringTile) {
return this.$store.state.gaiaViewer.data.tiles.scorings.round[this.round - 1];
}
get event () {
return new Event(this.content);
}
get reward () {
return this.event.rewards[0];
}
get content () {
return tiles.roundScorings[this.tile][0];
}
get tooltip () {
return eventDesc(this.event);
}
get highlighted () {
return this.$store.state.gaiaViewer.data.round === this.round && !this.faded;
}
get faded () {
return this.$store.state.gaiaViewer.data.round > this.round || this.$store.state.gaiaViewer.data.phase === Phase.EndGame;
}
}
</script>
<style lang="scss">
@import '../stylesheets/planets.scss';
g {
&.scoringTile {
& > rect.contour {
fill: none;
stroke: #333;
stroke-width: 1px;
}
.title {
font-size: 10px;
font-weight: bold;
pointer-events: none;
}
.content {
font-size: 12px;
pointer-events: none;
}
&.highlighted > rect.contour {
stroke: $highlighted;
stroke-width: 1.5px;
}
&.faded {
opacity: 0.5;
}
}
}
</style>

View file

@ -1,136 +0,0 @@
<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, hex.data.player)}` : ''}}{{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 style="stroke-width: 10;" v-if="hex.data.building" :building='hex.data.building' :faction='faction(hex.data.player)' outline :flat="flat" transform="scale(0.1)" />
<Building style="stroke-width: 10;" v-if="hex.data.additionalMine !== undefined" :faction='faction(hex.data.additionalMine)' building="m" transform="translate(0.4, 0.2) scale(0.09)" class="additionalMine" :flat="flat" outline />
<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, Faction } 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 flat () {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
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, player) {
return `${buildingName(building)} (${factions[this.faction(player)].name})`;
}
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;
}
}
</script>
<style lang="scss">
svg {
.spaceHex {
fill: #172E62;
stroke: #666;
stroke-width: 0.01;
&:hover {
fill-opacity: 0.5;
}
&.highlighted {
fill: white;
cursor: pointer;
&.qic {
fill: lightGreen
}
&.power {
fill: #d378d3
}
}
&.toSelect {
cursor: pointer;
opacity: 0.7;
}
}
.spaceHexFederation {
stroke-width: 0.1;
fill: none;
pointer-events: none;
}
.sector-name {
text-anchor: middle;
dominant-baseline: central;
font-size: 1px;
fill: white;
opacity: 0.35;
pointer-events: none;
}
}
</style>

View file

@ -1,113 +0,0 @@
<template>
<g>
<text :class="['content', {smaller: content.length >= 10}]" x="-25" y="0" v-if="showText">{{content}}</text>
<SpecialAction v-if="isAction" :action="['>' + content.split('=>')[1].trim()]" y=-20 width=40 height=40 x=-20 />
<Condition :condition=condition v-if="condition === 'a'" transform="scale(1.5)" />
<Resource v-if="cornerReward" :count=cornerReward.count :kind=cornerReward.type transform="translate(19, -19), scale(1.35)" />
<g v-if="event.operator === '|'">
<polygon points="-30,-28 -20,-28 -20,28 -30,28" fill="#F8031D" stroke=black stroke-width=1 stroke-miterlimit=1 />
<text x=-25 y=0 style="text-anchor: middle; dominant-baseline: central; font-size: 8px; fill: white !important; letter-spacing: 0px; writing-mode: vertical-rl; text-orientation: upright; ">PASS</text>
</g>
<Condition :condition=condition v-if="condition !== 'a'" :transform="`translate(${event.operator==='>>' && condition !== 'a' ? 8 : 0}, 0) scale(1.5)`" />
<Resource v-for="(res, i) in centerRewards" :count=res.count :kind=res.type :key=i :transform="`translate(${centerRewards.length > 1 ? (i - 0.5) * 26 : 0 }, 0) scale(${centerRewards.length === 1 ? 2 : 1.5})`" />
<Resource v-for="(res, i) in rightRewards" :count=res.count :kind=res.type :key="'right-'+i" :transform="`translate(13, ${rightRewards.length > 1 ? (i - 0.5) * 28 : 0 }) scale(1.5)`" />
<template v-if="event.operator === 'PA->4pw'">
<Building building="PI" :transform="`translate(${flat ? -8 : -5.5}, -8) scale(2.7)`" :flat="flat" faction='gen' />
<Building building="ac1" :transform="`translate(${flat ? 8 : 5.5}, ${flat? -8 : -6 }) scale(2.7)`" :flat="flat" faction='gen' />
<Resource kind="t" transform="translate(-20, 18) scale(0.8)" />
<Resource kind="t" transform="translate(-6.66, 18) scale(0.8)" />
<Resource kind="t" transform="translate(6.66, 18) scale(0.8)" />
<Resource kind="t" transform="translate(20, 18) scale(0.8)" />
</template>
<template v-else-if="event.operator==='>>'">
<Operator :operator=event.operator :condition=event.condition transform="translate(2,5) scale(1.2)" />
</template>
<text style="font-size: 40px; stroke: black; fill: white; dominant-baseline: central; text-anchor: middle; stroke-width: 1px; font-weight: bold;" x="-14" v-if="event.operator === '+'">+</text>
</g>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, PlayerEnum, Event, TechTilePos, AdvTechTilePos, Operator as OperatorEnum, Condition as ConditionEnum, Building as BuildingEnum } from '@gaia-project/engine';
import { eventDesc } from '../data/event';
import Resource from './Resource.vue';
import Building from './Building.vue';
import Condition from './Condition.vue';
import Operator from './Operator.vue';
import SpecialAction from './SpecialAction.vue';
@Component({
components: {
Building,
Condition,
Operator,
Resource,
SpecialAction
}
})
export default class TechContent extends Vue {
@Prop()
content!: string;
get event () {
return new Event(this.content);
}
get cornerReward () {
if (this.event.operator === OperatorEnum.Trigger || this.event.operator === OperatorEnum.Pass || (this.event.operator === OperatorEnum.Once && this.event.condition !== ConditionEnum.None)) {
return this.event.rewards[0];
}
return null;
}
get centerRewards () {
if (this.event.operator === OperatorEnum.Once && this.event.condition === ConditionEnum.None) {
return this.event.rewards;
}
return [];
}
get condition () {
return this.event.condition;
}
get rightRewards () {
if (this.event.operator === OperatorEnum.Income) {
return this.event.rewards;
}
return [];
}
get showText () {
if (this.event.operator === OperatorEnum.Activate || this.event.operator === OperatorEnum.Income || this.event.operator === OperatorEnum.Special) {
return false;
}
if (this.event.operator === OperatorEnum.Once || this.event.operator === OperatorEnum.Trigger || this.event.operator === OperatorEnum.Pass) {
// console.log(this.event, this.event.condition);
if ([ConditionEnum.None, ConditionEnum.Federation, ConditionEnum.PlanetaryInstituteOrAcademy, ConditionEnum.AdvanceResearch, ConditionEnum.MineOnGaia, ConditionEnum.PlanetType, ConditionEnum.Sector, ConditionEnum.Gaia, ...Object.values(BuildingEnum)].includes(this.event.condition as any)) {
return false;
}
}
return true;
}
get isAction () {
return this.event.operator === OperatorEnum.Activate;
}
get rewards () {
return this.event.rewards;
}
get flat () {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
}
</script>

View file

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

View file

@ -1,109 +0,0 @@
import { Faction, Operator, Building, Planet, factions, terraformingStepsRequired, factionBoard } 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>
`;
}

View file

@ -1,24 +0,0 @@
import { Faction, factions, Planet } from "@gaia-project/engine";
import planets from "../data/planets";
export function factionColor (faction: Faction | "gen"): string {
if (faction === "gen") {
return "#d3d3d3";
}
return planets[factions[faction].planet].color;
}
export function planetColor (planet: Planet): string {
return planets[planet].color;
}
export function planetClass (faction: string): string {
switch (faction as any) {
case "wild": return Planet.Transdim;
case "gaia": return Planet.Gaia;
case "gen": return "gen";
case "dig": return "dig";
case "automa": return "gen";
default: return factions.planet(faction as Faction);
}
}

View file

73
viewer/README.md Normal file
View file

@ -0,0 +1,73 @@
# gaia-viewer
A Vue.js / SVG UI for Gaia Project
## Demo
Check out [boardgamers.space](https://www.boardgamers.space)!
## Build and Run
```bash
# install deps, do this everytime yarn.lock is modified
yarn install
# run
yarn serve
```
And open localhost:8080 in the browser.
You can change [src/self-contained.ts](src/self-contained.ts) to change the initial setup: number of players, factions...
## Include in other projects
For now there are three ways to include the viewer:
- By importing individual components: If you want to integrate into an existing Vue APP, for example
- Through `index.ts`, the default export is the `launch` function: The viewer will create its own Vue App on the given selector
- Through `unpkg.com/@gaia-project/viewer`, which will set `window.gaiaViewer` or `global.gaiaViewer`. Here is an example:
```html
<script src="//unpkg.com/vue@^2/dist/vue.min.js"></script>
<script src="//unpkg.com/bootstrap-vue@^2/dist/bootstrap-vue.min.js"></script>
<script source="//unpkg.com/@gaia-project/viewer">
<link type="text/css" rel="stylesheet" href="//unpkg.com/@gaia-project/viewer/dist/package/viewer.css">
```
If you want something else, contact us.
### launch function
The default export, and `window.gaiaViewer.launch` / `global.gaiaViewer.launch` when included via a `script` tag, is a function taking a css selector as an argument. When executed, it instantiates a Game on the aformentioned element, and returns an `EventEmitter` that can be communicated with.
The EventEmitter has this interface:
```js
// Give the new game data to the viewer
emitter.emit("state", gameData);
// Update preferences
emitter.emit("preferences", { noFactionFill: true });
// Set player - choose either. If no player is set, then everyone can play
// in the same window
emitter.emit("player", { auth: "xxx" });
emitter.emit("player", { index: 0 });
// Listen for move actions
emitter.on("move", (move) => {
/* send move to backend and give back result */
});
// Signals that a player's name was clicked
emitter.on("player:clicked", ({ name, index, auth }) => {
/* ... */
});
```
If you want a self-contained game which plays in the browser with no interaction with your code, you can do:
```js
// via <script>
window.gaiaViewer.launchSelfContained("#my-selector");
// via import
import { launchSelfContained } from "@gaia-project/viewer";
```

View file

@ -28,9 +28,9 @@
"dist/package/img"
],
"dependencies": {
"@gaia-project/engine": "^4.4.2",
"bootstrap": "^4.4.1",
"bootstrap-vue": "^2.12.0",
"@engine": "../engine",
"lodash": "^4.17.15",
"vue": "^2.6.11",
"vuex": "^3.0.1"
@ -53,7 +53,7 @@
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2",
"hexagrid": "^2.1.0",
"node-sass": "^4.7.2",
"sass": "^1.32.8",
"popper": "^1.0.1",
"popper.js": "^1.16.1",
"sass-loader": "^8.0.2",

View file

Before

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

After

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

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 968 B

After

Width:  |  Height:  |  Size: 968 B

Before After
Before After

View file

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 580 B

After

Width:  |  Height:  |  Size: 580 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 409 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 778 B

After

Width:  |  Height:  |  Size: 778 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 306 B

After

Width:  |  Height:  |  Size: 306 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 316 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 369 B

After

Width:  |  Height:  |  Size: 369 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 373 B

After

Width:  |  Height:  |  Size: 373 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 911 B

After

Width:  |  Height:  |  Size: 911 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 339 B

After

Width:  |  Height:  |  Size: 339 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 913 B

After

Width:  |  Height:  |  Size: 913 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 528 B

After

Width:  |  Height:  |  Size: 528 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 253 B

After

Width:  |  Height:  |  Size: 253 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 376 B

After

Width:  |  Height:  |  Size: 376 B

Before After
Before After

View file

@ -8,39 +8,50 @@
</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>
<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 />
<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 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>
<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';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import Engine, { LogEntry } from "@gaia-project/engine";
@Component({
computed: {
data () {
data() {
return this.$store.state.gaiaViewer.data;
},
history (): Array<{move: string; entry: LogEntry}> {
history(): Array<{ move: string; entry: LogEntry }> {
const ret = [];
let advancedLogIndex = 0;
let nextLogEntry = this.data.advancedLog[advancedLogIndex];
@ -73,16 +84,13 @@ import Engine, { LogEntry } from '@gaia-project/engine';
ret.reverse();
return ret;
}
}
},
},
})
export default class AdvancedLog extends Vue {
}
export default class AdvancedLog extends Vue {}
</script>
<style lang="scss" scoped>
.major-event {
font-weight: bold;
}

View file

@ -0,0 +1,151 @@
<template>
<g :class="['boardAction', kind, { highlighted }]" v-b-tooltip :title="tooltip">
<SpecialAction
:class="{ faded }"
:action="boardActions[action].income"
:highlighted="highlighted"
:board="true"
x="-20"
y="-25"
width="40"
@click="onClick"
/>
<g transform="translate(-15,-15)">
<image v-if="kind === 'power'" xlink:href='../assets/resources/power-charge.svg' width=20 :height=133/345*20
transform=" scale(-1,1) translate(-9, -12)" />
<rect
x="-8"
y="-8"
width="16"
height="16"
:rx="kind === 'power' ? 8 : 0"
:ry="kind === 'power' ? 8 : 0"
stroke="black"
stroke-width="1"
:fill="kind === 'power' ? '#984FF1' : 'green'"
transform="scale(0.8)"
v-if="costNumber > 1"
/>
<text x="-3" y="3.5" v-if="costNumber > 1" fill="white" style="fill: white !important">
{{ costNumber }}
</text>
</g>
<g v-if="faded">
<line y1="-11" y2="11" x1="-11" x2="11" stroke="#333" stroke-width="5" />
<line y1="11" y2="-11" x1="-11" x2="11" stroke="#333" stroke-width="5" />
</g>
</g>
</template>
<script lang="ts">
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { tiles, Event, BoardAction as BoardActionEnum, boardActions, Reward } from "@gaia-project/engine";
import { eventDesc } from "../data/event";
import Resource from "./Resource.vue";
import SpecialAction from "./SpecialAction.vue";
@Component<BoardAction>({
components: {
Resource,
SpecialAction,
},
})
export default class BoardAction extends Vue {
@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);
}
get tooltip() {
const costDesc = "Spend " + this.cost + "\n";
return costDesc + boardActions[this.action].income.map(x => eventDesc(new Event(x))).join("\n");
}
get faded() {
return !this.$store.state.gaiaViewer.data.boardActions[this.action];
}
get kind() {
return this.action[0] === "p" ? "power" : "qic";
}
get rewards() {
return boardActions[this.action].income.map(x => new Reward(x));
}
get 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("-");
})
);
}
get cost() {
return boardActions[this.action].cost;
}
get costNumber() {
return new Reward(this.cost).count;
}
boardActions = boardActions;
}
</script>
<style lang="scss">
@import "../stylesheets/planets.scss";
g {
&.boardAction {
& > polygon {
stroke: #333;
stroke-width: 0.02;
}
&.qic {
& > polygon {
fill: $res-qic;
}
}
&.power {
& > polygon {
fill: $res-power;
}
}
& > text {
fill: white;
text-anchor: middle;
dominant-baseline: middle;
font-size: 12px;
pointer-events: none;
}
&.highlighted > polygon {
stroke: $highlighted;
cursor: pointer;
stroke-width: 0.08;
}
}
.faded {
opacity: 0.5;
}
}
</style>

View file

@ -1,44 +1,64 @@
<template>
<svg :class='["booster", {highlighted, disabled}]' v-b-tooltip :title="tooltip" @click="onClick" width="60" height="120" viewBox="-32 -62 64 124" style="overflow: visible">
<rect x="-30" y="-60" width="60" height="120" rx="3" ry="3" stroke="black" stroke-width=1 class="booster-background" filter="url(#shadow-1)" />
<line x1=-29 x2=29 y1=-8 y2=-8 stroke=#aaa stroke-width=2 />
<TechContent :content=event1 transform="translate(0, -33)" />
<TechContent :content=event2 :transform="`translate(0, ${30 - (event2.startsWith('+') ? 4 : 0)})`" />
</svg>
<svg
:class="['booster', { highlighted, disabled }]"
v-b-tooltip
:title="tooltip"
@click="onClick"
width="60"
height="120"
viewBox="-32 -62 64 124"
style="overflow: visible"
>
<rect
x="-30"
y="-60"
width="60"
height="120"
rx="3"
ry="3"
stroke="black"
stroke-width="1"
class="booster-background"
filter="url(#shadow-1)"
/>
<line x1="-29" x2="29" y1="-8" y2="-8" stroke="#aaa" stroke-width="2" />
<TechContent :content="event1" transform="translate(0, -33)" />
<TechContent :content="event2" :transform="`translate(0, ${30 - (event2.startsWith('+') ? 4 : 0)})`" />
</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';
import TechContent from './TechContent.vue';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { tiles, Event } from "@gaia-project/engine";
import { eventDesc } from "../data/event";
import TechContent from "./TechContent.vue";
@Component<Booster>({
computed: {
tileObject () {
tileObject() {
return tiles.boosters[this.booster];
},
event1 () {
event1() {
return this.tileObject[0];
},
event2 () {
event2() {
return this.tileObject[1];
},
title () {
title() {
return this.booster;
},
tooltip () {
tooltip() {
return `- ${eventDesc(new Event(this.event1))}\n- ${eventDesc(new Event(this.event2))}`;
}
},
},
components: {
TechContent
}
TechContent,
},
})
export default class Booster extends Vue {
@Prop()
@ -47,20 +67,20 @@ export default class Booster extends Vue {
@Prop()
disabled: boolean;
onClick () {
onClick() {
if (this.highlighted) {
this.$store.dispatch("gaiaViewer/boosterClick", this.booster);
}
}
get highlighted () {
get highlighted() {
return this.$store.state.gaiaViewer.context.highlighted.boosters.has(this.booster);
}
}
</script>
<style lang="scss">
@import '../stylesheets/planets.scss';
@import "../stylesheets/planets.scss";
svg {
&.booster {
@ -72,7 +92,8 @@ svg {
font-weight: bold;
pointer-events: none;
}
.event1, .event2 {
.event1,
.event2 {
font-size: 12px;
pointer-events: none;
}
@ -88,5 +109,4 @@ svg {
}
}
}
</style>

View file

@ -0,0 +1,138 @@
<template>
<g :class="['building']">
<component
:is="buildingComponent"
:faction="faction"
:filter="outline ? 'url(#shadow-5)' : outlineWhite ? 'url(#white-shadow-5)' : ''"
v-if="!flat"
/>
<g :class="['planet-fill', planetClass]" v-else>
<rect v-if="mine" x="-20" y="-20" width="40" height="40" />
<rect v-else-if="planetaryInstitute" x="-37.5" y="-37.5" width="75" height="75" />
<polygon v-else-if="gaiaFormer" :points="hexCorners" />
<circle v-else-if="lab" r="30" />
<circle v-else-if="academy" r="50" />
<polygon v-else-if="tradingStation" points="-20,-20 0,-38 20,-20 20,20 -20,20" transform="translate(0, 0.08)" />
<circle v-else-if="spaceStation" r="20" />
</g>
</g>
</template>
<script lang="ts">
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { Faction, Building as BuildingEnum, Planet, factions } from "@gaia-project/engine";
import Academy from "./Buildings/Academy.vue";
import GaiaFormer from "./Buildings/GaiaFormer.vue";
import Mine from "./Buildings/Mine.vue";
import PlanetaryInstitute from "./Buildings/PlanetaryInstitute.vue";
import ResearchLab from "./Buildings/ResearchLab.vue";
import SpaceStation from "./Buildings/SpaceStation.vue";
import TradingStation from "./Buildings/TradingStation.vue";
import { corners } from "../graphics/hex";
import { planetClass } from "../graphics/utils";
const components = {
[BuildingEnum.Mine]: "Mine",
[BuildingEnum.TradingStation]: "TradingStation",
[BuildingEnum.GaiaFormer]: "GaiaFormer",
[BuildingEnum.SpaceStation]: "SpaceStation",
[BuildingEnum.Academy1]: "Academy",
[BuildingEnum.Academy2]: "Academy",
[BuildingEnum.PlanetaryInstitute]: "PlanetaryInstitute",
[BuildingEnum.ResearchLab]: "ResearchLab",
};
@Component({
components: {
Academy,
GaiaFormer,
Mine,
PlanetaryInstitute,
ResearchLab,
SpaceStation,
TradingStation,
},
})
export default class Building extends Vue {
@Prop()
faction: Faction;
@Prop({ default: false, type: Boolean })
flat: boolean;
@Prop()
building: BuildingEnum;
@Prop({ default: false, type: Boolean })
outline: boolean;
@Prop({ default: false, type: Boolean })
outlineWhite: boolean;
get buildingComponent() {
return components[this.building];
}
// FLAT buildings
get planetClass() {
return planetClass(this.faction);
}
get hexCorners() {
return corners()
.map(({ x, y }) => `${x * 40},${y * 40}`)
.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: 3;
pointer-events: none;
stroke: #111;
& > * {
transform: scale(0.1);
}
}
.additionalMine {
stroke-width: 5;
}
}
</style>

View file

@ -4,7 +4,7 @@
<h5>
<span v-if="init">Pick the number of players</span>
<span v-else>
{{[player, ...titles].join(' - ')}}
{{ [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>
@ -12,15 +12,38 @@
</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>
<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
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
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>
@ -28,8 +51,8 @@
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import Engine, {
AvailableCommand,
Booster,
@ -43,30 +66,30 @@ import Engine, {
Resource,
Reward,
SpaceMap,
tiles
} from '@gaia-project/engine';
import MoveButton from './MoveButton.vue';
import { buildingName } from '../data/building';
import { ButtonData, GameContext } from '../data';
import { eventDesc } from '../data/event';
import { factionDesc } from '../data/factions';
tiles,
} from "@gaia-project/engine";
import MoveButton from "./MoveButton.vue";
import { buildingName } from "../data/building";
import { ButtonData, GameContext } from "../data";
import { eventDesc } from "../data/event";
import { factionDesc } from "../data/factions";
@Component<Commands>({
watch: {
availableCommands (this: Commands, val) {
availableCommands(this: Commands, val) {
this.loadCommands(val);
}
},
},
methods: {
tooltip (faction: Faction) {
tooltip(faction: Faction) {
return factionDesc(faction);
}
},
},
computed: {
canUndo () {
canUndo() {
return !this.$store.state.gaiaViewer.data.newTurn;
},
randomFactionButton () {
randomFactionButton() {
this.updater = this.updater + 1;
const command = this.command;
const faction = command.data[Math.floor(Math.random() * command.data.length)];
@ -75,21 +98,21 @@ import { factionDesc } from '../data/factions';
command: `${command.name} ${faction}`,
label: "Random",
modal: this.tooltip(faction),
title: factions[faction].name
title: factions[faction].name,
};
}
},
},
components: {
MoveButton
}
MoveButton,
},
})
export default class Commands extends Vue {
@Prop({ default: '' })
@Prop({ default: "" })
remainingTime: string;
updater = 0;
loadCommands (val: AvailableCommand[]) {
loadCommands(val: AvailableCommand[]) {
this.commandTitles = [];
this.customButtons = [];
this.commandChain = [];
@ -97,7 +120,7 @@ export default class Commands extends Vue {
for (const command of val) {
if (command.name === Command.ChooseFaction) {
this.title('Choose your faction');
this.title("Choose your faction");
return;
}
}
@ -112,15 +135,15 @@ export default class Commands extends Vue {
// });
}
get availableCommands (): AvailableCommand[] {
get availableCommands(): AvailableCommand[] {
return this.engine.availableCommands;
}
get command (): AvailableCommand {
get command(): AvailableCommand {
return this.availableCommands ? this.availableCommands[0] : null;
}
get player (): string {
get player(): string {
if (this.engine.players[this.command.player].faction) {
return factions[this.engine.players[this.command.player].faction].name;
}
@ -130,39 +153,43 @@ export default class Commands extends Vue {
return "Player " + (this.command.player + 1);
}
get playerSlug (): string {
get playerSlug(): string {
return this.$store.state.gaiaViewer.data.players[this.command.player].faction || `p${this.command.player + 1}`;
}
get init () {
get init() {
return (!this.command && this.engine.moveHistory.length === 0) || this.command.name === Command.Init;
}
get commandName () {
get commandName() {
return this.command?.name;
}
get chooseFaction () {
get chooseFaction() {
return this.commandName === Command.ChooseFaction;
}
get titles () {
get titles() {
return this.commandTitles.length === 0 ? ["Your turn"] : this.commandTitles;
}
get factions () {
get factions() {
return factions;
}
updateRandomFaction () {
updateRandomFaction() {
this.updater += 1;
}
handleCommand (command: string, source: MoveButton, final: boolean) {
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")) {
if (
this.commandChain.length > 0 &&
this.commandChain.slice(-1).pop() === command &&
(command === "income" || command === "booster")
) {
console.log("repeating command, ignoring");
return;
}
@ -186,31 +213,31 @@ export default class Commands extends Vue {
if (this.init) {
this.$emit("command", command);
} else {
this.$emit("command", `${this.playerSlug} ${[...this.commandChain, command].join(' ')}`);
this.$emit("command", `${this.playerSlug} ${[...this.commandChain, command].join(" ")}`);
}
}
undo () {
undo() {
this.$emit("undo");
}
title (title: string) {
title(title: string) {
this.commandTitles.push(title);
}
get context (): GameContext {
get context(): GameContext {
return this.$store.state.gaiaViewer.context;
}
get engine (): Engine {
get engine(): Engine {
return this.$store.state.gaiaViewer.data;
}
get map (): SpaceMap {
get map(): SpaceMap {
return this.engine.map;
}
get buttons (): ButtonData[] {
get buttons(): ButtonData[] {
const ret: ButtonData[] = [];
for (const command of this.availableCommands) {
switch (command.name) {
@ -218,8 +245,10 @@ export default class Commands extends Vue {
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 [GaiaHex, {}])),
rotation: true
hexes: new Map<GaiaHex, {}>(
this.map.configuration().centers.map(center => [this.engine.map.grid.get(center), {}] as [GaiaHex, {}])
),
rotation: true,
});
break;
@ -235,7 +264,11 @@ export default class Commands extends Vue {
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) {
} else if (
coordinates[0].cost === "~" ||
building === Building.SpaceStation ||
building === Building.GaiaFormer
) {
label = `Place a ${buildingName(building)}`;
}
@ -243,7 +276,9 @@ export default class Commands extends Vue {
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]))
hexes: new Map<GaiaHex, { cost?: string }>(
coordinates.map(coord => [this.engine.map.getS(coord.coordinates), coord])
),
});
}
}
@ -255,7 +290,7 @@ export default class Commands extends Vue {
ret.push({
label: "Swap Planetary Institute",
command: command.name,
hexes: new Map(command.data.buildings.map(coord => [this.engine.map.getS(coord.coordinates), coord]))
hexes: new Map(command.data.buildings.map(coord => [this.engine.map.getS(coord.coordinates), coord])),
});
break;
}
@ -264,7 +299,7 @@ export default class Commands extends Vue {
ret.push({
label: "Place Lost Planet",
command: command.name,
hexes: new Map(command.data.spaces.map(coord => [this.engine.map.getS(coord.coordinates), coord]))
hexes: new Map(command.data.spaces.map(coord => [this.engine.map.getS(coord.coordinates), coord])),
});
break;
}
@ -273,7 +308,12 @@ export default class Commands extends Vue {
case Command.ChooseRoundBooster: {
const buttons: ButtonData[] = [];
const warning = (this.engine.round > 0 && this.engine.players[this.command.player].data.hasResource(new Reward(1, Resource.GaiaFormer)) && this.engine.players[this.command.player].faction === Faction.BalTaks) ? "Are you sure you want to pass with gaiaformers not yet converted?" : undefined;
const warning =
this.engine.round > 0 &&
this.engine.players[this.command.player].data.hasResource(new Reward(1, Resource.GaiaFormer)) &&
this.engine.players[this.command.player].faction === Faction.BalTaks
? "Are you sure you want to pass with gaiaformers not yet converted?"
: undefined;
Booster.values(Expansion.All).forEach((booster, i) => {
if (command.data.boosters.includes(booster)) {
@ -283,7 +323,7 @@ export default class Commands extends Vue {
booster,
needConfirm: true,
tooltip: tiles.boosters[booster].map(spec => eventDesc(new Event(spec))).join("\n"),
warning
warning,
});
}
});
@ -294,11 +334,13 @@ export default class Commands extends Vue {
label: "Pass",
command: Command.Pass,
needConfirm: true,
buttons: [{
command: "",
label: `Confirm Pass`
}],
warning
buttons: [
{
command: "",
label: `Confirm Pass`,
},
],
warning,
});
} else {
ret.push({
@ -306,18 +348,18 @@ export default class Commands extends Vue {
command: command.name,
buttons,
boosters: command.data.boosters,
warning
warning,
});
}
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}`
command: `${Command.UpgradeResearch} ${command.data.tracks[0].field}`,
});
} else {
ret.push({
@ -325,18 +367,19 @@ export default class Commands extends Vue {
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)
researchTiles: command.data.tracks.map(track => track.field + "-" + track.to),
});
}
break;
}
case Command.ChooseTechTile: case Command.ChooseCoverTechTile: {
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, tech: tile.pos }))
buttons: command.data.tiles.map(tile => ({ command: tile.pos, tech: tile.pos })),
});
break;
}
@ -344,10 +387,10 @@ export default class Commands extends Vue {
case Command.ChargePower: {
for (const offer of command.data.offers) {
const leech = offer.offer;
const action = leech.includes('pw') ? "Charge" : "Gain";
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}`
command: `${Command.ChargePower} ${leech}`,
});
}
@ -359,24 +402,27 @@ export default class Commands extends Vue {
ret.push({
label: `Decline ${command.data.offers[0].offer}`,
command: `${Command.Decline} ${command.data.offers[0].offer}`,
warning: command.data.offers[0].offer === 'tech' ? "Are you sure you want to decline a tech tile?" : undefined
warning:
command.data.offers[0].offer === "tech" ? "Are you sure you want to decline a tech tile?" : undefined,
});
} else {
// LEGACY CODE
// TODO: Remove when games are updated
ret.push({
label: `Decline ${command.data.offer}`,
command: `${Command.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}`
})));
ret.push(
...command.data.sort().map(area => ({
label: `Brainstone ${area}`,
command: `${command.name} ${area}`,
}))
);
break;
}
@ -387,18 +433,21 @@ export default class Commands extends Vue {
buttons: command.data.acts.map(act => ({
label: `Spend ${act.cost} to gain ${act.income}`,
command: `${act.cost} for ${act.income}`,
times: act.range
}))
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(" / ")}` }))
buttons: command.data.poweracts.map(act => ({
command: act.name,
label: `Spend ${act.cost} for ${act.income.join(" / ")}`,
})),
});
break;
}
@ -408,7 +457,7 @@ export default class Commands extends Vue {
label: "Special Action",
command: Command.Special,
actions: command.data.specialacts.map(act => act.income),
buttons: command.data.specialacts.map(act => ({ command: act.income }))
buttons: command.data.specialacts.map(act => ({ command: act.income })),
});
break;
}
@ -417,7 +466,7 @@ export default class Commands extends Vue {
ret.push({
label: "Burn power",
command: Command.BurnPower,
buttons: command.data.map(val => ({ command: val }))
buttons: command.data.map(val => ({ command: val })),
});
break;
}
@ -427,78 +476,86 @@ export default class Commands extends Vue {
label: "End Turn",
command: Command.EndTurn,
needConfirm: true,
buttons: [{
command: Command.EndTurn,
label: `Confirm End Turn`
}]
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}`
})));
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
})));
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}`
})));
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]}`
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 }])),
hexes: new Map(fed.hexes.split(",").map(coord => [this.engine.map.getS(coord), { coordinates: coord }])),
hover: true,
buttons: tilesButtons
buttons: tilesButtons,
}));
locationButtons.push({
label: "Custom location",
selectHexes: true,
buttons: tilesButtons
buttons: tilesButtons,
});
ret.push(({
ret.push({
label: "Form federation",
command: Command.FormFederation,
buttons: locationButtons
}));
buttons: locationButtons,
});
break;
}
case Command.ChooseFederationTile: {
const tilesButtons = command.data.tiles.map((fed, i) => ({
command: fed,
label: `Federation ${i + 1}: ${tiles.federations[fed]}`
label: `Federation ${i + 1}: ${tiles.federations[fed]}`,
}));
ret.push(({
ret.push({
label: "Rescore federation",
command: Command.ChooseFederationTile,
buttons: tilesButtons
}));
buttons: tilesButtons,
});
break;
}
}
@ -515,7 +572,7 @@ export default class Commands extends Vue {
return ret;
}
back () {
back() {
this.$store.commit("gaiaViewer/clearContext");
this.commandChain.pop();
this.commandTitles.pop();
@ -538,52 +595,71 @@ export default class Commands extends Vue {
private commandChain: string[] = [];
private buttonChain: ButtonData[] = [];
}
</script>
<style lang="scss">
@import '../stylesheets/planets.scss';
@import "../stylesheets/planets.scss";
i.planet {
&::before {
content: "\25cf";
.player-info &, .faction-desc & {
.player-info &,
.faction-desc & {
font-size: 25px;
}
}
// terra
&.r {color: $terra }
&.r {
color: $terra;
}
// desert
&.d {color: $desert}
&.d {
color: $desert;
}
// swamp
&.s {color: $swamp}
&.s {
color: $swamp;
}
// oxide
&.o {color: $oxide}
&.o {
color: $oxide;
}
// titanium
&.t {color: $titanium}
&.t {
color: $titanium;
}
// ice
&.i {color: $ice}
&.i {
color: $ice;
}
// volcanic
&.v {color: $volcanic}
&.v {
color: $volcanic;
}
// gaia
&.g {color: $gaia}
&.g {
color: $gaia;
}
// transdim
&.m {color: $transdim}
&.m {
color: $transdim;
}
// lost planet
&.l {color: $lost}
&.l {
color: $lost;
}
filter: drop-shadow(0px 0px 1px black);
.player-info & {
filter: drop-shadow(0px 0px 1px black);
&.r, &.d, &.i {
&.r,
&.d,
&.i {
filter: drop-shadow(0px 0px 1px black);
}
}
}
</style>

View file

@ -0,0 +1,107 @@
<template>
<g class="condition">
<Building
v-if="isBuilding"
outline-white
:building="condition"
:flat="flat"
faction="gen"
transform="translate(0, 0) scale(2.2)"
/>
<g v-else-if="condition === 'fed'" transform="scale(0.45)">
<Federation width="50" x="-20" y="-30" :used="true" filter="url(#white-shadow-1)" />
</g>
<PlanetType v-else-if="condition === 'pt'" transform="scale(1.1)" />
<Sector v-else-if="condition === 's'" transform="scale(1.5)" />
<g v-else-if="condition === 'g'" transform="scale(0.85)">
<image
xlink:href="../assets/conditions/planet.svg"
width="25"
height="25"
x="-12"
y="-11.5"
transform="scale(-1,1)"
/>
</g>
<Resource v-else-if="condition === 'step'" kind="step" />
<g v-else-if="condition === 'mg'">
<image v-if="!flat" xlink:href="../assets/conditions/planet-flat.svg" :height=120/198*30 width=30 x=-12 y=-13.5
transform="translate(-2,0) scale(-1,-1)" />
<circle v-else r="10" :class="['planet-fill', 'g']" transform="translate(0,0)" />
<Building
building="m"
outline-white
:flat="flat"
faction="gen"
:transform="`translate(${flat ? 0 : 0}, ${flat ? 0 : 0}) scale(2.2)`"
/>
</g>
<g v-else-if="condition === 'PA'">
<Building
building="PI"
outline-white
:flat="flat"
faction="gen"
:transform="`translate(${flat ? -5 : -2}, 1) scale(1.8)`"
/>
<Building
building="ac1"
outline-white
:flat="flat"
faction="gen"
:transform="`translate(5, ${flat ? 1 : 2}) scale(1.8)`"
/>
</g>
<g v-else-if="condition === 'a'">
<line x1="-15" x2="15" stroke="#666" />
<line x1="-15" x2="15" y1="-10" y2="-10" stroke="#666" />
<line x1="-15" x2="15" y1="10" y2="10" stroke="#666" />
<image xlink:href="../assets/operators/trigger.svg" width=15 :height=529/328*15 :transform="`rotate(180),
translate(6, -8), scale(0.7)`" />
<!-- <text y=-1 style="font-size: 9px">3</text>
<text y=8.5 style="font-size: 9px">2</text>-->
</g>
</g>
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch } from "vue-property-decorator";
import { Condition as ConditionEnum, Building as BuildingEnum } from "@gaia-project/engine";
import Building from "./Building.vue";
import Federation from "./FederationTile.vue";
import Planet from "./Planet.vue";
import PlanetType from "./Conditions/PlanetType.vue";
import Sector from "./Conditions/Sector.vue";
@Component({
components: {
Building,
Federation,
Planet,
PlanetType,
Sector,
},
})
export default class Condition extends Vue {
@Prop()
condition!: ConditionEnum;
get isBuilding() {
return Object.values(BuildingEnum).includes(this.condition as any);
}
get flat() {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
}
</script>
<style lang="scss">
@import "../stylesheets/planets.scss";
g {
&.condition {
&.gaia {
fill: $gaia;
}
}
}
</style>

View file

@ -34,20 +34,20 @@ import Engine, { factions, Planet } from "@gaia-project/engine";
@Component
export default class FactionWheel extends Vue {
get r () {
get r() {
return 3;
}
get gameData (): Engine {
get gameData(): Engine {
return this.$store.state.gaiaViewer.data;
}
remainingPlanets (planet: string) {
remainingPlanets(planet: string) {
return Array.from(this.gameData.map.grid.values()).filter(hex => !hex.occupied() && hex.data.planet === planet)
.length;
}
strokeWidth (pos: number) {
strokeWidth(pos: number) {
const planet = this.planet(pos);
if (this.gameData.players.some(p => p.faction && factions[p.faction].planet === planet)) {
return "0.2px; stroke-dasharray:.5 .2";
@ -56,7 +56,7 @@ export default class FactionWheel extends Vue {
return "0.05px";
}
planet (pos: number) {
planet(pos: number) {
const list = [
Planet.Terra,
Planet.Oxide,
@ -66,7 +66,7 @@ export default class FactionWheel extends Vue {
Planet.Titanium,
Planet.Ice,
Planet.Gaia,
Planet.Transdim
Planet.Transdim,
];
if (pos < 7) {
const data = this.gameData;
@ -82,7 +82,7 @@ export default class FactionWheel extends Vue {
return list[pos];
}
planetFill (planet: string) {
planetFill(planet: string) {
if (planet === Planet.Titanium || planet === Planet.Swamp) {
return "white";
}

View file

@ -1,29 +1,36 @@
<template>
<svg viewBox="-25 -25 50 50" width="50" height="50" style="overflow: visible">
<g :class='["federationTile", {highlighted, disabled}]'>
<image xlink:href="../assets/conditions/federation.svg" :height=739/636*50 v-if="!disabled" style="color: #247B0A" width=50 x=-25 y=-25 @click="onClick" :filter=filter />
<image xlink:href="../assets/conditions/federation-used.svg" v-if="disabled" :height=739/636*50 style="color: #247B0A" width=50 x=-25 y=-25 @click="onClick" :filter=filter />
<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}}
<g :class="['federationTile', { highlighted, disabled }]">
<image xlink:href="../assets/conditions/federation.svg" :height=739/636*50 v-if="!disabled" style="color: #247B0A"
width=50 x=-25 y=-25 @click="onClick" :filter=filter /> <image
xlink:href="../assets/conditions/federation-used.svg" v-if="disabled" :height=739/636*50 style="color: #247B0A"
width=50 x=-25 y=-25 @click="onClick" :filter=filter />
<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>
<g v-if="federation !== undefined">
<Resource
v-for="(reward, i) in rewards"
:key=i
:count=reward.count
:kind=reward.type
:transform="`translate(${i === 2 ? 0 : (i - Math.min(rewards.length - 1, 1)/2) * 22}, ${rewards.length === 1 ? 12.5 : (i === 2 ? -7 : 10)})`" />
:key="i"
:count="reward.count"
:kind="reward.type"
:transform="
`translate(${i === 2 ? 0 : (i - Math.min(rewards.length - 1, 1) / 2) * 22}, ${
rewards.length === 1 ? 12.5 : i === 2 ? -7 : 10
})`
"
/>
</g>
</g>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, Event, Federation as FederationEnum, PlayerEnum, Reward } from '@gaia-project/engine';
import { eventDesc } from '../data/event';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { tiles, Event, Federation as FederationEnum, PlayerEnum, Reward } from "@gaia-project/engine";
import { eventDesc } from "../data/event";
@Component
export default class FederationTile extends Vue {
@ -33,36 +40,35 @@ export default class FederationTile extends Vue {
@Prop()
used: boolean;
@Prop({ default: '' })
@Prop({ default: "" })
filter: string;
@Prop()
numTiles: number;
get rewards (): Reward[] {
get rewards(): Reward[] {
return Reward.parse(tiles.federations[this.federation]);
}
get disabled () {
get disabled() {
return this.used || this.federation === FederationEnum.Fed1;
}
onClick () {
onClick() {
if (!this.highlighted) {
return;
}
this.$store.dispatch("gaiaViewer/federationClick", this.federation);
}
get highlighted () {
get highlighted() {
return this.$store.state.gaiaViewer.context.highlighted.federations.has(this.federation);
}
}
</script>
<style lang="scss">
@import '../stylesheets/planets.scss';
@import "../stylesheets/planets.scss";
g {
&.federationTile {
@ -86,5 +92,4 @@ g {
}
}
}
</style>

View file

@ -1,11 +1,11 @@
<template>
<defs>
<filter id="shadow-1" x="-20%" y="-20%" width="140%" height="140%">
<feMorphology in="SourceAlpha" result="DILATED" operator="dilate" radius="1" ></feMorphology>
<feMorphology in="SourceAlpha" result="DILATED" operator="dilate" radius="1"></feMorphology>
<feFlood flood-color="black" flood-opacity="0.8" result="PINK"></feFlood>
<feComposite in="PINK" in2="DILATED" operator="in" result="OUTLINE"></feComposite>
<feGaussianBlur in="OUTLINE" stdDeviation=2 result="BLURRED" />
<feGaussianBlur in="OUTLINE" stdDeviation="2" result="BLURRED" />
<feMerge>
<feMergeNode in="BLURRED" />
@ -13,10 +13,10 @@
</feMerge>
</filter>
<filter id="drop-shadow-1" x="-20%" y="-20%" width="140%" height="140%">
<feMorphology in="SourceAlpha" result="DILATED" operator="dilate" radius="0" ></feMorphology>
<feMorphology in="SourceAlpha" result="DILATED" operator="dilate" radius="0"></feMorphology>
<feFlood flood-color="black" flood-opacity="1" result="BLACK"></feFlood>
<feComposite in="BLACK" in2="DILATED" operator="in" result="OUTLINE"></feComposite>
<feGaussianBlur in="OUTLINE" stdDeviation=2 result="BLURRED" />
<feGaussianBlur in="OUTLINE" stdDeviation="2" result="BLURRED" />
<feOffset in="BLURRED" dx="2" dy="2" result="DROPPED" />
<feMerge>
@ -29,7 +29,7 @@
<feFlood flood-color="black" flood-opacity="1" result="PINK"></feFlood>
<feComposite in="PINK" in2="DILATED" operator="in" result="OUTLINE"></feComposite>
<feGaussianBlur in="OUTLINE" stdDeviation=1 result="BLURRED" />
<feGaussianBlur in="OUTLINE" stdDeviation="1" result="BLURRED" />
<feMerge>
<feMergeNode in="BLURRED" />
@ -41,7 +41,7 @@
<feFlood flood-color="white" flood-opacity="0.8" result="PINK"></feFlood>
<feComposite in="PINK" in2="DILATED" operator="in" result="OUTLINE"></feComposite>
<feGaussianBlur in="OUTLINE" stdDeviation=3 result="BLURRED"/>
<feGaussianBlur in="OUTLINE" stdDeviation="3" result="BLURRED" />
<feMerge>
<feMergeNode in="BLURRED" />
@ -53,7 +53,7 @@
<feFlood flood-color="white" flood-opacity="0.8" result="PINK"></feFlood>
<feComposite in="PINK" in2="DILATED" operator="in" result="OUTLINE"></feComposite>
<feGaussianBlur in="OUTLINE" stdDeviation=4 result="BLURRED"/>
<feGaussianBlur in="OUTLINE" stdDeviation="4" result="BLURRED" />
<feMerge>
<feMergeNode in="BLURRED" />
@ -83,20 +83,31 @@
</feMerge>
</filter>
<template v-for="[faction, r, g, b, x, s] in factionData">
<filter :id="`color-${faction}`" :key=faction>
<feColorMatrix type="matrix" result=A :values="`${r/x} 0 0 0 0
${g/x} 0 0 0 0
${b/x} 0 0 0 0
0 0 0 1 0`"/>
<feColorMatrix in="A" type="saturate" :values="s"/>
<filter :id="`color-${faction}`" :key="faction">
<feColorMatrix
type="matrix"
result="A"
:values="
`${r / x} 0 0 0 0
${g / x} 0 0 0 0
${b / x} 0 0 0 0
0 0 0 1 0`
"
/>
<feColorMatrix in="A" type="saturate" :values="s" />
</filter>
</template>
<template v-for="[planet, r, g, b, x] in planetData">
<filter :id="`color-planet-${planet}`" :key="'pl-' + planet">
<feColorMatrix type="matrix" :values="`${r/(3*x)} ${r/(3*x)} ${r/(3*x)} 0 0
${g/(3*x)} ${g/(3*x)} ${g/(3*x)} 0 0
${b/(3*x)} ${b/(3*x)} ${b/(3*x)} 0 0
0 0 0 1 0`"/>
<feColorMatrix
type="matrix"
:values="
`${r / (3 * x)} ${r / (3 * x)} ${r / (3 * x)} 0 0
${g / (3 * x)} ${g / (3 * x)} ${g / (3 * x)} 0 0
${b / (3 * x)} ${b / (3 * x)} ${b / (3 * x)} 0 0
0 0 0 1 0`
"
/>
</filter>
</template>
</defs>
@ -106,7 +117,7 @@ import { Vue, Component, Prop, Watch } from "vue-property-decorator";
import { Faction, Planet } from "@gaia-project/engine";
import { factionColor, planetColor } from "../graphics/utils";
function getDarkness (faction: string): number {
function getDarkness(faction: string): number {
switch (faction) {
case Faction.Ambas:
case Faction.Taklons:
@ -123,7 +134,7 @@ function getDarkness (faction: string): number {
}
export default class Filters extends Vue {
get factionData () {
get factionData() {
const factions = ["gen", "gaia", ...Object.values(Faction)];
return factions.map(faction => {
/* Gaia faction is used for gaia-colored gaia formers for Baltaks */
@ -131,17 +142,30 @@ export default class Filters extends Vue {
const darkness = getDarkness(faction);
const saturation = faction === (Faction.Ivits || faction === Faction.HadschHallas) ? 1 : 1.5;
return [faction, parseInt(color.slice(1, 3), 16) / 255, parseInt(color.slice(3, 5), 16) / 255, parseInt(color.slice(5, 7), 16) / 255, darkness, saturation];
return [
faction,
parseInt(color.slice(1, 3), 16) / 255,
parseInt(color.slice(3, 5), 16) / 255,
parseInt(color.slice(5, 7), 16) / 255,
darkness,
saturation,
];
});
}
get planetData () {
get planetData() {
const planets = Object.values(Planet).filter(pl => pl !== Planet.Empty);
return planets.map(planet => {
const color = planetColor(planet);
const darkness = 1;
return [planet, parseInt(color.slice(1, 3), 16) / 255, parseInt(color.slice(3, 5), 16) / 255, parseInt(color.slice(5, 7), 16) / 255, darkness];
return [
planet,
parseInt(color.slice(1, 3), 16) / 255,
parseInt(color.slice(3, 5), 16) / 255,
parseInt(color.slice(5, 7), 16) / 255,
darkness,
];
});
}
}

View file

@ -1,59 +1,73 @@
<template>
<g :class='["finalScoringTile", {highlighted}]' v-b-tooltip :title="tooltip">
<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)}) scale(0.4)`" :key="player.faction"/>
<text v-for="(player, index) in players" :key="player.faction + '-text'" :transform="`translate(${tokenX(index)}, ${tokenY(index)})`" :class="['score', player.faction]">
{{progress(player)}}
<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)}) scale(0.4)`"
:key="player.faction"
/>
<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 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 () {
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');
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 () {
highlighted() {
return this.$store.state.gaiaViewer.data.phase === Phase.EndGame;
}
},
},
components: {
Token
}
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);
progress(player: Player) {
return (player.faction as Faction | "automa") === "automa"
? finalScorings[this.tile].neutralPlayer
: player.progress(this.tile);
}
get tile () {
get tile() {
return this.$store.state.gaiaViewer.data.tiles.scorings.final[this.index];
}
get content () {
get content() {
return this.tile;
}
get players () {
get players() {
const pls = this.$store.state.gaiaViewer.data.players.filter(player => !!player && player.faction);
if (this.$store.state.gaiaViewer.data.players.length === 2) {
@ -63,19 +77,18 @@ export default class FinalScoringTile extends Vue {
return pls;
}
tokenX (index: number) {
tokenX(index: number) {
return (index % 2) * 30 + 23;
}
tokenY (index: number) {
tokenY(index: number) {
return 25 + (index > 1 ? 19 : 0);
}
}
</script>
<style lang="scss">
@import '../stylesheets/planets.scss';
@import "../stylesheets/planets.scss";
g {
&.finalScoringTile {
@ -96,7 +109,11 @@ g {
text-anchor: middle;
dominant-baseline: central;
&.automa,&.gleens,&.xenos,&.itars,&.nevlas {
&.automa,
&.gleens,
&.xenos,
&.itars,
&.nevlas {
fill: #333;
}
}
@ -116,7 +133,5 @@ g {
stroke-width: 1;
}
}
}
</style>

View file

@ -1,11 +1,20 @@
<template>
<div :class="`${globalStyles}`">
<div :class="['row', 'no-gutters', 'justify-content-center', engine.players.length > 2 ? 'medium-map' : 'small-map']" v-if="hasMap">
<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', 'col-md-7']" />
<svg class="scoring-research-board" :viewBox="`0 0 480 505`" >
<ResearchBoard height="450" ref="researchBoard" x=-50 />
<ScoringBoard class="ml-4" width="90" x="380" y=-25 />
<BoardAction :scale="17" :transform="`translate(${30 + 45*i}, 480)`" v-for="(action, i) in actions" :key="action" :action="action" />
<svg class="scoring-research-board" :viewBox="`0 0 480 505`">
<ResearchBoard height="450" ref="researchBoard" x="-50" />
<ScoringBoard class="ml-4" width="90" x="380" y="-25" />
<BoardAction
:scale="17"
:transform="`translate(${30 + 45 * i}, 480)`"
v-for="(action, i) in actions"
:key="action"
:action="action"
/>
</svg>
</div>
<div class="row mt-2">
@ -14,11 +23,16 @@
<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" />
<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" />
<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" />
@ -27,33 +41,45 @@
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import Engine, { Command, Phase, factions, Player, EngineOptions, Expansion, BoardAction as BoardActionEnum } from '@gaia-project/engine';
import AdvancedLog from './AdvancedLog.vue';
import BoardAction from './BoardAction.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';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import Engine, {
Command,
Phase,
factions,
Player,
EngineOptions,
Expansion,
BoardAction as BoardActionEnum,
} from "@gaia-project/engine";
import AdvancedLog from "./AdvancedLog.vue";
import BoardAction from "./BoardAction.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) {
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.$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))
backup: JSON.parse(JSON.stringify(this.engine)),
};
return;
}
@ -69,13 +95,22 @@ import { resolve } from 'dns';
this.replayData.current = dest;
this.$store.dispatch("gaiaViewer/replayInfo", { start: 1, end: this.replayData.backup.moveHistory.length, 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 }));
this.handleData(
new Engine(this.replayData.backup.moveHistory.slice(0, dest), {
...this.replayData.backup.options,
noFedCheck: true,
})
);
return;
}
@ -99,8 +134,8 @@ import { resolve } from 'dns';
ResearchBoard,
ScoringBoard,
SpaceMap,
TurnOrder
}
TurnOrder,
},
})
export default class Game extends Vue {
public currentMove = "";
@ -108,28 +143,28 @@ export default class Game extends Vue {
// When joining a game
name = "";
replayData: {current: number; backup: Engine} = null;
replayData: { current: number; backup: Engine } = null;
@Prop()
options: EngineOptions;
get engine (): Engine {
get engine(): Engine {
return this.$store.state.gaiaViewer.data;
}
get expansions () {
get expansions() {
return this.$store.state.gaiaViewer.data.expansions;
}
get actions (): BoardActionEnum[] {
get actions(): BoardActionEnum[] {
return BoardActionEnum.values(this.expansions);
}
get ended () {
get ended() {
return this.engine.phase === Phase.EndGame;
}
get orderedPlayers () {
get orderedPlayers() {
const engine = this.engine;
if (!engine.round || !engine.turnOrder) {
@ -145,33 +180,35 @@ export default class Game extends Vue {
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 canPlay() {
return (
!this.ended && (!this.$store.state.gaiaViewer.player || this.sessionPlayer === this.engine.players[this.player])
);
}
get hasMap () {
get hasMap() {
return !!this.$store.state.gaiaViewer.data.map;
}
get globalStyles () {
get globalStyles() {
const preferences = this.$store.state.gaiaViewer.preferences;
const styles = [];
if (preferences) {
if (preferences.noFactionFill) {
styles.push('no-faction-fill');
styles.push("no-faction-fill");
}
if (preferences.accessibleSpaceMap) {
styles.push('accessible-space-map');
styles.push("accessible-space-map");
}
}
return styles.join(" ");
}
get player () {
get player() {
return this.engine.availableCommands?.[0]?.player;
}
get sessionPlayer () {
get sessionPlayer() {
const player = this.$store.state.gaiaViewer.player;
if (player) {
if (player.index !== undefined) {
@ -180,14 +217,14 @@ export default class Game extends Vue {
}
}
handleData (data: Engine, keepMoveHistory?: boolean) {
handleData(data: Engine, keepMoveHistory?: boolean) {
console.log("handle data", keepMoveHistory);
for (const sector of document.getElementsByClassName('sector') as any as Element[]) {
for (const sector of (document.getElementsByClassName("sector") as any) as Element[]) {
sector.classList.add("notransition");
}
this.$store.commit('gaiaViewer/receiveData', data);
this.$store.commit("gaiaViewer/receiveData", data);
this.clearCurrentMove = false;
@ -198,13 +235,13 @@ export default class Game extends Vue {
}
setTimeout(() => {
for (const sector of document.getElementsByClassName('sector') as any as Element[]) {
for (const sector of (document.getElementsByClassName("sector") as any) as Element[]) {
sector.classList.remove("notransition");
}
});
}
handleCommand (command: string) {
handleCommand(command: string) {
if (command.startsWith(Command.Init) || this.engine.round <= 0) {
this.addMove(command);
return;
@ -225,7 +262,7 @@ export default class Game extends Vue {
}
}
undoMove () {
undoMove() {
if (this.currentMove.includes(".")) {
this.currentMove = this.currentMove.slice(0, this.currentMove.lastIndexOf("."));
} else {
@ -234,34 +271,34 @@ export default class Game extends Vue {
this.addMove(this.currentMove);
}
addMove (command: string) {
addMove(command: string) {
this.$store.commit("gaiaViewer/clearContext");
this.$store.dispatch("gaiaViewer/move", command);
}
parseMove (command: string): {player: string; command: string; args: string[]} {
parseMove(command: string): { player: string; command: string; args: string[] } {
command = command.trim();
if (command.includes('.')) {
return this.parseMove(command.slice(0, command.indexOf('.')));
if (command.includes(".")) {
return this.parseMove(command.slice(0, command.indexOf(".")));
}
const split = command.split(' ');
const split = command.split(" ");
return {
player: split[0],
command: split[1],
args: split.slice(2)
args: split.slice(2),
};
}
}
</script>
<style lang="scss">
@import "../stylesheets/frontend.scss";
.space-map, .scoring-research-board {
.space-map,
.scoring-research-board {
max-height: 600px;
width: 100%;
@ -269,14 +306,15 @@ export default class Game extends Vue {
height: intrinsic;
}
.medium-map, .small-map {
.medium-map,
.small-map {
flex-wrap: nowrap;
}
@media (max-width: 767px) {
.small-map, .medium-map {
.small-map,
.medium-map {
flex-wrap: wrap;
}
}
</style>

View file

@ -1,50 +1,74 @@
<template>
<div class="move-button">
<Booster v-if="button.booster" class="mb-1 mr-1" @click="handleClick" :booster="button.booster" />
<TechTile v-else-if="button.tech" class="mb-1 mr-1" @click="handleClick" :pos="button.tech" :count-override=1 />
<b-btn v-else-if="!button.times" :variant="button.warning ? 'warning': 'secondary'" class='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" >
<TechTile v-else-if="button.tech" class="mb-1 mr-1" @click="handleClick" :pos="button.tech" :count-override="1" />
<b-btn
v-else-if="!button.times"
:variant="button.warning ? 'warning' : 'secondary'"
class="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"
>
</b-btn>
<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
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!">
<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';
import TechTile from './TechTile.vue';
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";
import TechTile from "./TechTile.vue";
@Component({
components: {
Booster,
TechTile
TechTile,
},
destroyed () {
destroyed() {
this.unsubscribe();
}
},
})
export default class MoveButton extends Vue {
@Prop()
public button: ButtonData;
private subscription: () => {} = null;
private modalShow = false;
private customLabel = '';
private customLabel = "";
private startingHex = null; // For range command
modalCancel (arg: string) {
modalCancel(arg: string) {
this.$emit("cancel");
}
subscribe (action: string, callback: any) {
subscribe(action: string, callback: any) {
action = "gaiaViewer/" + action;
this.unsubscribe();
@ -65,18 +89,18 @@ export default class MoveButton extends Vue {
});
}
subscribeFinal (action: string) {
subscribeFinal(action: string) {
this.subscribe(action, field => this.emitCommand(field, { final: true }));
this.emitCommand(null, { disappear: false });
}
unsubscribe () {
unsubscribe() {
if (this.subscription) {
this.subscription();
}
}
async handleClick () {
async handleClick() {
if (this.button.hide) {
console.log("click on hidden button, ignoring");
return;
@ -97,32 +121,40 @@ export default class MoveButton extends Vue {
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.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()));
this.subscribe("hexClick", hex => this.emitCommand(hex.toString()));
}
} else if (this.button.researchTiles) {
this.$store.commit("gaiaViewer/highlightResearchTiles", this.button.researchTiles);
this.subscribeFinal('researchClick');
this.subscribeFinal("researchClick");
} else if (this.button.techs) {
this.$store.commit("gaiaViewer/highlightTechs", this.button.techs);
this.subscribeFinal('techClick');
this.subscribeFinal("techClick");
} else if (this.button.boosters) {
this.$store.commit("gaiaViewer/highlightBoosters", this.button.boosters);
this.subscribeFinal('boosterClick');
this.subscribeFinal("boosterClick");
} else if (this.button.actions) {
this.$store.commit("gaiaViewer/highlightActions", this.button.actions);
this.subscribeFinal('actionClick');
this.subscribeFinal("actionClick");
} else if (this.button.needConfirm) {
this.subscribeFinal('needConfirmClick');
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.button.command = [...this.$store.state.gaiaViewer.context.highlighted.hexes.keys()]
.map(hex => hex.toString())
.join(",");
this.emitCommand();
return;
}
@ -131,7 +163,7 @@ export default class MoveButton extends Vue {
this.customLabel = "Custom location - End selection";
this.subscribe('hexClick', hex => {
this.subscribe("hexClick", hex => {
const highlighted = this.$store.state.gaiaViewer.context.highlighted.hexes;
if (highlighted.has(hex)) {
@ -151,17 +183,17 @@ export default class MoveButton extends Vue {
for (const rotation of rotations) {
rotation[1] %= 6;
}
this.emitCommand([].concat(...rotations.filter(r => !!r[1])).join(' '));
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.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 => {
this.subscribe("hexClick", hex => {
if (this.startingHex) {
this.emitCommand(`${this.startingHex} ${hex}`);
this.startingHex = undefined;
@ -176,7 +208,7 @@ export default class MoveButton extends Vue {
const withinDistance = map.withinDistance(hex, range);
for (const target of withinDistance) {
highlighted.set(target, { cost: costs?.[map.distance(hex, target)] ?? '~' });
highlighted.set(target, { cost: costs?.[map.distance(hex, target)] ?? "~" });
}
this.$store.commit("gaiaViewer/highlightHexes", highlighted);
@ -190,15 +222,15 @@ export default class MoveButton extends Vue {
}
}
handleRangeClick (times: number) {
handleRangeClick(times: number) {
this.emitCommand(null, { times });
}
handleOK () {
handleOK() {
this.emitCommand();
}
emitCommand (append?: string, params?: {disappear?: boolean; final?: boolean; times?: number}) {
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);
@ -210,7 +242,7 @@ export default class MoveButton extends Vue {
this.$store.commit("gaiaViewer/activeButton", null);
}
let commandBody: string [] = [];
let commandBody: string[] = [];
if (final) {
commandBody = append ? [append] : [];
@ -221,18 +253,18 @@ export default class MoveButton extends Vue {
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(/\b[0-9]+/g, x => "" + parseInt(x) * times);
}
command = command.replace(/\$times\b/g, '' + (times ?? 0));
command = command.replace(/\$times\b/g, "" + (times ?? 0));
commandBody = [command, append].filter(x => !!x);
}
this.$emit('trigger', commandBody.join(" "), this, final);
this.$emit("trigger", commandBody.join(" "), this, final);
}
hover () {
hover() {
if (!this.button.hover || this.$store.state.gaiaViewer.context.activeButton !== null) {
return;
}
@ -240,7 +272,7 @@ export default class MoveButton extends Vue {
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
}
leave () {
leave() {
if (!this.button.hover || this.$store.state.gaiaViewer.context.activeButton !== null) {
return;
}
@ -248,11 +280,13 @@ export default class MoveButton extends Vue {
this.$store.commit("gaiaViewer/clearContext");
}
get isActiveButton () {
return this.$store.state.gaiaViewer.context.activeButton && this.$store.state.gaiaViewer.context.activeButton.label === this.button.label;
get isActiveButton() {
return (
this.$store.state.gaiaViewer.context.activeButton &&
this.$store.state.gaiaViewer.context.activeButton.label === this.button.label
);
}
}
</script>
<style lang="scss">

View file

@ -1,6 +1,7 @@
<template>
<g class="operator">
<image xlink:href="../assets/operators/build.svg" v-if="condition !== 'step' && condition !== 'a'" width=15 :height=1152/584*15 :transform="`translate(-22,-24)`" />
<image xlink:href="../assets/operators/build.svg" v-if="condition !== 'step' && condition !== 'a'" width=15
:height=1152/584*15 :transform="`translate(-22,-24)`" />
</g>
</template>
<script lang="ts">
@ -8,8 +9,7 @@ import { Vue, Component, Prop, Watch } from "vue-property-decorator";
import { Condition as ConditionEnum, Building as BuildingEnum, Operator as OperatorEnum } from "@gaia-project/engine";
@Component({
components: {
}
components: {},
})
export default class Operator extends Vue {
@Prop()
@ -18,9 +18,8 @@ export default class Operator extends Vue {
@Prop()
operator: OperatorEnum;
get isTrigger () {
get isTrigger() {
return this.operator === OperatorEnum.Trigger;
}
}
</script>

View file

@ -0,0 +1,155 @@
<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;
}
.accessible-space-map &.v {
stroke-dasharray: 0.25;
stroke-width: 0.1;
}
// gaia
&.g {
stroke: $gaia;
}
.accessible-space-map &.g {
stroke-dasharray: 0.14;
stroke-width: 0.1;
}
// transdim
&.m {
stroke: $transdim;
}
.accessible-space-map &.m {
stroke-dasharray: 0.14;
stroke-width: 0.1;
}
// 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;
}
// generic planet
&.gen {
fill: $generic;
}
//diggable planet
&.dig {
fill: $dig;
}
}
}
</style>

View file

@ -1,21 +1,68 @@
<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)" style="opacity: 0.7" />
<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="buildingFaction(i)" :transform="`translate(${isPI ? 0.5 : 0}, 0) scale(0.15)`" v-if="showBuilding(i)" :flat="flat" outline />
<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)`" style="opacity: 0.7" />
<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)"
style="opacity: 0.7"
/>
<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="buildingFaction(i)"
:transform="`translate(${isPI ? 0.5 : 0}, 0) scale(0.15)`"
v-if="showBuilding(i)"
:flat="flat"
outline
/>
<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)`"
style="opacity: 0.7"
/>
</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 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,
@ -23,19 +70,19 @@ import {
factionBoard,
Operator,
Resource as ResourceEnum,
Reward
} from '@gaia-project/engine';
Reward,
} from "@gaia-project/engine";
@Component({
components: {
Building,
Resource
Resource,
},
watch: {
faction (newVal) {
faction(newVal) {
this.board = factionBoard(newVal);
}
}
},
},
})
export default class BuildingGroup extends Vue {
@Prop()
@ -67,60 +114,68 @@ export default class BuildingGroup extends Vue {
board: FactionBoard = factionBoard(this.faction || Faction.Terrans);
get buildingList () {
get buildingList() {
return [0, 1, 2, 3, 4, 5, 6, 7].slice(0, this.nBuildings);
}
get isPI () {
get isPI() {
return this.building === BuildingEnum.PlanetaryInstitute;
}
tooltip (i: number) {
tooltip(i: number) {
const b = this.board.buildings[this.building];
const cost = this.discount ? b.cost.map(c => `${c.count - this.discount}${c.type}`).join(", ") : b.cost.join(", ") || "~";
const cost = this.discount
? b.cost.map(c => `${c.count - this.discount}${c.type}`).join(", ")
: b.cost.join(", ") || "~";
const isolatedCost = b.isolatedCost ? "\n Isolated cost: " + (b.isolatedCost.join(", ") || "~") : "";
const income = this.building === BuildingEnum.GaiaFormer ? "" : "\n " + (this.resources(i, true).join(", ") || "~");
return "Cost: " + cost + isolatedCost + income;
}
get offset () {
get offset() {
return this.building === BuildingEnum.GaiaFormer ? 0.2 : 1.4;
}
get buildingSpacing () {
get buildingSpacing() {
return 2.2;
}
get paddingRight () {
get paddingRight() {
return 0.2;
}
get width () {
return Math.max(this.nBuildings, this.building === BuildingEnum.GaiaFormer ? 3 : 2) * this.buildingSpacing + this.offset + this.paddingRight;
get width() {
return (
Math.max(this.nBuildings, this.building === BuildingEnum.GaiaFormer ? 3 : 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));
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));
}
get flat () {
get flat() {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
showBuilding (i: number) {
showBuilding(i: number) {
if (this.ac1 || this.ac2) {
return i === 0 ? !this.ac1 : !this.ac2;
}
return i >= this.placed + this.gaia;
}
buildingFaction (i: number) {
buildingFaction(i: number) {
return this.faction;
}
resources (i: number, tooltip = false): Array<string | Reward> {
resources(i: number, tooltip = false): Array<string | Reward> {
if (this.showBuilding(i) && !tooltip) {
return [];
}
@ -156,7 +211,6 @@ export default class BuildingGroup extends Vue {
return [].concat(...ret).filter(r => r != null);
}
}
</script>
<style lang="scss">

View file

@ -107,8 +107,8 @@ import VictoryPoint from "../Resources/VictoryPoint.vue";
@Component({
components: {
Resource,
VictoryPoint
}
VictoryPoint,
},
})
export default class BuildingGroup extends Vue {
@Prop()
@ -120,15 +120,15 @@ export default class BuildingGroup extends Vue {
@Prop()
player: Player;
get engine () {
get engine() {
return this.$store.state.gaiaViewer.data;
}
get factionName (): string {
get factionName(): string {
return factions[this.faction].name;
}
income (resource: ResourceEnum) {
income(resource: ResourceEnum) {
const index = this.player.income.search(new RegExp("[0-9]+" + resource));
if (index < 0) {
@ -138,15 +138,15 @@ export default class BuildingGroup extends Vue {
return parseInt(this.player.income.substr(index));
}
researchType (index: number): ResearchField {
researchType(index: number): ResearchField {
return ResearchField.values()[index];
}
research (index: number): number {
research(index: number): number {
return this.data.research[this.researchType(index)];
}
get sectors (): number {
get sectors(): number {
return uniq(this.data.occupied.filter(hex => hex.colonizedBy(this.player.player)).map(hex => hex.data.sector))
.length;
}

View file

@ -0,0 +1,196 @@
<template>
<g class="power-bowls">
<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="#00aa00" />
<Resource
v-if="power('gaia') > 0"
:kind="'bowl-t'"
:count="power('gaia')"
:transform="`translate(${xPos('gaia')}, ${yPos('gaia')}) scale(0.11)`"
/>
<Resource
v-if="brainstone('gaia') == 1"
:kind="'brainstone'"
:transform="`translate(${power('gaia') > 0 ? 0.9 : 0}, ${yPos('gaia')}) scale(0.11)`"
/>
<Resource
v-if="data.gaiaformersInGaia > 0"
:kind="'gf'"
:count="data.gaiaformersInGaia"
:faction="faction"
:transform="`translate(0, 0.7) scale(0.09)`"
/>
</g>
<g :transform="`translate(${-r * spacing}, ${2 * r * sin60 * spacing})`">
<circle :r="r" class="power-bowl" />
<Resource
v-if="power('area1') > 0"
:kind="'bowl-t'"
:count="power('area1')"
:transform="`translate(${xPos('area1')}, 0) scale(0.11)`"
/>
<Resource
v-if="brainstone('area1') == 1"
:kind="'brainstone'"
:transform="`translate(${power('area1') > 0 ? 0.9 : 0}, 0) scale(0.11)`"
/>
<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" class="power-bowl" />
<Resource
v-if="power('area2') > 0"
:kind="'bowl-t'"
:count="power('area2')"
:transform="`translate(${xPos('area2')}, 0) scale(0.11)`"
/>
<Resource
v-if="brainstone('area2') == 1"
:kind="'brainstone'"
:transform="`translate(${power('area2') > 0 ? 0.9 : 0}, 0) scale(0.11)`"
/>
<text class="label" x="-2.6">II</text>
</g>
<g :transform="`translate(${2 * r * spacing}, 0)`">
<circle :r="r" class="power-bowl" />
<Resource
v-if="power('area3') > 0"
:kind="'bowl-t'"
:count="power('area3')"
:transform="`translate(${xPos('area3')}, 0) scale(0.11)`"
/>
<Resource
v-if="brainstone('area3') == 1"
:kind="'brainstone'"
:transform="`translate(${power('area3') > 0 ? 0.9 : 0}, 0) scale(0.11)`"
/>
<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 Building from "../Building.vue";
import {
Faction,
Reward,
FactionBoard,
Operator,
Resource as ResourceEnum,
factions,
PlayerData,
Player,
} from "@gaia-project/engine";
@Component({
components: {
Resource,
Building,
},
})
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;
}
xPos(area: string) {
return this.brainstone(area) ? -0.9 : 0;
}
yPos(area: string) {
return this.data.gaiaformersInGaia > 0 ? -0.5 : 0;
}
power(area: string) {
return this.data.power[area];
}
brainstone(area: string) {
return this.data.brainstone === area;
}
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));
}
get flat() {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
}
</script>
<style lang="scss">
@import "../../stylesheets/planets.scss";
.power-bowls {
circle {
stroke-width: 0.05px;
stroke: black;
}
.power-bowl {
fill: purple;
}
.power {
fill: $res-power;
}
.brainstone {
fill: $res-power;
}
text {
fill: white;
font-size: 1.2px;
text-anchor: middle;
dominant-baseline: mathematical;
&.label {
fill: #333;
}
}
}
</style>

View file

@ -197,68 +197,68 @@ import { factionDesc, planetsWithSteps } from "../data/factions";
FederationTile,
BuildingGroup,
PowerBowls,
PlayerBoardInfo
}
PlayerBoardInfo,
},
})
export default class PlayerInfo extends Vue {
@Prop()
player: Player;
get playerData () {
get playerData() {
return this.player?.data;
}
playerClick (player: Player) {
playerClick(player: Player) {
this.$store.dispatch("gaiaViewer/playerClick", player);
}
get factionColor () {
get factionColor() {
return factionColor(this.player.faction);
}
get name () {
get name() {
if (this.player.name) {
return this.player.name;
}
return "Player " + (this.player.player + 1);
}
get tooltip () {
get tooltip() {
return factionDesc(this.player.faction);
}
get planet () {
get planet() {
return factions[this.player.faction].planet;
}
get factionName (): string {
get factionName(): string {
return factions[this.player.faction].name;
}
planetFill (planet: string) {
planetFill(planet: string) {
if (planet === Planet.Titanium || planet === Planet.Swamp) {
return "white";
}
return "black";
}
planetsWithSteps (steps: number) {
planetsWithSteps(steps: number) {
return planetsWithSteps(this.planet, steps);
}
get passed () {
get passed() {
return (this.$store.state.gaiaViewer.data.passedPlayers || []).includes(this.player.player);
}
get round () {
get round() {
return this.$store.state.gaiaViewer.data.round;
}
get hasPlanets () {
get hasPlanets() {
return this.player.ownedPlanets.length > 0;
}
get hasLostPlanet () {
get hasLostPlanet() {
return (this.player.ownedPlanetsCount.l ?? 0) > 0;
}
}

View file

@ -1,41 +1,47 @@
<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']">
<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-2" />
<FederationTile v-for="([tile, numTiles], i) in federations" :key="`${tile}-${i}`" :federation="tile" :numTiles="numTiles" class="mb-2 mr-2" filter="url(#shadow-1)" />
<FederationTile
v-for="([tile, numTiles], i) in federations"
:key="`${tile}-${i}`"
:federation="tile"
:numTiles="numTiles"
class="mb-2 mr-2"
filter="url(#shadow-1)"
/>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import Booster from './Booster.vue';
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';
import { Booster as BoosterEnum, Expansion } from "@gaia-project/engine";
@Component({
computed: {
boosters () {
boosters() {
return BoosterEnum.values(Expansion.All).filter(key => this.$store.state.gaiaViewer.data.tiles.boosters[key]);
},
federations () {
federations() {
return Object.entries(this.$store.state.gaiaViewer.data.tiles.federations).filter(([key, value]) => value > 0);
}
},
},
components: {
Booster,
FederationTile
}
FederationTile,
},
})
export default class Pool extends Vue {
}
export default class Pool extends Vue {}
</script>
<style lang="scss" scoped>
.pool {
margin-bottom: 1em;
padding-bottom: 0.5em;

View file

@ -4,47 +4,53 @@
v-for="(field, index) in [...fields].reverse()"
:field="field"
:x="(fields.length - 1 - index) * 60"
:key="field"/>
:key="field"
/>
<text y="198" x="180" style="font-size: 12px; text-anchor: middle">Charge 3 power</text>
<g v-if="$store.state.gaiaViewer.data.tiles && $store.state.gaiaViewer.data.tiles.techs['gaia']">
<g transform="translate(30, 410) scale(0.95)">
<TechTile pos="free1" x="-30" y="-30"/>
<TechTile pos="free1" x="-30" y="-30" />
</g>
<g transform="translate(90, 410) scale(0.95)">
<TechTile pos="free2" x="-30" y="-30"/>
<TechTile pos="free2" x="-30" y="-30" />
</g>
<g transform="translate(150, 410) scale(0.95)">
<TechTile pos="free3" x="-30" y="-30"/>
<TechTile pos="free3" x="-30" y="-30" />
</g>
<!-- resource conversion-->
<g transform="translate(247, 412) scale(0.95)">
<defs>
<polygon id="arrow" points="0 0, 10 3.5, 0 7" fill="white" stroke="black"
transform="scale(.7) translate(4, -3.5)"/>
<polygon
id="arrow"
points="0 0, 10 3.5, 0 7"
fill="white"
stroke="black"
transform="scale(.7) translate(4, -3.5)"
/>
</defs>
<Resource kind="pay-pw" :count="4" transform="translate(-45, -15)"/>
<Resource kind="pay-pw" :count="1" transform="translate(-15, -15)"/>
<Resource kind="pay-pw" :count="3" transform="translate(15, -15)"/>
<Resource kind="pay-pw" :count="4" transform="translate(57, -15)"/>
<Resource kind="pay-pw" :count="4" transform="translate(-45, -15)" />
<Resource kind="pay-pw" :count="1" transform="translate(-15, -15)" />
<Resource kind="pay-pw" :count="3" transform="translate(15, -15)" />
<Resource kind="pay-pw" :count="4" transform="translate(57, -15)" />
<use xlink:href="#arrow" x="-6" y="45" transform="rotate(90)"/>
<use xlink:href="#arrow" x="-6" y="15" transform="rotate(90)"/>
<use xlink:href="#arrow" x="-6" y="-15" transform="rotate(90)"/>
<use xlink:href="#arrow" x="50" y="0" transform="rotate(90 57 0)"/>
<use xlink:href="#arrow" x="-6" y="45" transform="rotate(90)" />
<use xlink:href="#arrow" x="-6" y="15" transform="rotate(90)" />
<use xlink:href="#arrow" x="-6" y="-15" transform="rotate(90)" />
<use xlink:href="#arrow" x="50" y="0" transform="rotate(90 57 0)" />
<use xlink:href="#arrow" x="14" y="18" transform="rotate(-30)"/>
<Resource kind="t" :count="1" transform="translate(38, 0)"/>
<use xlink:href="#arrow" x="66" y="15" transform="rotate(-32 57 15)"/>
<Resource kind="range" :count="2" transform="translate(88, -2) scale(1)"/>
<use xlink:href="#arrow" x="14" y="18" transform="rotate(-30)" />
<Resource kind="t" :count="1" transform="translate(38, 0)" />
<use xlink:href="#arrow" x="66" y="15" transform="rotate(-32 57 15)" />
<Resource kind="range" :count="2" transform="translate(88, -2) scale(1)" />
<Resource kind="k" :count="1" transform="translate(-45, 15)"/>
<use xlink:href="#arrow" x="-37" y="15"/>
<Resource kind="c" :count="1" transform="translate(-15, 15)"/>
<use xlink:href="#arrow" x="-6" y="-15" transform="rotate(180)"/>
<Resource kind="o" :count="1" transform="translate(15, 15)"/>
<use xlink:href="#arrow" x="32" y="15" transform="rotate(180 38 15)"/>
<Resource kind="q" :count="1" transform="translate(57, 15)"/>
<Resource kind="k" :count="1" transform="translate(-45, 15)" />
<use xlink:href="#arrow" x="-37" y="15" />
<Resource kind="c" :count="1" transform="translate(-15, 15)" />
<use xlink:href="#arrow" x="-6" y="-15" transform="rotate(180)" />
<Resource kind="o" :count="1" transform="translate(15, 15)" />
<use xlink:href="#arrow" x="32" y="15" transform="rotate(180 38 15)" />
<Resource kind="q" :count="1" transform="translate(57, 15)" />
</g>
</g>
</svg>
@ -60,25 +66,23 @@ import BoardAction from "./BoardAction.vue";
@Component({
computed: {
fields (): ResearchField[] {
fields(): ResearchField[] {
return ResearchField.values(this.expansions);
},
expansions () {
expansions() {
return this.$store.state.gaiaViewer.data.expansions;
},
viewWidth () {
viewWidth() {
return this.fields.length * 60;
}
},
},
components: {
ResearchTrack,
TechTile,
BoardAction
}
BoardAction,
},
})
export default class ResearchBoard extends Vue {
}
export default class ResearchBoard extends Vue {}
</script>
<style lang="scss" scoped>

View file

@ -61,7 +61,7 @@ import {
ResearchField,
researchTracks,
Resource as ResourceEnum,
Reward
Reward,
} from "@gaia-project/engine";
import { descriptions } from "../data/research";
import Token from "./Token.vue";
@ -71,25 +71,25 @@ import Resource from "./Resource.vue";
@Component<ResearchTile>({
computed: {
players (): Player[] {
players(): Player[] {
return this.$store.state.gaiaViewer.data.players.filter(
player => player.faction && player.data.research[this.field] === this.level
);
},
tooltip () {
tooltip() {
return `<b>Level ${this.level}:</b> ${descriptions[this.field][this.level]}`;
},
height () {
height() {
return this.level === 5 ? 46 : 36;
},
federation (): Federation {
federation(): Federation {
if (this.level === 5) {
if (this.field === ResearchField.Terraforming) {
return this.$store.state.gaiaViewer.data.terraformingFederation;
}
}
},
lostPlanet (): PlanetEnum {
lostPlanet(): PlanetEnum {
if (this.level === 5 && this.field === ResearchField.Navigation) {
for (const pl of this.players) {
if (pl.data.lostPlanet) {
@ -98,14 +98,14 @@ import Resource from "./Resource.vue";
}
return PlanetEnum.Lost;
}
}
},
},
components: {
Token,
FederationTile,
Resource,
Planet
}
Planet,
},
})
export default class ResearchTile extends Vue {
@Prop()
@ -117,7 +117,7 @@ export default class ResearchTile extends Vue {
@Prop({ type: Number })
level: number;
resourceX (index: number) {
resourceX(index: number) {
const res = this.resources;
const l = res.length;
const sep = l <= 2 ? 7 : 6;
@ -125,25 +125,25 @@ export default class ResearchTile extends Vue {
return -6 * (l - 1) + index * 2 * sep - ((res[0].count as any) === "+" ? 2 : 0);
}
tokenX (index: number) {
tokenX(index: number) {
return 10 + 13 * (index % 4) + 22 * (index > 3 ? 1 : 0);
}
tokenY (index: number) {
tokenY(index: number) {
return 10 + 13 * (index > 3 ? 1 : 0);
}
onClick () {
onClick() {
if (this.highlighted) {
this.$store.dispatch("gaiaViewer/researchClick", this.field);
}
}
get resourceOffset () {
get resourceOffset() {
return this.techContent.length > 0 ? -15 : 0;
}
get resources () {
get resources() {
const rewards = Reward.merge(...this.events.slice(0, 1).map(ev => ev.rewards));
if (this.events[0] && this.events[0].operator === Operator.Income) {
@ -152,22 +152,31 @@ export default class ResearchTile extends Vue {
}
const extraRewards = new Map<ResearchField, Map<number, string>>([
[ResearchField.Terraforming, new Map([
[0, "d"],
[2, "2d"],
[3, "3d"]
])],
[ResearchField.Navigation, new Map([
[0, "1r"],
[2, "2r"],
[4, "3r"],
[5, "4r"]
])],
[ResearchField.GaiaProject, new Map([
[1, "6tg"],
[3, "4tg"],
[4, "3tg"]
])]
[
ResearchField.Terraforming,
new Map([
[0, "d"],
[2, "2d"],
[3, "3d"],
]),
],
[
ResearchField.Navigation,
new Map([
[0, "1r"],
[2, "2r"],
[4, "3r"],
[5, "4r"],
]),
],
[
ResearchField.GaiaProject,
new Map([
[1, "6tg"],
[3, "4tg"],
[4, "3tg"],
]),
],
]);
const extra = extraRewards.get(this.field)?.get(this.level);
@ -181,15 +190,15 @@ export default class ResearchTile extends Vue {
return rewards;
}
get events () {
get events() {
return researchTracks[this.field][this.level].map(s => new Event(s));
}
get techContent () {
get techContent() {
return this.events.filter(event => event.condition !== Condition.None);
}
get highlighted (): boolean {
get highlighted(): boolean {
return this.$store.state.gaiaViewer.context.highlighted.researchTiles.has(this.field + "-" + this.level);
}
}
@ -232,7 +241,6 @@ svg {
&.int {
fill: $rt-int;
}
}
text {

View file

@ -8,27 +8,27 @@
<ResearchTile y="0" :level="5" :field="field" />
<g v-if="$store.state.gaiaViewer.data.tiles && $store.state.gaiaViewer.data.tiles.techs['gaia']">
<g transform="translate(30, 79) scale(0.95)">
<TechTile :pos="'adv-'+field" x=-30 y=-30 />
<TechTile :pos="'adv-' + field" x="-30" y="-30" />
</g>
<g transform="translate(30, 351) scale(0.95)">
<TechTile :pos="field" x=-30 y=-30 />
<TechTile :pos="field" x="-30" y="-30" />
</g>
</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';
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
}
TechTile,
},
})
export default class ResearchTrack extends Vue {
@Prop()
@ -39,6 +39,4 @@ export default class ResearchTrack extends Vue {
}
</script>
<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>

View file

@ -0,0 +1,223 @@
<template>
<g class="resource">
<template v-if="kind === 'q'">
<Qic v-if="!flat" class="qic" :transform="`translate(-0.5,0)`" />
<rect v-else class="qic" width="14" height="14" x="-7" y="-7" />
</template>
<!-- <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="['pw', 'pay-pw', 't', 'bowl-t', 'tg', 'brainstone'].includes(kind)"
:class="kind === 'tg' ? 'gaia' : 'power'"
width="15"
height="15"
ry="7.5"
rx="7.5"
x="-7.5"
y="-7.5"
/>
<polygon
points="-7.5,3 -3,7.5 3,7.5 7.5,3 7.5,-3 3,-7.5 -3,-7.5 -7.5,-3"
v-else-if="kind == 'k'"
class="knowledge"
/>
<g v-else-if="kind == 'vp'" transform="translate(-7.5,-7.5)" class="vp">
<VictoryPoint width="15" height="15" />
</g>
<Building
v-else-if="kind == 'gf'"
building="gf"
transform="translate(0.5, 0) scale(2.5)"
:flat="flat"
:faction="faction"
/>
<g v-else-if="kind == 'swap-PI'" transform="scale(-1,1)">
<Building faction="ambas" building="m" transform="translate(-8.5, 0) scale(1.5)" :flat="flat" />
<Building faction="ambas" building="PI" transform="translate(6, 0) scale(1.5)" :flat="flat" />
<image xlink:href="../assets/resources/swap-arrow.svg" width=15 :height=129/343*15 x=-7.5 y=-14 />
</g>
<g v-else-if="kind == 'down-lab'" transform="scale(-1,1)">
<Building faction="firaks" building="lab" transform="translate(-7.5, 0) scale(1.5)" :flat="flat" />
<Building faction="firaks" building="ts" transform="translate(7.5, 0) scale(-1.5,1.5)" :flat="flat" />
<image xlink:href="../assets/resources/arrow-charge.svg" width=15 :height=133/346*15 x=-7.5 y=-14 />
</g>
<Building
v-else-if="kind == 'space-station'"
building="sp"
transform="translate(0.5, 0) scale(2.5)"
faction="ivits"
:flat="flat"
/>
<template v-else-if="kind === 'step'">
<image v-if="!flat" xlink:href="../assets/resources/dig-planet.svg" width="20" height="20" x="-10" y="-10" />
<circle v-else r="10" :class="['planet-fill', 'dig']" />
<template v-if="count === 1 || !count">
<image xlink:href='../assets/resources/dig-arrow.svg' width=14 :height=325/308*14 x=-11 y=-4 />
</template>
<template v-else-if="count === 2">
<image xlink:href='../assets/resources/dig-arrow.svg' width=14 :height=325/308*14 x=-13 y=-7 /> <image
xlink:href='../assets/resources/dig-arrow.svg' width=14 :height=325/308*14 x=-9 y=-2 />
</template>
</template>
<template v-else-if="kind === 'd'">
<g transform="translate(3,0)">
<image v-if="!flat" xlink:href="../assets/resources/dig-planet.svg" width="20" height="20" x="-10" y="-10" />
<circle v-else r="10" :class="['planet-fill', 'dig']" />
<image xlink:href='../assets/resources/dig-arrow.svg' :height=325/308*14 width=14 x=-11 y=-4 />
</g>
<g transform="translate(-7,-7)">
<rect class="ore" width="12" height="12" x="-6" y="-6" />
<text x="0" y="0">{{ 4 - count }}</text>
</g>
</template>
<image v-else-if="kind === 'tech'" xlink:href='../assets/resources/tech.svg' :height=155/211*22 width=22 x=-11 y=-8
/>
<Federation v-else-if="kind === 'fed'" width="22" x="-11" y="-26.5" :used="true" />
<template v-else-if="kind === 'range'">
<image xlink:href="../assets/resources/flat-hex.svg" :height=162/328*20 width=15 y=-9 x=-2 /> <image
xlink:href="../assets/resources/flat-hex.svg" :height=162/328*20 width=20 y=3 x=-10 /> <image
xlink:href="../assets/resources/range-arrow.svg" :height=285/164*9 width=9 y=-8 x=-2 transform="rotate(5)" />
<text
v-if="count > 1"
x="-7"
y="-2.5"
stroke="black"
stroke-width="0.3"
style="font-weight: bold; font-size: 15px; stroke-width: 0.7px"
>
{{ count }}
</text>
</template>
<template v-else-if="kind === 'r'">
<g transform="scale(1) translate(-13,0)">
<image xlink:href="../assets/resources/flat-hex.svg" :height=162/328*20 width=20 x=-10 y=-4 />
</g>
<g transform="scale(1) translate(13,0)">
<image xlink:href="../assets/resources/flat-hex.svg" :height=162/328*20 width=20 x=-10 y=-4 />
</g>
<g transform="translate(1,0) rotate(70)">
<image xlink:href="../assets/resources/range-arrow.svg" :height=285/164*9 width=10 x=-5 y=-8 />
</g>
<text v-if="count >= 1" x="13" y="1.2" stroke-width="0.3" style="font-weight: bold; font-size: 10px">
{{ count }}
</text>
</template>
<template v-else-if="kind === 'up-lowest'">
<Condition condition="a" transform="scale(0.75)" />
<Token faction="bescods" transform="scale(0.15) translate(50,-24)" />
<Token faction="bescods" transform="scale(0.15) translate(-5,26)" />
</template>
<image v-if="kind === 'pw'" xlink:href='../assets/resources/power-charge.svg' :height=133/346*20 width=20
transform="translate(-9.5, -13.5)" /> <image v-if="kind === 'pay-pw'"
xlink:href='../assets/resources/power-charge.svg' :height=133/346*20 width=20 transform="translate(9.5, -13.5)
scale(-1,1) " />
<text
x="0"
y="0"
v-if="
(count >= 0 && ['o', 'c', 'k', 'pw', 'pay-pw', 't', 'bowl-t', 'tg', 'vp', 'q', 'gf'].includes(kind)) ||
count === '+'
"
:class="{ plus: count === '+' }"
>{{ kind === "t" ? "+" : "" }}{{ count }}</text
>
<text x="0" y="0" v-if="kind == 'brainstone'">B</text>
</g>
</template>
<script lang="ts">
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { Faction } from "@gaia-project/engine";
import Building from "./Building.vue";
import Qic from "./Resources/Qic.vue";
import VictoryPoint from "./Resources/VictoryPoint.vue";
import Federation from "./FederationTile.vue";
import Token from "./Token.vue";
@Component({
components: {
Building,
Federation,
Qic,
Token,
VictoryPoint,
},
})
export default class Resource extends Vue {
@Prop()
kind: Resource | "brainstone";
@Prop()
count: number;
@Prop({ default: false })
centerLeft: boolean;
@Prop({ default: "gen" })
faction: Faction;
get flat() {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
}
</script>
<style lang="scss">
@import "../stylesheets/planets.scss";
g.resource {
pointer-events: none;
rect,
.knowledge {
stroke: #111;
stroke-width: 0.9px;
fill: $res-knowledge;
}
.qic {
fill: $res-qic;
}
.ore {
fill: $res-ore;
}
.credit {
fill: $res-credit;
}
.power {
fill: $res-power;
}
.gaia {
fill: $gaia;
}
.ore,
.credit,
.building.r {
& + text {
fill: black;
}
}
text {
font-size: 10px;
fill: white;
font-weight: 600;
dominant-baseline: central;
text-anchor: middle;
&.plus {
font-size: 22px;
stroke: #111;
fill: white;
}
}
}
</style>

View file

@ -0,0 +1,104 @@
<template>
<g :class="['scoringTile', { highlighted, faded }]" v-b-tooltip :title="tooltip">
<rect x="1" y="1" width="75" height="40" rx="2" ry="2" stroke="none" fill="white" />
<text class="title" x="58" y="36">R{{ round }}</text>
<!-- <text class="content" x="5" y="31">{{content.split(" ")[0]}}</text>-->
<Resource :kind="reward.type" :count="reward.count" transform="translate(63.7, 13.1) scale(1.5)" />
<Condition
:condition="event.condition"
:transform="
`translate(${
event.condition === 'step' || event.condition === 'a' || event.condition === 'PA'
? 27 + (event.condition === 'PA' ? 8 : 0)
: 34
}, ${event.condition === 'step' ? 20 : 22}) scale(1.3)`
"
/>
<Operator :condition="event.condition" :operator="event.operator" transform="translate(28, 27) scale(1)" />
<rect x="1" y="1" width="75" height="40" rx="2" ry="2" class="contour" />
</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";
import Condition from "./Condition.vue";
import Resource from "./Resource.vue";
import Operator from "./Operator.vue";
@Component<ScoringTile>({
components: {
Condition,
Operator,
Resource,
},
})
export default class ScoringTile extends Vue {
@Prop()
round: number;
get tile(this: ScoringTile) {
return this.$store.state.gaiaViewer.data.tiles.scorings.round[this.round - 1];
}
get event() {
return new Event(this.content);
}
get reward() {
return this.event.rewards[0];
}
get content() {
return tiles.roundScorings[this.tile][0];
}
get tooltip() {
return eventDesc(this.event);
}
get highlighted() {
return this.$store.state.gaiaViewer.data.round === this.round && !this.faded;
}
get faded() {
return (
this.$store.state.gaiaViewer.data.round > this.round || this.$store.state.gaiaViewer.data.phase === Phase.EndGame
);
}
}
</script>
<style lang="scss">
@import "../stylesheets/planets.scss";
g {
&.scoringTile {
& > rect.contour {
fill: none;
stroke: #333;
stroke-width: 1px;
}
.title {
font-size: 10px;
font-weight: bold;
pointer-events: none;
}
.content {
font-size: 12px;
pointer-events: none;
}
&.highlighted > rect.contour {
stroke: $highlighted;
stroke-width: 1.5px;
}
&.faded {
opacity: 0.5;
}
}
}
</style>

View file

@ -1,50 +1,54 @@
<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)" />
<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 Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { GaiaHex } from "@gaia-project/engine";
import { hexCenter } from "../graphics/hex";
import SpaceHex from './SpaceHex.vue';
import { CubeCoordinates, Hex } from 'hexagrid';
import SpaceHex from "./SpaceHex.vue";
import { CubeCoordinates, Hex } from "hexagrid";
@Component<Sector>({
components: {
SpaceHex
}
SpaceHex,
},
})
export default class Sector extends Vue {
@Prop()
center: CubeCoordinates;
centerOffset (hex: GaiaHex) {
centerOffset(hex: GaiaHex) {
return hexCenter({
q: hex.q - this.center.q,
r: hex.r - this.center.r
r: hex.r - this.center.r,
});
}
isCenter (hex: GaiaHex) {
isCenter(hex: GaiaHex) {
return hex.q === this.center.q && hex.r === this.center.r;
}
get map () {
get map() {
return this.$store.state.gaiaViewer.data.map;
}
get sector (): GaiaHex[] {
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">

View file

@ -0,0 +1,181 @@
<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, hex.data.player)}` : ""
}}{{ 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
style="stroke-width: 10;"
v-if="hex.data.building"
:building="hex.data.building"
:faction="faction(hex.data.player)"
outline
:flat="flat"
transform="scale(0.1)"
/>
<Building
style="stroke-width: 10;"
v-if="hex.data.additionalMine !== undefined"
:faction="faction(hex.data.additionalMine)"
building="m"
transform="translate(0.4, 0.2) scale(0.09)"
class="additionalMine"
:flat="flat"
outline
/>
<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,
Faction,
} 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 flat() {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
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, player) {
return `${buildingName(building)} (${factions[this.faction(player)].name})`;
}
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;
}
}
</script>
<style lang="scss">
svg {
.spaceHex {
fill: #172e62;
stroke: #666;
stroke-width: 0.01;
&:hover {
fill-opacity: 0.5;
}
&.highlighted {
fill: white;
cursor: pointer;
&.qic {
fill: lightGreen;
}
&.power {
fill: #d378d3;
}
}
&.toSelect {
cursor: pointer;
opacity: 0.7;
}
}
.spaceHexFederation {
stroke-width: 0.1;
fill: none;
pointer-events: none;
}
.sector-name {
text-anchor: middle;
dominant-baseline: central;
font-size: 1px;
fill: white;
opacity: 0.35;
pointer-events: none;
}
}
</style>

View file

@ -1,18 +1,27 @@
<template>
<svg :viewBox="`-13 -11.5 ${right} 24`">
<Filters />
<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)"/>
<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 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 Sector from "./Sector.vue";
import { CubeCoordinates } from "hexagrid";
import FactionWheel from "./FactionWheel.vue";
import Filters from "./Filters.vue";
@ -20,33 +29,30 @@ import Filters from "./Filters.vue";
components: {
FactionWheel,
Filters,
Sector
}
Sector,
},
})
export default class SpaceMap extends Vue {
hexCenter (hex: GaiaHex) {
hexCenter(hex: GaiaHex) {
return hexCenter(hex);
}
get sectors (): CubeCoordinates[] {
get sectors(): CubeCoordinates[] {
return this.map.configuration().centers;
}
rotation (center: CubeCoordinates) {
rotation(center: CubeCoordinates) {
return this.$store.state.gaiaViewer.context.rotation.get(`${center.q}x${center.r}`) || 0;
}
get map (): SpaceMapData {
get map(): SpaceMapData {
return this.$store.state.gaiaViewer.data.map;
}
get right () {
get right() {
return (this.sectors || []).length > 7 ? 33.5 : 26;
}
}
</script>
<style lang="scss">
</style>
<style lang="scss"></style>

View file

@ -1,22 +1,27 @@
<template>
<svg viewBox="-25 -25 50 50" width="50" height="50" style="overflow: visible">
<g :class='["specialAction", {highlighted: isHighlighted, disabled, board}]'>
<g :class="['specialAction', { highlighted: isHighlighted, disabled, board }]">
<polygon points="-10,4 -4,10 4,10 10,4 10,-4 4,-10 -4,-10 -10,-4" transform="scale(2.4)" @click="onClick" />
<!-- <Resource v-for="(reward, i) in rewards" :key=i :count=reward.count :kind=reward.type :transform="`translate(${rewards.length > 1 ? (i - 0.5) * 20 : 0}, ${reward.type === 'pw' ? 4 : 0}), scale(1.5)`" />-->
<TechContent :content="act" v-for="(act, i) in action" :key=i :transform="`translate(0, ${(i - (action.length-1)/2) * 24}) scale(${action.length === 1 ? 0.8 : 0.55})`" />
<TechContent
:content="act"
v-for="(act, i) in action"
:key="i"
:transform="`translate(0, ${(i - (action.length - 1) / 2) * 24}) scale(${action.length === 1 ? 0.8 : 0.55})`"
/>
</g>
<g v-if="disabled">
<line y1="-14" y2="14" x1=-14 x2=14 stroke=#333 stroke-width=5 />
<line y1="14" y2="-14" x1=-14 x2=14 stroke=#333 stroke-width=5 />
<line y1="-14" y2="14" x1="-14" x2="14" stroke="#333" stroke-width="5" />
<line y1="14" y2="-14" x1="-14" x2="14" stroke="#333" stroke-width="5" />
</g>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, Event, Reward } from '@gaia-project/engine';
import { eventDesc } from '../data/event';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { tiles, Event, Reward } from "@gaia-project/engine";
import { eventDesc } from "../data/event";
@Component
export default class SpecialAction extends Vue {
@ -32,7 +37,7 @@ export default class SpecialAction extends Vue {
@Prop()
action: string[];
onClick () {
onClick() {
if (!this._highlighted) {
this.$emit("click");
return;
@ -40,24 +45,26 @@ export default class SpecialAction extends Vue {
this.$store.dispatch("gaiaViewer/actionClick", this.action.join(","));
}
get rewards () {
get rewards() {
return new Event(this.action[0]).rewards;
}
/** When the action content is highlighted - not the parent component */
get _highlighted () {
return this.$store.state.gaiaViewer.context.highlighted.actions.has(this.action.join(",")) || this.$store.state.gaiaViewer.context.highlighted.actions.has(this.action.join(",").replace(/>/g, ''));
get _highlighted() {
return (
this.$store.state.gaiaViewer.context.highlighted.actions.has(this.action.join(",")) ||
this.$store.state.gaiaViewer.context.highlighted.actions.has(this.action.join(",").replace(/>/g, ""))
);
}
get isHighlighted () {
get isHighlighted() {
return this.highlighted || this._highlighted;
}
}
</script>
<style lang="scss">
@import '../stylesheets/planets.scss';
@import "../stylesheets/planets.scss";
g {
&.specialAction {
@ -82,5 +89,4 @@ g {
}
}
}
</style>

View file

@ -0,0 +1,196 @@
<template>
<g>
<text :class="['content', { smaller: content.length >= 10 }]" x="-25" y="0" v-if="showText">{{ content }}</text>
<SpecialAction
v-if="isAction"
:action="['>' + content.split('=>')[1].trim()]"
y="-20"
width="40"
height="40"
x="-20"
/>
<Condition :condition="condition" v-if="condition === 'a'" transform="scale(1.5)" />
<Resource
v-if="cornerReward"
:count="cornerReward.count"
:kind="cornerReward.type"
transform="translate(19, -19), scale(1.35)"
/>
<g v-if="event.operator === '|'">
<polygon
points="-30,-28 -20,-28 -20,28 -30,28"
fill="#F8031D"
stroke="black"
stroke-width="1"
stroke-miterlimit="1"
/>
<text
x="-25"
y="0"
style="text-anchor: middle; dominant-baseline: central; font-size: 8px; fill: white !important; letter-spacing: 0px; writing-mode: vertical-rl; text-orientation: upright; "
>PASS</text
>
</g>
<Condition
:condition="condition"
v-if="condition !== 'a'"
:transform="`translate(${event.operator === '>>' && condition !== 'a' ? 8 : 0}, 0) scale(1.5)`"
/>
<Resource
v-for="(res, i) in centerRewards"
:count="res.count"
:kind="res.type"
:key="i"
:transform="
`translate(${centerRewards.length > 1 ? (i - 0.5) * 26 : 0}, 0) scale(${centerRewards.length === 1 ? 2 : 1.5})`
"
/>
<Resource
v-for="(res, i) in rightRewards"
:count="res.count"
:kind="res.type"
:key="'right-' + i"
:transform="`translate(13, ${rightRewards.length > 1 ? (i - 0.5) * 28 : 0}) scale(1.5)`"
/>
<template v-if="event.operator === 'PA->4pw'">
<Building building="PI" :transform="`translate(${flat ? -8 : -5.5}, -8) scale(2.7)`" :flat="flat" faction="gen" />
<Building
building="ac1"
:transform="`translate(${flat ? 8 : 5.5}, ${flat ? -8 : -6}) scale(2.7)`"
:flat="flat"
faction="gen"
/>
<Resource kind="t" transform="translate(-20, 18) scale(0.8)" />
<Resource kind="t" transform="translate(-6.66, 18) scale(0.8)" />
<Resource kind="t" transform="translate(6.66, 18) scale(0.8)" />
<Resource kind="t" transform="translate(20, 18) scale(0.8)" />
</template>
<template v-else-if="event.operator === '>>'">
<Operator :operator="event.operator" :condition="event.condition" transform="translate(2,5) scale(1.2)" />
</template>
<text
style="font-size: 40px; stroke: black; fill: white; dominant-baseline: central; text-anchor: middle; stroke-width: 1px; font-weight: bold;"
x="-14"
v-if="event.operator === '+'"
>+</text
>
</g>
</template>
<script lang="ts">
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import {
tiles,
PlayerEnum,
Event,
TechTilePos,
AdvTechTilePos,
Operator as OperatorEnum,
Condition as ConditionEnum,
Building as BuildingEnum,
} from "@gaia-project/engine";
import { eventDesc } from "../data/event";
import Resource from "./Resource.vue";
import Building from "./Building.vue";
import Condition from "./Condition.vue";
import Operator from "./Operator.vue";
import SpecialAction from "./SpecialAction.vue";
@Component({
components: {
Building,
Condition,
Operator,
Resource,
SpecialAction,
},
})
export default class TechContent extends Vue {
@Prop()
content!: string;
get event() {
return new Event(this.content);
}
get cornerReward() {
if (
this.event.operator === OperatorEnum.Trigger ||
this.event.operator === OperatorEnum.Pass ||
(this.event.operator === OperatorEnum.Once && this.event.condition !== ConditionEnum.None)
) {
return this.event.rewards[0];
}
return null;
}
get centerRewards() {
if (this.event.operator === OperatorEnum.Once && this.event.condition === ConditionEnum.None) {
return this.event.rewards;
}
return [];
}
get condition() {
return this.event.condition;
}
get rightRewards() {
if (this.event.operator === OperatorEnum.Income) {
return this.event.rewards;
}
return [];
}
get showText() {
if (
this.event.operator === OperatorEnum.Activate ||
this.event.operator === OperatorEnum.Income ||
this.event.operator === OperatorEnum.Special
) {
return false;
}
if (
this.event.operator === OperatorEnum.Once ||
this.event.operator === OperatorEnum.Trigger ||
this.event.operator === OperatorEnum.Pass
) {
// console.log(this.event, this.event.condition);
if (
[
ConditionEnum.None,
ConditionEnum.Federation,
ConditionEnum.PlanetaryInstituteOrAcademy,
ConditionEnum.AdvanceResearch,
ConditionEnum.MineOnGaia,
ConditionEnum.PlanetType,
ConditionEnum.Sector,
ConditionEnum.Gaia,
...Object.values(BuildingEnum),
].includes(this.event.condition as any)
) {
return false;
}
}
return true;
}
get isAction() {
return this.event.operator === OperatorEnum.Activate;
}
get rewards() {
return this.event.rewards;
}
get flat() {
return this.$store.state.gaiaViewer.preferences.flatBuildings;
}
}
</script>

View file

@ -1,24 +1,53 @@
<template>
<svg :class='["techTile", pos, {highlighted, covered, advanced: isAdvanced}]' v-show="this.count" v-b-tooltip :title="tooltip" @click="onClick" width="60" height="60" viewBox="-32 -32 64 64">
<g :transform="`scale(${isAdvanced? 0.9 : 1})`">
<rect x=-30 y=-30 width=60 height=60 rx=3 ry=3 stroke="black" stroke-width=1 class="tech-border" filter="url(#shadow-1)" />
<svg
:class="['techTile', pos, { highlighted, covered, advanced: isAdvanced }]"
v-show="this.count"
v-b-tooltip
:title="tooltip"
@click="onClick"
width="60"
height="60"
viewBox="-32 -32 64 64"
>
<g :transform="`scale(${isAdvanced ? 0.9 : 1})`">
<rect
x="-30"
y="-30"
width="60"
height="60"
rx="3"
ry="3"
stroke="black"
stroke-width="1"
class="tech-border"
filter="url(#shadow-1)"
/>
<!--<text class="title" x="-25" y="-18">{{title}}</text>-->
<TechContent :content=rawContent style="pointer-events:none;" />
<TechContent :content="rawContent" style="pointer-events:none;" />
</g>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { tiles, PlayerEnum, Event, TechTilePos, AdvTechTilePos, Operator as OperatorEnum, Condition as ConditionEnum, Building as BuildingEnum } from '@gaia-project/engine';
import { eventDesc } from '../data/event';
import TechContent from './TechContent.vue';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import {
tiles,
PlayerEnum,
Event,
TechTilePos,
AdvTechTilePos,
Operator as OperatorEnum,
Condition as ConditionEnum,
Building as BuildingEnum,
} from "@gaia-project/engine";
import { eventDesc } from "../data/event";
import TechContent from "./TechContent.vue";
@Component({
components: {
TechContent
}
TechContent,
},
})
export default class TechTile extends Vue {
@Prop()
@ -33,29 +62,29 @@ export default class TechTile extends Vue {
@Prop()
covered: boolean;
onClick () {
onClick() {
if (this.highlighted) {
this.$store.dispatch("gaiaViewer/techClick", this.pos);
}
}
get highlighted () {
get highlighted() {
return this.$store.state.gaiaViewer.context.highlighted.techs.has(this.pos);
}
get tileObject () {
get tileObject() {
return this.$store.state.gaiaViewer.data.tiles.techs[this.pos];
}
get tile () {
get tile() {
return this.tileObject.tile;
}
get event () {
get event() {
return new Event(this.rawContent);
}
get count () {
get count() {
if (this.countOverride !== undefined) {
return this.countOverride;
}
@ -65,11 +94,11 @@ export default class TechTile extends Vue {
return this.tileObject.count;
}
get rawContent () {
get rawContent() {
return tiles.techs[this.tile][0];
}
get title () {
get 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})`;
@ -78,19 +107,18 @@ export default class TechTile extends Vue {
return this.pos;
}
get isAdvanced () {
get isAdvanced() {
return this.pos.startsWith("adv-");
}
get tooltip () {
get tooltip() {
return eventDesc(this.event);
}
}
</script>
<style lang="scss">
@import '../stylesheets/planets.scss';
@import "../stylesheets/planets.scss";
svg {
&.techTile {
@ -126,7 +154,7 @@ svg {
fill: $rt-sci;
}
&.terra .tech-border {
fill: $rt-terra
fill: $rt-terra;
}
&.nav .tech-border {
fill: $rt-nav;
@ -149,5 +177,4 @@ svg {
}
}
}
</style>

View file

@ -5,28 +5,26 @@
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { factions, Faction, Planet } from '@gaia-project/engine';
import { planetClass } from '../graphics/utils';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { factions, Faction, Planet } from "@gaia-project/engine";
import { planetClass } from "../graphics/utils";
@Component
export default class PlayerToken extends Vue {
@Prop()
faction: Faction | 'automa';
faction: Faction | "automa";
get planetClass () {
get planetClass() {
return planetClass(this.faction);
}
}
</script>
<style lang="scss">
g .player-token {
stroke: #111;
pointer-events: none;
stroke-width: 3;
}
</style>

View file

@ -3,15 +3,36 @@
<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>
<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
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>
@ -22,16 +43,21 @@ import Engine, { factions, Player, Planet, Phase } from "@gaia-project/engine";
@Component
export default class TurnOrder extends Vue {
get gameData (): Engine {
get gameData(): Engine {
return this.$store.state.gaiaViewer.data;
}
get phaseBeforeSetupBuilding (): boolean {
get phaseBeforeSetupBuilding(): boolean {
const data = this.gameData;
return (data.phase === Phase.SetupInit || data.phase === Phase.SetupBoard || data.phase === Phase.SetupFaction || data.phase === Phase.SetupAuction);
return (
data.phase === Phase.SetupInit ||
data.phase === Phase.SetupBoard ||
data.phase === Phase.SetupFaction ||
data.phase === Phase.SetupAuction
);
}
get turnOrder (): Player[] {
get turnOrder(): Player[] {
const data = this.gameData;
if (this.phaseBeforeSetupBuilding) {
return data.players;
@ -42,15 +68,18 @@ export default class TurnOrder extends Vue {
return data.turnOrder.map(player => data.players[player]);
}
get passedPlayers (): 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);
isCurrentPlayer(pl: Player) {
return (
this.gameData.players[this.gameData.availableCommands?.[0]?.player] === pl &&
!(this.gameData.phase === Phase.SetupAuction)
);
}
stroke (pl: Player) {
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";
@ -66,24 +95,26 @@ export default class TurnOrder extends Vue {
return "stroke-width: 0.06px !important";
}
planetFill (planet: string) {
planetFill(planet: string) {
if (planet === Planet.Titanium || planet === Planet.Swamp) {
return "white";
}
return "black";
}
planet (player: Player, index: number) {
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); };
if (player.faction) {
return factions.planet(player.faction);
}
return Planet.Lost;
}
initial (player: Player, index: number) {
initial(player: Player, index: number) {
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
return this.gameData.setup[index][0].toUpperCase();
}
@ -95,7 +126,7 @@ export default class TurnOrder extends Vue {
return "?";
}
name (player: Player, index: number) {
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]);
@ -109,20 +140,17 @@ export default class TurnOrder extends Vue {
return player.name.substring(0, 3);
} else {
return "P" + (player.player + 1);
};
}
}
return "?";
}
}
</script>
<style lang="scss">
.turn-order {
& > svg {
max-width: 250px;
}
}
</style>

Some files were not shown because too many files have changed in this diff Show more