Lint project
This commit is contained in:
parent
89f214e248
commit
cc1e507b2b
48 changed files with 1511 additions and 669 deletions
5
.editorconfig
Normal file
5
.editorconfig
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
[*.{js,jsx,ts,tsx,vue}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
28
.eslintrc.js
Normal file
28
.eslintrc.js
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
node: true
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
'plugin:vue/essential',
|
||||||
|
'@vue/standard',
|
||||||
|
'@vue/typescript/recommended'
|
||||||
|
],
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2020
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||||
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||||
|
semi: ['error', 'always'],
|
||||||
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
|
'@typescript-eslint/consistent-type-assertions': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'@typescript-eslint/no-empty-function': 'off',
|
||||||
|
'@typescript-eslint/no-unused-vars': 'off',
|
||||||
|
'no-return-assign': 'off',
|
||||||
|
'no-lone-blocks': 'off',
|
||||||
|
'no-unmodified-loop-condition': 'off',
|
||||||
|
quotes: 'off'
|
||||||
|
}
|
||||||
|
};
|
||||||
18
package.json
18
package.json
|
|
@ -4,14 +4,14 @@
|
||||||
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
|
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
|
||||||
"author": "coyotte508, rzulian",
|
"author": "coyotte508, rzulian",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"serve": "vue-cli-service serve --port 8080",
|
||||||
"build": "vue-cli-service build",
|
"build": "vue-cli-service build",
|
||||||
|
"lint": "vue-cli-service lint",
|
||||||
"package": "vue-cli-service build --target lib src/wrapper.ts",
|
"package": "vue-cli-service build --target lib src/wrapper.ts",
|
||||||
"prepublishOnly": "npm run package",
|
"prepublishOnly": "npm run package",
|
||||||
"serve": "vue-cli-service serve --port 8080",
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"unpkg": "dist/package/viewer.umd.min.js",
|
"unpkg": "dist/package/viewer.umd.min.js",
|
||||||
"source": "index.ts",
|
|
||||||
"files": [
|
"files": [
|
||||||
"index.ts",
|
"index.ts",
|
||||||
"tsconfig.json",
|
"tsconfig.json",
|
||||||
|
|
@ -31,8 +31,19 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jquery": "^3.3.1",
|
"@types/jquery": "^3.3.1",
|
||||||
"@types/node": "^10.5.2",
|
"@types/node": "^10.5.2",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^2.26.0",
|
||||||
|
"@typescript-eslint/parser": "^2.26.0",
|
||||||
|
"@vue/cli-plugin-eslint": "~4.3.0",
|
||||||
"@vue/cli-plugin-typescript": "~4.2.3",
|
"@vue/cli-plugin-typescript": "~4.2.3",
|
||||||
"@vue/cli-service": "~4.2.3",
|
"@vue/cli-service": "~4.2.3",
|
||||||
|
"@vue/eslint-config-standard": "^5.1.2",
|
||||||
|
"@vue/eslint-config-typescript": "^5.0.2",
|
||||||
|
"eslint": "^6.7.2",
|
||||||
|
"eslint-plugin-import": "^2.20.2",
|
||||||
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
"eslint-plugin-promise": "^4.2.1",
|
||||||
|
"eslint-plugin-standard": "^4.0.0",
|
||||||
|
"eslint-plugin-vue": "^6.2.2",
|
||||||
"hexagrid": "^2.0.1",
|
"hexagrid": "^2.0.1",
|
||||||
"node-sass": "^4.7.2",
|
"node-sass": "^4.7.2",
|
||||||
"popper": "^1.0.1",
|
"popper": "^1.0.1",
|
||||||
|
|
@ -60,5 +71,6 @@
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/donkeytech/gaia-viewer.git"
|
"url": "git+https://github.com/donkeytech/gaia-viewer.git"
|
||||||
}
|
},
|
||||||
|
"source": "index.ts"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,17 @@
|
||||||
</thead> -->
|
</thead> -->
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="major-event" v-if="data.phase === 'endGame'"><td colspan=3>Game Ended</td></tr>
|
<tr class="major-event" v-if="data.phase === 'endGame'"><td colspan=3>Game Ended</td></tr>
|
||||||
<tr v-for="event in history">
|
<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-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==='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==='roundGaia'" class="phase-change">Gaia phase</td>
|
||||||
<td v-else-if="event.entry.phase==='endGame'" class="phase-change">End scoring</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 v-else>{{event.move || data.players[event.entry.player].faction}}</td>
|
||||||
<td style="width: 1px; white-space: nowrap;">
|
<td style="width: 1px; white-space: nowrap;">
|
||||||
<div v-for="(changes, source) in event.entry.changes" v-html="source === 'undefined' ? ' ' : source" />
|
<div v-for="(changes, source, i) in event.entry.changes" v-html="source === 'undefined' ? ' ' : source" :key=i />
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 1px; white-space: nowrap;">
|
<td style="width: 1px; white-space: nowrap;">
|
||||||
<div v-for="(changes, source) in event.entry.changes">
|
<div v-for="(changes, source, i) in event.entry.changes" :key=i>
|
||||||
{{Object.keys(changes).map(key => `${changes[key]}${key}`).join(', ')}}
|
{{Object.keys(changes).map(key => `${changes[key]}${key}`).join(', ')}}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -31,16 +31,16 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import Engine, {LogEntry} from '@gaia-project/engine';
|
import Engine, { LogEntry } from '@gaia-project/engine';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
computed: {
|
computed: {
|
||||||
data() {
|
data () {
|
||||||
return this.$store.state.gaiaViewer.data;
|
return this.$store.state.gaiaViewer.data;
|
||||||
},
|
},
|
||||||
history(): Array<{move: string, entry: LogEntry}> {
|
history (): Array<{move: string; entry: LogEntry}> {
|
||||||
const ret = [];
|
const ret = [];
|
||||||
let advancedLogIndex = 0;
|
let advancedLogIndex = 0;
|
||||||
let nextLogEntry = this.data.advancedLog[advancedLogIndex];
|
let nextLogEntry = this.data.advancedLog[advancedLogIndex];
|
||||||
|
|
@ -48,16 +48,16 @@ import Engine, {LogEntry} from '@gaia-project/engine';
|
||||||
const bumpLog = () => {
|
const bumpLog = () => {
|
||||||
advancedLogIndex += 1;
|
advancedLogIndex += 1;
|
||||||
nextLogEntry = this.data.advancedLog[advancedLogIndex];
|
nextLogEntry = this.data.advancedLog[advancedLogIndex];
|
||||||
}
|
};
|
||||||
|
|
||||||
this.data.moveHistory.forEach((move, i) => {
|
this.data.moveHistory.forEach((move, i) => {
|
||||||
while (nextLogEntry && (nextLogEntry.move === undefined || nextLogEntry.move < i)) {
|
while (nextLogEntry && (nextLogEntry.move === undefined || nextLogEntry.move < i)) {
|
||||||
if (nextLogEntry.player === undefined || !!nextLogEntry.changes) {
|
if (nextLogEntry.player === undefined || !!nextLogEntry.changes) {
|
||||||
ret.push({entry: nextLogEntry});
|
ret.push({ entry: nextLogEntry });
|
||||||
}
|
}
|
||||||
bumpLog();
|
bumpLog();
|
||||||
}
|
}
|
||||||
const entry = {move, entry: {} as LogEntry};
|
const entry = { move, entry: {} as LogEntry };
|
||||||
if (nextLogEntry && nextLogEntry.move === i) {
|
if (nextLogEntry && nextLogEntry.move === i) {
|
||||||
entry.entry = nextLogEntry;
|
entry.entry = nextLogEntry;
|
||||||
bumpLog();
|
bumpLog();
|
||||||
|
|
@ -65,12 +65,12 @@ import Engine, {LogEntry} from '@gaia-project/engine';
|
||||||
ret.push(entry);
|
ret.push(entry);
|
||||||
while (nextLogEntry && nextLogEntry.move === undefined) {
|
while (nextLogEntry && nextLogEntry.move === undefined) {
|
||||||
if (nextLogEntry.player === undefined || !!nextLogEntry.changes) {
|
if (nextLogEntry.player === undefined || !!nextLogEntry.changes) {
|
||||||
ret.push({entry: nextLogEntry});
|
ret.push({ entry: nextLogEntry });
|
||||||
}
|
}
|
||||||
bumpLog();
|
bumpLog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ret.reverse();
|
ret.reverse();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -90,4 +90,4 @@ export default class AdvancedLog extends Vue {
|
||||||
.phase-change {
|
.phase-change {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<g :class='["boardAction", kind, {highlighted, faded}]' v-b-tooltip :title="tooltip">
|
<g :class='["boardAction", kind, {highlighted, faded}]' v-b-tooltip :title="tooltip">
|
||||||
<polygon points="-1,0.5 -0.5,1 0.5,1 1,0.5 1,-0.5 0.5,-1 -0.5,-1 -1,-0.5" :transform="`scale(${scale})`" @click="onClick" />
|
<polygon points="-1,0.5 -0.5,1 0.5,1 1,0.5 1,-0.5 0.5,-1 -0.5,-1 -1,-0.5" :transform="`scale(${scale})`" @click="onClick" />
|
||||||
<text :transform="`scale(${scale/17})`">
|
<text :transform="`scale(${scale/17})`">
|
||||||
<tspan :x="i+1 < income.length ? 1 : 0" v-for="(line, i) in income" :key="i" :dy="`${i*1.15 - (income.length - 1) / 4}em`">
|
<tspan :x="i+1 < income.length ? 1 : 0" v-for="(line, i) in income" :key="i" :dy="`${i*1.15 - (income.length - 1) / 4}em`">
|
||||||
{{line.replace(/ /g, '')}}
|
{{line.replace(/ /g, '')}}
|
||||||
</tspan>
|
</tspan>
|
||||||
</text>
|
</text>
|
||||||
|
|
@ -10,32 +10,28 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { tiles, Event, BoardAction as BoardActionEnum, boardActions } from '@gaia-project/engine';
|
import { tiles, Event, BoardAction as BoardActionEnum, boardActions } from '@gaia-project/engine';
|
||||||
import { eventDesc } from '../data/event';
|
import { eventDesc } from '../data/event';
|
||||||
|
|
||||||
@Component<BoardAction>({
|
@Component<BoardAction>({
|
||||||
computed: {
|
computed: {
|
||||||
tooltip() {
|
tooltip () {
|
||||||
const costDesc = "Spend "+ this.cost + "\n";
|
const costDesc = "Spend " + this.cost + "\n";
|
||||||
|
|
||||||
return costDesc + boardActions[this.action].income.map(x => eventDesc(new Event(x))).join('\n');
|
return costDesc + boardActions[this.action].income.map(x => eventDesc(new Event(x))).join('\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
highlighted() {
|
faded () {
|
||||||
return this.$store.state.gaiaViewer.context.highlighted.actions.has(this.action);
|
|
||||||
},
|
|
||||||
|
|
||||||
faded() {
|
|
||||||
return !this.$store.state.gaiaViewer.data.boardActions[this.action];
|
return !this.$store.state.gaiaViewer.data.boardActions[this.action];
|
||||||
},
|
},
|
||||||
|
|
||||||
kind() {
|
kind () {
|
||||||
return this.action[0] === 'p' ? 'power' : 'qic';
|
return this.action[0] === 'p' ? 'power' : 'qic';
|
||||||
},
|
},
|
||||||
|
|
||||||
income() {
|
income () {
|
||||||
return [].concat(...boardActions[this.action].income.map(x => {
|
return [].concat(...boardActions[this.action].income.map(x => {
|
||||||
if (x.includes('+')) {
|
if (x.includes('+')) {
|
||||||
return [x.slice(0, x.indexOf('+')), x.slice(x.indexOf('+'))];
|
return [x.slice(0, x.indexOf('+')), x.slice(x.indexOf('+'))];
|
||||||
|
|
@ -44,7 +40,7 @@ import { eventDesc } from '../data/event';
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
cost() {
|
cost () {
|
||||||
return boardActions[this.action].cost;
|
return boardActions[this.action].cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,15 +52,16 @@ export default class BoardAction extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
action: BoardActionEnum;
|
action: BoardActionEnum;
|
||||||
|
|
||||||
onClick() {
|
onClick () {
|
||||||
if (!this.highlighted) {
|
if (!this.highlighted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$store.dispatch("gaiaViewer/actionClick", this.action);
|
this.$store.dispatch("gaiaViewer/actionClick", this.action);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export default interface BoardAction {
|
get highlighted () {
|
||||||
highlighted: boolean;
|
return this.$store.state.gaiaViewer.context.highlighted.actions.has(this.action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -8,35 +8,31 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { tiles, Event } from '@gaia-project/engine';
|
import { tiles, Event } from '@gaia-project/engine';
|
||||||
import { eventDesc } from '../data/event';
|
import { eventDesc } from '../data/event';
|
||||||
|
|
||||||
@Component<Booster>({
|
@Component<Booster>({
|
||||||
computed: {
|
computed: {
|
||||||
tileObject() {
|
tileObject () {
|
||||||
return tiles.boosters[this.booster];
|
return tiles.boosters[this.booster];
|
||||||
},
|
},
|
||||||
|
|
||||||
event1() {
|
event1 () {
|
||||||
return this.tileObject[0];
|
return this.tileObject[0];
|
||||||
},
|
},
|
||||||
|
|
||||||
event2() {
|
event2 () {
|
||||||
return this.tileObject[1];
|
return this.tileObject[1];
|
||||||
},
|
},
|
||||||
|
|
||||||
title() {
|
title () {
|
||||||
return this.booster;
|
return this.booster;
|
||||||
},
|
},
|
||||||
|
|
||||||
tooltip() {
|
tooltip () {
|
||||||
return `- ${eventDesc(new Event(this.event1))}\n- ${eventDesc(new Event(this.event2))}`;
|
return `- ${eventDesc(new Event(this.event1))}\n- ${eventDesc(new Event(this.event2))}`;
|
||||||
},
|
|
||||||
|
|
||||||
highlighted() {
|
|
||||||
return this.$store.state.gaiaViewer.context.highlighted.boosters.has(this.booster);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -46,17 +42,17 @@ export default class Booster extends Vue {
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
|
|
||||||
onClick() {
|
onClick () {
|
||||||
if (this.highlighted) {
|
if (this.highlighted) {
|
||||||
this.$store.dispatch("gaiaViewer/boosterClick", this.booster);
|
this.$store.dispatch("gaiaViewer/boosterClick", this.booster);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export default interface TechTile {
|
|
||||||
highlighted: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
get highlighted () {
|
||||||
|
return this.$store.state.gaiaViewer.context.highlighted.boosters.has(this.booster);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
||||||
|
|
@ -29,25 +29,25 @@ export default class Building extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
building: BuildingEnum;
|
building: BuildingEnum;
|
||||||
|
|
||||||
get planet() {
|
get planet () {
|
||||||
return (this.faction as any === "wild") ? Planet.Transdim : factions.planet(this.faction);
|
return (this.faction as any === "wild") ? Planet.Transdim : factions.planet(this.faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
get hexCorners() {
|
get hexCorners () {
|
||||||
return corners().map(({x, y}) => `${x*0.4},${y*0.4}`).join(" ");
|
return corners().map(({ x, y }) => `${x * 0.4},${y * 0.4}`).join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
get triangleCorners() {
|
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(" ");
|
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 mine () { return this.building === BuildingEnum.Mine; }
|
||||||
get tradingStation() {return this.building === BuildingEnum.TradingStation }
|
get tradingStation () { return this.building === BuildingEnum.TradingStation; }
|
||||||
get planetaryInstitute() {return this.building === BuildingEnum.PlanetaryInstitute}
|
get planetaryInstitute () { return this.building === BuildingEnum.PlanetaryInstitute; }
|
||||||
get lab() {return this.building === BuildingEnum.ResearchLab}
|
get lab () { return this.building === BuildingEnum.ResearchLab; }
|
||||||
get academy() {return this.building === BuildingEnum.Academy1 || this.building === BuildingEnum.Academy2}
|
get academy () { return this.building === BuildingEnum.Academy1 || this.building === BuildingEnum.Academy2; }
|
||||||
get gaiaFormer() {return this.building === BuildingEnum.GaiaFormer}
|
get gaiaFormer () { return this.building === BuildingEnum.GaiaFormer; }
|
||||||
get spaceStation() { return this.building === BuildingEnum.SpaceStation }
|
get spaceStation () { return this.building === BuildingEnum.SpaceStation; }
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -66,4 +66,4 @@ svg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -28,31 +28,31 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import Engine,{ AvailableCommand,Command,factions,Building,GaiaHex,Booster,tiles,Event,Federation,Faction, SpaceMap, Expansion } from '@gaia-project/engine';
|
import Engine, { AvailableCommand, Command, factions, Building, GaiaHex, Booster, tiles, Event, Federation, Faction, SpaceMap, Expansion } from '@gaia-project/engine';
|
||||||
import MoveButton from './MoveButton.vue';
|
import MoveButton from './MoveButton.vue';
|
||||||
import {buildingName} from '../data/building';
|
import { buildingName } from '../data/building';
|
||||||
import {GameContext, ButtonData} from '../data';
|
import { GameContext, ButtonData } from '../data';
|
||||||
import { eventDesc } from '../data/event';
|
import { eventDesc } from '../data/event';
|
||||||
import { factionDesc } from '../data/factions';
|
import { factionDesc } from '../data/factions';
|
||||||
import { BIconDash } from 'bootstrap-vue';
|
import { BIconDash } from 'bootstrap-vue';
|
||||||
@Component<Commands>({
|
@Component<Commands>({
|
||||||
watch: {
|
watch: {
|
||||||
availableCommands(this: Commands, val) {
|
availableCommands (this: Commands, val) {
|
||||||
this.loadCommands(val);
|
this.loadCommands(val);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
tooltip(faction: Faction) {
|
tooltip (faction: Faction) {
|
||||||
return factionDesc(faction);
|
return factionDesc(faction);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
canUndo() {
|
canUndo () {
|
||||||
return !this.$store.state.gaiaViewer.data.newTurn;
|
return !this.$store.state.gaiaViewer.data.newTurn;
|
||||||
},
|
},
|
||||||
randomFactionButton() {
|
randomFactionButton () {
|
||||||
this.updater = this.updater + 1;
|
this.updater = this.updater + 1;
|
||||||
const command = this.command;
|
const command = this.command;
|
||||||
const faction = command.data[Math.floor(Math.random() * command.data.length)];
|
const faction = command.data[Math.floor(Math.random() * command.data.length)];
|
||||||
|
|
@ -62,7 +62,7 @@ import { BIconDash } from 'bootstrap-vue';
|
||||||
label: "Random",
|
label: "Random",
|
||||||
modal: this.tooltip(faction),
|
modal: this.tooltip(faction),
|
||||||
title: factions[faction].name
|
title: factions[faction].name
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -70,12 +70,12 @@ import { BIconDash } from 'bootstrap-vue';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class Commands extends Vue {
|
export default class Commands extends Vue {
|
||||||
@Prop({default: ''})
|
@Prop({ default: '' })
|
||||||
remainingTime: string;
|
remainingTime: string;
|
||||||
|
|
||||||
updater: number = 0;
|
updater = 0;
|
||||||
|
|
||||||
loadCommands(val: AvailableCommand[]) {
|
loadCommands (val: AvailableCommand[]) {
|
||||||
this.commandTitles = [];
|
this.commandTitles = [];
|
||||||
this.customButtons = [];
|
this.customButtons = [];
|
||||||
this.commandChain = [];
|
this.commandChain = [];
|
||||||
|
|
@ -98,29 +98,29 @@ export default class Commands extends Vue {
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
get availableCommands(): AvailableCommand[] {
|
get availableCommands (): AvailableCommand[] {
|
||||||
return this.engine.availableCommands;
|
return this.engine.availableCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
get command(): AvailableCommand {
|
get command (): AvailableCommand {
|
||||||
return this.availableCommands ? this.availableCommands[0] : null;
|
return this.availableCommands ? this.availableCommands[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get player(): string {
|
get player (): string {
|
||||||
if (this.engine.players[this.command.player].faction) {
|
if (this.engine.players[this.command.player].faction) {
|
||||||
return factions[this.engine.players[this.command.player].faction].name;
|
return factions[this.engine.players[this.command.player].faction].name;
|
||||||
}
|
}
|
||||||
if (this.engine.players[this.command.player].name) {
|
if (this.engine.players[this.command.player].name) {
|
||||||
return this.engine.players[this.command.player].name;
|
return this.engine.players[this.command.player].name;
|
||||||
}
|
}
|
||||||
return "Player " + (this.command.player+1);
|
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}`;
|
return this.$store.state.gaiaViewer.data.players[this.command.player].faction || `p${this.command.player + 1}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
get init() {
|
get init () {
|
||||||
return !this.command || this.command.name === Command.Init;
|
return !this.command || this.command.name === Command.Init;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,23 +128,23 @@ export default class Commands extends Vue {
|
||||||
return this.command ? this.command.name : null;
|
return this.command ? this.command.name : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get chooseFaction() {
|
get chooseFaction () {
|
||||||
return this.commandName === Command.ChooseFaction;
|
return this.commandName === Command.ChooseFaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
get titles() {
|
get titles () {
|
||||||
return this.commandTitles.length === 0 ? ["Your turn"] : this.commandTitles;
|
return this.commandTitles.length === 0 ? ["Your turn"] : this.commandTitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
get factions() {
|
get factions () {
|
||||||
return factions;
|
return factions;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRandomFaction() {
|
updateRandomFaction () {
|
||||||
this.updater += 1;
|
this.updater += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCommand(command: string, source: MoveButton, final: boolean) {
|
handleCommand (command: string, source: MoveButton, final: boolean) {
|
||||||
console.log("handle command", command);
|
console.log("handle command", command);
|
||||||
|
|
||||||
// Some users seem to have a bug with repeating commands on mobile, like clicking the income button twice
|
// Some users seem to have a bug with repeating commands on mobile, like clicking the income button twice
|
||||||
|
|
@ -176,27 +176,27 @@ export default class Commands extends Vue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
undo() {
|
undo () {
|
||||||
this.$emit("undo");
|
this.$emit("undo");
|
||||||
}
|
}
|
||||||
|
|
||||||
title(title: string) {
|
title (title: string) {
|
||||||
this.commandTitles.push(title);
|
this.commandTitles.push(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
get context(): GameContext {
|
get context (): GameContext {
|
||||||
return this.$store.state.gaiaViewer.context;
|
return this.$store.state.gaiaViewer.context;
|
||||||
}
|
}
|
||||||
|
|
||||||
get engine(): Engine {
|
get engine (): Engine {
|
||||||
return this.$store.state.gaiaViewer.data;
|
return this.$store.state.gaiaViewer.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
get map() : SpaceMap {
|
get map (): SpaceMap {
|
||||||
return this.engine.map;
|
return this.engine.map;
|
||||||
}
|
}
|
||||||
|
|
||||||
get buttons(): ButtonData[] {
|
get buttons (): ButtonData[] {
|
||||||
const ret: ButtonData[] = [];
|
const ret: ButtonData[] = [];
|
||||||
for (const command of this.availableCommands) {
|
for (const command of this.availableCommands) {
|
||||||
switch (command.name) {
|
switch (command.name) {
|
||||||
|
|
@ -281,7 +281,7 @@ export default class Commands extends Vue {
|
||||||
hexes: new Map(command.data.ships.map(coord => [this.engine.map.grid.getS(coord.coordinates), coord])),
|
hexes: new Map(command.data.ships.map(coord => [this.engine.map.grid.getS(coord.coordinates), coord])),
|
||||||
range: command.data.range,
|
range: command.data.range,
|
||||||
costs: command.data.costs
|
costs: command.data.costs
|
||||||
})
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -293,21 +293,21 @@ export default class Commands extends Vue {
|
||||||
if (command.data.boosters.includes(booster)) {
|
if (command.data.boosters.includes(booster)) {
|
||||||
buttons.push({
|
buttons.push({
|
||||||
command: booster,
|
command: booster,
|
||||||
label: `Booster ${i+1}`,
|
label: `Booster ${i + 1}`,
|
||||||
tooltip: tiles.boosters[booster].map(spec => eventDesc(new Event(spec))).join("\n")
|
tooltip: tiles.boosters[booster].map(spec => eventDesc(new Event(spec))).join("\n")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// need a Pass confirmation if it's the last round, where Command = PAss but no Boosters
|
// need a Pass confirmation if it's the last round, where Command = PAss but no Boosters
|
||||||
if ( command.data.boosters.length === 0 ) {
|
if (command.data.boosters.length === 0) {
|
||||||
ret.push({
|
ret.push({
|
||||||
label: "Pass" ,
|
label: "Pass",
|
||||||
command: Command.Pass,
|
command: Command.Pass,
|
||||||
needConfirm: true,
|
needConfirm: true,
|
||||||
buttons: [{
|
buttons: [{
|
||||||
command: "",
|
command: "",
|
||||||
label: `Confirm Pass`
|
label: `Confirm Pass`
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -319,12 +319,11 @@ export default class Commands extends Vue {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
case Command.UpgradeResearch: {
|
case Command.UpgradeResearch: {
|
||||||
if ( command.data.tracks.length === 1 ) {
|
if (command.data.tracks.length === 1) {
|
||||||
ret.push({
|
ret.push({
|
||||||
label: "Advance " + command.data.tracks[0].field,
|
label: "Advance " + command.data.tracks[0].field,
|
||||||
command: `${Command.UpgradeResearch} ${command.data.tracks[0].field}`
|
command: `${Command.UpgradeResearch} ${command.data.tracks[0].field}`
|
||||||
|
|
@ -334,8 +333,8 @@ export default class Commands extends Vue {
|
||||||
label: "Advance research",
|
label: "Advance research",
|
||||||
command: command.name,
|
command: command.name,
|
||||||
// track.to contains actual level, to use when implementing research viewer
|
// track.to contains actual level, to use when implementing research viewer
|
||||||
buttons: command.data.tracks.map(track => ({command: track.field})),
|
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;
|
break;
|
||||||
|
|
@ -346,7 +345,7 @@ export default class Commands extends Vue {
|
||||||
label: command.name === Command.ChooseCoverTechTile ? "Pick tech tile to cover" : "Pick tech tile",
|
label: command.name === Command.ChooseCoverTechTile ? "Pick tech tile to cover" : "Pick tech tile",
|
||||||
command: command.name,
|
command: command.name,
|
||||||
techs: command.data.tiles.map(tile => tile.pos),
|
techs: command.data.tiles.map(tile => tile.pos),
|
||||||
buttons: command.data.tiles.map(tile => ({command: tile.pos}))
|
buttons: command.data.tiles.map(tile => ({ command: tile.pos }))
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -368,14 +367,14 @@ export default class Commands extends Vue {
|
||||||
if (command.data.offers) {
|
if (command.data.offers) {
|
||||||
ret.push({
|
ret.push({
|
||||||
label: `Decline ${command.data.offers[0].offer}`,
|
label: `Decline ${command.data.offers[0].offer}`,
|
||||||
command: `${Command.Decline} ${command.data.offers[0].offer}`
|
command: `${Command.Decline} ${command.data.offers[0].offer}`
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// LEGACY CODE
|
// LEGACY CODE
|
||||||
// TODO: Remove when games are updated
|
// TODO: Remove when games are updated
|
||||||
ret.push({
|
ret.push({
|
||||||
label: `Decline ${command.data.offer}`,
|
label: `Decline ${command.data.offer}`,
|
||||||
command: `${Command.Decline} ${command.data.offer}`
|
command: `${Command.Decline} ${command.data.offer}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -393,12 +392,12 @@ export default class Commands extends Vue {
|
||||||
// If only one free action, display it here
|
// If only one free action, display it here
|
||||||
if (command.data.acts.length === 1 && this.availableCommands.some(cmd => cmd.name === Command.MoveShip)) {
|
if (command.data.acts.length === 1 && this.availableCommands.some(cmd => cmd.name === Command.MoveShip)) {
|
||||||
const act = command.data.acts[0];
|
const act = command.data.acts[0];
|
||||||
ret.push({label: `Spend ${act.cost} to gain ${act.income}`, command: `${Command.Spend} ${act.cost} for ${act.income}`});
|
ret.push({ label: `Spend ${act.cost} to gain ${act.income}`, command: `${Command.Spend} ${act.cost} for ${act.income}` });
|
||||||
} else {
|
} else {
|
||||||
ret.push({
|
ret.push({
|
||||||
label: "Free action",
|
label: "Free action",
|
||||||
command: Command.Spend,
|
command: Command.Spend,
|
||||||
buttons: command.data.acts.map(act => ({label: `Spend ${act.cost} to gain ${act.income}`, command: `${act.cost} for ${act.income}`, times: act.range}))
|
buttons: command.data.acts.map(act => ({ label: `Spend ${act.cost} to gain ${act.income}`, command: `${act.cost} for ${act.income}`, times: act.range }))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -409,7 +408,7 @@ export default class Commands extends Vue {
|
||||||
label: "Power/Q.I.C Action",
|
label: "Power/Q.I.C Action",
|
||||||
command: Command.Action,
|
command: Command.Action,
|
||||||
actions: command.data.poweracts.map(act => act.name),
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -419,7 +418,7 @@ export default class Commands extends Vue {
|
||||||
label: "Special Action",
|
label: "Special Action",
|
||||||
command: Command.Special,
|
command: Command.Special,
|
||||||
actions: command.data.specialacts.map(act => act.income),
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -428,7 +427,7 @@ export default class Commands extends Vue {
|
||||||
ret.push({
|
ret.push({
|
||||||
label: "Burn power",
|
label: "Burn power",
|
||||||
command: Command.BurnPower,
|
command: Command.BurnPower,
|
||||||
buttons: command.data.map(val => ({command: val}))
|
buttons: command.data.map(val => ({ command: val }))
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -439,9 +438,9 @@ export default class Commands extends Vue {
|
||||||
command: Command.EndTurn,
|
command: Command.EndTurn,
|
||||||
needConfirm: true,
|
needConfirm: true,
|
||||||
buttons: [{
|
buttons: [{
|
||||||
command: Command.EndTurn,
|
command: Command.EndTurn,
|
||||||
label: `Confirm End Turn`
|
label: `Confirm End Turn`
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -455,12 +454,11 @@ export default class Commands extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
case Command.Bid: {
|
case Command.Bid: {
|
||||||
|
|
||||||
ret.push(...command.data.bids.map(pos => ({
|
ret.push(...command.data.bids.map(pos => ({
|
||||||
label: `Bid ${pos.bid[0]} for ${pos.faction}`,
|
label: `Bid ${pos.bid[0]} for ${pos.faction}`,
|
||||||
command: `${Command.Bid} ${pos.faction} $times`,
|
command: `${Command.Bid} ${pos.faction} $times`,
|
||||||
times: pos.bid
|
times: pos.bid
|
||||||
})));
|
})));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -475,13 +473,13 @@ export default class Commands extends Vue {
|
||||||
case Command.FormFederation: {
|
case Command.FormFederation: {
|
||||||
const tilesButtons = command.data.tiles.map((fed, i) => ({
|
const tilesButtons = command.data.tiles.map((fed, i) => ({
|
||||||
command: fed,
|
command: fed,
|
||||||
label: `Federation ${i+1}: ${tiles.federations[fed]}`
|
label: `Federation ${i + 1}: ${tiles.federations[fed]}`
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const locationButtons = command.data.federations.map((fed, i) => ({
|
const locationButtons = command.data.federations.map((fed, i) => ({
|
||||||
command: fed.hexes,
|
command: fed.hexes,
|
||||||
label: `Location ${i+1}`,
|
label: `Location ${i + 1}`,
|
||||||
hexes: new Map(fed.hexes.split(',').map(coord => [this.engine.map.grid.getS(coord), {coordinates: coord}])),
|
hexes: new Map(fed.hexes.split(',').map(coord => [this.engine.map.grid.getS(coord), { coordinates: coord }])),
|
||||||
hover: true,
|
hover: true,
|
||||||
buttons: tilesButtons
|
buttons: tilesButtons
|
||||||
}));
|
}));
|
||||||
|
|
@ -503,7 +501,7 @@ export default class Commands extends Vue {
|
||||||
case Command.ChooseFederationTile: {
|
case Command.ChooseFederationTile: {
|
||||||
const tilesButtons = command.data.tiles.map((fed, i) => ({
|
const tilesButtons = command.data.tiles.map((fed, i) => ({
|
||||||
command: fed,
|
command: fed,
|
||||||
label: `Federation ${i+1}: ${tiles.federations[fed]}`
|
label: `Federation ${i + 1}: ${tiles.federations[fed]}`
|
||||||
}));
|
}));
|
||||||
|
|
||||||
ret.push(({
|
ret.push(({
|
||||||
|
|
@ -527,7 +525,7 @@ export default class Commands extends Vue {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
back() {
|
back () {
|
||||||
this.$store.commit("gaiaViewer/clearContext");
|
this.$store.commit("gaiaViewer/clearContext");
|
||||||
this.commandChain.pop();
|
this.commandChain.pop();
|
||||||
this.commandTitles.pop();
|
this.commandTitles.pop();
|
||||||
|
|
|
||||||
|
|
@ -16,23 +16,19 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { tiles, Event, Federation as FederationEnum, PlayerEnum } from '@gaia-project/engine';
|
import { tiles, Event, Federation as FederationEnum, PlayerEnum } from '@gaia-project/engine';
|
||||||
import { eventDesc } from '../data/event';
|
import { eventDesc } from '../data/event';
|
||||||
|
|
||||||
@Component<FederationTile>({
|
@Component<FederationTile>({
|
||||||
computed: {
|
computed: {
|
||||||
highlighted() {
|
income () {
|
||||||
return this.$store.state.gaiaViewer.context.highlighted.federations.has(this.federation);
|
|
||||||
},
|
|
||||||
|
|
||||||
income() {
|
|
||||||
const [first, ...others] = tiles.federations[this.federation].split(",");
|
const [first, ...others] = tiles.federations[this.federation].split(",");
|
||||||
return others.length > 0 ? [first, others.join(", ")] : first.split("-");
|
return others.length > 0 ? [first, others.join(", ")] : first.split("-");
|
||||||
},
|
},
|
||||||
|
|
||||||
disabled() {
|
disabled () {
|
||||||
return this.used || this.federation === FederationEnum.Fed1;
|
return this.used || this.federation === FederationEnum.Fed1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -47,15 +43,16 @@ export default class FederationTile extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
numTiles: number;
|
numTiles: number;
|
||||||
|
|
||||||
onClick() {
|
onClick () {
|
||||||
if (!this.highlighted) {
|
if (!this.highlighted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$store.dispatch("gaiaViewer/federationClick", this.federation);
|
this.$store.dispatch("gaiaViewer/federationClick", this.federation);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export default interface Federation {
|
get highlighted () {
|
||||||
highlighted: boolean;
|
return this.$store.state.gaiaViewer.context.highlighted.federations.has(this.federation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -10,32 +10,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { tiles, Event, factions, FinalTile, Phase, Player, finalScorings, Faction } from '@gaia-project/engine';
|
import { tiles, Event, factions, FinalTile, Phase, Player, finalScorings, Faction } from '@gaia-project/engine';
|
||||||
import Token from "./Token.vue";
|
import Token from "./Token.vue";
|
||||||
|
|
||||||
@Component<FinalScoringTile>({
|
@Component<FinalScoringTile>({
|
||||||
computed: {
|
computed: {
|
||||||
tile() {
|
tooltip () {
|
||||||
return this.$store.state.gaiaViewer.data.tiles.scorings.final[this.index];
|
|
||||||
},
|
|
||||||
|
|
||||||
content() {
|
|
||||||
return this.tile;
|
|
||||||
},
|
|
||||||
|
|
||||||
players() {
|
|
||||||
const pls = this.$store.state.gaiaViewer.data.players.filter(player => !!player && player.faction);
|
|
||||||
|
|
||||||
if (this.$store.state.gaiaViewer.data.players.length === 2) {
|
|
||||||
pls.push({faction: "automa"});
|
|
||||||
}
|
|
||||||
|
|
||||||
return pls;
|
|
||||||
},
|
|
||||||
|
|
||||||
tooltip() {
|
|
||||||
const tile = this.tile;
|
const tile = this.tile;
|
||||||
const players = this.players;
|
const players = this.players;
|
||||||
|
|
||||||
|
|
@ -46,7 +28,7 @@ import Token from "./Token.vue";
|
||||||
}).join('\n');
|
}).join('\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
highlighted() {
|
highlighted () {
|
||||||
return this.$store.state.gaiaViewer.data.phase === Phase.EndGame;
|
return this.$store.state.gaiaViewer.data.phase === Phase.EndGame;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -59,22 +41,36 @@ export default class FinalScoringTile extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
index: number;
|
index: number;
|
||||||
|
|
||||||
progress(player: Player) {
|
progress (player: Player) {
|
||||||
return (player.faction as Faction | "automa") === "automa" ? finalScorings[this.tile].neutralPlayer : player.progress(this.tile);
|
return (player.faction as Faction | "automa") === "automa" ? finalScorings[this.tile].neutralPlayer : player.progress(this.tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenX(index: number) {
|
get tile () {
|
||||||
return (index%2) * 30 + 23;
|
return this.$store.state.gaiaViewer.data.tiles.scorings.final[this.index];
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenY(index: number) {
|
get content () {
|
||||||
|
return this.tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
get players () {
|
||||||
|
const pls = this.$store.state.gaiaViewer.data.players.filter(player => !!player && player.faction);
|
||||||
|
|
||||||
|
if (this.$store.state.gaiaViewer.data.players.length === 2) {
|
||||||
|
pls.push({ faction: "automa" });
|
||||||
|
}
|
||||||
|
|
||||||
|
return pls;
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenX (index: number) {
|
||||||
|
return (index % 2) * 30 + 23;
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenY (index: number) {
|
||||||
return 25 + (index > 1 ? 17 : 0);
|
return 25 + (index > 1 ? 17 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default interface FinalScoringTile {
|
|
||||||
tile: FinalTile;
|
|
||||||
players: Player[];
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import Engine,{ Command,Phase,factions, Player, EngineOptions, Expansion } from '@gaia-project/engine';
|
import Engine, { Command, Phase, factions, Player, EngineOptions, Expansion } from '@gaia-project/engine';
|
||||||
|
|
||||||
import AdvancedLog from './AdvancedLog.vue';
|
import AdvancedLog from './AdvancedLog.vue';
|
||||||
import Commands from './Commands.vue';
|
import Commands from './Commands.vue';
|
||||||
|
|
@ -40,54 +40,8 @@ import SpaceMap from './SpaceMap.vue';
|
||||||
import TurnOrder from './TurnOrder.vue';
|
import TurnOrder from './TurnOrder.vue';
|
||||||
|
|
||||||
@Component<Game>({
|
@Component<Game>({
|
||||||
computed: {
|
created (this: Game) {
|
||||||
data() {
|
const unsub = this.$store.subscribeAction(({ type, payload }) => {
|
||||||
return this.$store.state.gaiaViewer.data;
|
|
||||||
},
|
|
||||||
ended() {
|
|
||||||
return this.data.phase === Phase.EndGame;
|
|
||||||
},
|
|
||||||
scoringX() {
|
|
||||||
return this.data.expansions ? 505 : 385;
|
|
||||||
},
|
|
||||||
orderedPlayers() {
|
|
||||||
const data = this.data;
|
|
||||||
|
|
||||||
if (!data.round || !data.turnOrder) {
|
|
||||||
return data.players;
|
|
||||||
}
|
|
||||||
let turnOrder = data.turnOrder;
|
|
||||||
|
|
||||||
// Do not switch boards anymore now that there's two in a row
|
|
||||||
// if (data.turnOrder.indexOf(this.player) !== -1) {
|
|
||||||
// turnOrder = turnOrder.slice(turnOrder.indexOf(this.player)).concat(turnOrder.slice(0, turnOrder.indexOf(this.player)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
return turnOrder.concat(data.passedPlayers).map(player => data.players[player]);
|
|
||||||
},
|
|
||||||
canPlay() {
|
|
||||||
return !this.ended && (!this.$store.state.gaiaViewer.player || this.sessionPlayer === this.data.players[this.player]);
|
|
||||||
},
|
|
||||||
hasMap() {
|
|
||||||
return !!this.$store.state.gaiaViewer.data.map;
|
|
||||||
},
|
|
||||||
player() {
|
|
||||||
return this.data.availableCommands?.[0]?.player;
|
|
||||||
},
|
|
||||||
sessionPlayer() {
|
|
||||||
const player = this.$store.state.gaiaViewer.player;
|
|
||||||
if (player) {
|
|
||||||
if (player.index !== undefined) {
|
|
||||||
return this.data.players[player.index];
|
|
||||||
}
|
|
||||||
if (player.auth) {
|
|
||||||
return this.data.players.find(pl => pl.auth === player.auth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created(this: Game) {
|
|
||||||
const unsub = this.$store.subscribeAction(({type, payload}) => {
|
|
||||||
if (type === "gaiaViewer/externalData") {
|
if (type === "gaiaViewer/externalData") {
|
||||||
this.handleData(Engine.fromData(payload));
|
this.handleData(Engine.fromData(payload));
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +57,7 @@ import TurnOrder from './TurnOrder.vue';
|
||||||
ResearchBoard,
|
ResearchBoard,
|
||||||
ScoringBoard,
|
ScoringBoard,
|
||||||
SpaceMap,
|
SpaceMap,
|
||||||
TurnOrder,
|
TurnOrder
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class Game extends Vue {
|
export default class Game extends Vue {
|
||||||
|
|
@ -115,7 +69,59 @@ export default class Game extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
options: EngineOptions;
|
options: EngineOptions;
|
||||||
|
|
||||||
handleData(data: Engine, keepMoveHistory?: boolean) {
|
get data () {
|
||||||
|
return this.$store.state.gaiaViewer.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ended () {
|
||||||
|
return this.data.phase === Phase.EndGame;
|
||||||
|
}
|
||||||
|
|
||||||
|
get scoringX () {
|
||||||
|
return this.data.expansions ? 505 : 385;
|
||||||
|
}
|
||||||
|
|
||||||
|
get orderedPlayers () {
|
||||||
|
const data = this.data;
|
||||||
|
|
||||||
|
if (!data.round || !data.turnOrder) {
|
||||||
|
return data.players;
|
||||||
|
}
|
||||||
|
const turnOrder = data.turnOrder;
|
||||||
|
|
||||||
|
// Do not switch boards anymore now that there's two in a row
|
||||||
|
// if (data.turnOrder.indexOf(this.player) !== -1) {
|
||||||
|
// turnOrder = turnOrder.slice(turnOrder.indexOf(this.player)).concat(turnOrder.slice(0, turnOrder.indexOf(this.player)));
|
||||||
|
// }
|
||||||
|
|
||||||
|
return turnOrder.concat(data.passedPlayers).map(player => data.players[player]);
|
||||||
|
}
|
||||||
|
|
||||||
|
get canPlay () {
|
||||||
|
return !this.ended && (!this.$store.state.gaiaViewer.player || this.sessionPlayer === this.data.players[this.player]);
|
||||||
|
}
|
||||||
|
|
||||||
|
get hasMap () {
|
||||||
|
return !!this.$store.state.gaiaViewer.data.map;
|
||||||
|
}
|
||||||
|
|
||||||
|
get player () {
|
||||||
|
return this.data.availableCommands?.[0]?.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
get sessionPlayer () {
|
||||||
|
const player = this.$store.state.gaiaViewer.player;
|
||||||
|
if (player) {
|
||||||
|
if (player.index !== undefined) {
|
||||||
|
return this.data.players[player.index];
|
||||||
|
}
|
||||||
|
if (player.auth) {
|
||||||
|
return this.data.players.find(pl => pl.auth === player.auth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleData (data: Engine, keepMoveHistory?: boolean) {
|
||||||
console.log("handle data", keepMoveHistory);
|
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[]) {
|
||||||
|
|
@ -139,7 +145,7 @@ export default class Game extends Vue {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCommand(command: string) {
|
handleCommand (command: string) {
|
||||||
if (command.startsWith(Command.Init) || this.data.round <= 0) {
|
if (command.startsWith(Command.Init) || this.data.round <= 0) {
|
||||||
this.addMove(command);
|
this.addMove(command);
|
||||||
return;
|
return;
|
||||||
|
|
@ -153,14 +159,14 @@ export default class Game extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentMove && !this.clearCurrentMove) {
|
if (this.currentMove && !this.clearCurrentMove) {
|
||||||
this.addMove(this.currentMove + `. ${command.slice(move.player.length+1)}`);
|
this.addMove(this.currentMove + `. ${command.slice(move.player.length + 1)}`);
|
||||||
} else {
|
} else {
|
||||||
this.clearCurrentMove = false;
|
this.clearCurrentMove = false;
|
||||||
this.addMove(command);
|
this.addMove(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
undoMove() {
|
undoMove () {
|
||||||
if (this.currentMove.includes(".")) {
|
if (this.currentMove.includes(".")) {
|
||||||
this.currentMove = this.currentMove.slice(0, this.currentMove.lastIndexOf("."));
|
this.currentMove = this.currentMove.slice(0, this.currentMove.lastIndexOf("."));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -169,12 +175,12 @@ export default class Game extends Vue {
|
||||||
this.addMove(this.currentMove);
|
this.addMove(this.currentMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
addMove(command: string) {
|
addMove (command: string) {
|
||||||
this.$store.commit("gaiaViewer/clearContext");
|
this.$store.commit("gaiaViewer/clearContext");
|
||||||
this.$store.dispatch("gaiaViewer/move", command);
|
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();
|
command = command.trim();
|
||||||
|
|
||||||
if (command.includes('.')) {
|
if (command.includes('.')) {
|
||||||
|
|
@ -190,15 +196,6 @@ export default class Game extends Vue {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used for type augmentation from computed properties
|
|
||||||
export default interface Game {
|
|
||||||
data: Engine;
|
|
||||||
player: number;
|
|
||||||
|
|
||||||
canPlay: boolean;
|
|
||||||
ended: boolean;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -12,18 +12,13 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import {GaiaHex, TechTilePos, AdvTechTilePos, Booster, Command, SpaceMap} from '@gaia-project/engine';
|
import { GaiaHex, TechTilePos, AdvTechTilePos, Booster, Command, SpaceMap } from '@gaia-project/engine';
|
||||||
import {HighlightHexData, ButtonData} from '../data';
|
import { HighlightHexData, ButtonData } from '../data';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
computed: {
|
destroyed () {
|
||||||
isActiveButton() {
|
|
||||||
return this.$store.state.gaiaViewer.context.activeButton && this.$store.state.gaiaViewer.context.activeButton.label === this.button.label;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
destroyed() {
|
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -33,21 +28,21 @@ export default class MoveButton extends Vue {
|
||||||
public button: ButtonData;
|
public button: ButtonData;
|
||||||
|
|
||||||
private subscription: () => {} = null;
|
private subscription: () => {} = null;
|
||||||
private modalShow: boolean = false;
|
private modalShow = false;
|
||||||
private customLabel = '';
|
private customLabel = '';
|
||||||
private startingHex = null; // For range command
|
private startingHex = null; // For range command
|
||||||
|
|
||||||
modalCancel(arg: string) {
|
modalCancel (arg: string) {
|
||||||
this.$emit("cancel");
|
this.$emit("cancel");
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribe(action: string, callback: any) {
|
subscribe (action: string, callback: any) {
|
||||||
action = "gaiaViewer/" + action;
|
action = "gaiaViewer/" + action;
|
||||||
|
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
this.$store.commit("gaiaViewer/activeButton", this.button);
|
this.$store.commit("gaiaViewer/activeButton", this.button);
|
||||||
|
|
||||||
this.subscription = (this.$store as any).subscribeAction(({type, payload}) => {
|
this.subscription = (this.$store as any).subscribeAction(({ type, payload }) => {
|
||||||
if (type !== action) {
|
if (type !== action) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -60,18 +55,18 @@ export default class MoveButton extends Vue {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribeFinal(action: string) {
|
subscribeFinal (action: string) {
|
||||||
this.subscribe(action, field => this.emitCommand(field, {final: true}));
|
this.subscribe(action, field => this.emitCommand(field, { final: true }));
|
||||||
this.emitCommand(null, {disappear: false});
|
this.emitCommand(null, { disappear: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
unsubscribe() {
|
unsubscribe () {
|
||||||
if (this.subscription) {
|
if (this.subscription) {
|
||||||
this.subscription();
|
this.subscription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClick() {
|
handleClick () {
|
||||||
if (this.button.hide) {
|
if (this.button.hide) {
|
||||||
console.log("click on hidden button, ignoring");
|
console.log("click on hidden button, ignoring");
|
||||||
return;
|
return;
|
||||||
|
|
@ -126,7 +121,7 @@ export default class MoveButton extends Vue {
|
||||||
const keys: GaiaHex[] = [...highlighted.keys()];
|
const keys: GaiaHex[] = [...highlighted.keys()];
|
||||||
this.$store.commit("gaiaViewer/highlightHexes", new Map([...keys.map(key => [key, null])] as any));
|
this.$store.commit("gaiaViewer/highlightHexes", new Map([...keys.map(key => [key, null])] as any));
|
||||||
});
|
});
|
||||||
} else if( this.button.modal ) {
|
} else if (this.button.modal) {
|
||||||
this.modalShow = true;
|
this.modalShow = true;
|
||||||
} else if (this.button.rotation) {
|
} else if (this.button.rotation) {
|
||||||
if (this.isActiveButton) {
|
if (this.isActiveButton) {
|
||||||
|
|
@ -140,7 +135,7 @@ export default class MoveButton extends Vue {
|
||||||
|
|
||||||
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
|
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"
|
this.customLabel = "Sector rotations finished";
|
||||||
} else if (this.button.range) {
|
} else if (this.button.range) {
|
||||||
console.log("range click");
|
console.log("range click");
|
||||||
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
|
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
|
||||||
|
|
@ -153,13 +148,13 @@ export default class MoveButton extends Vue {
|
||||||
this.startingHex = hex;
|
this.startingHex = hex;
|
||||||
|
|
||||||
const map: SpaceMap = this.$store.state.gaiaViewer.data.map;
|
const map: SpaceMap = this.$store.state.gaiaViewer.data.map;
|
||||||
const {range, costs} = this.button;
|
const { range, costs } = this.button;
|
||||||
|
|
||||||
const highlighted = new Map();
|
const highlighted = new Map();
|
||||||
|
|
||||||
const withinDistance = map.withinDistance(hex, range);
|
const withinDistance = map.withinDistance(hex, range);
|
||||||
for (const target of withinDistance) {
|
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);
|
this.$store.commit("gaiaViewer/highlightHexes", highlighted);
|
||||||
|
|
@ -173,19 +168,19 @@ export default class MoveButton extends Vue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRangeClick(times: number) {
|
handleRangeClick (times: number) {
|
||||||
this.emitCommand(null, {times});
|
this.emitCommand(null, { times });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleOK() {
|
handleOK () {
|
||||||
this.emitCommand();
|
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);
|
console.log("emit command", this.button.command, append);
|
||||||
|
|
||||||
params = Object.assign({}, {disappear: true, final: false, times: 1}, params)
|
params = Object.assign({}, { disappear: true, final: false, times: 1 }, params);
|
||||||
const {disappear, final, times} = params;
|
const { disappear, final, times } = params;
|
||||||
|
|
||||||
if (disappear) {
|
if (disappear) {
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
|
|
@ -215,7 +210,7 @@ export default class MoveButton extends Vue {
|
||||||
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) {
|
if (!this.button.hover || this.$store.state.gaiaViewer.context.activeButton !== null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -223,16 +218,17 @@ export default class MoveButton extends Vue {
|
||||||
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
|
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
leave() {
|
leave () {
|
||||||
if (!this.button.hover || this.$store.state.gaiaViewer.context.activeButton !== null) {
|
if (!this.button.hover || this.$store.state.gaiaViewer.context.activeButton !== null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$store.commit("gaiaViewer/clearContext");
|
this.$store.commit("gaiaViewer/clearContext");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export default interface MoveButton {
|
get isActiveButton () {
|
||||||
isActiveButton: boolean;
|
return this.$store.state.gaiaViewer.context.activeButton && this.$store.state.gaiaViewer.context.activeButton.label === this.button.label;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -241,4 +237,4 @@ export default interface MoveButton {
|
||||||
.move-button {
|
.move-button {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,15 @@ import { Planet as PlanetEnum, factions, Faction } from '@gaia-project/engine';
|
||||||
export default class Planet extends Vue {
|
export default class Planet extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
planet: PlanetEnum;
|
planet: PlanetEnum;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
faction: Faction;
|
faction: Faction;
|
||||||
|
|
||||||
get radius() {
|
get radius () {
|
||||||
return planets[this.planet].radius;
|
return planets[this.planet].radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
get fill() {
|
get fill () {
|
||||||
// Comment for planet staying planets!
|
// Comment for planet staying planets!
|
||||||
if (this.faction) {
|
if (this.faction) {
|
||||||
return factions.planet(this.faction);
|
return factions.planet(this.faction);
|
||||||
|
|
@ -43,7 +44,7 @@ svg {
|
||||||
stroke-width: 0.04;
|
stroke-width: 0.04;
|
||||||
fill: none;
|
fill: none;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
// terra
|
// terra
|
||||||
&.r {stroke: $terra }
|
&.r {stroke: $terra }
|
||||||
// desert
|
// desert
|
||||||
|
|
@ -70,7 +71,7 @@ svg {
|
||||||
.no-faction-fill &.faction-fill {
|
.no-faction-fill &.faction-fill {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
// terra
|
// terra
|
||||||
&.r {fill: $terra }
|
&.r {fill: $terra }
|
||||||
// desert
|
// desert
|
||||||
|
|
@ -94,4 +95,4 @@ svg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import Building from '../Building.vue';
|
import Building from '../Building.vue';
|
||||||
import Resource from '../Resource.vue';
|
import Resource from '../Resource.vue';
|
||||||
import {Building as BuildingEnum, Faction, Reward, FactionBoard, factionBoard, Operator, Resource as ResourceEnum} from '@gaia-project/engine';
|
import { Building as BuildingEnum, Faction, Reward, FactionBoard, factionBoard, Operator, Resource as ResourceEnum } from '@gaia-project/engine';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -24,7 +24,7 @@ import {Building as BuildingEnum, Faction, Reward, FactionBoard, factionBoard, O
|
||||||
Resource
|
Resource
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
faction(newVal) {
|
faction (newVal) {
|
||||||
this.board = factionBoard(newVal);
|
this.board = factionBoard(newVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -32,63 +32,69 @@ import {Building as BuildingEnum, Faction, Reward, FactionBoard, factionBoard, O
|
||||||
export default class BuildingGroup extends Vue {
|
export default class BuildingGroup extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
nBuildings: number;
|
nBuildings: number;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
building: BuildingEnum;
|
building: BuildingEnum;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
faction: Faction;
|
faction: Faction;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
placed: number;
|
placed: number;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
resource: ResourceEnum[];
|
resource: ResourceEnum[];
|
||||||
@Prop({default: false})
|
|
||||||
|
@Prop({ default: false })
|
||||||
ac1: boolean;
|
ac1: boolean;
|
||||||
@Prop({default: false})
|
|
||||||
|
@Prop({ default: false })
|
||||||
ac2: boolean;
|
ac2: boolean;
|
||||||
|
|
||||||
board: FactionBoard = factionBoard(this.faction || Faction.Terrans);
|
board: FactionBoard = factionBoard(this.faction || Faction.Terrans);
|
||||||
|
|
||||||
get buildingList() {
|
get buildingList () {
|
||||||
return [0,1,2,3,4,5,6,7].slice(0, this.nBuildings);
|
return [0, 1, 2, 3, 4, 5, 6, 7].slice(0, this.nBuildings);
|
||||||
}
|
}
|
||||||
|
|
||||||
get isPI() {
|
get isPI () {
|
||||||
return this.building === BuildingEnum.PlanetaryInstitute;
|
return this.building === BuildingEnum.PlanetaryInstitute;
|
||||||
}
|
}
|
||||||
|
|
||||||
tooltip(i: number) {
|
tooltip (i: number) {
|
||||||
return "Income: " + (this.resources(i, true).join(", ") || "~");
|
return "Income: " + (this.resources(i, true).join(", ") || "~");
|
||||||
}
|
}
|
||||||
|
|
||||||
get offset() {
|
get offset () {
|
||||||
return 1.4;
|
return 1.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
get buildingSpacing() {
|
get buildingSpacing () {
|
||||||
return 2.2;
|
return 2.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
get paddingRight() {
|
get paddingRight () {
|
||||||
return 0.2;
|
return 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
get width() {
|
get width () {
|
||||||
return Math.max(this.nBuildings, 2) * this.buildingSpacing + this.offset + this.paddingRight;
|
return Math.max(this.nBuildings, 2) * this.buildingSpacing + this.offset + this.paddingRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
get factionIncome(): Reward[] {
|
get factionIncome (): Reward[] {
|
||||||
const income: Reward[] = [].concat(...this.board.income.filter(ev => ev.operator === Operator.Income).map(ev => ev.rewards));
|
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));
|
return income.filter(rew => this.resource.includes(rew.type));
|
||||||
}
|
}
|
||||||
|
|
||||||
showBuilding(i: number) {
|
showBuilding (i: number) {
|
||||||
if (this.ac1 || this.ac2) {
|
if (this.ac1 || this.ac2) {
|
||||||
return i === 0 ? !this.ac1 : !this.ac2;
|
return i === 0 ? !this.ac1 : !this.ac2;
|
||||||
}
|
}
|
||||||
return i >= this.placed;
|
return i >= this.placed;
|
||||||
}
|
}
|
||||||
|
|
||||||
resources(i: number, forced = false) : Reward[] {
|
resources (i: number, forced = false): Reward[] {
|
||||||
if (this.showBuilding(i) && !forced) {
|
if (this.showBuilding(i) && !forced) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +109,7 @@ export default class BuildingGroup extends Vue {
|
||||||
return [].concat(...this.board.buildings[building].income[i].filter(ev => {
|
return [].concat(...this.board.buildings[building].income[i].filter(ev => {
|
||||||
if (ev.operator === Operator.Income) {
|
if (ev.operator === Operator.Income) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const rew = ev.rewards.toString();
|
const rew = ev.rewards.toString();
|
||||||
|
|
||||||
return ev.operator === Operator.Activate && (rew === "1q" || rew === "4c");
|
return ev.operator === Operator.Activate && (rew === "1q" || rew === "4c");
|
||||||
|
|
@ -121,4 +127,4 @@ export default class BuildingGroup extends Vue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import Resource from '../Resource.vue';
|
import Resource from '../Resource.vue';
|
||||||
import {Building as BuildingEnum, Faction, Reward, Operator, Resource as ResourceEnum, factions, PlayerData, Player} from '@gaia-project/engine';
|
import { Building as BuildingEnum, Faction, Reward, Operator, Resource as ResourceEnum, factions, PlayerData, Player } from '@gaia-project/engine';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -78,20 +78,22 @@ import {Building as BuildingEnum, Faction, Reward, Operator, Resource as Resourc
|
||||||
export default class BuildingGroup extends Vue {
|
export default class BuildingGroup extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
faction: Faction;
|
faction: Faction;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
data: PlayerData;
|
data: PlayerData;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
player: Player;
|
player: Player;
|
||||||
|
|
||||||
get factionName(): string {
|
get factionName (): string {
|
||||||
return factions[this.faction].name;
|
return factions[this.faction].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
get spaceShips(): boolean {
|
get spaceShips (): boolean {
|
||||||
return (this.$store.state.gaiaViewer.data.expansions % 2) === 1;
|
return (this.$store.state.gaiaViewer.data.expansions % 2) === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
income(resource: ResourceEnum) {
|
income (resource: ResourceEnum) {
|
||||||
const index = this.player.income.search(new RegExp('[0-9]+' + resource));
|
const index = this.player.income.search(new RegExp('[0-9]+' + resource));
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import Resource from '../Resource.vue';
|
import Resource from '../Resource.vue';
|
||||||
import {Faction, Reward, FactionBoard, Operator, Resource as ResourceEnum, factions, PlayerData, Player} from '@gaia-project/engine';
|
import { Faction, Reward, FactionBoard, Operator, Resource as ResourceEnum, factions, PlayerData, Player } from '@gaia-project/engine';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -41,32 +41,34 @@ import {Faction, Reward, FactionBoard, Operator, Resource as ResourceEnum, facti
|
||||||
export default class BuildingGroup extends Vue {
|
export default class BuildingGroup extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
faction: Faction;
|
faction: Faction;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
data: PlayerData;
|
data: PlayerData;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
player: Player;
|
player: Player;
|
||||||
|
|
||||||
get r() {
|
get r () {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
get spacing() {
|
get spacing () {
|
||||||
return 1.1;
|
return 1.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
get sin60() {
|
get sin60 () {
|
||||||
return 0.86602540378;
|
return 0.86602540378;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isTerran() {
|
get isTerran () {
|
||||||
return this.faction === Faction.Terrans;
|
return this.faction === Faction.Terrans;
|
||||||
}
|
}
|
||||||
|
|
||||||
power(area: string) {
|
power (area: string) {
|
||||||
return this.data.power[area] + (this.data.brainstone === area ? "(b)" : "");
|
return this.data.power[area] + (this.data.brainstone === area ? "(b)" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
income(resource: ResourceEnum) {
|
income (resource: ResourceEnum) {
|
||||||
const index = this.player.income.search(new RegExp('[0-9]+' + resource));
|
const index = this.player.income.search(new RegExp('[0-9]+' + resource));
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { Player, factions, tiles, PlayerData, Planet, Federation, terraformingStepsRequired, Building, Condition } from '@gaia-project/engine';
|
import { Player, factions, tiles, PlayerData, Planet, Federation, terraformingStepsRequired, Building, Condition } from '@gaia-project/engine';
|
||||||
import { factionColor } from '../graphics/utils';
|
import { factionColor } from '../graphics/utils';
|
||||||
|
|
@ -68,11 +68,6 @@ import PowerBowls from './PlayerBoard/PowerBowls.vue';
|
||||||
import { factionDesc, planetsWithSteps } from '../data/factions';
|
import { factionDesc, planetsWithSteps } from '../data/factions';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
computed: {
|
|
||||||
data() {
|
|
||||||
return this.player ? this.player.data : null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
components: {
|
||||||
TechTile,
|
TechTile,
|
||||||
Booster,
|
Booster,
|
||||||
|
|
@ -87,60 +82,60 @@ export default class PlayerInfo extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
player: Player;
|
player: Player;
|
||||||
|
|
||||||
playerClick(player: Player) {
|
get data () {
|
||||||
|
return this.player ? this.player.data : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerClick (player: Player) {
|
||||||
this.$store.dispatch("gaiaViewer/playerClick", player);
|
this.$store.dispatch("gaiaViewer/playerClick", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
get factionColor() {
|
get factionColor () {
|
||||||
return factionColor(this.player.faction);
|
return factionColor(this.player.faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name () {
|
||||||
if (this.player.name) {
|
if (this.player.name) {
|
||||||
return this.player.name;
|
return this.player.name;
|
||||||
}
|
}
|
||||||
return "Player " + (this.player.player + 1);
|
return "Player " + (this.player.player + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
get tooltip() {
|
get tooltip () {
|
||||||
return factionDesc(this.player.faction);
|
return factionDesc(this.player.faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
get planet() {
|
get planet () {
|
||||||
return factions[this.player.faction].planet;
|
return factions[this.player.faction].planet;
|
||||||
}
|
}
|
||||||
|
|
||||||
get factionName(): string {
|
get factionName (): string {
|
||||||
return factions[this.player.faction].name;
|
return factions[this.player.faction].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
planetFill(planet: string) {
|
planetFill (planet: string) {
|
||||||
if (planet === Planet.Titanium || planet === Planet.Swamp) {
|
if (planet === Planet.Titanium || planet === Planet.Swamp) {
|
||||||
return "white";
|
return "white";
|
||||||
}
|
}
|
||||||
return "black";
|
return "black";
|
||||||
}
|
}
|
||||||
|
|
||||||
planetsWithSteps(steps: number) {
|
planetsWithSteps (steps: number) {
|
||||||
return planetsWithSteps(this.planet, steps);
|
return planetsWithSteps(this.planet, steps);
|
||||||
}
|
}
|
||||||
|
|
||||||
get passed() {
|
get passed () {
|
||||||
return (this.$store.state.gaiaViewer.data.passedPlayers || []).includes(this.player.player);
|
return (this.$store.state.gaiaViewer.data.passedPlayers || []).includes(this.player.player);
|
||||||
}
|
}
|
||||||
|
|
||||||
get round() {
|
get round () {
|
||||||
return this.$store.state.gaiaViewer.data.round;
|
return this.$store.state.gaiaViewer.data.round;
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasPlanets() {
|
get hasPlanets () {
|
||||||
return this.player.ownedPlanets.length > 0;
|
return this.player.ownedPlanets.length > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default interface PlayerInfo {
|
|
||||||
data: PlayerData;
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
<div class="container-fluid">
|
<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-1" />
|
<Booster v-for="booster in boosters" :key="booster" :booster="booster" class="mb-2 mr-1" />
|
||||||
<FederationTile v-for="(numTiles, tile, i) in federations" :key="`${tile}-${i}`" :federation="tile" :numTiles="numTiles" v-if="numTiles" class="mb-2 mr-1" />
|
<FederationTile v-for="([tile, numTiles], i) in federations" :key="`${tile}-${i}`" :federation="tile" :numTiles="numTiles" class="mb-2 mr-1" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import Booster from './Booster.vue';
|
import Booster from './Booster.vue';
|
||||||
import FederationTile from "./FederationTile.vue";
|
import FederationTile from "./FederationTile.vue";
|
||||||
|
|
@ -16,11 +16,11 @@ import { Booster as BoosterEnum, Expansion } from '@gaia-project/engine';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
computed: {
|
computed: {
|
||||||
boosters() {
|
boosters () {
|
||||||
return BoosterEnum.values(Expansion.All).filter(key => this.$store.state.gaiaViewer.data.tiles.boosters[key]);
|
return BoosterEnum.values(Expansion.All).filter(key => this.$store.state.gaiaViewer.data.tiles.boosters[key]);
|
||||||
},
|
},
|
||||||
federations() {
|
federations () {
|
||||||
return this.$store.state.gaiaViewer.data.tiles.federations;
|
return Object.entries(this.$store.state.gaiaViewer.data.tiles.federations).filter(([key, value]) => value > 0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { ResearchField, BoardAction as BoardActionEnum } from '@gaia-project/engine';
|
import { ResearchField, BoardAction as BoardActionEnum } from '@gaia-project/engine';
|
||||||
import ResearchTrack from './ResearchTrack.vue';
|
import ResearchTrack from './ResearchTrack.vue';
|
||||||
|
|
@ -22,20 +22,20 @@ import BoardAction from "./BoardAction.vue";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
computed: {
|
computed: {
|
||||||
fields(): ResearchField[] {
|
fields (): ResearchField[] {
|
||||||
return ResearchField.values(this.expansions);
|
return ResearchField.values(this.expansions);
|
||||||
},
|
},
|
||||||
actions(): BoardActionEnum[] {
|
actions (): BoardActionEnum[] {
|
||||||
return BoardActionEnum.values(this.expansions);
|
return BoardActionEnum.values(this.expansions);
|
||||||
},
|
},
|
||||||
expansions() {
|
expansions () {
|
||||||
return this.$store.state.gaiaViewer.data.expansions;
|
return this.$store.state.gaiaViewer.data.expansions;
|
||||||
},
|
},
|
||||||
viewWidth() {
|
viewWidth () {
|
||||||
return this.fields.length * 60;
|
return this.fields.length * 60;
|
||||||
},
|
},
|
||||||
width() {
|
width () {
|
||||||
return this.height/440*this.viewWidth;
|
return this.height / 440 * this.viewWidth;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -45,7 +45,7 @@ import BoardAction from "./BoardAction.vue";
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class ResearchBoard extends Vue {
|
export default class ResearchBoard extends Vue {
|
||||||
@Prop({default: 450})
|
@Prop({ default: 450 })
|
||||||
height: number
|
height: number
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { ResearchField, Player, Federation, Resource as ResourceEnum, researchTracks, Event, Reward, Operator, Planet as PlanetEnum } from '@gaia-project/engine';
|
import { ResearchField, Player, Federation, Resource as ResourceEnum, researchTracks, Event, Reward, Operator, Planet as PlanetEnum } from '@gaia-project/engine';
|
||||||
import { descriptions } from '../data/research';
|
import { descriptions } from '../data/research';
|
||||||
|
|
@ -21,31 +21,28 @@ import Resource from './Resource.vue';
|
||||||
|
|
||||||
@Component<ResearchTile>({
|
@Component<ResearchTile>({
|
||||||
computed: {
|
computed: {
|
||||||
players(): Player[] {
|
players (): Player[] {
|
||||||
return this.$store.state.gaiaViewer.data.players.filter(player => player.faction && player.data.research[this.field] == this.level);
|
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]}`;
|
return `<b>Level ${this.level}:</b> ${descriptions[this.field][this.level]}`;
|
||||||
},
|
},
|
||||||
highlighted(): boolean {
|
height () {
|
||||||
return this.$store.state.gaiaViewer.context.highlighted.researchTiles.has(this.field + "-" + this.level)
|
return (this.level === 0 || this.level === 5) ? 46 : 36;
|
||||||
},
|
},
|
||||||
height() {
|
federation (): Federation {
|
||||||
return (this.level == 0 || this.level == 5) ? 46 : 36
|
if (this.level === 5) {
|
||||||
},
|
|
||||||
federation(): Federation {
|
|
||||||
if (this.level == 5) {
|
|
||||||
if (this.field === ResearchField.Terraforming) {
|
if (this.field === ResearchField.Terraforming) {
|
||||||
return this.$store.state.gaiaViewer.data.terraformingFederation;
|
return this.$store.state.gaiaViewer.data.terraformingFederation;
|
||||||
} else if (this.field === ResearchField.TradingVolume && this.players.length === 0) {
|
} else if (this.field === ResearchField.TradingVolume && this.players.length === 0) {
|
||||||
return Federation.Ship;
|
return Federation.Ship;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lostPlanet(): PlanetEnum {
|
lostPlanet (): PlanetEnum {
|
||||||
if (this.level == 5 && this.field === ResearchField.Navigation) {
|
if (this.level === 5 && this.field === ResearchField.Navigation) {
|
||||||
for (const pl of this.players) {
|
for (const pl of this.players) {
|
||||||
if ( pl.data.lostPlanet ) { return undefined }
|
if (pl.data.lostPlanet) { return undefined; }
|
||||||
}
|
}
|
||||||
return PlanetEnum.Lost;
|
return PlanetEnum.Lost;
|
||||||
}
|
}
|
||||||
|
|
@ -61,63 +58,65 @@ import Resource from './Resource.vue';
|
||||||
export default class ResearchTile extends Vue {
|
export default class ResearchTile extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
field: ResearchField;
|
field: ResearchField;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
y: number;
|
y: number;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
level: number;
|
level: number;
|
||||||
|
|
||||||
resourceX(index: number) {
|
resourceX (index: number) {
|
||||||
const res = this.resources;
|
const res = this.resources;
|
||||||
const l = res.length;
|
const l = res.length;
|
||||||
const sep = l <= 2 ? 7 : 6;
|
const sep = l <= 2 ? 7 : 6;
|
||||||
|
|
||||||
return - 6 * (l - 1) + index * 2 * sep - (res[0].count as any === '+' ? 2 : 0)
|
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);
|
return 10 + 13 * (index % 4) + 22 * (index > 3 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenY(index: number) {
|
tokenY (index: number) {
|
||||||
return 10 + 13*(index > 3 ? 1 : 0);
|
return 10 + 13 * (index > 3 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick() {
|
onClick () {
|
||||||
if (this.highlighted) {
|
if (this.highlighted) {
|
||||||
this.$store.dispatch('gaiaViewer/researchClick', this.field)
|
this.$store.dispatch('gaiaViewer/researchClick', this.field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
label() {
|
label () {
|
||||||
|
if (this.field === ResearchField.Terraforming) {
|
||||||
if (this.field == ResearchField.Terraforming) {
|
return this.level === 0 ? "cost 3" : this.level === 2 ? "cost 2" : this.level === 3 ? "cost 1" : "";
|
||||||
return this.level == 0 ? "cost 3" : this.level == 2 ? "cost 2" : this.level == 3 ? "cost 1" : "";
|
|
||||||
};
|
};
|
||||||
if (this.field == ResearchField.Navigation) {
|
if (this.field === ResearchField.Navigation) {
|
||||||
return this.level == 0 ? "nav 1" : this.level == 2 ? "nav 2" : this.level == 4 ? "nav 3" : this.level == 5 ? "nav 4" : "";
|
return this.level === 0 ? "nav 1" : this.level === 2 ? "nav 2" : this.level === 4 ? "nav 3" : this.level === 5 ? "nav 4" : "";
|
||||||
};
|
};
|
||||||
if (this.field == ResearchField.GaiaProject) {
|
if (this.field === ResearchField.GaiaProject) {
|
||||||
return this.level == 5 ? '4vp, g>vp' : "";
|
return this.level === 5 ? '4vp, g>vp' : "";
|
||||||
};
|
};
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
get resources() {
|
get resources () {
|
||||||
const events = researchTracks[this.field][this.level].map(s => new Event(s)).slice(0, 1);
|
const events = researchTracks[this.field][this.level].map(s => new Event(s)).slice(0, 1);
|
||||||
|
|
||||||
const rewards = Reward.merge(...events.map(ev => ev.rewards), this.level == 37 ? [new Reward('-3pw')] : []);
|
const rewards = Reward.merge(...events.map(ev => ev.rewards), this.level === 3 ? [new Reward('-3pw')] : []);
|
||||||
|
|
||||||
if (events[0] && events[0].operator === Operator.Income) {
|
if (events[0] && events[0].operator === Operator.Income) {
|
||||||
rewards.unshift(new Reward('+', ResourceEnum.None));
|
rewards.unshift(new Reward('+', ResourceEnum.None));
|
||||||
rewards[0].count = '+' as any;
|
rewards[0].count = '+' as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rewards;
|
return rewards;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export default interface ResearchTile {
|
get highlighted (): boolean {
|
||||||
highlighted: boolean;
|
return this.$store.state.gaiaViewer.context.highlighted.researchTiles.has(this.field + "-" + this.level);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -165,20 +164,18 @@ svg {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
text {
|
text {
|
||||||
font-family: arial;
|
font-family: arial;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
fill: black;
|
fill: black;
|
||||||
|
|
||||||
|
|
||||||
&.levDesc {
|
&.levDesc {
|
||||||
dominant-baseline: central;
|
dominant-baseline: central;
|
||||||
text-anchor: middle;
|
text-anchor: middle;
|
||||||
fill: white;
|
fill: white;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { ResearchField } from '@gaia-project/engine';
|
import { ResearchField } from '@gaia-project/engine';
|
||||||
import ResearchTile from './ResearchTile.vue';
|
import ResearchTile from './ResearchTile.vue';
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { Resource as ResourceEnum } from '@gaia-project/engine';
|
import { Resource as ResourceEnum } from '@gaia-project/engine';
|
||||||
import Building from './Building.vue';
|
import Building from './Building.vue';
|
||||||
|
|
@ -33,7 +33,6 @@ export default class Resource extends Vue {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import '../stylesheets/planets.scss';
|
@import '../stylesheets/planets.scss';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component } from 'vue-property-decorator';
|
import { Component } from 'vue-property-decorator';
|
||||||
import ScoringTile from './ScoringTile.vue';
|
import ScoringTile from './ScoringTile.vue';
|
||||||
import FinalScoringTile from './FinalScoringTile.vue';
|
import FinalScoringTile from './FinalScoringTile.vue';
|
||||||
|
|
|
||||||
|
|
@ -7,30 +7,30 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { tiles, Event, Phase} from '@gaia-project/engine';
|
import { tiles, Event, Phase } from '@gaia-project/engine';
|
||||||
import { eventDesc } from '../data/event';
|
import { eventDesc } from '../data/event';
|
||||||
|
|
||||||
@Component<ScoringTile>({
|
@Component<ScoringTile>({
|
||||||
computed: {
|
computed: {
|
||||||
tile(this: ScoringTile) {
|
tile (this: ScoringTile) {
|
||||||
return this.$store.state.gaiaViewer.data.tiles.scorings.round[this.round - 1];
|
return this.$store.state.gaiaViewer.data.tiles.scorings.round[this.round - 1];
|
||||||
},
|
},
|
||||||
|
|
||||||
content() {
|
content () {
|
||||||
return tiles.roundScorings[this.tile][0];
|
return tiles.roundScorings[this.tile][0];
|
||||||
},
|
},
|
||||||
|
|
||||||
tooltip() {
|
tooltip () {
|
||||||
return eventDesc(new Event(this.content));
|
return eventDesc(new Event(this.content));
|
||||||
},
|
},
|
||||||
|
|
||||||
highlighted() {
|
highlighted () {
|
||||||
return this.$store.state.gaiaViewer.data.round === this.round && !this.faded;
|
return this.$store.state.gaiaViewer.data.round === this.round && !this.faded;
|
||||||
},
|
},
|
||||||
|
|
||||||
faded() {
|
faded () {
|
||||||
return this.$store.state.gaiaViewer.data.round > this.round || this.$store.state.gaiaViewer.data.phase === Phase.EndGame;
|
return this.$store.state.gaiaViewer.data.round > this.round || this.$store.state.gaiaViewer.data.phase === Phase.EndGame;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import {MapData, HighlightHexData} from '../data';
|
import { MapData, HighlightHexData } from '../data';
|
||||||
import { GaiaHex, GaiaHexData } from '@gaia-project/engine';
|
import { GaiaHex, GaiaHexData } from '@gaia-project/engine';
|
||||||
import { hexCenter } from "../graphics/hex";
|
import { hexCenter } from "../graphics/hex";
|
||||||
import SpaceHex from './SpaceHex.vue';
|
import SpaceHex from './SpaceHex.vue';
|
||||||
|
|
@ -22,23 +22,23 @@ export default class Sector extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
center: CubeCoordinates;
|
center: CubeCoordinates;
|
||||||
|
|
||||||
centerOffset(hex: GaiaHex) {
|
centerOffset (hex: GaiaHex) {
|
||||||
return hexCenter({
|
return hexCenter({
|
||||||
q: hex.q - this.center.q,
|
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;
|
return hex.q === this.center.q && hex.r === this.center.r;
|
||||||
}
|
}
|
||||||
|
|
||||||
get map() {
|
get map () {
|
||||||
return this.$store.state.gaiaViewer.data.map
|
return this.$store.state.gaiaViewer.data.map;
|
||||||
}
|
}
|
||||||
|
|
||||||
get sector(): GaiaHex[] {
|
get sector (): GaiaHex[] {
|
||||||
const coords = Hex.hexagon(2, {center: this.center});
|
const coords = Hex.hexagon(2, { center: this.center });
|
||||||
const ret = coords.map(coord => this.map.grid.get(coord));
|
const ret = coords.map(coord => this.map.grid.get(coord));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -15,25 +15,17 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import {MapData, HighlightHexData} from '../data';
|
import { MapData, HighlightHexData } from '../data';
|
||||||
import { GaiaHex, factions, Building as BuildingEnum, Planet as PlanetEnum, SpaceMap as ISpaceMap, Faction } from '@gaia-project/engine';
|
import { GaiaHex, factions, Building as BuildingEnum, Planet as PlanetEnum, SpaceMap as ISpaceMap, Faction } from '@gaia-project/engine';
|
||||||
import {corners } from "../graphics/hex";
|
import { corners } from "../graphics/hex";
|
||||||
import Planet from './Planet.vue';
|
import Planet from './Planet.vue';
|
||||||
import Building from './Building.vue';
|
import Building from './Building.vue';
|
||||||
import SpaceShip from './SpaceShip.vue';
|
import SpaceShip from './SpaceShip.vue';
|
||||||
import { buildingName } from '../data/building';
|
import { buildingName } from '../data/building';
|
||||||
import { planetNames } from '../data/planets';
|
import { planetNames } from '../data/planets';
|
||||||
import { Direction } from 'hexagrid';
|
import { Direction } from 'hexagrid';
|
||||||
|
|
||||||
@Component<SpaceHex>({
|
@Component<SpaceHex>({
|
||||||
computed: {
|
|
||||||
highlightedHexes(): Set<GaiaHex> {
|
|
||||||
return this.$store.state.gaiaViewer.context.highlighted.hexes;
|
|
||||||
},
|
|
||||||
toSelect() {
|
|
||||||
return !!this.$store.state.gaiaViewer.context.hexSelection;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
components: {
|
||||||
Planet,
|
Planet,
|
||||||
Building,
|
Building,
|
||||||
|
|
@ -43,66 +35,75 @@ import { Direction } from 'hexagrid';
|
||||||
export default class SpaceHex extends Vue {
|
export default class SpaceHex extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
hex: GaiaHex;
|
hex: GaiaHex;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
isCenter: boolean;
|
isCenter: boolean;
|
||||||
|
|
||||||
get hexCorners() {
|
get hexCorners () {
|
||||||
return corners();
|
return corners();
|
||||||
}
|
}
|
||||||
|
|
||||||
get map(): ISpaceMap {
|
get map (): ISpaceMap {
|
||||||
return this.$store.state.gaiaViewer.data.map;
|
return this.$store.state.gaiaViewer.data.map;
|
||||||
}
|
}
|
||||||
|
|
||||||
get tradeTokens() {
|
get tradeTokens () {
|
||||||
return this.hex.data.tradeTokens || [];
|
return this.hex.data.tradeTokens || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
cost(hex: GaiaHex) {
|
cost (hex: GaiaHex) {
|
||||||
const data = this.highlightedHexes.get(hex);
|
const data = this.highlightedHexes.get(hex);
|
||||||
|
|
||||||
return (data && data.cost && data.cost !== "~") ? data.cost.replace(/,/g, ', ') : '';
|
return (data && data.cost && data.cost !== "~") ? data.cost.replace(/,/g, ', ') : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
hexClick(hex: GaiaHex) {
|
hexClick (hex: GaiaHex) {
|
||||||
if (this.highlightedHexes.has(hex) || this.toSelect) {
|
if (this.highlightedHexes.has(hex) || this.toSelect) {
|
||||||
this.$store.dispatch('gaiaViewer/hexClick', hex);
|
this.$store.dispatch('gaiaViewer/hexClick', hex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
faction(player) {
|
faction (player) {
|
||||||
if (player === undefined || player === "wild") {
|
if (player === undefined || player === "wild") {
|
||||||
return player; // Wild will get recognized as purple, for trade tokens. A bit of a hack
|
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;
|
return this.$store.state.gaiaViewer.data.players[player].faction;
|
||||||
}
|
}
|
||||||
|
|
||||||
planet(player) {
|
planet (player) {
|
||||||
return factions.planet(this.faction(player));
|
return factions.planet(this.faction(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
buildingName(building: BuildingEnum) {
|
buildingName (building: BuildingEnum) {
|
||||||
return buildingName(building);
|
return buildingName(building);
|
||||||
}
|
}
|
||||||
|
|
||||||
planetName(planet: PlanetEnum) {
|
planetName (planet: PlanetEnum) {
|
||||||
return planetNames[planet];
|
return planetNames[planet];
|
||||||
}
|
}
|
||||||
|
|
||||||
shipX(index) {
|
get highlightedHexes (): Map<GaiaHex, any> {
|
||||||
return SpaceHex.shipXs[index % 7]
|
return this.$store.state.gaiaViewer.context.highlighted.hexes;
|
||||||
}
|
}
|
||||||
|
|
||||||
shipY(index) {
|
get toSelect () {
|
||||||
return SpaceHex.shipYs[index % 7]
|
return !!this.$store.state.gaiaViewer.context.hexSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
tradeX(index) {
|
shipX (index) {
|
||||||
return SpaceHex.tradeXs[index]
|
return SpaceHex.shipXs[index % 7];
|
||||||
}
|
}
|
||||||
|
|
||||||
tradeY(index) {
|
shipY (index) {
|
||||||
return SpaceHex.tradeYs[index]
|
return SpaceHex.shipYs[index % 7];
|
||||||
|
}
|
||||||
|
|
||||||
|
tradeX (index) {
|
||||||
|
return SpaceHex.tradeXs[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
tradeY (index) {
|
||||||
|
return SpaceHex.tradeYs[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
static shipXs = [-0.5, 0.5, -1.3, 1.3, -0.5, 0.5, 0];
|
static shipXs = [-0.5, 0.5, -1.3, 1.3, -0.5, 0.5, 0];
|
||||||
|
|
@ -111,11 +112,6 @@ export default class SpaceHex extends Vue {
|
||||||
static tradeXs = [-0.5, 0.5, -0.9, 0, 0.9, -0.5, 0.5];
|
static tradeXs = [-0.5, 0.5, -0.9, 0, 0.9, -0.5, 0.5];
|
||||||
static tradeYs = [-0.9, -0.9, 0, 0, 0, 0.9, 0.9];
|
static tradeYs = [-0.9, -0.9, 0, 0, 0, 0.9, 0.9];
|
||||||
}
|
}
|
||||||
export default interface SpaceMap {
|
|
||||||
highlightedHexes: HighlightHexData;
|
|
||||||
toSelect: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component } from 'vue-property-decorator';
|
import { Component } from 'vue-property-decorator';
|
||||||
import { GaiaHex, SpaceMap as SpaceMapData } from '@gaia-project/engine';
|
import { GaiaHex, SpaceMap as SpaceMapData } from '@gaia-project/engine';
|
||||||
import { hexCenter } from "../graphics/hex";
|
import { hexCenter } from "../graphics/hex";
|
||||||
|
|
@ -14,10 +14,7 @@ import { CubeCoordinates } from 'hexagrid';
|
||||||
|
|
||||||
@Component<SpaceMap>({
|
@Component<SpaceMap>({
|
||||||
computed: {
|
computed: {
|
||||||
map(this: SpaceMap): SpaceMapData {
|
right () {
|
||||||
return this.$store.state.gaiaViewer.data.map
|
|
||||||
},
|
|
||||||
right() {
|
|
||||||
return (this.$store.state.gaiaViewer.data.players || []).length > 2 ? 33.5 : 26;
|
return (this.$store.state.gaiaViewer.data.players || []).length > 2 ? 33.5 : 26;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -26,20 +23,21 @@ import { CubeCoordinates } from 'hexagrid';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class SpaceMap extends Vue {
|
export default class SpaceMap extends Vue {
|
||||||
hexCenter(hex: GaiaHex) {
|
hexCenter (hex: GaiaHex) {
|
||||||
return hexCenter(hex);
|
return hexCenter(hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
get sectors(): CubeCoordinates[] {
|
get sectors (): CubeCoordinates[] {
|
||||||
return this.map.configuration().centers;
|
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;
|
return this.$store.state.gaiaViewer.context.rotation.get(`${center.q}x${center.r}`) || 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export default interface SpaceMap {
|
get map (this: SpaceMap): SpaceMapData {
|
||||||
map: SpaceMapData
|
return this.$store.state.gaiaViewer.data.map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -4,27 +4,30 @@
|
||||||
</g>
|
</g>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { factions, Faction, Planet } from '@gaia-project/engine';
|
import { factions, Faction, Planet } from '@gaia-project/engine';
|
||||||
|
|
||||||
/** Code similar to Token. See if it can be refactored / inherited */
|
/** Code similar to Token. See if it can be refactored / inherited */
|
||||||
@Component
|
@Component
|
||||||
export default class Ship extends Vue {
|
export default class Ship extends Vue {
|
||||||
@Prop({default: 'automa'})
|
@Prop({ default: 'automa' })
|
||||||
faction: Faction | 'automa';
|
faction: Faction | 'automa';
|
||||||
@Prop({default: 1})
|
|
||||||
|
@Prop({ default: 1 })
|
||||||
scale: number;
|
scale: number;
|
||||||
@Prop({default: 0})
|
|
||||||
|
@Prop({ default: 0 })
|
||||||
x: number;
|
x: number;
|
||||||
@Prop({default: 0})
|
|
||||||
|
@Prop({ default: 0 })
|
||||||
y: number;
|
y: number;
|
||||||
|
|
||||||
get animated() {
|
get animated () {
|
||||||
return this.scale < 1;
|
return this.scale < 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
get planet(): Planet {
|
get planet (): Planet {
|
||||||
return this.faction === 'automa' ? Planet.Lost : factions.planet(this.faction);
|
return this.faction === 'automa' ? Planet.Lost : factions.planet(this.faction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -49,4 +52,3 @@ export default class Ship extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<g :class='["specialAction", {highlighted, disabled}]'>
|
<g :class='["specialAction", {highlighted, disabled}]'>
|
||||||
<polygon points="-1,0.5 -0.5,1 0.5,1 1,0.5 1,-0.5 0.5,-1 -0.5,-1 -1,-0.5" transform="scale(24)" @click="onClick" />
|
<polygon points="-1,0.5 -0.5,1 0.5,1 1,0.5 1,-0.5 0.5,-1 -0.5,-1 -1,-0.5" transform="scale(24)" @click="onClick" />
|
||||||
<text>
|
<text>
|
||||||
<tspan x="0" v-for="(line, i) in income" :dy="`${i === 0 ? - 0.5*(income.length - 1)*11 : 11}px`" :key="i">
|
<tspan x="0" v-for="(line, i) in income" :dy="`${i === 0 ? - 0.5*(income.length - 1)*11 : 11}px`" :key="i">
|
||||||
{{line.replace(/ /g, '')}}
|
{{line.replace(/ /g, '')}}
|
||||||
</tspan>
|
</tspan>
|
||||||
</text>
|
</text>
|
||||||
|
|
@ -12,18 +12,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { tiles, Event} from '@gaia-project/engine';
|
import { tiles, Event } from '@gaia-project/engine';
|
||||||
import { eventDesc } from '../data/event';
|
import { eventDesc } from '../data/event';
|
||||||
|
|
||||||
@Component<SpecialAction>({
|
@Component<SpecialAction>({
|
||||||
computed: {
|
computed: {
|
||||||
highlighted() {
|
income () {
|
||||||
return this.$store.state.gaiaViewer.context.highlighted.actions.has(this.action);
|
|
||||||
},
|
|
||||||
|
|
||||||
income() {
|
|
||||||
return this.action.includes(',') ? this.action.split(',') : this.action.split('-');
|
return this.action.includes(',') ? this.action.split(',') : this.action.split('-');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -35,15 +31,16 @@ export default class SpecialAction extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
action: string;
|
action: string;
|
||||||
|
|
||||||
onClick() {
|
onClick () {
|
||||||
if (!this.highlighted) {
|
if (!this.highlighted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$store.dispatch("gaiaViewer/actionClick", this.action);
|
this.$store.dispatch("gaiaViewer/actionClick", this.action);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export default interface SpecialAction {
|
get highlighted () {
|
||||||
highlighted: boolean;
|
return this.$store.state.gaiaViewer.context.highlighted.actions.has(this.action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -7,39 +7,39 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { tiles, PlayerEnum, Event, TechTilePos, AdvTechTilePos } from '@gaia-project/engine';
|
import { tiles, PlayerEnum, Event, TechTilePos, AdvTechTilePos } from '@gaia-project/engine';
|
||||||
import { eventDesc } from '../data/event';
|
import { eventDesc } from '../data/event';
|
||||||
|
|
||||||
@Component<TechTile>({
|
@Component<TechTile>({
|
||||||
computed: {
|
computed: {
|
||||||
tileObject() {
|
tileObject () {
|
||||||
return this.$store.state.gaiaViewer.data.tiles.techs[this.pos];
|
return this.$store.state.gaiaViewer.data.tiles.techs[this.pos];
|
||||||
},
|
},
|
||||||
|
|
||||||
tile() {
|
tile () {
|
||||||
return this.tileObject.tile;
|
return this.tileObject.tile;
|
||||||
},
|
},
|
||||||
|
|
||||||
count() {
|
count () {
|
||||||
if (this.player !== undefined) {
|
if (this.player !== undefined) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return this.tileObject.count;
|
return this.tileObject.count;
|
||||||
},
|
},
|
||||||
|
|
||||||
rawContent() {
|
rawContent () {
|
||||||
return tiles.techs[this.tile][0];
|
return tiles.techs[this.tile][0];
|
||||||
},
|
},
|
||||||
|
|
||||||
content() {
|
content () {
|
||||||
const val = this.rawContent;
|
const val = this.rawContent;
|
||||||
|
|
||||||
return val.length > 10 && val[0] !== '=' ? val.replace(/ /g, '') : val;
|
return val.length > 10 && val[0] !== '=' ? val.replace(/ /g, '') : val;
|
||||||
},
|
},
|
||||||
|
|
||||||
title() {
|
title () {
|
||||||
// Only show count if there are more players than tech tiles available
|
// Only show count if there are more players than tech tiles available
|
||||||
if (this.count > 1 && this.$store.state.gaiaViewer.data.players.length > 4) {
|
if (this.count > 1 && this.$store.state.gaiaViewer.data.players.length > 4) {
|
||||||
return `${this.pos} (${this.count})`;
|
return `${this.pos} (${this.count})`;
|
||||||
|
|
@ -48,33 +48,30 @@ import { eventDesc } from '../data/event';
|
||||||
return this.pos;
|
return this.pos;
|
||||||
},
|
},
|
||||||
|
|
||||||
tooltip() {
|
tooltip () {
|
||||||
return eventDesc(new Event(this.rawContent));
|
return eventDesc(new Event(this.rawContent));
|
||||||
},
|
|
||||||
|
|
||||||
highlighted() {
|
|
||||||
return this.$store.state.gaiaViewer.context.highlighted.techs.has(this.pos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class TechTile extends Vue {
|
export default class TechTile extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
pos: TechTilePos | AdvTechTilePos;
|
pos: TechTilePos | AdvTechTilePos;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
player: PlayerEnum;
|
player: PlayerEnum;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
covered: boolean;
|
covered: boolean;
|
||||||
|
|
||||||
onClick() {
|
onClick () {
|
||||||
if (this.highlighted) {
|
if (this.highlighted) {
|
||||||
this.$store.dispatch("gaiaViewer/techClick", this.pos);
|
this.$store.dispatch("gaiaViewer/techClick", this.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export default interface TechTile {
|
get highlighted () {
|
||||||
highlighted: boolean;
|
return this.$store.state.gaiaViewer.context.highlighted.techs.has(this.pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import { Component, Prop } from 'vue-property-decorator';
|
import { Component, Prop } from 'vue-property-decorator';
|
||||||
import { factions, Faction, Planet } from '@gaia-project/engine';
|
import { factions, Faction, Planet } from '@gaia-project/engine';
|
||||||
|
|
||||||
|
|
@ -13,12 +13,14 @@ import { factions, Faction, Planet } from '@gaia-project/engine';
|
||||||
export default class PlayerToken extends Vue {
|
export default class PlayerToken extends Vue {
|
||||||
@Prop()
|
@Prop()
|
||||||
faction: Faction | 'automa';
|
faction: Faction | 'automa';
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
scale: number;
|
scale: number;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
planet: Planet;
|
planet: Planet;
|
||||||
|
|
||||||
get renderPlanet(): Planet {
|
get renderPlanet (): Planet {
|
||||||
if (this.planet) {
|
if (this.planet) {
|
||||||
return this.planet;
|
return this.planet;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,37 +17,36 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {Vue, Component, Prop, Watch} from "vue-property-decorator";
|
import { Vue, Component, Prop, Watch } from "vue-property-decorator";
|
||||||
import Engine, { factions, Player, Planet, Phase} from "@gaia-project/engine";
|
import Engine, { factions, Player, Planet, Phase } from "@gaia-project/engine";
|
||||||
import { isNull } from "util";
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class TurnOrder extends Vue {
|
export default class TurnOrder extends Vue {
|
||||||
get gameData(): Engine {
|
get gameData (): Engine {
|
||||||
return this.$store.state.gaiaViewer.data;
|
return this.$store.state.gaiaViewer.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
get phaseBeforeSetupBuilding(): boolean {
|
get phaseBeforeSetupBuilding (): boolean {
|
||||||
const data = this.gameData;
|
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;
|
const data = this.gameData;
|
||||||
if ( this.phaseBeforeSetupBuilding ) {
|
if (this.phaseBeforeSetupBuilding) {
|
||||||
return data.players;
|
return data.players;
|
||||||
}
|
}
|
||||||
if ( data.phase == Phase.SetupBuilding || data.phase == Phase.SetupBooster || data.phase == Phase.SetupShip) {
|
if (data.phase === Phase.SetupBuilding || data.phase === Phase.SetupBooster || data.phase === Phase.SetupShip) {
|
||||||
return data.setup.map(faction => data.players.find( pl => pl.faction == faction));
|
return data.setup.map(faction => data.players.find(pl => pl.faction === faction));
|
||||||
}
|
}
|
||||||
return data.turnOrder.map(player => data.players[player]);
|
return data.turnOrder.map(player => data.players[player]);
|
||||||
}
|
}
|
||||||
|
|
||||||
get passedPlayers(): Player[] {
|
get passedPlayers (): Player[] {
|
||||||
return (this.gameData.passedPlayers ?? []).map(player => this.gameData.players[player]);
|
return (this.gameData.passedPlayers ?? []).map(player => this.gameData.players[player]);
|
||||||
}
|
}
|
||||||
|
|
||||||
isCurrentPlayer(pl: Player) {
|
isCurrentPlayer (pl: Player) {
|
||||||
return this.gameData.players[this.gameData.availableCommands?.[0]?.player] === pl && !(this.gameData.phase === Phase.SetupAuction);
|
return this.gameData.players[this.gameData.availableCommands?.[0]?.player] === pl && !(this.gameData.phase === Phase.SetupAuction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,25 +66,25 @@ export default class TurnOrder extends Vue {
|
||||||
return "stroke-width: 0.06px !important";
|
return "stroke-width: 0.06px !important";
|
||||||
}
|
}
|
||||||
|
|
||||||
planetFill(planet: string) {
|
planetFill (planet: string) {
|
||||||
if (planet === Planet.Titanium || planet === Planet.Swamp) {
|
if (planet === Planet.Titanium || planet === Planet.Swamp) {
|
||||||
return "white";
|
return "white";
|
||||||
}
|
}
|
||||||
return "black";
|
return "black";
|
||||||
}
|
}
|
||||||
|
|
||||||
planet(player: Player, index: number) {
|
planet (player: Player, index: number) {
|
||||||
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
|
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
|
||||||
return factions.planet(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;
|
return Planet.Lost;
|
||||||
}
|
}
|
||||||
|
|
||||||
initial(player: Player, index: number) {
|
initial (player: Player, index: number) {
|
||||||
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
|
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
|
||||||
return this.gameData.setup[index][0].toUpperCase();
|
return this.gameData.setup[index][0].toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,24 +95,23 @@ export default class TurnOrder extends Vue {
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
name(player: Player, index: number) {
|
name (player: Player, index: number) {
|
||||||
|
if (this.phaseBeforeSetupBuilding) {
|
||||||
if (this.phaseBeforeSetupBuilding ) {
|
|
||||||
if (this.gameData.phase === Phase.SetupAuction) {
|
if (this.gameData.phase === Phase.SetupAuction) {
|
||||||
player = this.gameData.players.find(pl => pl.faction == this.gameData.setup[index])
|
player = this.gameData.players.find(pl => pl.faction === this.gameData.setup[index]);
|
||||||
} else {
|
} else {
|
||||||
return ""
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player) {
|
if (player) {
|
||||||
if (player.name) {
|
if (player.name) {
|
||||||
return player.name.substring(0, 3);
|
return player.name.substring(0, 3);
|
||||||
} else {
|
} else {
|
||||||
return "P" + (player.player + 1);
|
return "P" + (player.player + 1);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -127,4 +125,4 @@ export default class TurnOrder extends Vue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -13,24 +13,24 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {Vue, Prop, Watch, Component} from "vue-property-decorator";
|
import { Vue, Prop, Watch, Component } from "vue-property-decorator";
|
||||||
import Game from "./Game.vue";
|
import Game from "./Game.vue";
|
||||||
|
|
||||||
@Component ({
|
@Component({
|
||||||
components: {Game}
|
components: { Game }
|
||||||
})
|
})
|
||||||
export default class Wrapper extends Vue {
|
export default class Wrapper extends Vue {
|
||||||
modalShow = false;
|
modalShow = false;
|
||||||
text = "";
|
text = "";
|
||||||
|
|
||||||
handleOK() {
|
handleOK () {
|
||||||
this.$store.dispatch("gaiaViewer/loadFromJSON", JSON.parse(this.text));
|
this.$store.dispatch("gaiaViewer/loadFromJSON", JSON.parse(this.text));
|
||||||
}
|
}
|
||||||
|
|
||||||
openExport() {
|
openExport () {
|
||||||
this.text = JSON.stringify(this.$store.state.gaiaViewer.data);
|
this.text = JSON.stringify(this.$store.state.gaiaViewer.data);
|
||||||
this.modalShow = true;
|
this.modalShow = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Building } from "@gaia-project/engine";
|
import { Building } from "@gaia-project/engine";
|
||||||
|
|
||||||
export function buildingName(building: Building): string {
|
export function buildingName (building: Building): string {
|
||||||
switch (building) {
|
switch (building) {
|
||||||
case Building.Mine: return "mine";
|
case Building.Mine: return "mine";
|
||||||
case Building.Academy1: return "academy1";
|
case Building.Academy1: return "academy1";
|
||||||
|
|
@ -11,4 +11,4 @@ export function buildingName(building: Building): string {
|
||||||
case Building.GaiaFormer: return "gaia-former";
|
case Building.GaiaFormer: return "gaia-former";
|
||||||
case Building.SpaceStation: return "space station";
|
case Building.SpaceStation: return "space station";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {Condition, Event, Operator, Reward, Resource} from "@gaia-project/engine";
|
import { Condition, Event, Operator, Reward, Resource } from "@gaia-project/engine";
|
||||||
|
|
||||||
const conditionsCount = {
|
const conditionsCount = {
|
||||||
[Condition.Mine]: "mine",
|
[Condition.Mine]: "mine",
|
||||||
|
|
@ -16,7 +16,7 @@ const conditionsCount = {
|
||||||
[Condition.Trade]: "trade token",
|
[Condition.Trade]: "trade token",
|
||||||
[Condition.AdvanceResearch]: "level reached in any research track",
|
[Condition.AdvanceResearch]: "level reached in any research track",
|
||||||
[Condition.PlanetsWithTradeToken]: "planet with a trade token (max 8)"
|
[Condition.PlanetsWithTradeToken]: "planet with a trade token (max 8)"
|
||||||
}
|
};
|
||||||
|
|
||||||
const conditionsTrigger = {
|
const conditionsTrigger = {
|
||||||
[Condition.Mine]: "building a mine",
|
[Condition.Mine]: "building a mine",
|
||||||
|
|
@ -28,7 +28,7 @@ const conditionsTrigger = {
|
||||||
[Condition.AdvanceResearch]: "advancing a level in research",
|
[Condition.AdvanceResearch]: "advancing a level in research",
|
||||||
[Condition.TerraformStep]: "terraforming a planet one step",
|
[Condition.TerraformStep]: "terraforming a planet one step",
|
||||||
[Condition.Trade]: "delivering trade"
|
[Condition.Trade]: "delivering trade"
|
||||||
}
|
};
|
||||||
|
|
||||||
const operators = {
|
const operators = {
|
||||||
[Operator.Pass]: "After passing,",
|
[Operator.Pass]: "After passing,",
|
||||||
|
|
@ -38,9 +38,9 @@ const operators = {
|
||||||
[Operator.Trigger]: "When ",
|
[Operator.Trigger]: "When ",
|
||||||
[Operator.Special]: "Planetary institutes and academies have a power value of 4, when building federations and charging power.",
|
[Operator.Special]: "Planetary institutes and academies have a power value of 4, when building federations and charging power.",
|
||||||
[Operator.AdvShip4]: "Gain two spaceships. Move them with a bonus range of 4 in addition to their normal range."
|
[Operator.AdvShip4]: "Gain two spaceships. Move them with a bonus range of 4 in addition to their normal range."
|
||||||
}
|
};
|
||||||
|
|
||||||
function rewardDesc(rewards: Reward[]) {
|
function rewardDesc (rewards: Reward[]) {
|
||||||
return rewards.map(reward => {
|
return rewards.map(reward => {
|
||||||
switch (reward.type) {
|
switch (reward.type) {
|
||||||
case Resource.TechTile: return `gain ${reward.count} tech tile${reward.count > 1 ? 's' : ''}`;
|
case Resource.TechTile: return `gain ${reward.count} tech tile${reward.count > 1 ? 's' : ''}`;
|
||||||
|
|
@ -55,10 +55,10 @@ function rewardDesc(rewards: Reward[]) {
|
||||||
}).join(", ");
|
}).join(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function eventDesc(event: Event) {
|
export function eventDesc (event: Event) {
|
||||||
const operatorString = operators[event.operator];
|
const operatorString = operators[event.operator];
|
||||||
const conditionString = event.operator === Operator.Trigger ? conditionsTrigger[event.condition] + "," : (conditionsCount[event.condition] && "for each " + conditionsCount[event.condition] + ",");
|
const conditionString = event.operator === Operator.Trigger ? conditionsTrigger[event.condition] + "," : (conditionsCount[event.condition] && "for each " + conditionsCount[event.condition] + ",");
|
||||||
const rewardString = event.rewards.length === 0 ? '' : rewardDesc(event.rewards);
|
const rewardString = event.rewards.length === 0 ? '' : rewardDesc(event.rewards);
|
||||||
|
|
||||||
return [operatorString, conditionString, rewardString].filter(x => !!x).join(" ");
|
return [operatorString, conditionString, rewardString].filter(x => !!x).join(" ");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,76 +1,75 @@
|
||||||
import { Faction, Operator, Building, Planet, factions, terraformingStepsRequired } from "@gaia-project/engine";
|
import { Faction, Operator, Building, Planet, factions, terraformingStepsRequired, factionBoard } from "@gaia-project/engine";
|
||||||
import {factionBoard} from '@gaia-project/engine';
|
|
||||||
|
|
||||||
const factionData: { [faction in Faction]: { ability: string, PI: string}} = {
|
const factionData: { [faction in Faction]: { ability: string; PI: string}} = {
|
||||||
[Faction.Terrans] : {
|
[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.",
|
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."
|
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] : {
|
[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.",
|
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."
|
PI: "Each time you build a mine on a planet colonized by an opponent, gain two knowledge."
|
||||||
},
|
},
|
||||||
[Faction.Xenos] : {
|
[Faction.Xenos]: {
|
||||||
ability : "You place a third starting mine after all other starting mines have been placed.",
|
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."
|
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] : {
|
[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.",
|
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."
|
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] : {
|
[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.",
|
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."
|
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] : {
|
[Faction.Ambas]: {
|
||||||
ability : "-",
|
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."
|
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] : {
|
[Faction.HadschHallas]: {
|
||||||
ability : "-",
|
ability: "-",
|
||||||
PI : "You can spend credits instead of power to take free actions that allow you to gain resources."
|
PI: "You can spend credits instead of power to take free actions that allow you to gain resources."
|
||||||
},
|
},
|
||||||
[Faction.Ivits] : {
|
[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.
|
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,
|
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.`,
|
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.
|
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
|
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.
|
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,
|
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).
|
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.`
|
Your opponents can place satellites in a space containing a space station.`
|
||||||
},
|
},
|
||||||
[Faction.Geodens] : {
|
[Faction.Geodens]: {
|
||||||
ability : "-",
|
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.)"
|
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] : {
|
[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.
|
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.`,
|
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."
|
PI: "You can now advance in the “Navigation” research area."
|
||||||
},
|
},
|
||||||
[Faction.Firaks] : {
|
[Faction.Firaks]: {
|
||||||
ability : "-",
|
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)."
|
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] : {
|
[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.
|
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
|
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.`,
|
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)."
|
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] : {
|
[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.",
|
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."
|
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.`
|
|
||||||
},
|
},
|
||||||
|
[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) {
|
export function planetsWithSteps (planet: Planet, steps: number) {
|
||||||
// Planets are ordered the same as in the planet wheel
|
// 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];
|
let list = [Planet.Terra, Planet.Oxide, Planet.Volcanic, Planet.Desert, Planet.Swamp, Planet.Titanium, Planet.Ice];
|
||||||
|
|
||||||
|
|
@ -82,11 +81,11 @@ export function planetsWithSteps(planet: Planet, steps: number) {
|
||||||
return list.filter(p => terraformingStepsRequired(planet, p) === steps);
|
return list.filter(p => terraformingStepsRequired(planet, p) === steps);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function factionDesc(faction: Faction) {
|
export function factionDesc (faction: Faction) {
|
||||||
const board = factionBoard(faction);
|
const board = factionBoard(faction);
|
||||||
const p = factions[faction].planet;
|
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 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 startingIncome = board.income.filter(ev => ev.operator === Operator.Once);
|
||||||
const roundIncome = board.income.filter(ev => ev.operator === Operator.Income);
|
const roundIncome = board.income.filter(ev => ev.operator === Operator.Income);
|
||||||
|
|
||||||
|
|
@ -99,7 +98,7 @@ export function factionDesc(faction: Faction) {
|
||||||
<b>Round Income:</b> ${roundIncome} </br>
|
<b>Round Income:</b> ${roundIncome} </br>
|
||||||
<span style="white-space: nowrap; line-height: 1em">
|
<span style="white-space: nowrap; line-height: 1em">
|
||||||
<b>Steps:</b>
|
<b>Steps:</b>
|
||||||
${[0,1,2,3].map(i => `<span class="ml-2">${planetsWithSteps(p, i).map(p =>
|
${[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" >
|
`<svg width="15" height="20" viewbox="0 0 15 15" >
|
||||||
<circle cx="7" cy="6" r="6" class="player-token planet-fill ${p}" />
|
<circle cx="7" cy="6" r="6" class="player-token planet-fill ${p}" />
|
||||||
</svg>`
|
</svg>`
|
||||||
|
|
@ -107,4 +106,4 @@ export function factionDesc(faction: Faction) {
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {TechTilePos, GaiaHex, AdvTechTilePos, Booster, Federation} from "@gaia-project/engine";
|
import { TechTilePos, GaiaHex, AdvTechTilePos, Booster, Federation } from "@gaia-project/engine";
|
||||||
|
|
||||||
export interface ButtonData {
|
export interface ButtonData {
|
||||||
label?: string;
|
label?: string;
|
||||||
|
|
@ -32,12 +32,12 @@ export type HighlightHexData = Map<GaiaHex, {cost?: string}>;
|
||||||
|
|
||||||
export interface GameContext {
|
export interface GameContext {
|
||||||
highlighted: {
|
highlighted: {
|
||||||
hexes: HighlightHexData,
|
hexes: HighlightHexData;
|
||||||
researchTiles: Set<string>,
|
researchTiles: Set<string>;
|
||||||
techs: Set<TechTilePos | AdvTechTilePos>,
|
techs: Set<TechTilePos | AdvTechTilePos>;
|
||||||
boosters: Set<Booster>,
|
boosters: Set<Booster>;
|
||||||
actions: Set<string>,
|
actions: Set<string>;
|
||||||
federations: Set<Federation>
|
federations: Set<Federation>;
|
||||||
};
|
};
|
||||||
|
|
||||||
rotation: Map<string, number>;
|
rotation: Map<string, number>;
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
import { Planet } from "@gaia-project/engine";
|
import { Planet } from "@gaia-project/engine";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
[Planet.Swamp]: {radius: 0.65, color: "#523A00", borderColor: "#874d12"},
|
[Planet.Swamp]: { radius: 0.65, color: "#523A00", borderColor: "#874d12" },
|
||||||
[Planet.Desert]: {radius: 0.65, color: "#F2FF00", borderColor: "#c1a925"},
|
[Planet.Desert]: { radius: 0.65, color: "#F2FF00", borderColor: "#c1a925" },
|
||||||
[Planet.Terra]: {radius: 0.65, color: "#2080f0", borderColor: "#3399ff"},
|
[Planet.Terra]: { radius: 0.65, color: "#2080f0", borderColor: "#3399ff" },
|
||||||
[Planet.Volcanic]: {radius: 0.65, color: "#ffa135", borderColor: "#ff0000"},
|
[Planet.Volcanic]: { radius: 0.65, color: "#ffa135", borderColor: "#ff0000" },
|
||||||
[Planet.Oxide]: {radius: 0.65, color: "#FF160A", borderColor: "#ff8566"},
|
[Planet.Oxide]: { radius: 0.65, color: "#FF160A", borderColor: "#ff8566" },
|
||||||
[Planet.Titanium]: {radius: 0.65, color: "#808080", borderColor: "#d1d1e0"},
|
[Planet.Titanium]: { radius: 0.65, color: "#808080", borderColor: "#d1d1e0" },
|
||||||
[Planet.Ice]: {radius: 0.65, color: "#F8FFF5", borderColor: "#00c2c2"},
|
[Planet.Ice]: { radius: 0.65, color: "#F8FFF5", borderColor: "#00c2c2" },
|
||||||
[Planet.Gaia]: {radius: 0.65, color: "#009933", borderColor: "#004d1a"},
|
[Planet.Gaia]: { radius: 0.65, color: "#009933", borderColor: "#004d1a" },
|
||||||
[Planet.Transdim]: {radius: 0.5, color: "#a64dff", borderColor: "#a64dff"},
|
[Planet.Transdim]: { radius: 0.5, color: "#a64dff", borderColor: "#a64dff" },
|
||||||
[Planet.Lost]: {radius: 0.5, color: "#000033", borderColor: "#ccccff"}
|
[Planet.Lost]: { radius: 0.5, color: "#000033", borderColor: "#ccccff" }
|
||||||
};
|
};
|
||||||
|
|
||||||
export const planetNames = {
|
export const planetNames = {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { ResearchField } from "@gaia-project/engine"
|
import { ResearchField } from "@gaia-project/engine";
|
||||||
|
|
||||||
export const descriptions = {
|
export const descriptions = {
|
||||||
[ResearchField.Economy]: [
|
[ResearchField.Economy]: [
|
||||||
|
|
@ -65,4 +65,4 @@ export const descriptions = {
|
||||||
"Three spaceships income. The move action moves three spaceships at current range + 2. Advance on the navigation or intelligence research track by one level.",
|
"Three spaceships income. The move action moves three spaceships at current range + 2. Advance on the navigation or intelligence research track by one level.",
|
||||||
"Four spaceships income. The move action moves four spaceships at current range + 3. Gain a special federation token with no vp that gives a 4th ship: Advanced Spaceship that is immmediately placed. You have an additional 5 wild trade tokens available, that can be placed on planets with one or none of your regular trade tokens when delivering trade."
|
"Four spaceships income. The move action moves four spaceships at current range + 3. Gain a special federation token with no vp that gives a 4th ship: Advanced Spaceship that is immmediately placed. You have an additional 5 wild trade tokens available, that can be placed on planets with one or none of your regular trade tokens when delivering trade."
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import { CubeCoordinatesPartial } from "hexagrid/src/cubecoordinates";
|
import { CubeCoordinatesPartial } from "hexagrid/src/cubecoordinates";
|
||||||
|
|
||||||
const vSpacing = Math.sqrt(3)/2;
|
const vSpacing = Math.sqrt(3) / 2;
|
||||||
|
|
||||||
export function hexCenter(hex: CubeCoordinatesPartial, radius: number = 1) {
|
export function hexCenter (hex: CubeCoordinatesPartial, radius = 1) {
|
||||||
return {
|
return {
|
||||||
x: hex.r * 1.5 * radius,
|
x: hex.r * 1.5 * radius,
|
||||||
y: -(2*hex.q + hex.r) * vSpacing * radius
|
y: -(2 * hex.q + hex.r) * vSpacing * radius
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function corners(radius: number = 1) {
|
export function corners (radius = 1) {
|
||||||
return [
|
return [
|
||||||
{x: -radius, y: 0},
|
{ x: -radius, y: 0 },
|
||||||
{x: -radius/2, y: -vSpacing*radius},
|
{ x: -radius / 2, y: -vSpacing * radius },
|
||||||
{x: radius/2, y: -vSpacing*radius},
|
{ x: radius / 2, y: -vSpacing * radius },
|
||||||
{x: radius, y: 0},
|
{ x: radius, y: 0 },
|
||||||
{x: radius/2, y: vSpacing*radius},
|
{ x: radius / 2, y: vSpacing * radius },
|
||||||
{x: -radius/2, y: vSpacing*radius}
|
{ x: -radius / 2, y: vSpacing * radius }
|
||||||
]
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Faction, factions } from "@gaia-project/engine";
|
import { Faction, factions } from "@gaia-project/engine";
|
||||||
import planets from "../data/planets";
|
import planets from "../data/planets";
|
||||||
|
|
||||||
export function factionColor(faction: Faction): number {
|
export function factionColor (faction: Faction): number {
|
||||||
return planets[factions[faction].planet].color;
|
return planets[factions[faction].planet].color;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,27 +3,27 @@ import { Store } from "vuex";
|
||||||
import BootstrapVue from 'bootstrap-vue';
|
import BootstrapVue from 'bootstrap-vue';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
|
||||||
import {makeStore} from './store';
|
import { makeStore } from './store';
|
||||||
import Game from './components/Game.vue';
|
import Game from './components/Game.vue';
|
||||||
import type { VueConstructor } from "vue/types/umd";
|
import type { VueConstructor } from "vue/types/umd";
|
||||||
|
|
||||||
Vue.use(BootstrapVue);
|
Vue.use(BootstrapVue);
|
||||||
|
|
||||||
function launch(selector: string, component: VueConstructor<Vue> = Game) {
|
function launch (selector: string, component: VueConstructor<Vue> = Game) {
|
||||||
const store = makeStore();
|
const store = makeStore();
|
||||||
|
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
store,
|
store,
|
||||||
render: (h) => h("div", {class: "container-fluid py-2"}, [h(component)]),
|
render: (h) => h("div", { class: "container-fluid py-2" }, [h(component)])
|
||||||
}).$mount(selector);
|
}).$mount(selector);
|
||||||
|
|
||||||
const item: EventEmitter & {store?: Store<unknown>, app?: Vue} = new EventEmitter();
|
const item: EventEmitter & {store?: Store<unknown>; app?: Vue} = new EventEmitter();
|
||||||
|
|
||||||
item.addListener("state:updated", data => store.dispatch("gaiaViewer/externalData", data));
|
item.addListener("state:updated", data => store.dispatch("gaiaViewer/externalData", data));
|
||||||
item.addListener("preferences", data => store.commit("gaiaViewer/preferences", data));
|
item.addListener("preferences", data => store.commit("gaiaViewer/preferences", data));
|
||||||
item.addListener("player", data => store.commit("gaiaViewer/player", data));
|
item.addListener("player", data => store.commit("gaiaViewer/player", data));
|
||||||
|
|
||||||
const unsub1 = store.subscribeAction(({type, payload}) => {
|
const unsub1 = store.subscribeAction(({ type, payload }) => {
|
||||||
// console.log("spy action", type, payload);
|
// console.log("spy action", type, payload);
|
||||||
|
|
||||||
if (type === "gaiaViewer/move") {
|
if (type === "gaiaViewer/move") {
|
||||||
|
|
@ -32,14 +32,14 @@ function launch(selector: string, component: VueConstructor<Vue> = Game) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === "gaiaViewer/playerClick") {
|
if (type === "gaiaViewer/playerClick") {
|
||||||
item.emit("player:clicked", {name: payload.name, auth: payload.auth, index: (store as Store<any>).state.gaiaViewer.data?.players?.findIndex(pl => pl === payload)});
|
item.emit("player:clicked", { name: payload.name, auth: payload.auth, index: (store as Store<any>).state.gaiaViewer.data?.players?.findIndex(pl => pl === payload) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const unsub2 = store.subscribe(({type, payload}) => {
|
const unsub2 = store.subscribe(({ type, payload }) => {
|
||||||
// console.log("spy mutation", type, payload);
|
// console.log("spy mutation", type, payload);
|
||||||
|
|
||||||
if (type == "info" || type == "error") {
|
if (type === "info" || type === "error") {
|
||||||
item.emit(type, payload);
|
item.emit(type, payload);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -55,4 +55,4 @@ function launch(selector: string, component: VueConstructor<Vue> = Game) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default launch;
|
export default launch;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ console.log(process.env);
|
||||||
|
|
||||||
if (process.env.VUE_APP_BGIO) {
|
if (process.env.VUE_APP_BGIO) {
|
||||||
launch("#app");
|
launch("#app");
|
||||||
} else if (process.env.VUE_APP_SelfContained || 1) {
|
} else /* if (process.env.VUE_APP_SelfContained || 1) */ {
|
||||||
launchSelfContained();
|
launchSelfContained();
|
||||||
} /* else {
|
} /* else {
|
||||||
launch("#app");
|
launch("#app");
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,12 @@ import Engine from '@gaia-project/engine';
|
||||||
import Wrapper from './components/Wrapper.vue';
|
import Wrapper from './components/Wrapper.vue';
|
||||||
import Game from './components/Game.vue';
|
import Game from './components/Game.vue';
|
||||||
|
|
||||||
function launchSelfContained(selector = "#app", debug = true) {
|
function launchSelfContained (selector = "#app", debug = true) {
|
||||||
const emitter = launch(selector, debug ? Wrapper: Game);
|
const emitter = launch(selector, debug ? Wrapper : Game);
|
||||||
|
|
||||||
let engine = new Engine();
|
let engine = new Engine();
|
||||||
|
|
||||||
const unsub = emitter.store.subscribeAction(({payload, type}) => {
|
const unsub = emitter.store.subscribeAction(({ payload, type }) => {
|
||||||
if (type === "gaiaViewer/loadFromJSON") {
|
if (type === "gaiaViewer/loadFromJSON") {
|
||||||
const egData: Engine = payload;
|
const egData: Engine = payload;
|
||||||
engine = new Engine(egData.moveHistory, egData.options);
|
engine = new Engine(egData.moveHistory, egData.options);
|
||||||
|
|
@ -37,4 +37,4 @@ function launchSelfContained(selector = "#app", debug = true) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default launchSelfContained;
|
export default launchSelfContained;
|
||||||
|
|
|
||||||
56
src/store.ts
56
src/store.ts
|
|
@ -26,51 +26,51 @@ const gaiaViewer = {
|
||||||
preferences: {
|
preferences: {
|
||||||
noFactionFill: false
|
noFactionFill: false
|
||||||
},
|
},
|
||||||
player: null as {index?: number, auth?: string} | null
|
player: null as {index?: number; auth?: string} | null
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
receiveData(state, data: Engine) {
|
receiveData (state, data: Engine) {
|
||||||
state.data = data;
|
state.data = data;
|
||||||
state.context.rotation = new Map();
|
state.context.rotation = new Map();
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightHexes(state, hexes: Map<GaiaHex, {cost?: string}>) {
|
highlightHexes (state, hexes: Map<GaiaHex, {cost?: string}>) {
|
||||||
state.context.highlighted.hexes = hexes;
|
state.context.highlighted.hexes = hexes;
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightResearchTiles(state, tiles: string[]) {
|
highlightResearchTiles (state, tiles: string[]) {
|
||||||
state.context.highlighted.researchTiles = new Set(tiles);
|
state.context.highlighted.researchTiles = new Set(tiles);
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightTechs(state, techs: Array<TechTilePos | AdvTechTilePos>) {
|
highlightTechs (state, techs: Array<TechTilePos | AdvTechTilePos>) {
|
||||||
state.context.highlighted.techs = new Set(techs);
|
state.context.highlighted.techs = new Set(techs);
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightBoosters(state, boosters: Booster[]) {
|
highlightBoosters (state, boosters: Booster[]) {
|
||||||
state.context.highlighted.boosters = new Set(boosters);
|
state.context.highlighted.boosters = new Set(boosters);
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightActions(state, actions: string[]) {
|
highlightActions (state, actions: string[]) {
|
||||||
state.context.highlighted.actions = new Set(actions);
|
state.context.highlighted.actions = new Set(actions);
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightFederations(state, federations: Federation[]) {
|
highlightFederations (state, federations: Federation[]) {
|
||||||
state.context.highlighted.federations = new Set(federations);
|
state.context.highlighted.federations = new Set(federations);
|
||||||
},
|
},
|
||||||
|
|
||||||
selectHexes(state, defaultHexes) {
|
selectHexes (state, defaultHexes) {
|
||||||
state.context.hexSelection = true;
|
state.context.hexSelection = true;
|
||||||
state.context.highlighted.hexes = new Map(defaultHexes || []);
|
state.context.highlighted.hexes = new Map(defaultHexes || []);
|
||||||
},
|
},
|
||||||
|
|
||||||
rotate(state, coords: CubeCoordinates) {
|
rotate (state, coords: CubeCoordinates) {
|
||||||
const coordsStr = `${coords.q}x${coords.r}`;
|
const coordsStr = `${coords.q}x${coords.r}`;
|
||||||
|
|
||||||
state.context.rotation.set(coordsStr, (state.context.rotation.get(coordsStr) || 0) + 1);
|
state.context.rotation.set(coordsStr, (state.context.rotation.get(coordsStr) || 0) + 1);
|
||||||
state.context.rotation = new Map(state.context.rotation.entries());
|
state.context.rotation = new Map(state.context.rotation.entries());
|
||||||
},
|
},
|
||||||
|
|
||||||
clearContext(state) {
|
clearContext (state) {
|
||||||
state.context.highlighted.hexes = new Map();
|
state.context.highlighted.hexes = new Map();
|
||||||
state.context.highlighted.researchTiles = new Set();
|
state.context.highlighted.researchTiles = new Set();
|
||||||
state.context.highlighted.techs = new Set();
|
state.context.highlighted.techs = new Set();
|
||||||
|
|
@ -82,39 +82,39 @@ const gaiaViewer = {
|
||||||
state.context.activeButton = null;
|
state.context.activeButton = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
activeButton(state, button) {
|
activeButton (state, button) {
|
||||||
state.context.activeButton = button;
|
state.context.activeButton = button;
|
||||||
},
|
},
|
||||||
|
|
||||||
preferences(state, preferences) {
|
preferences (state, preferences) {
|
||||||
state.preferences = preferences;
|
state.preferences = preferences;
|
||||||
},
|
},
|
||||||
|
|
||||||
player(state, data) {
|
player (state, data) {
|
||||||
state.player = data;
|
state.player = data;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
// No body, used for signalling with store.subscribeAction
|
// No body, used for signalling with store.subscribeAction
|
||||||
hexClick(context, hex: GaiaHex) {},
|
hexClick (context, hex: GaiaHex) {},
|
||||||
researchClick(context, field: ResearchField) {},
|
researchClick (context, field: ResearchField) {},
|
||||||
techClick(context, pos: TechTilePos | AdvTechTilePos) {},
|
techClick (context, pos: TechTilePos | AdvTechTilePos) {},
|
||||||
boosterClick(context, booster: Booster) {},
|
boosterClick (context, booster: Booster) {},
|
||||||
actionClick(context, action: string) {},
|
actionClick (context, action: string) {},
|
||||||
federationClick(context, federation: Federation) {},
|
federationClick (context, federation: Federation) {},
|
||||||
playerClick(context, player: Player) {},
|
playerClick (context, player: Player) {},
|
||||||
confirmClick(context, action: string) {},
|
confirmClick (context, action: string) {},
|
||||||
// API COMMUNICATOIN
|
// API COMMUNICATOIN
|
||||||
move(context, move: string) {},
|
move (context, move: string) {},
|
||||||
externalData(context, data: Engine) {},
|
externalData (context, data: Engine) {},
|
||||||
// WRAPPER / DEBUG COMMUNICATION
|
// WRAPPER / DEBUG COMMUNICATION
|
||||||
loadFromJSON(context, data: any) {}
|
loadFromJSON (context, data: any) {}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function makeStore() {
|
function makeStore () {
|
||||||
return new Vuex.Store({
|
return new Vuex.Store({
|
||||||
modules: {
|
modules: {
|
||||||
gaiaViewer
|
gaiaViewer
|
||||||
|
|
@ -124,4 +124,4 @@ function makeStore() {
|
||||||
|
|
||||||
export default makeStore();
|
export default makeStore();
|
||||||
|
|
||||||
export {gaiaViewer, makeStore};
|
export { gaiaViewer, makeStore };
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,14 @@ import launchSelfContained from './self-contained';
|
||||||
|
|
||||||
let globalItem: any;
|
let globalItem: any;
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
globalItem = window;
|
globalItem = window;
|
||||||
} else if (typeof global !== 'undefined') {
|
} else if (typeof global !== 'undefined') {
|
||||||
globalItem = global;
|
globalItem = global;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globalItem) {
|
if (globalItem) {
|
||||||
globalItem.gaiaViewer = {launch, launchSelfContained};
|
globalItem.gaiaViewer = { launch, launchSelfContained };
|
||||||
}
|
}
|
||||||
|
|
||||||
export {launchSelfContained};
|
export { launchSelfContained };
|
||||||
export default launch;
|
export default launch;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable */
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
if (process.argv.includes("lib")) {
|
if (process.argv.includes("lib")) {
|
||||||
|
|
@ -8,12 +9,12 @@ if (process.argv.includes("lib")) {
|
||||||
chainWebpack: config => {
|
chainWebpack: config => {
|
||||||
config.externals({
|
config.externals({
|
||||||
'bootstrap-vue': 'BootstrapVue'
|
'bootstrap-vue': 'BootstrapVue'
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
lintOnSave: false,
|
lintOnSave: false,
|
||||||
outputDir: path.join(__dirname, "dist/app"),
|
outputDir: path.join(__dirname, "dist/app")
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue