Skip to content

Commit

Permalink
round end
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Oct 19, 2024
1 parent 20398ab commit 6654330
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 23 deletions.
56 changes: 56 additions & 0 deletions src/components/turn/EndRoundButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<template v-if="isNotStartPlayer">
<button class="btn btn-secondary btn mt-4 ms-2" data-bs-toggle="modal" data-bs-target="#endRoundModal">
{{t('endRoundButton.title')}}
</button>
<ModalDialog id="endRoundModal" :title="t('endRoundButton.title')">
<template #body>
<p v-html="t('endRoundButton.confirm', {round})"></p>
</template>
<template #footer>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" @click="endRound()">{{t('endRoundButton.title')}}</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{t('action.cancel')}}</button>
</template>
</ModalDialog>
</template>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue'
import { useI18n } from 'vue-i18n'
import { useStateStore } from '@/store/state'
import NavigationState from '@/util/NavigationState'
import ModalDialog from '@brdgm/brdgm-commons/src/components/structure/ModalDialog.vue'
export default defineComponent({
name: 'EndRoundButton',
components: {
ModalDialog
},
emits: ['endRound'],
setup() {
const { t } = useI18n()
const state = useStateStore()
return { t, state }
},
props: {
navigationState: {
type: Object as PropType<NavigationState>,
required: true
}
},
computed: {
round() : number {
return this.navigationState.round
},
isNotStartPlayer() : boolean {
return this.navigationState.player != this.navigationState.startPlayer
}
},
methods: {
endRound() : void {
this.$emit('endRound')
}
}
})
</script>
41 changes: 38 additions & 3 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand All @@ -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}"
},
Expand All @@ -74,6 +105,10 @@
"4": "Fortgeschritten",
"5": "Schwer"
},
"player": {
"player": "Spieler",
"bot": "V.I.C.I"
},
"notfound": {
"title": "Nicht Gefunden"
},
Expand Down
41 changes: 38 additions & 3 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand All @@ -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}"
},
Expand All @@ -74,6 +105,10 @@
"4": "Advanced",
"5": "Expert"
},
"player": {
"player": "Player",
"bot": "V.I.C.I"
},
"notfound": {
"title": "Not Found"
},
Expand Down
2 changes: 1 addition & 1 deletion src/util/NavigationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
94 changes: 84 additions & 10 deletions src/views/RoundEnd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,58 @@

<h1 class="mb-3">{{t('roundEnd.title')}}</h1>

<h3>5) Site phase</h3>
<h3 v-html="t('roundEnd.sitePhase.title')"></h3>
<p v-html="t('roundEnd.sitePhase.botNotAffected')"></p>

<h3>6) Feeding phase</h3>
<h3 v-html="t('roundEnd.feedingPhase.title')"></h3>
<ul>
<li v-html="t('roundEnd.feedingPhase.feedTribes.title')"></li>
<ul>
<li class="fst-italic">TODO: Perform 1 provision action.</li>
<li class="fst-italic">TODO: Feed/weaken tribes.</li>
</ul>
<li v-html="t('roundEnd.feedingPhase.scoreStrongTribes')"></li>
</ul>

<h3>7) Event phase</h3>
<h3 v-html="t('roundEnd.eventPhase.title')"></h3>
<ul>
<li v-html="t('roundEnd.eventPhase.adjustWeather')"></li>
<li v-html="t('roundEnd.eventPhase.resolveEvent.title')"></li>
<ul>
<li class="fst-italic">TODO: Take V.I.C.I into accounts for determining your bonus.</li>
</ul>
<li v-html="t('roundEnd.eventPhase.scoreCategory')"></li>
<template v-if="!isLastRound">
<li v-html="t('roundEnd.eventPhase.startingCivilization.title')"></li>
<ul>
<li>
<span class="me-2 fw-bold">
Next start player:
</span>
<div class="form-check form-check-inline" v-for="player in playerOptions" :key="player">
<label class="form-check-label fw-bold">
<input class="form-check-input" type="radio" :value="player" v-model="nextStartPlayer" name="nextStartPlayer">
{{t(`player.${player}`)}}
</label>
</div>
</li>
</ul>
</template>
</ul>

<h3>8) Income phase</h3>
<h3 v-html="t('roundEnd.incomePhase.title')"></h3>
<ul>
<li v-html="t('roundEnd.incomePhase.scoreStatues')"></li>
</ul>

<button class="btn btn-primary btn-lg mt-4" @click="next()">
<div v-if="nextStartPlayerMissing" class="container-fluid">
<div class="row">
<div class="col alert alert-info">
{{t('roundEnd.noNextStartPlayer')}}
</div>
</div>
</div>
<button v-else class="btn btn-primary btn-lg mt-4" @click="next()">
{{t('action.next')}}
</button>

Expand All @@ -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',
Expand All @@ -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`)
}
}
}
})
</script>

<style lang="scss" scoped>
ul > li {
margin-top: 0.5rem;
}
ul > ul > li {
margin-top: 0;
}
</style>
4 changes: 2 additions & 2 deletions src/views/RoundStart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1 class="mb-3">{{t('roundStart.title')}}</h1>

<h3 v-html="t('roundStart.newCards.title')"></h3>
<p v-html="t('roundStart.newCards.playAsUsual')"></p>
<p v-html="t('roundStart.newCards.noAction')"></p>

<h3 v-html="t('roundStart.newGoals.title')"></h3>
<ol>
Expand All @@ -16,7 +16,7 @@
</ol>

<h3 v-html="t('roundStart.extraFind.title')"></h3>
<p v-html="t('roundStart.extraFind.playAsUsual')"></p>
<p v-html="t('roundStart.extraFind.noAction')"></p>

<button class="btn btn-primary btn-lg mt-4" @click="next()">
{{t('action.next')}}
Expand Down
Loading

0 comments on commit 6654330

Please sign in to comment.