feat: show who has voted in play mode
refactor: move all types to engine.d.ts
This commit is contained in:
parent
4b85bdd196
commit
cb5895d8d8
@ -4,20 +4,17 @@
|
|||||||
{{ $t('waiting-for-gamemaster') }}
|
{{ $t('waiting-for-gamemaster') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="lobby__players-list">
|
<div class="lobby__players-list">
|
||||||
<PlayerList :players="players" :hide-scores="true" />
|
<PlayerList :show-score="false" :show-checkbox="false" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import useI18n from '@/composables/useI18n'
|
import useI18n from '@/composables/useI18n'
|
||||||
import { usePlayersStore } from '@/stores/PlayersStore'
|
|
||||||
|
|
||||||
const { $t } = useI18n({
|
const { $t } = useI18n({
|
||||||
'waiting-for-gamemaster': { en: 'waiting for gamemaster to start the game ...', de: 'warten, bis der/die Gamemaster:in das Spiel startet ...'},
|
'waiting-for-gamemaster': { en: 'waiting for gamemaster to start the game ...', de: 'warten, bis der/die Gamemaster:in das Spiel startet ...'},
|
||||||
})
|
})
|
||||||
|
|
||||||
const players = usePlayersStore().players
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@ -1,30 +1,27 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="['player__row', { 'player__row__idle': player.isIdle }]">
|
<div :class="['player__row', { 'player__row__idle': player.isIdle }]">
|
||||||
<div class="player__status">
|
<div class="player__status">
|
||||||
<span v-if="isPhaseSelectQuote">{{ hasSelected ? '☑' : '☐' }}</span>
|
<span v-if="showCheckbox">{{ checked ? '☑' : '☐' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="player__name">
|
<div class="player__name">
|
||||||
{{ player.name }}
|
{{ player.name }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!hideScore" class="player__score">
|
<div v-if="showScore" class="player__score">
|
||||||
{{ player.score || 0 }}
|
{{ player.score || 0 }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { Player } from '@/composables/engine.d';
|
||||||
import { Player } from '@/stores/PlayersStore';
|
|
||||||
import { useGameinfoStore } from "@/stores/GameinfoStore"
|
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
player: Player,
|
player: Player,
|
||||||
hideScore?: boolean,
|
showScore?: boolean,
|
||||||
|
showCheckbox?: boolean,
|
||||||
|
checked?: boolean,
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const game = useGameinfoStore()
|
|
||||||
const isPhaseSelectQuote = computed(() => game.state === 'play' && game.phase === 'select-quote')
|
|
||||||
const hasSelected = computed(() => false) // return this.$store.state.round.selections[this.player.id]
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@ -1,18 +1,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="player-list">
|
<div class="player-list">
|
||||||
<div v-for="player in players" :key="player.id">
|
<div v-for="player in players" :key="player.id">
|
||||||
<Player :player="player" :hide-score="hideScores" />
|
<Player :player="player" :show-score="showScore" :show-checkbox="showCheckbox" :checked="round.selections[player.id]" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Players } from '@/stores/PlayersStore'
|
import { usePlayersStore } from '@/stores/PlayersStore'
|
||||||
|
import { useRoundStore } from '@/stores/RoundStore'
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
players: Players,
|
showScore?: boolean,
|
||||||
hideScores?: boolean,
|
showCheckbox?: boolean,
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const players = usePlayersStore().players
|
||||||
|
const round = useRoundStore().round
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@ -11,19 +11,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="playground__players-list">
|
<div class="playground__players-list">
|
||||||
<PlayerList :players="players" />
|
<PlayerList :show-score="true" :show-checkbox="playerListShowCheckbox" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import type { Quote, Source } from '@/composables/engine.d'
|
import type { Quote, Source } from '@/composables/engine.d'
|
||||||
import { usePlayersStore } from '@/stores/PlayersStore'
|
|
||||||
import { useRoundStore } from '@/stores/RoundStore'
|
import { useRoundStore } from '@/stores/RoundStore'
|
||||||
import useEngine from '@/composables/useEngine'
|
import useEngine from '@/composables/useEngine'
|
||||||
|
import { useGameinfoStore } from "@/stores/GameinfoStore"
|
||||||
const players = usePlayersStore().players
|
|
||||||
|
|
||||||
const round = useRoundStore().round
|
const round = useRoundStore().round
|
||||||
const quote = { quote: round.quote } as Quote
|
const quote = { quote: round.quote } as Quote
|
||||||
@ -38,6 +36,9 @@ const selectSource = async (source: Source): Promise<void> => {
|
|||||||
selection.value = source.id
|
selection.value = source.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const game = useGameinfoStore()
|
||||||
|
const playerListShowCheckbox = computed(() => game.state === 'play' && game.phase === 'select-quote')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
35
client/src/composables/engine.d.ts
vendored
35
client/src/composables/engine.d.ts
vendored
@ -1,3 +1,12 @@
|
|||||||
|
export type Player = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
isIdle: boolean
|
||||||
|
score: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Players = Array<Player>
|
||||||
|
|
||||||
export type Quote = {
|
export type Quote = {
|
||||||
id: string
|
id: string
|
||||||
quote: string
|
quote: string
|
||||||
@ -11,3 +20,29 @@ export type Source = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type Sources = Array<Sources>
|
export type Sources = Array<Sources>
|
||||||
|
|
||||||
|
export type Selection = {
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Selections = Array<Selection>
|
||||||
|
|
||||||
|
export type RevelationVotes = {
|
||||||
|
[key: string]: Array<string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RevelationSources = {
|
||||||
|
[key: string]: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Revelations = {
|
||||||
|
votes: RevelationVotes
|
||||||
|
sources: RevelationSources
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Round = {
|
||||||
|
quote: string
|
||||||
|
sources: Sources
|
||||||
|
selections: Selections
|
||||||
|
revelations: Revelations
|
||||||
|
}
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
import { Players } from '@/composables/engine.d';
|
||||||
export type Player = {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
isIdle: boolean
|
|
||||||
score: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Players = Array<Player>
|
|
||||||
|
|
||||||
export const usePlayersStore = defineStore('PlayersStore', {
|
export const usePlayersStore = defineStore('PlayersStore', {
|
||||||
state: () => {
|
state: () => {
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
import type { Round, Sources, Selections, RevelationVotes, RevelationSources } from '@/composables/engine.d'
|
||||||
export type Source = {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Round = {
|
|
||||||
quote: string
|
|
||||||
sources: Array<Source>
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useRoundStore = defineStore('RoundStore', {
|
export const useRoundStore = defineStore('RoundStore', {
|
||||||
state: () => {
|
state: () => {
|
||||||
@ -16,14 +7,22 @@ export const useRoundStore = defineStore('RoundStore', {
|
|||||||
round: {
|
round: {
|
||||||
quote: '',
|
quote: '',
|
||||||
sources: [],
|
sources: [],
|
||||||
|
selections: [],
|
||||||
|
revelations: {
|
||||||
|
votes: {},
|
||||||
|
sources: {},
|
||||||
|
},
|
||||||
} as Round,
|
} as Round,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setRound(round: Round): void {
|
setRound(round: Round): void {
|
||||||
round = round || {} as Round
|
round = round || {} as Round
|
||||||
this.round.quote = round.quote
|
this.round.quote = round.quote || ''
|
||||||
this.round.sources = round.sources
|
this.round.sources = round.sources || [] as Sources
|
||||||
|
this.round.selections = round.selections || [] as Selections
|
||||||
|
this.round.revelations.votes = round.revelations?.votes || {} as RevelationVotes
|
||||||
|
this.round.revelations.sources = round.revelations?.sources || {} as RevelationSources
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user