mark quote as played after reveal

This commit is contained in:
Settel 2021-09-17 23:40:15 +02:00
parent dfda2d25cf
commit 47ead87043
4 changed files with 16 additions and 4 deletions

View File

@ -15,6 +15,7 @@ func (gm *Game) revealSource() {
gm.round.revelation.sources[source.id] = false
}
quote := gm.quotes[gm.round.quoteId]
quote.SetIsPlayed()
sourceId := quote.GetSourceId()
gm.round.revelation.sources[sourceId] = true

View File

@ -29,11 +29,12 @@ func (gm *Game) selectQuote() {
var quote *quote.Quote
sources := make([]Source, 0)
for idx, quoteIdx := range r.Perm(len(allQuotes)) {
if idx == 0 {
quote = allQuotes[0]
for _, quoteIdx := range r.Perm(len(allQuotes)) {
q := allQuotes[quoteIdx]
if quote == nil && !q.IsPlayed() {
quote = q
}
sourceId := allQuotes[quoteIdx].GetSourceId()
sourceId := q.GetSourceId()
if !gm.isSourceIdInList(sources, sourceId) {
sources = append(sources, gm.getSourceById(sourceId))

View File

@ -24,6 +24,7 @@ func NewQuoteFromFile(fileName string) (*Quote, error) {
id: id,
sourceId: quJson.SourceId,
quote: quJson.Quote,
isPlayed: false,
}
return qu, nil
@ -41,3 +42,11 @@ func (qu *Quote) GetSourceId() string {
func (qu *Quote) GetQuote() string {
return qu.quote
}
func (qu *Quote) IsPlayed() bool {
return qu.isPlayed
}
func (qu *Quote) SetIsPlayed() {
qu.isPlayed = true
}

View File

@ -4,6 +4,7 @@ type Quote struct {
id string
sourceId string
quote string
isPlayed bool
}
type QuoteJson struct {