refactor making new AllKillWords just without assignees and now
parent
ff5071215a
commit
ae593bc092
|
|
@ -365,7 +365,6 @@ func (games Games) CreateEventAssignmentRotation(ctx context.Context, id string,
|
|||
Word: word,
|
||||
Points: points,
|
||||
},
|
||||
AllKillWords: make(AllKillWords),
|
||||
}
|
||||
|
||||
prevAllKillWords := make(AllKillWords)
|
||||
|
|
@ -373,15 +372,13 @@ func (games Games) CreateEventAssignmentRotation(ctx context.Context, id string,
|
|||
prevAllKillWords[k] = v.KillWords
|
||||
}
|
||||
|
||||
event.AllKillWords = prev.ShuffleAssignees(killer, victim, word)
|
||||
event.AllKillWords = prevAllKillWords.ShuffleAssignees(killer, victim, word)
|
||||
event.AllKillWords = event.AllKillWords.FillKillWords()
|
||||
|
||||
return games.createEvent(ctx, id, event)
|
||||
}
|
||||
|
||||
func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWords {
|
||||
now := time.Now()
|
||||
|
||||
m := prev.withoutAssignees()
|
||||
|
||||
if killerState, ok := prev[killer]; !ok {
|
||||
|
|
@ -411,12 +408,8 @@ func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWo
|
|||
if k == assignee || prev[k].Assignee == assignee {
|
||||
return false
|
||||
}
|
||||
allKillWords[k] = KillWords{
|
||||
Global: v.Global,
|
||||
Assigned: now,
|
||||
Assignee: assignee,
|
||||
Assignment: v.Assignment,
|
||||
}
|
||||
v.Assignee = assignee
|
||||
allKillWords[k] = v
|
||||
}
|
||||
|
||||
m = allKillWords
|
||||
|
|
@ -428,6 +421,7 @@ func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWo
|
|||
}
|
||||
|
||||
func (m AllKillWords) withoutAssignees() AllKillWords {
|
||||
now := time.Now()
|
||||
result := make(AllKillWords)
|
||||
for k := range m {
|
||||
result[k] = KillWords{
|
||||
|
|
|
|||
Loading…
Reference in New Issue