🏗 Use pnpm / pnpm workspace

This commit is contained in:
coyotte508 2021-02-20 19:31:29 +01:00
commit 5befa5440a
42 changed files with 12037 additions and 11306 deletions

View file

@ -25,7 +25,10 @@ jobs:
node-version: ${{ env.node_version }} node-version: ${{ env.node_version }}
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED # setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
registry-url: "https://registry.npmjs.org" registry-url: "https://registry.npmjs.org"
- run: yarn install - uses: pnpm/action-setup@v1.2.1
with:
version: 5.17.1
- run: pnpm install
- run: git config --global user.name github-actions - run: git config --global user.name github-actions
- run: git config --global user.email bot@github.com - run: git config --global user.email bot@github.com
- run: yarn version --${{ github.event.inputs.newversion }} - run: yarn version --${{ github.event.inputs.newversion }}

View file

@ -21,7 +21,10 @@ jobs:
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: "12" node-version: "12"
- run: yarn install - uses: pnpm/action-setup@v1.2.1
with:
version: 5.17.1
- run: pnpm install
- run: yarn build - run: yarn build
- run: yarn lint - run: yarn lint
- run: yarn prettier-check - run: yarn prettier-check

View file

@ -25,7 +25,10 @@ jobs:
node-version: ${{ env.node_version }} node-version: ${{ env.node_version }}
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED # setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
registry-url: "https://registry.npmjs.org" registry-url: "https://registry.npmjs.org"
- run: yarn install - uses: pnpm/action-setup@v1.2.1
with:
version: 5.17.1
- run: pnpm install
- run: git config --global user.name github-action - run: git config --global user.name github-action
- run: git config --global user.email hello@github.com - run: git config --global user.email hello@github.com
- run: yarn version --${{ github.event.inputs.newversion }} - run: yarn version --${{ github.event.inputs.newversion }}

View file

@ -23,6 +23,9 @@ jobs:
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: "14" node-version: "14"
- run: yarn install - uses: pnpm/action-setup@v1.2.1
with:
version: 5.17.1
- run: pnpm install
- run: yarn test - run: yarn test
- run: yarn build - run: yarn build

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
node_modules

1
.npmrc Normal file
View file

@ -0,0 +1 @@
shared-workspace-lockfile = false

View file

@ -11,14 +11,17 @@ Checkout their READMEs:
Check out [boardgamers.space](https://www.boardgamers.space)! Reach out to us if you want to contribute. Check out [boardgamers.space](https://www.boardgamers.space)! Reach out to us if you want to contribute.
## Install
Do `pnpm install` in the main folder
## Test locally ## Test locally
You can run the viewer with: After the installation step, you can run the viewer with:
``` ```
cd viewer cd viewer
yarn install npm run serve
yarn serve
``` ```
It will use the engine in its sibling folder It will use the engine in its sibling folder

View file

@ -1 +1,2 @@
/dist /dist
pnpm-lock.yaml

View file

@ -14,35 +14,9 @@ Have node 6+, hopefully 8+. Have npm 5+, and tsc.
### Dependencies ### Dependencies
In the project's folder:
```
yarn
```
### Build
To compile Typescript into javascript:
```
yarn build
```
### Test ### Test
``` ```
yarn test pnpm install
``` npm run test
### Usage as a dependency from another module
If you want to use your local copy of this module instead of the npm version, as a dependency of
another module, do this:
```
## In this folder
yarn link
## In the other project's folder
yarn link @gaia-project/engine
``` ```

1817
engine/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

3
pnpm-workspace.yaml Normal file
View file

@ -0,0 +1,3 @@
packages:
- "viewer"
- "engine"

View file

@ -8,11 +8,11 @@ Check out [boardgamers.space](https://www.boardgamers.space)!
## Build and Run ## Build and Run
In the viewer's folder:
```bash ```bash
# install deps, do this everytime yarn.lock is modified pnpm install
yarn install npm run serve
# run
yarn serve
``` ```
And open localhost:8080 in the browser. And open localhost:8080 in the browser.

View file

@ -30,7 +30,7 @@
"dependencies": { "dependencies": {
"bootstrap": "^4.4.1", "bootstrap": "^4.4.1",
"bootstrap-vue": "^2.12.0", "bootstrap-vue": "^2.12.0",
"@engine": "../engine", "@engine": "workspace:../engine",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"vue": "^2.6.11", "vue": "^2.6.11",
"vuex": "^3.0.1" "vuex": "^3.0.1"
@ -58,7 +58,8 @@
"popper.js": "^1.16.1", "popper.js": "^1.16.1",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"typescript": "^3.8.3", "typescript": "^3.8.3",
"vue-property-decorator": "^8.4.1", "vue-property-decorator": "^9.1.2",
"vue-class-component": "^7.2.6",
"vue-template-compiler": "^2.6.11", "vue-template-compiler": "^2.6.11",
"webpack": "^4.16.1" "webpack": "^4.16.1"
}, },

10054
viewer/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -17,18 +17,18 @@
<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 <div
v-for="(changes, source, i) in event.entry.changes" v-for="(changes, source, i) in event.entry.changes"
v-html="source === 'undefined' ? '&nbsp;' : source" v-html="source === 'undefined' ? '&nbsp;' : source"
:key="i" :key="i"
/> />
</td> </td>
<td style="width: 1px; white-space: nowrap;"> <td style="width: 1px; white-space: nowrap">
<div v-for="(changes, source, i) in event.entry.changes" :key="i"> <div v-for="(changes, source, i) in event.entry.changes" :key="i">
{{ {{
Object.keys(changes) Object.keys(changes)
.map(key => `${changes[key]}${key}`) .map((key) => `${changes[key]}${key}`)
.join(", ") .join(", ")
}} }}
</div> </div>

View file

@ -69,7 +69,7 @@ export default class BoardAction extends Vue {
get tooltip() { get 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");
} }
get faded() { get faded() {
@ -81,12 +81,12 @@ export default class BoardAction extends Vue {
} }
get rewards() { get rewards() {
return boardActions[this.action].income.map(x => new Reward(x)); return boardActions[this.action].income.map((x) => new Reward(x));
} }
get income() { get income() {
return [].concat( return [].concat(
...boardActions[this.action].income.map(x => { ...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("+"))];
} }

View file

@ -246,7 +246,7 @@ export default class Commands extends Vue {
label: "Rotate sectors", label: "Rotate sectors",
command: Command.RotateSectors, command: Command.RotateSectors,
hexes: new Map<GaiaHex, {}>( hexes: new Map<GaiaHex, {}>(
this.map.configuration().centers.map(center => [this.engine.map.grid.get(center), {}] as [GaiaHex, {}]) this.map.configuration().centers.map((center) => [this.engine.map.grid.get(center), {}] as [GaiaHex, {}])
), ),
rotation: true, rotation: true,
}); });
@ -255,7 +255,7 @@ export default class Commands extends Vue {
} }
case Command.Build: { case Command.Build: {
for (const building of Object.values(Building)) { for (const building of Object.values(Building)) {
const coordinates = command.data.buildings.filter(bld => bld.building === building); const coordinates = command.data.buildings.filter((bld) => bld.building === building);
if (coordinates.length > 0) { if (coordinates.length > 0) {
let label = `Build a ${buildingName(building)}`; let label = `Build a ${buildingName(building)}`;
@ -277,7 +277,7 @@ export default class Commands extends Vue {
command: `${Command.Build} ${building}`, command: `${Command.Build} ${building}`,
automatic: command.data.automatic, automatic: command.data.automatic,
hexes: new Map<GaiaHex, { cost?: string }>( hexes: new Map<GaiaHex, { cost?: string }>(
coordinates.map(coord => [this.engine.map.getS(coord.coordinates), coord]) coordinates.map((coord) => [this.engine.map.getS(coord.coordinates), coord])
), ),
}); });
} }
@ -290,7 +290,7 @@ export default class Commands extends Vue {
ret.push({ ret.push({
label: "Swap Planetary Institute", label: "Swap Planetary Institute",
command: command.name, command: command.name,
hexes: new Map(command.data.buildings.map(coord => [this.engine.map.getS(coord.coordinates), coord])), hexes: new Map(command.data.buildings.map((coord) => [this.engine.map.getS(coord.coordinates), coord])),
}); });
break; break;
} }
@ -299,7 +299,7 @@ export default class Commands extends Vue {
ret.push({ ret.push({
label: "Place Lost Planet", label: "Place Lost Planet",
command: command.name, command: command.name,
hexes: new Map(command.data.spaces.map(coord => [this.engine.map.getS(coord.coordinates), coord])), hexes: new Map(command.data.spaces.map((coord) => [this.engine.map.getS(coord.coordinates), coord])),
}); });
break; break;
} }
@ -322,7 +322,7 @@ export default class Commands extends Vue {
label: `Booster ${i + 1}`, label: `Booster ${i + 1}`,
booster, booster,
needConfirm: true, needConfirm: true,
tooltip: tiles.boosters[booster].map(spec => eventDesc(new Event(spec))).join("\n"), tooltip: tiles.boosters[booster].map((spec) => eventDesc(new Event(spec))).join("\n"),
warning, warning,
}); });
} }
@ -366,8 +366,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;
@ -378,8 +378,8 @@ export default class Commands extends Vue {
ret.push({ ret.push({
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, tech: tile.pos })), buttons: command.data.tiles.map((tile) => ({ command: tile.pos, tech: tile.pos })),
}); });
break; break;
} }
@ -418,7 +418,7 @@ export default class Commands extends Vue {
case Command.BrainStone: { case Command.BrainStone: {
ret.push( ret.push(
...command.data.sort().map(area => ({ ...command.data.sort().map((area) => ({
label: `Brainstone ${area}`, label: `Brainstone ${area}`,
command: `${command.name} ${area}`, command: `${command.name} ${area}`,
})) }))
@ -430,7 +430,7 @@ export default class Commands extends Vue {
ret.push({ ret.push({
label: "Free action", label: "Free action",
command: Command.Spend, command: Command.Spend,
buttons: command.data.acts.map(act => ({ buttons: command.data.acts.map((act) => ({
label: `Spend ${act.cost} to gain ${act.income}`, label: `Spend ${act.cost} to gain ${act.income}`,
command: `${act.cost} for ${act.income}`, command: `${act.cost} for ${act.income}`,
times: act.range, times: act.range,
@ -443,8 +443,8 @@ export default class Commands extends Vue {
ret.push({ ret.push({
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 => ({ buttons: command.data.poweracts.map((act) => ({
command: act.name, command: act.name,
label: `Spend ${act.cost} for ${act.income.join(" / ")}`, label: `Spend ${act.cost} for ${act.income.join(" / ")}`,
})), })),
@ -456,8 +456,8 @@ export default class Commands extends Vue {
ret.push({ ret.push({
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;
} }
@ -466,7 +466,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;
} }
@ -488,7 +488,7 @@ export default class Commands extends Vue {
case Command.ChooseIncome: { case Command.ChooseIncome: {
ret.push( ret.push(
...command.data.map(income => ({ ...command.data.map((income) => ({
label: `Income ${income}`, label: `Income ${income}`,
command: `${Command.ChooseIncome} ${income}`, command: `${Command.ChooseIncome} ${income}`,
})) }))
@ -498,7 +498,7 @@ export default class Commands extends Vue {
case Command.Bid: { case Command.Bid: {
ret.push( ret.push(
...command.data.bids.map(pos => ({ ...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,
@ -509,7 +509,7 @@ export default class Commands extends Vue {
case Command.PickReward: { case Command.PickReward: {
ret.push( ret.push(
...command.data.rewards.map(reward => ({ ...command.data.rewards.map((reward) => ({
label: `Gain ${reward}`, label: `Gain ${reward}`,
command: `${Command.PickReward} ${reward}`, command: `${Command.PickReward} ${reward}`,
})) }))
@ -526,7 +526,7 @@ export default class Commands extends Vue {
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.getS(coord), { coordinates: coord }])), hexes: new Map(fed.hexes.split(",").map((coord) => [this.engine.map.getS(coord), { coordinates: coord }])),
hover: true, hover: true,
buttons: tilesButtons, buttons: tilesButtons,
})); }));

View file

@ -4,10 +4,9 @@
<g <g
v-for="i in [0, 1, 2, 3, 4, 5, 6]" v-for="i in [0, 1, 2, 3, 4, 5, 6]"
:key="i" :key="i"
:transform=" :transform="`translate(${r * Math.sin(((-180 + i * 51) * Math.PI) / 180)}, ${
`translate(${r * Math.sin(((-180 + i * 51) * Math.PI) / 180)}, ${r * r * Math.cos(((-180 + i * 51) * Math.PI) / 180)
Math.cos(((-180 + i * 51) * Math.PI) / 180)})` })`"
"
> >
<circle :r="1" :class="['planet-fill', planet(i)]" :style="`stroke-width: ${strokeWidth(i)}`" /> <circle :r="1" :class="['planet-fill', planet(i)]" :style="`stroke-width: ${strokeWidth(i)}`" />
<text <text
@ -43,13 +42,13 @@ export default class FactionWheel extends Vue {
} }
remainingPlanets(planet: string) { remainingPlanets(planet: string) {
return Array.from(this.gameData.map.grid.values()).filter(hex => !hex.occupied() && hex.data.planet === planet) return Array.from(this.gameData.map.grid.values()).filter((hex) => !hex.occupied() && hex.data.planet === planet)
.length; .length;
} }
strokeWidth(pos: number) { strokeWidth(pos: number) {
const planet = this.planet(pos); const planet = this.planet(pos);
if (this.gameData.players.some(p => p.faction && factions[p.faction].planet === planet)) { if (this.gameData.players.some((p) => p.faction && factions[p.faction].planet === planet)) {
return "0.2px; stroke-dasharray:.5 .2"; return "0.2px; stroke-dasharray:.5 .2";
} }

View file

@ -15,11 +15,9 @@
:key="i" :key="i"
:count="reward.count" :count="reward.count"
:kind="reward.type" :kind="reward.type"
:transform=" :transform="`translate(${i === 2 ? 0 : (i - Math.min(rewards.length - 1, 1) / 2) * 22}, ${
`translate(${i === 2 ? 0 : (i - Math.min(rewards.length - 1, 1) / 2) * 22}, ${ rewards.length === 1 ? 12.5 : i === 2 ? -7 : 10
rewards.length === 1 ? 12.5 : i === 2 ? -7 : 10 })`"
})`
"
/> />
</g> </g>
</g> </g>

View file

@ -87,12 +87,10 @@
<feColorMatrix <feColorMatrix
type="matrix" type="matrix"
result="A" result="A"
:values=" :values="`${r / x} 0 0 0 0
`${r / x} 0 0 0 0
${g / x} 0 0 0 0 ${g / x} 0 0 0 0
${b / x} 0 0 0 0 ${b / x} 0 0 0 0
0 0 0 1 0` 0 0 0 1 0`"
"
/> />
<feColorMatrix in="A" type="saturate" :values="s" /> <feColorMatrix in="A" type="saturate" :values="s" />
</filter> </filter>
@ -101,12 +99,10 @@
<filter :id="`color-planet-${planet}`" :key="'pl-' + planet"> <filter :id="`color-planet-${planet}`" :key="'pl-' + planet">
<feColorMatrix <feColorMatrix
type="matrix" type="matrix"
:values=" :values="`${r / (3 * x)} ${r / (3 * x)} ${r / (3 * x)} 0 0
`${r / (3 * x)} ${r / (3 * x)} ${r / (3 * x)} 0 0
${g / (3 * x)} ${g / (3 * x)} ${g / (3 * x)} 0 0 ${g / (3 * x)} ${g / (3 * x)} ${g / (3 * x)} 0 0
${b / (3 * x)} ${b / (3 * x)} ${b / (3 * x)} 0 0 ${b / (3 * x)} ${b / (3 * x)} ${b / (3 * x)} 0 0
0 0 0 1 0` 0 0 0 1 0`"
"
/> />
</filter> </filter>
</template> </template>
@ -136,7 +132,7 @@ function getDarkness(faction: string): number {
export default class Filters extends Vue { export default class Filters extends Vue {
get factionData() { get factionData() {
const factions = ["gen", "gaia", ...Object.values(Faction)]; const factions = ["gen", "gaia", ...Object.values(Faction)];
return factions.map(faction => { return factions.map((faction) => {
/* Gaia faction is used for gaia-colored gaia formers for Baltaks */ /* Gaia faction is used for gaia-colored gaia formers for Baltaks */
const color = faction === "gaia" ? planetColor(Planet.Gaia) : factionColor(faction as Faction); const color = faction === "gaia" ? planetColor(Planet.Gaia) : factionColor(faction as Faction);
const darkness = getDarkness(faction); const darkness = getDarkness(faction);
@ -154,8 +150,8 @@ export default class Filters extends Vue {
} }
get planetData() { get planetData() {
const planets = Object.values(Planet).filter(pl => pl !== Planet.Empty); const planets = Object.values(Planet).filter((pl) => pl !== Planet.Empty);
return planets.map(planet => { return planets.map((planet) => {
const color = planetColor(planet); const color = planetColor(planet);
const darkness = 1; const darkness = 1;

View file

@ -32,7 +32,7 @@ import Token from "./Token.vue";
const players = this.players; const players = this.players;
return players return players
.map(pl => { .map((pl) => {
const name = pl.faction === "automa" ? "Automa" : factions[pl.faction].name; const name = pl.faction === "automa" ? "Automa" : factions[pl.faction].name;
const points = this.progress(pl); const points = this.progress(pl);
return `- ${name}: ${points}`; return `- ${name}: ${points}`;
@ -68,7 +68,7 @@ export default class FinalScoringTile extends Vue {
} }
get players() { get players() {
const pls = this.$store.state.gaiaViewer.data.players.filter(player => !!player && player.faction); const pls = this.$store.state.gaiaViewer.data.players.filter((player) => !!player && player.faction);
if (this.$store.state.gaiaViewer.data.players.length === 2) { if (this.$store.state.gaiaViewer.data.players.length === 2) {
pls.push({ faction: "automa" }); pls.push({ faction: "automa" });

View file

@ -28,7 +28,7 @@
<template v-else> <template v-else>
<PlayerInfo :player="sessionPlayer" class="col-md-6 order-3" /> <PlayerInfo :player="sessionPlayer" class="col-md-6 order-3" />
<PlayerInfo <PlayerInfo
v-for="player in orderedPlayers.filter(pl => pl !== sessionPlayer)" v-for="player in orderedPlayers.filter((pl) => pl !== sessionPlayer)"
:player="player" :player="player"
:key="player.player" :key="player.player"
class="col-md-6 order-6" class="col-md-6 order-6"
@ -177,7 +177,7 @@ export default class Game extends Vue {
// turnOrder = turnOrder.slice(turnOrder.indexOf(this.player)).concat(turnOrder.slice(0, turnOrder.indexOf(this.player))); // turnOrder = turnOrder.slice(turnOrder.indexOf(this.player)).concat(turnOrder.slice(0, turnOrder.indexOf(this.player)));
// } // }
return turnOrder.concat(engine.passedPlayers).map(player => engine.players[player]); return turnOrder.concat(engine.passedPlayers).map((player) => engine.players[player]);
} }
get canPlay() { get canPlay() {

View file

@ -90,7 +90,7 @@ 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 });
} }
@ -133,7 +133,7 @@ export default class MoveButton extends Vue {
this.emitCommand(hex.toString()); this.emitCommand(hex.toString());
} else { } else {
this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes); this.$store.commit("gaiaViewer/highlightHexes", this.button.hexes);
this.subscribe("hexClick", hex => this.emitCommand(hex.toString())); this.subscribe("hexClick", (hex) => this.emitCommand(hex.toString()));
} }
} else if (this.button.researchTiles) { } else if (this.button.researchTiles) {
this.$store.commit("gaiaViewer/highlightResearchTiles", this.button.researchTiles); this.$store.commit("gaiaViewer/highlightResearchTiles", this.button.researchTiles);
@ -153,7 +153,7 @@ export default class MoveButton extends Vue {
// If already the active button, end the selection // If already the active button, end the selection
if (this.isActiveButton) { if (this.isActiveButton) {
this.button.command = [...this.$store.state.gaiaViewer.context.highlighted.hexes.keys()] this.button.command = [...this.$store.state.gaiaViewer.context.highlighted.hexes.keys()]
.map(hex => hex.toString()) .map((hex) => hex.toString())
.join(","); .join(",");
this.emitCommand(); this.emitCommand();
return; return;
@ -163,7 +163,7 @@ export default class MoveButton extends Vue {
this.customLabel = "Custom location - End selection"; this.customLabel = "Custom location - End selection";
this.subscribe("hexClick", hex => { this.subscribe("hexClick", (hex) => {
const highlighted = this.$store.state.gaiaViewer.context.highlighted.hexes; const highlighted = this.$store.state.gaiaViewer.context.highlighted.hexes;
if (highlighted.has(hex)) { if (highlighted.has(hex)) {
@ -173,7 +173,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;
@ -183,17 +183,17 @@ export default class MoveButton extends Vue {
for (const rotation of rotations) { for (const rotation of rotations) {
rotation[1] %= 6; rotation[1] %= 6;
} }
this.emitCommand([].concat(...rotations.filter(r => !!r[1])).join(" ")); this.emitCommand([].concat(...rotations.filter((r) => !!r[1])).join(" "));
return; return;
} }
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);
this.subscribe("hexClick", hex => { this.subscribe("hexClick", (hex) => {
if (this.startingHex) { if (this.startingHex) {
this.emitCommand(`${this.startingHex} ${hex}`); this.emitCommand(`${this.startingHex} ${hex}`);
this.startingHex = undefined; this.startingHex = undefined;
@ -253,12 +253,12 @@ export default class MoveButton extends Vue {
if (times && typeof times === "number") { if (times && typeof times === "number") {
// the \b is necessary for things like '1t-a3', so the 3 is not caught // the \b is necessary for things like '1t-a3', so the 3 is not caught
command = command.replace(/\b[0-9]+/g, x => "" + parseInt(x) * times); command = command.replace(/\b[0-9]+/g, (x) => "" + parseInt(x) * times);
} }
command = command.replace(/\$times\b/g, "" + (times ?? 0)); command = command.replace(/\$times\b/g, "" + (times ?? 0));
commandBody = [command, append].filter(x => !!x); commandBody = [command, append].filter((x) => !!x);
} }
this.$emit("trigger", commandBody.join(" "), this, final); this.$emit("trigger", commandBody.join(" "), this, final);

View file

@ -1,7 +1,7 @@
<template> <template>
<g> <g>
<circle :r="radius" :class="['planet-fill', planet]" style="pointer-events: none;" /> <circle :r="radius" :class="['planet-fill', planet]" style="pointer-events: none" />
<circle :r="radius" :class="['planet-fill', 'faction-fill', fill]" v-if="faction" style="pointer-events: none;" /> <circle :r="radius" :class="['planet-fill', 'faction-fill', fill]" v-if="faction" style="pointer-events: none" />
<circle :r="radius" :class="['planet', planet]" /> <circle :r="radius" :class="['planet', planet]" />
</g> </g>
</template> </template>

View file

@ -125,7 +125,7 @@ export default class BuildingGroup extends Vue {
tooltip(i: number) { tooltip(i: number) {
const b = this.board.buildings[this.building]; const b = this.board.buildings[this.building];
const cost = this.discount const cost = this.discount
? b.cost.map(c => `${c.count - this.discount}${c.type}`).join(", ") ? b.cost.map((c) => `${c.count - this.discount}${c.type}`).join(", ")
: b.cost.join(", ") || "~"; : b.cost.join(", ") || "~";
const isolatedCost = b.isolatedCost ? "\n Isolated cost: " + (b.isolatedCost.join(", ") || "~") : ""; const isolatedCost = b.isolatedCost ? "\n Isolated cost: " + (b.isolatedCost.join(", ") || "~") : "";
const income = this.building === BuildingEnum.GaiaFormer ? "" : "\n " + (this.resources(i, true).join(", ") || "~"); const income = this.building === BuildingEnum.GaiaFormer ? "" : "\n " + (this.resources(i, true).join(", ") || "~");
@ -154,10 +154,10 @@ export default class BuildingGroup extends Vue {
get factionIncome(): Reward[] { get factionIncome(): Reward[] {
const income: Reward[] = [].concat( const income: Reward[] = [].concat(
...this.board.income.filter(ev => ev.operator === Operator.Income).map(ev => ev.rewards) ...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));
} }
get flat() { get flat() {
@ -192,7 +192,7 @@ export default class BuildingGroup extends Vue {
} }
let incomeAdded = false; let incomeAdded = false;
const ret = this.board.buildings[building].income[i].map(ev => { const ret = this.board.buildings[building].income[i].map((ev) => {
const rew = ev.rewards.toString(); const rew = ev.rewards.toString();
const special = ev.operator === Operator.Activate && (rew === "1q" || rew === "4c"); const special = ev.operator === Operator.Activate && (rew === "1q" || rew === "4c");
@ -208,7 +208,7 @@ export default class BuildingGroup extends Vue {
return null; return null;
}); });
return [].concat(...ret).filter(r => r != null); return [].concat(...ret).filter((r) => r != null);
} }
} }
</script> </script>

View file

@ -147,7 +147,7 @@ export default class BuildingGroup extends Vue {
} }
get sectors(): number { get sectors(): number {
return uniq(this.data.occupied.filter(hex => hex.colonizedBy(this.player.player)).map(hex => hex.data.sector)) return uniq(this.data.occupied.filter((hex) => hex.colonizedBy(this.player.player)).map((hex) => hex.data.sector))
.length; .length;
} }
} }

View file

@ -113,9 +113,9 @@
> >
<circle :r="1" style="stroke-width: 0.06px !important" :class="['player-token', 'planet-fill', planet]" /> <circle :r="1" style="stroke-width: 0.06px !important" :class="['player-token', 'planet-fill', planet]" />
<text <text
:style=" :style="`font-size: 1.4px; text-anchor: middle; dominant-baseline: central; fill: ${planetFill(
`font-size: 1.4px; text-anchor: middle; dominant-baseline: central; fill: ${planetFill(planet)}` planet
" )}`"
> >
{{ player.ownedPlanetsCount[planet] }} {{ player.ownedPlanetsCount[planet] }}
</text> </text>

View file

@ -27,7 +27,7 @@ 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 Object.entries(this.$store.state.gaiaViewer.data.tiles.federations).filter(([key, value]) => value > 0); return Object.entries(this.$store.state.gaiaViewer.data.tiles.federations).filter(([key, value]) => value > 0);

View file

@ -73,7 +73,7 @@ import Resource from "./Resource.vue";
computed: { computed: {
players(): Player[] { players(): Player[] {
return this.$store.state.gaiaViewer.data.players.filter( return this.$store.state.gaiaViewer.data.players.filter(
player => player.faction && player.data.research[this.field] === this.level (player) => player.faction && player.data.research[this.field] === this.level
); );
}, },
tooltip() { tooltip() {
@ -144,7 +144,7 @@ export default class ResearchTile extends Vue {
} }
get resources() { get resources() {
const rewards = Reward.merge(...this.events.slice(0, 1).map(ev => ev.rewards)); const rewards = Reward.merge(...this.events.slice(0, 1).map((ev) => ev.rewards));
if (this.events[0] && this.events[0].operator === Operator.Income) { if (this.events[0] && this.events[0].operator === Operator.Income) {
rewards.unshift(new Reward("+", ResourceEnum.None)); rewards.unshift(new Reward("+", ResourceEnum.None));
@ -191,11 +191,11 @@ export default class ResearchTile extends Vue {
} }
get events() { get events() {
return researchTracks[this.field][this.level].map(s => new Event(s)); return researchTracks[this.field][this.level].map((s) => new Event(s));
} }
get techContent() { get techContent() {
return this.events.filter(event => event.condition !== Condition.None); return this.events.filter((event) => event.condition !== Condition.None);
} }
get highlighted(): boolean { get highlighted(): boolean {

View file

@ -117,7 +117,7 @@
y="0" y="0"
v-if=" v-if="
(count >= 0 && ['o', 'c', 'k', 'pw', 'pay-pw', 't', 'bowl-t', 'tg', 'vp', 'q', 'gf'].includes(kind)) || (count >= 0 && ['o', 'c', 'k', 'pw', 'pay-pw', 't', 'bowl-t', 'tg', 'vp', 'q', 'gf'].includes(kind)) ||
count === '+' count === '+'
" "
:class="{ plus: count === '+' }" :class="{ plus: count === '+' }"
>{{ kind === "t" ? "+" : "" }}{{ count }}</text >{{ kind === "t" ? "+" : "" }}{{ count }}</text

View file

@ -6,13 +6,11 @@
<Resource :kind="reward.type" :count="reward.count" transform="translate(63.7, 13.1) scale(1.5)" /> <Resource :kind="reward.type" :count="reward.count" transform="translate(63.7, 13.1) scale(1.5)" />
<Condition <Condition
:condition="event.condition" :condition="event.condition"
:transform=" :transform="`translate(${
`translate(${ event.condition === 'step' || event.condition === 'a' || event.condition === 'PA'
event.condition === 'step' || event.condition === 'a' || event.condition === 'PA' ? 27 + (event.condition === 'PA' ? 8 : 0)
? 27 + (event.condition === 'PA' ? 8 : 0) : 34
: 34 }, ${event.condition === 'step' ? 20 : 22}) scale(1.3)`"
}, ${event.condition === 'step' ? 20 : 22}) scale(1.3)`
"
/> />
<Operator :condition="event.condition" :operator="event.operator" transform="translate(28, 27) scale(1)" /> <Operator :condition="event.condition" :operator="event.operator" transform="translate(28, 27) scale(1)" />
<rect x="1" y="1" width="75" height="40" rx="2" ry="2" class="contour" /> <rect x="1" y="1" width="75" height="40" rx="2" ry="2" class="contour" />
@ -39,7 +37,7 @@ export default class ScoringTile extends Vue {
@Prop() @Prop()
round: number; round: number;
get tile(this: ScoringTile) { get tile() {
return this.$store.state.gaiaViewer.data.tiles.scorings.round[this.round - 1]; return this.$store.state.gaiaViewer.data.tiles.scorings.round[this.round - 1];
} }

View file

@ -44,7 +44,7 @@ export default class Sector extends Vue {
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;
} }

View file

@ -6,7 +6,7 @@
}}{{ cost(hex) ? `&#10;Cost: ${cost(hex)}` : "" }} }}{{ cost(hex) ? `&#10;Cost: ${cost(hex)}` : "" }}
</title> </title>
<polygon <polygon
:points="hexCorners.map(p => `${p.x},${p.y}`).join(' ')" :points="hexCorners.map((p) => `${p.x},${p.y}`).join(' ')"
:class="[ :class="[
'spaceHex', 'spaceHex',
{ {
@ -23,7 +23,7 @@
}}</text> }}</text>
<Planet v-if="hex.data.planet !== 'e'" :planet="hex.data.planet" :faction="faction(hex.data.player)" /> <Planet v-if="hex.data.planet !== 'e'" :planet="hex.data.planet" :faction="faction(hex.data.player)" />
<Building <Building
style="stroke-width: 10;" style="stroke-width: 10"
v-if="hex.data.building" v-if="hex.data.building"
:building="hex.data.building" :building="hex.data.building"
:faction="faction(hex.data.player)" :faction="faction(hex.data.player)"
@ -32,7 +32,7 @@
transform="scale(0.1)" transform="scale(0.1)"
/> />
<Building <Building
style="stroke-width: 10;" style="stroke-width: 10"
v-if="hex.data.additionalMine !== undefined" v-if="hex.data.additionalMine !== undefined"
:faction="faction(hex.data.additionalMine)" :faction="faction(hex.data.additionalMine)"
building="m" building="m"
@ -43,7 +43,7 @@
/> />
<polygon <polygon
v-for="(player, index) in hex.data.federations || []" v-for="(player, index) in hex.data.federations || []"
:points="hexCorners.map(p => `${p.x * (1 - (index + 0.5) / 8)},${p.y * (1 - (index + 0.5) / 8)}`).join(' ')" :points="hexCorners.map((p) => `${p.x * (1 - (index + 0.5) / 8)},${p.y * (1 - (index + 0.5) / 8)}`).join(' ')"
:class="['spaceHexFederation', 'planet', planet(player)]" :class="['spaceHexFederation', 'planet', planet(player)]"
:key="`${player}-${index}`" :key="`${player}-${index}`"
/> />

View file

@ -5,11 +5,9 @@
v-for="center in this.sectors" v-for="center in this.sectors"
:center="center" :center="center"
:key="`${center.q}x{center.r}`" :key="`${center.q}x{center.r}`"
:style=" :style="`transform: translate(${hexCenter(center).x * 1.01}px, ${hexCenter(center).y * 1.01}px) rotate(${
`transform: translate(${hexCenter(center).x * 1.01}px, ${hexCenter(center).y * 1.01}px) rotate(${rotation( rotation(center) * 60
center }deg);`"
) * 60}deg);`
"
/> />
<FactionWheel transform="translate(-10.5, -8.7) scale(0.5, 0.5)" /> <FactionWheel transform="translate(-10.5, -8.7) scale(0.5, 0.5)" />
</svg> </svg>

View file

@ -27,7 +27,15 @@
<text <text
x="-25" x="-25"
y="0" y="0"
style="text-anchor: middle; dominant-baseline: central; font-size: 8px; fill: white !important; letter-spacing: 0px; writing-mode: vertical-rl; text-orientation: upright; " style="
text-anchor: middle;
dominant-baseline: central;
font-size: 8px;
fill: white !important;
letter-spacing: 0px;
writing-mode: vertical-rl;
text-orientation: upright;
"
>PASS</text >PASS</text
> >
</g> </g>
@ -41,9 +49,9 @@
:count="res.count" :count="res.count"
:kind="res.type" :kind="res.type"
:key="i" :key="i"
:transform=" :transform="`translate(${centerRewards.length > 1 ? (i - 0.5) * 26 : 0}, 0) scale(${
`translate(${centerRewards.length > 1 ? (i - 0.5) * 26 : 0}, 0) scale(${centerRewards.length === 1 ? 2 : 1.5})` centerRewards.length === 1 ? 2 : 1.5
" })`"
/> />
<Resource <Resource
v-for="(res, i) in rightRewards" v-for="(res, i) in rightRewards"
@ -69,7 +77,15 @@
<Operator :operator="event.operator" :condition="event.condition" transform="translate(2,5) scale(1.2)" /> <Operator :operator="event.operator" :condition="event.condition" transform="translate(2,5) scale(1.2)" />
</template> </template>
<text <text
style="font-size: 40px; stroke: black; fill: white; dominant-baseline: central; text-anchor: middle; stroke-width: 1px; font-weight: bold;" style="
font-size: 40px;
stroke: black;
fill: white;
dominant-baseline: central;
text-anchor: middle;
stroke-width: 1px;
font-weight: bold;
"
x="-14" x="-14"
v-if="event.operator === '+'" v-if="event.operator === '+'"
>+</text >+</text

View file

@ -23,7 +23,7 @@
filter="url(#shadow-1)" filter="url(#shadow-1)"
/> />
<!--<text class="title" x="-25" y="-18">{{title}}</text>--> <!--<text class="title" x="-25" y="-18">{{title}}</text>-->
<TechContent :content="rawContent" style="pointer-events:none;" /> <TechContent :content="rawContent" style="pointer-events: none" />
</g> </g>
</svg> </svg>
</template> </template>

View file

@ -5,11 +5,9 @@
<g v-for="(player, index) in turnOrder" :key="index" :transform="`translate(${index * 2.5})`"> <g v-for="(player, index) in turnOrder" :key="index" :transform="`translate(${index * 2.5})`">
<circle :r="1" :style="stroke(player)" :class="['player-token', 'planet-fill', planet(player, index)]" /> <circle :r="1" :style="stroke(player)" :class="['player-token', 'planet-fill', planet(player, index)]" />
<text <text
:style=" :style="`font-size: 1.2px; text-anchor: middle; dominant-baseline: central; fill: ${planetFill(
`font-size: 1.2px; text-anchor: middle; dominant-baseline: central; fill: ${planetFill( planet(player, index)
planet(player, index) )}`"
)}`
"
> >
{{ initial(player, index) }} {{ initial(player, index) }}
</text> </text>
@ -24,11 +22,9 @@
> >
<circle :r="1" :style="stroke(player)" :class="['player-token', 'planet-fill', planet(player, index)]" /> <circle :r="1" :style="stroke(player)" :class="['player-token', 'planet-fill', planet(player, index)]" />
<text <text
:style=" :style="`font-size: 1.2px; text-anchor: middle; dominant-baseline: central; fill: ${planetFill(
`font-size: 1.2px; text-anchor: middle; dominant-baseline: central; fill: ${planetFill( planet(player, index)
planet(player, index) )}`"
)}`
"
> >
{{ initial(player, index) }} {{ initial(player, index) }}
</text> </text>
@ -63,13 +59,13 @@ export default class TurnOrder extends Vue {
return data.players; return data.players;
} }
if (data.phase === Phase.SetupBuilding || data.phase === Phase.SetupBooster) { if (data.phase === Phase.SetupBuilding || data.phase === Phase.SetupBooster) {
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) {
@ -129,7 +125,7 @@ export default class TurnOrder extends Vue {
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 "";
} }

View file

@ -39,7 +39,7 @@ const operators = {
function rewardDesc(rewards: Reward[]) { function rewardDesc(rewards: Reward[]) {
return rewards return rewards
.map(reward => { .map((reward) => {
switch (reward.type) { switch (reward.type) {
case Resource.TechTile: case Resource.TechTile:
return `gain ${reward.count} tech tile${reward.count > 1 ? "s" : ""}`; return `gain ${reward.count} tech tile${reward.count > 1 ? "s" : ""}`;
@ -67,5 +67,5 @@ export function eventDesc(event: Event) {
: conditionsCount[event.condition] && "for each " + conditionsCount[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(" ");
} }

View file

@ -101,7 +101,7 @@ export function planetsWithSteps(planet: Planet, steps: number) {
list = list.slice(list.lastIndexOf(planet)).concat(list.slice(0, list.indexOf(planet))); list = list.slice(list.lastIndexOf(planet)).concat(list.slice(0, list.indexOf(planet)));
} }
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) {
@ -111,9 +111,9 @@ export function factionDesc(faction: Faction) {
const buildingDesc = const buildingDesc =
"<ul>" + "<ul>" +
Object.values(Building) Object.values(Building)
.filter(bld => bld !== Building.GaiaFormer && bld !== Building.SpaceStation) .filter((bld) => bld !== Building.GaiaFormer && bld !== Building.SpaceStation)
.map( .map(
bld => (bld) =>
"<li><b>" + "<li><b>" +
bld + bld +
"</b> - " + "</b> - " +
@ -124,8 +124,8 @@ export function factionDesc(faction: Faction) {
) )
.join("\n") + .join("\n") +
"</ul>"; "</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);
return ` return `
<div class='faction-desc'> <div class='faction-desc'>
@ -138,10 +138,10 @@ export function factionDesc(faction: Faction) {
<b>Steps:</b> <b>Steps:</b>
${[0, 1, 2, 3] ${[0, 1, 2, 3]
.map( .map(
i => (i) =>
`<span class="ml-2">${planetsWithSteps(p, i) `<span class="ml-2">${planetsWithSteps(p, i)
.map( .map(
p => (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>`

View file

@ -6,9 +6,6 @@
"moduleResolution": "node", "moduleResolution": "node",
"sourceMap": true, "sourceMap": true,
"outDir": "./dist" /* Redirect output structure to the directory. */, "outDir": "./dist" /* Redirect output structure to the directory. */,
// "paths": {
// "@engine": ["../engine"]
// },
"baseUrl": ".", "baseUrl": ".",
"experimentalDecorators": true, "experimentalDecorators": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,

File diff suppressed because it is too large Load diff