randomize order of sources
This commit is contained in:
parent
a00931d50a
commit
56bb29611b
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user