Compact layout, multi-vote, step reveal, imposter weights + resolve bug fix

BUG FIX: resolve_round now reads liar_keys directly from DB via
performResolveRound() helper, bypassing loadRoom()'s redaction
(liarKeys=[] when roundOutcome is null) — fixes 0 points + no_liar bug.

resolve logic extracted into performResolveRound() used by both
manual resolve_round and auto-resolve in lock_vote.

Migration V7:
- gtl_rooms: reveal_index INT DEFAULT -1, imposter_weights VARCHAR(500)
- gtl_players: vote_locked TINYINT, vote_request TINYINT

API:
- lock_vote: stores JSON votes array, locks player, auto-resolves when all locked
- request_voting: democratic vote-start; opens voting when all players request
- reveal_next: increments reveal_index one answer at a time
- reveal/reveal_all: sets reveal_index=9999 (show all)
- update_weights: saves imposter_weights JSON per room
- resolveVotes(): handles votes[] array instead of single voteFor string
- new_round: resets vote_locked, vote_request, reveal_index, active_emojis
- assign_questions: resets vote state + reveal_index on each new question set

Layout:
- wrap max-width 640→960px for grid layout
- Player view: 3-col grid (sidebar scores | gameplay | emoji reactions)
- Host view: 2-col grid (sidebar players+tally+scores | main content)
- Compact sb-row sidebar rows with avatar + name + score

Voting:
- Multi-select checkboxes (client-side) + "Stimme abschicken" lock button
- Niemand exclusive: checking it clears other selections and vice versa
- Once locked: checkboxes hidden, confirmation shown
- Auto-resolve triggers when last player locks vote

Reveal:
- "Nächste aufdecken" reveals one answer at a time via reveal_index
- "Alle aufdecken" reveals everything at once
- Host sees which answers are still hidden vs revealed
- Players only see answers up to current reveal_index

Imposter weights:
- JSON field in host UI e.g. {"3-5":1,"6-9":2,"10+":3}
- randomImposters() reads weights to pick appropriate count
- Saved per-room via update_weights API

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
danny 2026-06-14 13:01:41 +02:00
parent 758001597c
commit e3ef770c81
3 changed files with 690 additions and 355 deletions

View file

@ -6,7 +6,7 @@
*/
declare(strict_types=1);
const LATEST_MIGRATION = 6;
const LATEST_MIGRATION = 7;
function runMigrations(PDO $pdo, string $dbname): void
{
@ -150,6 +150,19 @@ function runMigrations(PDO $pdo, string $dbname): void
'TEXT NULL DEFAULT NULL AFTER voting_open');
markMigration($pdo, 6);
}
// ── V7: Schrittweises Aufdecken, Imposter-Gewichte, Vote-Lock, Vote-Request ──
if ($current < 7) {
addColumnIfMissing($pdo, $dbname, 'gtl_rooms', 'reveal_index',
'INT NOT NULL DEFAULT -1 AFTER active_emojis');
addColumnIfMissing($pdo, $dbname, 'gtl_rooms', 'imposter_weights',
'VARCHAR(500) NULL DEFAULT NULL AFTER reveal_index');
addColumnIfMissing($pdo, $dbname, 'gtl_players', 'vote_locked',
'TINYINT(1) NOT NULL DEFAULT 0');
addColumnIfMissing($pdo, $dbname, 'gtl_players', 'vote_request',
'TINYINT(1) NOT NULL DEFAULT 0');
markMigration($pdo, 7);
}
}
// ── Hilfsfunktionen ──────────────────────────────────────────