From 6b3d4f0bc6481b6f8be109868adf75fd06dbd3b0 Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 14 Dec 2024 23:45:47 -0700 Subject: [PATCH] assignmentRotation impl --- cmd/server/games.go | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/cmd/server/games.go b/cmd/server/games.go index 1988379..71c0197 100644 --- a/cmd/server/games.go +++ b/cmd/server/games.go @@ -78,9 +78,11 @@ type ( } KillWords struct { - Global string - Assigned time.Time - Assignee string + Global string + + Assigned time.Time + Assignee string + Assignment Assignment } @@ -99,10 +101,10 @@ type ( } EventGameComplete struct{} EventAssignmentRotation struct { - Killer string - Killed string - KillWord string - Assignments map[string]Assignment + Killer string + Killed string + KillWord string + KillWords map[string]KillWords } ) @@ -169,11 +171,21 @@ func (games Games) GameState(ctx context.Context, id string) (GameState, error) result.Players[assignmentRotation.Killer] = killer } + for k, v := range result.Players { + v.KillWords = KillWords{} + result.Players[k] = v + } + + for k, v := range assignmentRotation.KillWords { + player := result.Players[k] + player.KillWords = v + result.Players[k] = player + } // TODO gather current assignees // TODO get victim's target // TODO assign victim's target to killer // TODO randomize everyone else so not the same as before AND not self - return fmt.Errorf("not impl: assignment rotation: %+v", assignmentRotation) + return nil default: return fmt.Errorf("unknown event type %d: %s", peek.Type, payload) }