From a1740b3467c6e59786ca7159db8b2a41cdda5c99 Mon Sep 17 00:00:00 2001 From: Settel Date: Sun, 5 Sep 2021 21:30:13 +0200 Subject: [PATCH] revelation: show number of voters --- client/src/components/ReadySet.vue | 2 +- client/src/components/Source.vue | 31 +++++++++++++++++++++++++ client/src/store/round.js | 3 +++ server/src/game/populateGetRoundInfo.go | 6 ++++- server/src/syncdata/syncdata.go | 6 +---- 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/client/src/components/ReadySet.vue b/client/src/components/ReadySet.vue index b8dbc01..4d3abe5 100644 --- a/client/src/components/ReadySet.vue +++ b/client/src/components/ReadySet.vue @@ -127,7 +127,7 @@ export default { 100% { transform: scale(1); } } @keyframes fade-out { - 25% { transform: scale(1.2); } + 25% { transform: scale(1.2); } 100% { transform: scale(0); } } diff --git a/client/src/components/Source.vue b/client/src/components/Source.vue index 05af22b..64e5e4e 100644 --- a/client/src/components/Source.vue +++ b/client/src/components/Source.vue @@ -8,6 +8,11 @@ {{ source.name }} +
+
+ {{ badgeCount }} +
+
@@ -22,6 +27,12 @@ export default { 'source__container__selected': this.isSelected(), } }, + badgeCount() { + const revelation = this.$store.state.round.revelation || {} + const votes = revelation.votes || {} + const list = votes[this.source.id] || [] + return list.length + }, }, methods: { isSelected() { @@ -87,5 +98,25 @@ export default { user-select: none; } + &__badge { + display: flex; + align-items: center; + position: absolute; + right: -12px; + top: -16px; + width: 24px; + height: 24px; + background-color: #6040c0; + border: 2px solid #ffffff; + border-radius: 14px; + color: #c0c060; + font-family: "Wendy One"; + font-size: 16px; + + &-count { + width: 100%; + text-align: center; + } + } } diff --git a/client/src/store/round.js b/client/src/store/round.js index 5c82f05..94ac7d8 100644 --- a/client/src/store/round.js +++ b/client/src/store/round.js @@ -2,6 +2,7 @@ export const state = () => ({ quote: "", sources: [], selections: {}, + revelation: {}, }) export const mutations = { @@ -10,10 +11,12 @@ export const mutations = { state.quote = game.round.quote state.sources = game.round.sources state.selections = game.round.selections + state.revelation = game.round.revelation } else { state.quote = "" state.sources = [] state.selections = {} + state.revelation = {} } }, } diff --git a/server/src/game/populateGetRoundInfo.go b/server/src/game/populateGetRoundInfo.go index 2bfe572..ee4000a 100644 --- a/server/src/game/populateGetRoundInfo.go +++ b/server/src/game/populateGetRoundInfo.go @@ -54,7 +54,11 @@ func (gm *Game) getRevelation() *syncdata.Revelation { return nil } - votes := make(map[string]syncdata.Votes, 0) + votes := make(map[string][]string, 0) + for key, val := range gm.round.selections { + votes[val] = append(votes[val], key) + } + revelation := syncdata.Revelation{ Votes: votes, } diff --git a/server/src/syncdata/syncdata.go b/server/src/syncdata/syncdata.go index 5d8ab0b..b5d6235 100644 --- a/server/src/syncdata/syncdata.go +++ b/server/src/syncdata/syncdata.go @@ -17,12 +17,8 @@ type SourceInfo struct { Name string `json:"name"` } -type Votes struct { - Count int `json:"count"` -} - type Revelation struct { - Votes map[string]Votes `json:"votes"` + Votes map[string][]string `json:"votes"` } type RoundInfo struct {