From 66543303287c236c4d021f7259a8191f089a6d75 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Sat, 19 Oct 2024 17:39:03 +0200 Subject: [PATCH] round end --- src/components/turn/EndRoundButton.vue | 56 +++++++++++++++ src/locales/de.json | 41 ++++++++++- src/locales/en.json | 41 ++++++++++- src/util/NavigationState.ts | 2 +- src/views/RoundEnd.vue | 94 +++++++++++++++++++++++--- src/views/RoundStart.vue | 4 +- src/views/TurnBot.vue | 29 +++++++- src/views/TurnPlayer.vue | 20 +++++- 8 files changed, 264 insertions(+), 23 deletions(-) create mode 100644 src/components/turn/EndRoundButton.vue diff --git a/src/components/turn/EndRoundButton.vue b/src/components/turn/EndRoundButton.vue new file mode 100644 index 0000000..a9f1b0b --- /dev/null +++ b/src/components/turn/EndRoundButton.vue @@ -0,0 +1,56 @@ + + + diff --git a/src/locales/de.json b/src/locales/de.json index a22ff52..1c06f66 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -37,7 +37,7 @@ "title": "Beginn der Epoche", "newCards": { "title": "1) Neue Karten", - "playAsUsual": "Keine Anpassungen." + "noAction": "V.I.C.I macht nichts." }, "newGoals": { "title": "2) Neue Ziele", @@ -48,7 +48,7 @@ }, "extraFind": { "title": "3) Sonderfund", - "playAsUsual": "Keine Anpassungen. V.I.C.I macht keinen Sonderfund." + "noAction": "V.I.C.I macht keinen Sonderfund." } }, "turnPlayer": { @@ -59,11 +59,42 @@ "title": "V.I.C.I" }, "roundEnd": { - "title": "Ende der Epoche" + "title": "Ende der Epoche", + "sitePhase": { + "title": "5) Ortsphase", + "botNotAffected": "V.I.C.I ist nie von Orten betroffen." + }, + "feedingPhase": { + "title": "6) Ernährungsphase", + "feedTribes": { + "title": "A) V.I.C.I Ernährungsphase:" + }, + "scoreStrongTribes": "B) Werte V.I.C.I starke Stämme." + }, + "eventPhase": { + "title": "7) Ereignisphase", + "adjustWeather": "A) V.I.C.I ist nie vom Wetter betroffen.", + "resolveEvent": { + "title": "B) V.I.C.I erhält nie Ereignis-Boni." + }, + "scoreCategory": "C) Werte aktuelle Kategorie für V.I.C.I.", + "startingCivilization": { + "title": "D) Bestimme Startzivilisation:" + } + }, + "incomePhase": { + "title": "8) Einkommensphase", + "scoreStatues": "B) Werte V.I.C.Is Statuen." + }, + "noNextStartPlayer": "Bitte den nächsten Startspieler bestimmen." }, "gameEnd": { "title": "Spielende" }, + "endRoundButton": { + "title": "Aktionsphase beenden", + "confirm": "Soll die Aktionsphase beendet werden?" + }, "sideBar": { "round": "Epoche {round}" }, @@ -74,6 +105,10 @@ "4": "Fortgeschritten", "5": "Schwer" }, + "player": { + "player": "Spieler", + "bot": "V.I.C.I" + }, "notfound": { "title": "Nicht Gefunden" }, diff --git a/src/locales/en.json b/src/locales/en.json index 7ec941e..1704d52 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -37,7 +37,7 @@ "title": "Era Start", "newCards": { "title": "1) New Cards", - "playAsUsual": "Play as usual." + "noAction": "V.I.C.I does nothing." }, "newGoals": { "title": "2) New goals", @@ -48,7 +48,7 @@ }, "extraFind": { "title": "3) Extra find", - "playAsUsual": "Play as usual, V.I.C.I makes no extra find." + "noAction": "V.I.C.I makes no extra find." } }, "turnPlayer": { @@ -59,11 +59,42 @@ "title": "V.I.C.I" }, "roundEnd": { - "title": "Era End" + "title": "Era End", + "sitePhase": { + "title": "5) Site phase", + "botNotAffected": "V.I.C.I is never affected by face-up sites." + }, + "feedingPhase": { + "title": "6) Feeding phase", + "feedTribes": { + "title": "A) V.I.C.I Feeding phase:" + }, + "scoreStrongTribes": "B) Score V.I.C.I's strong tribes." + }, + "eventPhase": { + "title": "7) Event phase", + "adjustWeather": "A) V.I.C.I is never affected by the weather.", + "resolveEvent": { + "title": "B) V.I.C.I never gets event bonuses." + }, + "scoreCategory": "C) Score current category for V.I.C.I.", + "startingCivilization": { + "title": "D) Determine starting civilization:" + } + }, + "incomePhase": { + "title": "8) Income phase", + "scoreStatues": "B) Score V.I.C.I's statues." + }, + "noNextStartPlayer": "Please determine the next start player." }, "gameEnd": { "title": "Game End" }, + "endRoundButton": { + "title": "End Action Phase", + "confirm": "Do you want to end the action phase?" + }, "sideBar": { "round": "Era {round}" }, @@ -74,6 +105,10 @@ "4": "Advanced", "5": "Expert" }, + "player": { + "player": "Player", + "bot": "V.I.C.I" + }, "notfound": { "title": "Not Found" }, diff --git a/src/util/NavigationState.ts b/src/util/NavigationState.ts index 350383d..db0799e 100644 --- a/src/util/NavigationState.ts +++ b/src/util/NavigationState.ts @@ -99,7 +99,7 @@ function getPreviousBotPersistence(state: State, round: number, turn: number) : if (roundData) { const lastBotPersistence = roundData.turns .filter(item => item.turn < turn) - .toSorted((a,b) => a.turn - b.turn) + .toSorted((a,b) => b.turn - a.turn) .map(item => item.botPersistence) .find(item => item != undefined) if (lastBotPersistence) { diff --git a/src/views/RoundEnd.vue b/src/views/RoundEnd.vue index 93f9274..133405f 100644 --- a/src/views/RoundEnd.vue +++ b/src/views/RoundEnd.vue @@ -3,15 +3,58 @@

{{t('roundEnd.title')}}

-

5) Site phase

+

+

-

6) Feeding phase

+

+ -

7) Event phase

+

+ -

8) Income phase

+

+ - @@ -23,9 +66,11 @@ import { defineComponent } from 'vue' import { useI18n } from 'vue-i18n' import FooterButtons from '@/components/structure/FooterButtons.vue' import { useRoute } from 'vue-router' -import { useStateStore } from '@/store/state' +import { Round, useStateStore } from '@/store/state' import SideBar from '@/components/turn/SideBar.vue' import NavigationState from '@/util/NavigationState' +import Player from '@/services/enum/Player' +import getAllEnumValues from '@brdgm/brdgm-commons/src/util/enum/getAllEnumValues' export default defineComponent({ name: 'RoundStart', @@ -43,27 +88,56 @@ export default defineComponent({ return { t, state, navigationState, round } }, + data() { + return { + nextStartPlayer: undefined as Player|undefined + } + }, computed: { backButtonRouteTo() : string { const roundData = this.state.rounds.find(item => item.round === this.round) if (roundData) { - const lastTurn = roundData.turns.toSorted((a,b) => a.turn - b.turn)[0] + const lastTurn = roundData.turns.toSorted((a,b) => b.turn - a.turn)[0] if (lastTurn) { return `/round/${lastTurn.round}/turn/${lastTurn.turn}/${lastTurn.player}` } } return '' + }, + isLastRound() : boolean { + return this.round == 4 + }, + nextStartPlayerMissing() : boolean { + return this.nextStartPlayer === undefined && !this.isLastRound + }, + playerOptions() : Player[] { + return getAllEnumValues(Player) } }, methods: { next() : void { - if (this.round < 4) { - this.$router.push(`/round/${this.round+1}/start`) + if (this.isLastRound) { + this.$router.push(`/gameEnd`) } else { - this.$router.push(`/gameEnd`) + const round : Round = { + round: this.round+1, + startPlayer: this.nextStartPlayer ?? Player.PLAYER, + turns: [] + } + this.state.storeRound(round) + this.$router.push(`/round/${this.round+1}/start`) } } } }) + + diff --git a/src/views/RoundStart.vue b/src/views/RoundStart.vue index d024a3d..587ba73 100644 --- a/src/views/RoundStart.vue +++ b/src/views/RoundStart.vue @@ -4,7 +4,7 @@

{{t('roundStart.title')}}

-

+

    @@ -16,7 +16,7 @@

-

+

+ @@ -17,16 +18,18 @@ import { defineComponent } from 'vue' import { useI18n } from 'vue-i18n' import FooterButtons from '@/components/structure/FooterButtons.vue' -import { useStateStore } from '@/store/state' +import { Turn, useStateStore } from '@/store/state' import { useRoute } from 'vue-router' import SideBar from '@/components/turn/SideBar.vue' import NavigationState from '@/util/NavigationState' +import EndRoundButton from '@/components/turn/EndRoundButton.vue' export default defineComponent({ name: 'TurnBot', components: { FooterButtons, - SideBar + SideBar, + EndRoundButton }, setup() { const { t } = useI18n() @@ -47,8 +50,30 @@ export default defineComponent({ } }, methods: { + saveTurn() : void { + const { player, cardDeck, evolutionCount, prosperityCount, actionRoll, territoryRoll, beaconRoll } = this.navigationState + const turn : Turn = { + round: this.round, + turn: this.turn, + player, + botPersistence: { + cardDeck: cardDeck.toPersistence(), + evolutionCount, + prosperityCount, + actionRoll, + territoryRoll, + beaconRoll + } + } + this.state.storeTurn(turn) + }, next() : void { + this.saveTurn() this.$router.push(`/round/${this.round}/turn/${this.turn+1}/player`) + }, + endRound() : void { + this.saveTurn() + this.$router.push(`/round/${this.round}/end`) } } }) diff --git a/src/views/TurnPlayer.vue b/src/views/TurnPlayer.vue index 3f199eb..d2c3e1f 100644 --- a/src/views/TurnPlayer.vue +++ b/src/views/TurnPlayer.vue @@ -10,6 +10,7 @@ + @@ -19,15 +20,17 @@ import { defineComponent } from 'vue' import { useI18n } from 'vue-i18n' import FooterButtons from '@/components/structure/FooterButtons.vue' import { useRoute } from 'vue-router' -import { useStateStore } from '@/store/state' +import { Turn, useStateStore } from '@/store/state' import SideBar from '@/components/turn/SideBar.vue' import NavigationState from '@/util/NavigationState' +import EndRoundButton from '@/components/turn/EndRoundButton.vue' export default defineComponent({ name: 'TurnPlayer', components: { FooterButtons, - SideBar + SideBar, + EndRoundButton }, setup() { const { t } = useI18n() @@ -48,8 +51,21 @@ export default defineComponent({ } }, methods: { + saveTurn() : void { + const turn : Turn = { + round: this.round, + turn: this.turn, + player: this.navigationState.player + } + this.state.storeTurn(turn) + }, next() : void { + this.saveTurn() this.$router.push(`/round/${this.round}/turn/${this.turn+1}/bot`) + }, + endRound() : void { + this.saveTurn() + this.$router.push(`/round/${this.round}/end`) } } })