diff --git a/bot/db_utils.py b/bot/db_utils.py index 491c1ec..a61df88 100644 --- a/bot/db_utils.py +++ b/bot/db_utils.py @@ -111,17 +111,19 @@ def insert_duel_request(username: str, target: str, duel_type: str) -> None: ''' + + # get the player ids player_1_1d = get_player(username) player_2_id = get_player(target) - # picks a random attacker - attacker_id = choices([player_1_1d, player_2_id], k=1)[0] + # sets the creation date + created_at = datetime.now().isoformat() - # sets the last round date to the current time - last_round_dt = datetime.now().isoformat() + competitive = duel_type + # insert the duel request CURSOR.execute( - 'INSERT INTO duels (player_1_id, player_2_id, attacker_id,last_round_dt) VALUES (?, ?, ?, ?)', + 'INSERT INTO duels (player_1_id, player_2_id, attacker_id,last_round_dt,competitive) VALUES (?, ?, ?, ?)', ) def insert_player(username: str) -> int: diff --git a/migrations/0007_duelv1.sql b/migrations/0007_duelv1.sql index 4ed9eb0..be62148 100644 --- a/migrations/0007_duelv1.sql +++ b/migrations/0007_duelv1.sql @@ -29,6 +29,14 @@ CREATE TABLE duels ( last_round_dt TEXT, is_finished BOOLEAN NOT NULL DEFAULT 0, points INTEGER NOT NULL DEFAULT 0, - winner_id INTEGER DEFAULT NULL, - accepted BOOLEAN NOT NULL DEFAULT 0 + 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 );