functional looking

main
Bel LaPointe 2024-12-15 09:49:09 -07:00
parent b9d06f81ba
commit ff5071215a
1 changed files with 16 additions and 10 deletions

View File

@ -373,23 +373,16 @@ func (games Games) CreateEventAssignmentRotation(ctx context.Context, id string,
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()
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()
for k := range prev {
m[k] = KillWords{
Global: prev[k].Global,
Assigned: now,
Assignee: "",
Assignment: prev[k].Assignment,
}
}
m := prev.withoutAssignees()
if killerState, ok := prev[killer]; !ok {
} else if victimState, ok := prev[victim]; !ok {
@ -434,6 +427,19 @@ func (m AllKillWords) ShuffleAssignees(prev AllKillWords, killer, victim, word s
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 {
var result []string
for k := range m {