From b9d06f81ba0dc4510179723a4528b80583a15a6e Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Sun, 15 Dec 2024 09:47:11 -0700 Subject: [PATCH] functional looking --- cmd/server/games.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/server/games.go b/cmd/server/games.go index c833a33..1362072 100644 --- a/cmd/server/games.go +++ b/cmd/server/games.go @@ -373,14 +373,13 @@ func (games Games) CreateEventAssignmentRotation(ctx context.Context, id string, prevAllKillWords[k] = v.KillWords } - event.AllKillWords.ShuffleAssignees(prevAllKillWords, killer, victim, word) - - event.AllKillWords.FillKillWords() + event.AllKillWords = event.AllKillWords.ShuffleAssignees(prevAllKillWords, killer, victim, word) + event.AllKillWords = event.AllKillWords.FillKillWords() return games.createEvent(ctx, id, event) } -func (m AllKillWords) ShuffleAssignees(prev AllKillWords, killer, victim, word string) { +func (m AllKillWords) ShuffleAssignees(prev AllKillWords, killer, victim, word string) AllKillWords { now := time.Now() for k := range prev { @@ -427,12 +426,12 @@ func (m AllKillWords) ShuffleAssignees(prev AllKillWords, killer, victim, word s } } - for k, v := range allKillWords { - m[k] = v - } + m = allKillWords return true }() { } + + return m } func (m AllKillWords) unassigned() []string { @@ -461,7 +460,7 @@ func (m AllKillWords) assigned() []string { return result } -func (m AllKillWords) FillKillWords() { +func (m AllKillWords) FillKillWords() AllKillWords { for k, v := range m { if v.Global.Word == "" { v.Global = KillWord{Word: m.unusedGlobal(), Points: -1} @@ -482,6 +481,7 @@ func (m AllKillWords) FillKillWords() { } } } + return m } //go:embed holiday.txt