From 264b165f1cd75c65ea34b9e69bb72b3722a52bf5 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Sun, 15 Dec 2024 02:36:18 -0700 Subject: [PATCH] o i think that looks like everything but is hard to tell --- cmd/server/ws.go | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/cmd/server/ws.go b/cmd/server/ws.go index 0e37efb..84d29b6 100644 --- a/cmd/server/ws.go +++ b/cmd/server/ws.go @@ -84,18 +84,41 @@ func (s *S) serveWS(w http.ResponseWriter, r *http.Request) error { if k == s.Session(ctx).ID { continue } + name, err := s.games.UserName(ctx, k) if err != nil { return err } + + tags := []map[string]any{} + if self := gameState.Players[s.Session(ctx).ID]; self.KillWords.Assignee == k { + for _, private := range v.KillWords.Assignment.Private { + tags = append(tags, map[string]any{ + "k": private.Word, + "v": private.Points, + }) + } + } + for _, public := range v.KillWords.Assignment.Public { + tags = append(tags, map[string]any{ + "k": public.Word, + "v": public.Points, + }) + } + if self := gameState.Players[s.Session(ctx).ID]; !slices.ContainsFunc(self.Kills, func(a Kill) bool { + return a.Victim == k + }) { + tags = append(tags, map[string]any{ + "k": self.KillWords.Global.Word, + "v": self.KillWords.Global.Points, + }) + } + items = append(items, map[string]any{ "name": name, "title": strconv.Itoa(v.Points()), - "tags": []map[string]any{ - map[string]any{"k": "k", "v": "1"}, - }, + "tags": tags, }) - _, _ = k, v } slices.SortFunc(items, func(a, b map[string]any) int { an, _ := strconv.Atoi(fmt.Sprint(a["title"]))