mark quote as played after reveal
This commit is contained in:
parent
dfda2d25cf
commit
47ead87043
@ -15,6 +15,7 @@ func (gm *Game) revealSource() {
|
|||||||
gm.round.revelation.sources[source.id] = false
|
gm.round.revelation.sources[source.id] = false
|
||||||
}
|
}
|
||||||
quote := gm.quotes[gm.round.quoteId]
|
quote := gm.quotes[gm.round.quoteId]
|
||||||
|
quote.SetIsPlayed()
|
||||||
sourceId := quote.GetSourceId()
|
sourceId := quote.GetSourceId()
|
||||||
gm.round.revelation.sources[sourceId] = true
|
gm.round.revelation.sources[sourceId] = true
|
||||||
|
|
||||||
|
@ -29,11 +29,12 @@ func (gm *Game) selectQuote() {
|
|||||||
var quote *quote.Quote
|
var quote *quote.Quote
|
||||||
sources := make([]Source, 0)
|
sources := make([]Source, 0)
|
||||||
|
|
||||||
for idx, quoteIdx := range r.Perm(len(allQuotes)) {
|
for _, quoteIdx := range r.Perm(len(allQuotes)) {
|
||||||
if idx == 0 {
|
q := allQuotes[quoteIdx]
|
||||||
quote = allQuotes[0]
|
if quote == nil && !q.IsPlayed() {
|
||||||
|
quote = q
|
||||||
}
|
}
|
||||||
sourceId := allQuotes[quoteIdx].GetSourceId()
|
sourceId := q.GetSourceId()
|
||||||
|
|
||||||
if !gm.isSourceIdInList(sources, sourceId) {
|
if !gm.isSourceIdInList(sources, sourceId) {
|
||||||
sources = append(sources, gm.getSourceById(sourceId))
|
sources = append(sources, gm.getSourceById(sourceId))
|
||||||
|
@ -24,6 +24,7 @@ func NewQuoteFromFile(fileName string) (*Quote, error) {
|
|||||||
id: id,
|
id: id,
|
||||||
sourceId: quJson.SourceId,
|
sourceId: quJson.SourceId,
|
||||||
quote: quJson.Quote,
|
quote: quJson.Quote,
|
||||||
|
isPlayed: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
return qu, nil
|
return qu, nil
|
||||||
@ -41,3 +42,11 @@ func (qu *Quote) GetSourceId() string {
|
|||||||
func (qu *Quote) GetQuote() string {
|
func (qu *Quote) GetQuote() string {
|
||||||
return qu.quote
|
return qu.quote
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (qu *Quote) IsPlayed() bool {
|
||||||
|
return qu.isPlayed
|
||||||
|
}
|
||||||
|
|
||||||
|
func (qu *Quote) SetIsPlayed() {
|
||||||
|
qu.isPlayed = true
|
||||||
|
}
|
||||||
|
@ -4,6 +4,7 @@ type Quote struct {
|
|||||||
id string
|
id string
|
||||||
sourceId string
|
sourceId string
|
||||||
quote string
|
quote string
|
||||||
|
isPlayed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type QuoteJson struct {
|
type QuoteJson struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user