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,
|
Word: word,
|
||||||
Points: points,
|
Points: points,
|
||||||
},
|
},
|
||||||
AllKillWords: make(AllKillWords),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prevAllKillWords := make(AllKillWords)
|
prevAllKillWords := make(AllKillWords)
|
||||||
|
|
@ -373,15 +372,13 @@ func (games Games) CreateEventAssignmentRotation(ctx context.Context, id string,
|
||||||
prevAllKillWords[k] = v.KillWords
|
prevAllKillWords[k] = v.KillWords
|
||||||
}
|
}
|
||||||
|
|
||||||
event.AllKillWords = prev.ShuffleAssignees(killer, victim, word)
|
event.AllKillWords = prevAllKillWords.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 (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWords {
|
func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWords {
|
||||||
now := time.Now()
|
|
||||||
|
|
||||||
m := prev.withoutAssignees()
|
m := prev.withoutAssignees()
|
||||||
|
|
||||||
if killerState, ok := prev[killer]; !ok {
|
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 {
|
if k == assignee || prev[k].Assignee == assignee {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
allKillWords[k] = KillWords{
|
v.Assignee = assignee
|
||||||
Global: v.Global,
|
allKillWords[k] = v
|
||||||
Assigned: now,
|
|
||||||
Assignee: assignee,
|
|
||||||
Assignment: v.Assignment,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m = allKillWords
|
m = allKillWords
|
||||||
|
|
@ -428,6 +421,7 @@ func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m AllKillWords) withoutAssignees() AllKillWords {
|
func (m AllKillWords) withoutAssignees() AllKillWords {
|
||||||
|
now := time.Now()
|
||||||
result := make(AllKillWords)
|
result := make(AllKillWords)
|
||||||
for k := range m {
|
for k := range m {
|
||||||
result[k] = KillWords{
|
result[k] = KillWords{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue