diff --git a/apps/server/src/game/engine.test.ts b/apps/server/src/game/engine.test.ts index a8638d2..7cbf67c 100644 --- a/apps/server/src/game/engine.test.ts +++ b/apps/server/src/game/engine.test.ts @@ -109,8 +109,9 @@ describe("GameEngine", () => { const ack = emits.find((e) => e.event === "round:voteAck")!.payload as { count: number total: number + voted: string[] } - expect(ack).toEqual({ count: 1, total: 2 }) + expect(ack).toEqual({ count: 1, total: 2, voted: [p1] }) engine.handleVote(p2, { choiceIndex: 0 }) await run diff --git a/apps/server/src/game/engine.ts b/apps/server/src/game/engine.ts index f4a8df9..6c56f59 100644 --- a/apps/server/src/game/engine.ts +++ b/apps/server/src/game/engine.ts @@ -73,6 +73,7 @@ export class GameEngine implements RoomGameController { this.io.to(this.room.code).emit("round:voteAck", { count: this.runtime.votes.size, total, + voted: [...this.runtime.votes.keys()], }) // Fin anticipée : tous les éligibles ont voté. if (total > 0 && this.runtime.votes.size >= total) { diff --git a/apps/web/src/components/player-cards.tsx b/apps/web/src/components/player-cards.tsx index 353116f..bab3677 100644 --- a/apps/web/src/components/player-cards.tsx +++ b/apps/web/src/components/player-cards.tsx @@ -1,14 +1,23 @@ import { AnimatePresence, motion } from "framer-motion" -import { Crown } from "lucide-react" +import { Check, Crown } from "lucide-react" import type { RoomSnapshot } from "@nerdware/shared" interface PlayerCardsProps { snapshot: RoomSnapshot playerId: string | null + /** Affiche l'état de vote (manche en cours uniquement). */ + showVoteStatus?: boolean + /** playerIds ayant déjà validé leur réponse. */ + votedIds?: string[] } /** HUD persistant : une card par joueur avec son score, couronne au leader. */ -export function PlayerCards({ snapshot, playerId }: PlayerCardsProps) { +export function PlayerCards({ + snapshot, + playerId, + showVoteStatus = false, + votedIds = [], +}: PlayerCardsProps) { const scoreOf = (id: string) => snapshot.scores.find((s) => s.playerId === id)?.score ?? 0 @@ -16,6 +25,7 @@ export function PlayerCards({ snapshot, playerId }: PlayerCardsProps) { const ranked = [...snapshot.players].sort( (a, b) => scoreOf(b.id) - scoreOf(a.id) ) + const voted = new Set(votedIds) return (