randomize order of sources

This commit is contained in:
Settel 2021-09-20 16:53:49 +02:00
parent a00931d50a
commit 56bb29611b
2 changed files with 21 additions and 6 deletions

View File

@ -21,7 +21,16 @@ func (gm *Game) nextRound() {
}
gm.notifyClients()
time.Sleep(2 * time.Second)
time.Sleep(1500 * time.Millisecond)
err = gm.changeGameState(STATE_READY_SET, STATE_READY_SET, "")
if err != nil {
fmt.Println(err)
return
}
gm.notifyClients()
time.Sleep(1500 * time.Millisecond)
err = gm.changeGameState(STATE_READY_SET, STATE_PLAY, PHASE_NONE)
if err != nil {

View File

@ -36,18 +36,24 @@ func (gm *Game) selectQuote() {
}
sourceId := q.GetSourceId()
if len(sources) == 12 {
if quote != nil {
break
}
} else {
if !gm.isSourceIdInList(sources, sourceId) {
sources = append(sources, gm.getSourceById(sourceId))
}
if len(sources) == 12 {
break
}
}
gm.mu.Lock()
defer gm.mu.Unlock()
gm.round.quoteId = quote.GetId()
gm.round.sources = sources
gm.round.sources = make([]Source, len(sources))
for idx, idxPerm := range r.Perm(len(sources)) {
gm.round.sources[idx] = sources[idxPerm]
}
}
func (gm *Game) getSourceById(id string) Source {