From 15118df95ce0c7b3e6090d02b1332ed156f03eef Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 14 Dec 2024 23:41:28 -0700 Subject: [PATCH] gitignore --- .gitignore | 1 + cmd/server/games.go | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..11b8e7b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/cmd/server/server diff --git a/cmd/server/games.go b/cmd/server/games.go index 3e0b66b..1988379 100644 --- a/cmd/server/games.go +++ b/cmd/server/games.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "io" + "slices" "time" ) @@ -100,6 +101,7 @@ type ( EventAssignmentRotation struct { Killer string Killed string + KillWord string Assignments map[string]Assignment } ) @@ -155,10 +157,22 @@ func (games Games) GameState(ctx context.Context, id string) (GameState, error) if err := json.Unmarshal(payload, &assignmentRotation); err != nil { return err } + + if killer, ok := result.Players[assignmentRotation.Killer]; !ok { + } else if victim, ok := result.Players[assignmentRotation.Killed]; !ok { + } else { + killer.Kills = append(killer.Kills, Kill{ + Timestamp: timestamp, + Victim: assignmentRotation.Killed, + Public: slices.Contains(victim.KillWords.Assignment.Public, assignmentRotation.KillWord), + }) + result.Players[assignmentRotation.Killer] = killer + } + // 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 + // TODO randomize everyone else so not the same as before AND not self return fmt.Errorf("not impl: assignment rotation: %+v", assignmentRotation) default: return fmt.Errorf("unknown event type %d: %s", peek.Type, payload)