From cd020e4a31428a366968ce5466d8d2625b1f12ea Mon Sep 17 00:00:00 2001 From: Settel Date: Mon, 6 Sep 2021 21:56:52 +0200 Subject: [PATCH] revelation of the source --- server/src/game/populateGetRoundInfo.go | 3 ++- server/src/game/revealSource.go | 10 ++++++++++ server/src/game/runRound.go | 3 ++- server/src/game/struct.go | 3 ++- server/src/syncdata/syncdata.go | 3 ++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/server/src/game/populateGetRoundInfo.go b/server/src/game/populateGetRoundInfo.go index fa442d8..edd3f2e 100644 --- a/server/src/game/populateGetRoundInfo.go +++ b/server/src/game/populateGetRoundInfo.go @@ -51,7 +51,8 @@ func (gm *Game) getSelections() map[string]bool { func (gm *Game) getRevelation() *syncdata.Revelation { revelation := syncdata.Revelation{ - Votes: gm.round.revelation.votes, + Votes: gm.round.revelation.votes, + Sources: gm.round.revelation.sources, } return &revelation diff --git a/server/src/game/revealSource.go b/server/src/game/revealSource.go index 9862ae5..c8e8b42 100644 --- a/server/src/game/revealSource.go +++ b/server/src/game/revealSource.go @@ -9,5 +9,15 @@ func (gm *Game) revealSource() { fmt.Println(err) return } + + gm.mu.Lock() + for _, source := range gm.round.sources { + gm.round.revelation.sources[source.id] = false + } + gm.round.revelation.sources["f17065b7-88e7-4777-bc48-15770a5b7c83"] = true + // quote := gm.quotes[gm.round.quoteId] + // gm.round.revelation.sources[quote.GetSourceId()] = true + gm.mu.Unlock() + gm.notifyClients() } diff --git a/server/src/game/runRound.go b/server/src/game/runRound.go index 0166b4e..8922261 100644 --- a/server/src/game/runRound.go +++ b/server/src/game/runRound.go @@ -29,7 +29,8 @@ func (gm *Game) setupRound() { gm.round = Round{ selections: make(map[string]string, 0), revelation: Revelation{ - votes: make(map[string][]string, 0), + votes: make(map[string][]string, 0), + sources: make(map[string]bool, 0), }, } } diff --git a/server/src/game/struct.go b/server/src/game/struct.go index 500aaef..fe8aaa4 100644 --- a/server/src/game/struct.go +++ b/server/src/game/struct.go @@ -39,7 +39,8 @@ type Source struct { } type Revelation struct { - votes map[string][]string + votes map[string][]string + sources map[string]bool } type Round struct { diff --git a/server/src/syncdata/syncdata.go b/server/src/syncdata/syncdata.go index b5d6235..18af840 100644 --- a/server/src/syncdata/syncdata.go +++ b/server/src/syncdata/syncdata.go @@ -18,7 +18,8 @@ type SourceInfo struct { } type Revelation struct { - Votes map[string][]string `json:"votes"` + Votes map[string][]string `json:"votes"` + Sources map[string]bool `json:"sources"` } type RoundInfo struct {