functional looking
parent
51c7cc4496
commit
b9d06f81ba
|
|
@ -373,14 +373,13 @@ func (games Games) CreateEventAssignmentRotation(ctx context.Context, id string,
|
||||||
prevAllKillWords[k] = v.KillWords
|
prevAllKillWords[k] = v.KillWords
|
||||||
}
|
}
|
||||||
|
|
||||||
event.AllKillWords.ShuffleAssignees(prevAllKillWords, killer, victim, word)
|
event.AllKillWords = event.AllKillWords.ShuffleAssignees(prevAllKillWords, killer, victim, word)
|
||||||
|
event.AllKillWords = event.AllKillWords.FillKillWords()
|
||||||
event.AllKillWords.FillKillWords()
|
|
||||||
|
|
||||||
return games.createEvent(ctx, id, event)
|
return games.createEvent(ctx, id, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m AllKillWords) ShuffleAssignees(prev AllKillWords, killer, victim, word string) {
|
func (m AllKillWords) ShuffleAssignees(prev AllKillWords, killer, victim, word string) AllKillWords {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
for k := range prev {
|
for k := range prev {
|
||||||
|
|
@ -427,12 +426,12 @@ func (m AllKillWords) ShuffleAssignees(prev AllKillWords, killer, victim, word s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range allKillWords {
|
m = allKillWords
|
||||||
m[k] = v
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}() {
|
}() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m AllKillWords) unassigned() []string {
|
func (m AllKillWords) unassigned() []string {
|
||||||
|
|
@ -461,7 +460,7 @@ func (m AllKillWords) assigned() []string {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m AllKillWords) FillKillWords() {
|
func (m AllKillWords) FillKillWords() AllKillWords {
|
||||||
for k, v := range m {
|
for k, v := range m {
|
||||||
if v.Global.Word == "" {
|
if v.Global.Word == "" {
|
||||||
v.Global = KillWord{Word: m.unusedGlobal(), Points: -1}
|
v.Global = KillWord{Word: m.unusedGlobal(), Points: -1}
|
||||||
|
|
@ -482,6 +481,7 @@ func (m AllKillWords) FillKillWords() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:embed holiday.txt
|
//go:embed holiday.txt
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue