WIP: dueling_v1 #64
2 changed files with 17 additions and 7 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue