killing them 200 line functions one at a time
parent
d05ab6d0ec
commit
6340469d53
|
|
@ -381,12 +381,10 @@ func (games Games) CreateEventAssignmentRotation(ctx context.Context, id string,
|
||||||
func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWords {
|
func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWords {
|
||||||
m := prev.withoutAssignees()
|
m := prev.withoutAssignees()
|
||||||
|
|
||||||
if killerState, ok := prev[killer]; !ok {
|
if _, ok := prev[killer]; !ok {
|
||||||
} else if victimState, ok := prev[victim]; !ok {
|
} else if victimState, ok := prev[victim]; !ok {
|
||||||
} else {
|
} else {
|
||||||
v := m[killer]
|
m.assign(killer, victimState.Assignee)
|
||||||
v.Assignee = victimState.Assignee
|
|
||||||
m[killer] = v
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for !func() bool {
|
for !func() bool {
|
||||||
|
|
@ -399,14 +397,20 @@ func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWo
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range allKillWords {
|
for k, v := range allKillWords {
|
||||||
assignee := pop()
|
if v.Assignee != "" {
|
||||||
if k == assignee || prev[k].Assignee == assignee {
|
continue
|
||||||
|
}
|
||||||
|
v.Assignee = pop()
|
||||||
|
if k == v.Assignee || prev[k].Assignee == v.Assignee {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
v.Assignee = assignee
|
|
||||||
allKillWords[k] = v
|
allKillWords[k] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(unassigned) > 0 {
|
||||||
|
panic(unassigned)
|
||||||
|
}
|
||||||
|
|
||||||
m = allKillWords
|
m = allKillWords
|
||||||
return true
|
return true
|
||||||
}() {
|
}() {
|
||||||
|
|
@ -415,6 +419,12 @@ func (prev AllKillWords) ShuffleAssignees(killer, victim, word string) AllKillWo
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m AllKillWords) assign(killer, victim string) {
|
||||||
|
v := m[killer]
|
||||||
|
v.Assignee = victim
|
||||||
|
m[killer] = v
|
||||||
|
}
|
||||||
|
|
||||||
func (m AllKillWords) withoutAssignees() AllKillWords {
|
func (m AllKillWords) withoutAssignees() AllKillWords {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
result := make(AllKillWords)
|
result := make(AllKillWords)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue