chore: integrate multiplayer code (wip)

This commit is contained in:
Henri Bourcereau 2026-04-22 17:42:05 +02:00
parent 2838d59f30
commit 4f5e21becb
66 changed files with 6423 additions and 18 deletions

View file

@ -0,0 +1,24 @@
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL UNIQUE,
email TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL,
created_at INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS game_records (
id INTEGER PRIMARY KEY AUTOINCREMENT,
game_id TEXT NOT NULL,
room_code TEXT NOT NULL,
started_at INTEGER NOT NULL,
ended_at INTEGER,
result TEXT
);
CREATE TABLE IF NOT EXISTS game_participants (
id INTEGER PRIMARY KEY AUTOINCREMENT,
game_record_id INTEGER NOT NULL REFERENCES game_records(id),
user_id INTEGER REFERENCES users(id),
player_id INTEGER NOT NULL,
outcome TEXT
);

View file

@ -0,0 +1,3 @@
-- Prevent duplicate participant rows if POST /games/result is called more than once.
CREATE UNIQUE INDEX IF NOT EXISTS idx_participants_unique
ON game_participants(game_record_id, player_id);