Fix targeted reveal, live vote tally, and ghost nobody-vote display

1. Targeted reveal (Bug 1): renderPlayer now uses revealedKeys array
   instead of the old sequential revealIndex slice — so only the
   specifically clicked player's answer becomes visible to others.
   renderHost anyRevealed/round-state also switched to revealedKeys.

2. Live vote tally for players (Bug 2): after locking their own vote
   players see a live per-player tally (locked votes only) so they
   can follow the voting while waiting for others to submit.

3. Ghost nobody-vote (Bug 3): host and player tallies now filter to
   p.voteLocked before counting, so unlocked/pre-vote players no
   longer generate a phantom "Niemand" vote in the display.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
danny 2026-06-14 13:33:42 +02:00
parent e3ef770c81
commit 11b2b4bf4d
3 changed files with 265 additions and 49 deletions

View file

@ -6,7 +6,7 @@
*/
declare(strict_types=1);
const LATEST_MIGRATION = 7;
const LATEST_MIGRATION = 8;
function runMigrations(PDO $pdo, string $dbname): void
{
@ -163,6 +163,22 @@ function runMigrations(PDO $pdo, string $dbname): void
'TINYINT(1) NOT NULL DEFAULT 0');
markMigration($pdo, 7);
}
// ── V8: Gezieltes Aufdecken (revealed_keys), Lobby-Chat ──────
if ($current < 8) {
addColumnIfMissing($pdo, $dbname, 'gtl_rooms', 'revealed_keys',
'TEXT NULL DEFAULT NULL AFTER reveal_index');
$pdo->exec("CREATE TABLE IF NOT EXISTS `gtl_chat_messages` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`room_code` VARCHAR(12) NOT NULL,
`player_name` VARCHAR(40) NOT NULL,
`message` VARCHAR(500) NOT NULL,
`created_at` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
INDEX `idx_room` (`room_code`, `created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci");
markMigration($pdo, 8);
}
}
// ── Hilfsfunktionen ──────────────────────────────────────────