functional looking
parent
b9d06f81ba
commit
ff5071215a
|
|
@ -373,23 +373,16 @@ func (games Games) CreateEventAssignmentRotation(ctx context.Context, id string,
|
||||||
prevAllKillWords[k] = v.KillWords
|
prevAllKillWords[k] = v.KillWords
|
||||||
}
|
}
|
||||||
|
|
||||||
event.AllKillWords = event.AllKillWords.ShuffleAssignees(prevAllKillWords, killer, victim, word)
|
event.AllKillWords = prev.ShuffleAssignees(killer, victim, word)
|
||||||
event.AllKillWords = event.AllKillWords.FillKillWords()
|
event.AllKillWords = 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) AllKillWords {
|
func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWords {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
for k := range prev {
|
m := prev.withoutAssignees()
|
||||||
m[k] = KillWords{
|
|
||||||
Global: prev[k].Global,
|
|
||||||
Assigned: now,
|
|
||||||
Assignee: "",
|
|
||||||
Assignment: prev[k].Assignment,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if killerState, ok := prev[killer]; !ok {
|
if killerState, ok := prev[killer]; !ok {
|
||||||
} else if victimState, ok := prev[victim]; !ok {
|
} else if victimState, ok := prev[victim]; !ok {
|
||||||
|
|
@ -434,6 +427,19 @@ func (m AllKillWords) ShuffleAssignees(prev AllKillWords, killer, victim, word s
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m AllKillWords) withoutAssignees() AllKillWords {
|
||||||
|
result := make(AllKillWords)
|
||||||
|
for k := range m {
|
||||||
|
result[k] = KillWords{
|
||||||
|
Global: m[k].Global,
|
||||||
|
Assigned: now,
|
||||||
|
Assignee: "",
|
||||||
|
Assignment: m[k].Assignment,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func (m AllKillWords) unassigned() []string {
|
func (m AllKillWords) unassigned() []string {
|
||||||
var result []string
|
var result []string
|
||||||
for k := range m {
|
for k := range m {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue