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"]))