🐛 (old-ui) Fix factionPlanet calls

This commit is contained in:
coyotte508 2021-05-18 23:14:48 +02:00
commit e2836cd8ae
7 changed files with 120 additions and 80 deletions

1
old-ui/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
dist

View file

@ -13,15 +13,15 @@
"publishConfig": {
"access": "public"
},
"unpkg": "dist/package/viewer.umd.min.js",
"unpkg": "dist/package/old-ui.umd.min.js",
"files": [
"index.ts",
"tsconfig.json",
"src",
"README.md",
"public",
"dist/package/viewer.umd.min.js",
"dist/package/viewer.css"
"dist/package/old-ui.umd.min.js",
"dist/package/old-ui.css"
],
"dependencies": {
"@gaia-project/engine": "workspace:../engine",

View file

@ -15,16 +15,16 @@
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { factions, Faction, Building as BuildingEnum, Planet } from '@gaia-project/engine';
import { corners } from '../graphics/hex';
import Token from './Token.vue';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { factions, Faction, Building as BuildingEnum, Planet, factionPlanet } from "@gaia-project/engine";
import { corners } from "../graphics/hex";
import Token from "./Token.vue";
@Component({
components: {
Token
}
Token,
},
})
export default class Building extends Vue {
@Prop()
@ -33,25 +33,47 @@ export default class Building extends Vue {
@Prop()
building: BuildingEnum;
get planet () {
return (this.faction as any === "wild") ? Planet.Transdim : factions.planet(this.faction);
get planet() {
return (this.faction as any) === "wild" ? Planet.Transdim : factionPlanet(this.faction);
}
get hexCorners () {
return corners().map(({ x, y }) => `${x * 0.4},${y * 0.4}`).join(" ");
get hexCorners() {
return corners()
.map(({ x, y }) => `${x * 0.4},${y * 0.4}`)
.join(" ");
}
get triangleCorners () {
return [{ x: -0.5, y: Math.sqrt(3) / 4 }, { x: 0.5, y: Math.sqrt(3) / 4 }, { x: 0, y: -Math.sqrt(3) / 4 }].map(({ x, y }) => `${x * 0.5},${y * 0.5}`).join(" ");
get triangleCorners() {
return [
{ x: -0.5, y: Math.sqrt(3) / 4 },
{ x: 0.5, y: Math.sqrt(3) / 4 },
{ x: 0, y: -Math.sqrt(3) / 4 },
]
.map(({ x, y }) => `${x * 0.5},${y * 0.5}`)
.join(" ");
}
get mine () { return this.building === BuildingEnum.Mine; }
get tradingStation () { return this.building === BuildingEnum.TradingStation; }
get planetaryInstitute () { return this.building === BuildingEnum.PlanetaryInstitute; }
get lab () { return this.building === BuildingEnum.ResearchLab; }
get academy () { return this.building === BuildingEnum.Academy1 || this.building === BuildingEnum.Academy2; }
get gaiaFormer () { return this.building === BuildingEnum.GaiaFormer; }
get spaceStation () { return this.building === BuildingEnum.SpaceStation; }
get mine() {
return this.building === BuildingEnum.Mine;
}
get tradingStation() {
return this.building === BuildingEnum.TradingStation;
}
get planetaryInstitute() {
return this.building === BuildingEnum.PlanetaryInstitute;
}
get lab() {
return this.building === BuildingEnum.ResearchLab;
}
get academy() {
return this.building === BuildingEnum.Academy1 || this.building === BuildingEnum.Academy2;
}
get gaiaFormer() {
return this.building === BuildingEnum.GaiaFormer;
}
get spaceStation() {
return this.building === BuildingEnum.SpaceStation;
}
}
</script>

View file

@ -7,10 +7,10 @@
</template>
<script lang="ts">
import Vue from 'vue';
import Vue from "vue";
import planets from "../data/planets";
import { Component, Prop } from 'vue-property-decorator';
import { Planet as PlanetEnum, factions, Faction } from '@gaia-project/engine';
import { Component, Prop } from "vue-property-decorator";
import { Planet as PlanetEnum, factions, Faction, factionPlanet } from "@gaia-project/engine";
@Component
export default class Planet extends Vue {
@ -20,14 +20,14 @@ export default class Planet extends Vue {
@Prop()
faction: Faction;
get radius () {
get radius() {
return planets[this.planet].radius;
}
get fill () {
get fill() {
// Comment for planet staying planets!
if (this.faction) {
return factions.planet(this.faction);
return factionPlanet(this.faction);
}
return this.planet;
}

View file

@ -47,20 +47,27 @@
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { GaiaHex, factions, Building as BuildingEnum, Planet as PlanetEnum, SpaceMap as ISpaceMap } from '@gaia-project/engine';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import {
GaiaHex,
factions,
Building as BuildingEnum,
Planet as PlanetEnum,
SpaceMap as ISpaceMap,
factionPlanet,
} from "@gaia-project/engine";
import { corners } from "../graphics/hex";
import Planet from './Planet.vue';
import Building from './Building.vue';
import { buildingName } from '../data/building';
import { planetNames } from '../data/planets';
import Planet from "./Planet.vue";
import Building from "./Building.vue";
import { buildingName } from "../data/building";
import { planetNames } from "../data/planets";
@Component<SpaceHex>({
components: {
Planet,
Building,
}
},
})
export default class SpaceHex extends Vue {
@Prop()
@ -69,66 +76,66 @@ export default class SpaceHex extends Vue {
@Prop()
isCenter: boolean;
get hexCorners () {
get hexCorners() {
return corners();
}
get map (): ISpaceMap {
get map(): ISpaceMap {
return this.$store.state.gaiaViewer.data.map;
}
cost (hex: GaiaHex) {
cost(hex: GaiaHex) {
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) {
this.$store.dispatch('gaiaViewer/hexClick', hex);
this.$store.dispatch("gaiaViewer/hexClick", hex);
}
}
faction (player) {
faction(player) {
if (player === undefined || player === "wild") {
return player; // Wild will get recognized as purple, for trade tokens. A bit of a hack
}
return this.$store.state.gaiaViewer.data.players[player].faction;
}
planet (player) {
return factions.planet(this.faction(player));
planet(player) {
return factionPlanet(this.faction(player));
}
buildingName (building: BuildingEnum) {
buildingName(building: BuildingEnum) {
return buildingName(building);
}
planetName (planet: PlanetEnum) {
planetName(planet: PlanetEnum) {
return planetNames[planet];
}
get highlightedHexes (): Map<GaiaHex, any> {
get highlightedHexes(): Map<GaiaHex, any> {
return this.$store.state.gaiaViewer.context.highlighted.hexes;
}
get toSelect () {
get toSelect() {
return !!this.$store.state.gaiaViewer.context.hexSelection;
}
shipX (index) {
shipX(index) {
return SpaceHex.shipXs[index % 7];
}
shipY (index) {
shipY(index) {
return SpaceHex.shipYs[index % 7];
}
tradeX (index) {
tradeX(index) {
return SpaceHex.tradeXs[index];
}
tradeY (index) {
tradeY(index) {
return SpaceHex.tradeYs[index];
}

View file

@ -5,14 +5,14 @@
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { factions, Faction, Planet } from '@gaia-project/engine';
import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { factions, Faction, Planet, factionPlanet } from "@gaia-project/engine";
@Component
export default class PlayerToken extends Vue {
@Prop()
faction: Faction | 'automa';
faction: Faction | "automa";
@Prop()
scale: number;
@ -20,11 +20,11 @@ export default class PlayerToken extends Vue {
@Prop()
planet: Planet;
get renderPlanet (): Planet {
get renderPlanet(): Planet {
if (this.planet) {
return this.planet;
}
return this.faction === 'automa' ? Planet.Lost : factions.planet(this.faction);
return this.faction === "automa" ? Planet.Lost : factionPlanet(this.faction);
}
}
</script>

View file

@ -35,39 +35,47 @@
</template>
<script lang="ts">
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, factionPlanet } from "@gaia-project/engine";
@Component
export default class TurnOrder extends Vue {
get gameData (): Engine {
get gameData(): Engine {
return this.$store.state.gaiaViewer.data;
}
get phaseBeforeSetupBuilding (): boolean {
get phaseBeforeSetupBuilding(): boolean {
const data = this.gameData;
return (data.phase === Phase.SetupInit || data.phase === Phase.SetupBoard || data.phase === Phase.SetupFaction || data.phase === Phase.SetupAuction);
return (
data.phase === Phase.SetupInit ||
data.phase === Phase.SetupBoard ||
data.phase === Phase.SetupFaction ||
data.phase === Phase.SetupAuction
);
}
get turnOrder (): Player[] {
get turnOrder(): Player[] {
const data = this.gameData;
if (this.phaseBeforeSetupBuilding) {
return data.players;
}
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[] {
return (this.gameData.passedPlayers ?? []).map(player => this.gameData.players[player]);
get passedPlayers(): Player[] {
return (this.gameData.passedPlayers ?? []).map((player) => this.gameData.players[player]);
}
isCurrentPlayer (pl: Player) {
return this.gameData.players[this.gameData.availableCommands?.[0]?.player] === pl && !(this.gameData.phase === Phase.SetupAuction);
isCurrentPlayer(pl: Player) {
return (
this.gameData.players[this.gameData.availableCommands?.[0]?.player] === pl &&
!(this.gameData.phase === Phase.SetupAuction)
);
}
stroke (pl: Player) {
stroke(pl: Player) {
if (this.gameData.players[this.gameData.currentPlayer] === pl) {
if (this.gameData.players[this.gameData.playerToMove] === pl) {
return "stroke-width: 0.16px !important; stroke: #2c4";
@ -83,24 +91,26 @@ export default class TurnOrder extends Vue {
return "stroke-width: 0.06px !important";
}
planetFill (planet: string) {
planetFill(planet: string) {
if (planet === Planet.Titanium || planet === Planet.Swamp) {
return "white";
}
return "black";
}
planet (player: Player, index: number) {
planet(player: Player, index: number) {
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
return factions.planet(this.gameData.setup[index]);
return factionPlanet(this.gameData.setup[index]);
}
if (player.faction) { return factions.planet(player.faction); };
if (player.faction) {
return factionPlanet(player.faction);
}
return Planet.Lost;
}
initial (player: Player, index: number) {
initial(player: Player, index: number) {
if (this.phaseBeforeSetupBuilding && this.gameData.setup[index]) {
return this.gameData.setup[index][0].toUpperCase();
}
@ -112,10 +122,10 @@ export default class TurnOrder extends Vue {
return "?";
}
name (player: Player, index: number) {
name(player: Player, index: number) {
if (this.phaseBeforeSetupBuilding) {
if (this.gameData.phase === Phase.SetupAuction) {
player = this.gameData.players.find(pl => pl.faction === this.gameData.setup[index]);
player = this.gameData.players.find((pl) => pl.faction === this.gameData.setup[index]);
} else {
return "";
}
@ -126,7 +136,7 @@ export default class TurnOrder extends Vue {
return player.name.substring(0, 3);
} else {
return "P" + (player.player + 1);
};
}
}
return "?";