From be0279fe89d6fdfd0ce23be511dd43acb94660e6 Mon Sep 17 00:00:00 2001 From: Settel Date: Fri, 27 Aug 2021 14:43:14 +0200 Subject: [PATCH] select source --- client/src/components/PlayerList.vue | 7 +-- client/src/components/Source.vue | 65 +++++++++++++++++++++------ client/src/store/selection.js | 22 +++++++++ server/src/game/populateSyncDataCb.go | 10 ++++- server/src/game/runRound.go | 22 ++++----- server/src/game/struct.go | 7 ++- server/src/syncdata/syncdata.go | 9 +++- 7 files changed, 111 insertions(+), 31 deletions(-) create mode 100644 client/src/store/selection.js diff --git a/client/src/components/PlayerList.vue b/client/src/components/PlayerList.vue index 7cb26e6..729d2f1 100644 --- a/client/src/components/PlayerList.vue +++ b/client/src/components/PlayerList.vue @@ -5,7 +5,7 @@ {{ player.isIdle ? '◯' : '⬤' }}
- {{ player.name + player.name + player.name + player.name }} + {{ player.name }}
{{ player.score || 0 }} @@ -24,6 +24,7 @@ export default { .player-list { padding: 8px 16px; border: 1px solid #ffffff; + border-radius: 10px; background-color: rgba(64, 32, 128, 0.5); &__player { @@ -31,7 +32,7 @@ export default { // height: 1.4em; color: #ffffff; font-family: Dosis; - font-size: 12px; + font-size: 18px; &-name { display: inline; @@ -42,7 +43,7 @@ export default { } &-status { margin-right: 8px; - font-size: 8px; + font-size: 12px; } &-score { width: 32px; diff --git a/client/src/components/Source.vue b/client/src/components/Source.vue index 8a58291..7f8f6b9 100644 --- a/client/src/components/Source.vue +++ b/client/src/components/Source.vue @@ -1,7 +1,12 @@ @@ -9,32 +14,66 @@ diff --git a/client/src/store/selection.js b/client/src/store/selection.js new file mode 100644 index 0000000..88f4549 --- /dev/null +++ b/client/src/store/selection.js @@ -0,0 +1,22 @@ +export const state = () => ({ + selection: {}, +}) + +export const mutations = { + select(state, id) { + state.selection = { + ...state.selection, + [id]: true, + } + }, + unselect(state, id) { + var selection = state.selection + delete selection[id] + state.selection = { + ...selection + } + }, + clearSelection(state) { + state.selection = {} + }, +} diff --git a/server/src/game/populateSyncDataCb.go b/server/src/game/populateSyncDataCb.go index 4d414d2..d8543f2 100644 --- a/server/src/game/populateSyncDataCb.go +++ b/server/src/game/populateSyncDataCb.go @@ -53,9 +53,17 @@ func (gm *Game) getRoundInfo() *syncdata.RoundInfo { return nil } + sources := make([]syncdata.SourceInfo, 0) + for _, source := range gm.round.sources { + sources = append(sources, syncdata.SourceInfo{ + Id: source.id, + Name: source.name, + }) + } + roundInfo := syncdata.RoundInfo{ Quote: quote.GetQuote(), - Sources: gm.round.sources, + Sources: sources, } return &roundInfo diff --git a/server/src/game/runRound.go b/server/src/game/runRound.go index 6164ee3..e51bd2f 100644 --- a/server/src/game/runRound.go +++ b/server/src/game/runRound.go @@ -26,16 +26,16 @@ func (gm *Game) selectQuote() { defer gm.mu.Unlock() gm.round.quoteId = "455df6bc-070d-4728-83ab-481ceafa8590" - gm.round.sources = []string{ - "Herbert Grönemeyer", - "Frank Sinatra", - "Gaius Julius Cäsar", - "Thomas Alva Edison", - "Konfuzius", - "George W. Bush jun.", - // "Plato", - // "Chrisoph Kolumbus", - // "Neil Armstrong", - "Max Planck", + gm.round.sources = []Source{ + {id: "cbc34770-3686-45ee-93bd-c5521e276e21", name: "Herbert Grönemeyer"}, + {id: "f0422e15-59c7-480b-adea-9e54f8471f02", name: "Frank Sinatra"}, + {id: "22915112-836e-4a11-b66c-a38a0e0f87b2", name: "Gaius Julius Cäsar"}, + {id: "f17065b7-88e7-4777-bc48-15770a5b7c83", name: "Thomas Alva Edison"}, + {id: "b6b3cd30-1d52-4e62-a0bd-bf3847c5c396", name: "Konfuzius"}, + {id: "c3fc2091-ae0e-433d-b4c3-215a5b57b2b7", name: "George W. Bush jun."}, + {id: "49514b62-96cf-4ee0-a59a-154c23b7df53", name: "Plato"}, + {id: "7545ee0f-0447-4c15-adc2-87d85304aeea", name: "Chrisoph Kolumbus"}, + {id: "dc20b5f1-23bc-4d80-ab2e-f3caa005064a", name: "Neil Armstrong"}, + {id: "2b9fbc3c-589f-4176-8708-cc8239e19a4f", name: "Max Planck"}, } } diff --git a/server/src/game/struct.go b/server/src/game/struct.go index c118a95..c28a11f 100644 --- a/server/src/game/struct.go +++ b/server/src/game/struct.go @@ -25,9 +25,14 @@ type playerInfo struct { isIdle bool } +type Source struct { + id string + name string +} + type Round struct { quoteId string - sources []string + sources []Source } type Game struct { diff --git a/server/src/syncdata/syncdata.go b/server/src/syncdata/syncdata.go index 5d496f6..7f2e796 100644 --- a/server/src/syncdata/syncdata.go +++ b/server/src/syncdata/syncdata.go @@ -6,9 +6,14 @@ type PlayerInfo struct { IsIdle bool `json:"isIdle"` } +type SourceInfo struct { + Id string `json:"id"` + Name string `json:"name"` +} + type RoundInfo struct { - Quote string `json:"quote"` - Sources []string `json:"sources"` + Quote string `json:"quote"` + Sources []SourceInfo `json:"sources"` } type GameInfo struct {