From ae593bc092b72cca1b3eb0ca19d7a90e377a73c9 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Sun, 15 Dec 2024 09:50:34 -0700 Subject: [PATCH] refactor making new AllKillWords just without assignees and now --- cmd/server/games.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/cmd/server/games.go b/cmd/server/games.go index b085111..330fa5c 100644 --- a/cmd/server/games.go +++ b/cmd/server/games.go @@ -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{