killing them 200 line functions one at a time

main
Bel LaPointe 2024-12-15 09:55:08 -07:00
parent d05ab6d0ec
commit 6340469d53
1 changed files with 17 additions and 7 deletions

View File

@ -381,12 +381,10 @@ func (games Games) CreateEventAssignmentRotation(ctx context.Context, id string,
func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWords {
m := prev.withoutAssignees()
if killerState, ok := prev[killer]; !ok {
if _, ok := prev[killer]; !ok {
} else if victimState, ok := prev[victim]; !ok {
} else {
v := m[killer]
v.Assignee = victimState.Assignee
m[killer] = v
m.assign(killer, victimState.Assignee)
}
for !func() bool {
@ -399,14 +397,20 @@ func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWo
}
for k, v := range allKillWords {
assignee := pop()
if k == assignee || prev[k].Assignee == assignee {
if v.Assignee != "" {
continue
}
v.Assignee = pop()
if k == v.Assignee || prev[k].Assignee == v.Assignee {
return false
}
v.Assignee = assignee
allKillWords[k] = v
}
if len(unassigned) > 0 {
panic(unassigned)
}
m = allKillWords
return true
}() {
@ -415,6 +419,12 @@ func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWo
return m
}
func (m AllKillWords) assign(killer, victim string) {
v := m[killer]
v.Assignee = victim
m[killer] = v
}
func (m AllKillWords) withoutAssignees() AllKillWords {
now := time.Now()
result := make(AllKillWords)