/*
Kemoverse - a gacha-style bot for the Fediverse.
Copyright © 2025 Waifu

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see https://www.gnu.org/licenses/. 
*/
CREATE TABLE duels (
    duel_id INTEGER PRIMARY KEY AUTOINCREMENT,
    player_1_id INTEGER NOT NULL,
    player_2_id INTEGER NOT NULL,
    attacker_id INTEGER,
    player_1_cards TEXT NOT NULL DEFAULT '[]',
    player_2_cards TEXT NOT NULL DEFAULT '[]',
    graveyard_p1 TEXT NOT NULL DEFAULT '[]',
    graveyard_p2 TEXT NOT NULL DEFAULT '[]',
    round INTEGER NOT NULL DEFAULT 1,
    competitive BOOLEAN NOT NULL DEFAULT 0,
    last_round_dt TEXT,
    is_finished BOOLEAN NOT NULL DEFAULT 0,
    points INTEGER NOT NULL DEFAULT 0,
    thread_id TEXT DEFAULT NULL,
    winner_id INTEGER DEFAULT NULL
);

CREATE TABLE duel_requests (
    duel_request_id INTEGER PRIMARY KEY AUTOINCREMENT,
    player_1_id INTEGER NOT NULL,
    player_2_id INTEGER NOT NULL,
    created_at TEXT NOT NULL DEFAULT (datetime('now')),
    accepted BOOLEAN NOT NULL DEFAULT 0,
    competitive BOOLEAN NOT NULL DEFAULT 0
);
