WIP: dueling_v1 #64

Draft
waifu wants to merge 15 commits from dueling_v1 into dev
2 changed files with 28 additions and 4 deletions
Showing only changes of commit 528e21db23 - Show all commits

View file

@ -116,14 +116,13 @@ def insert_duel_request(username: str, target: str, duel_type: str) -> None:
player_1_1d = get_player(username) player_1_1d = get_player(username)
player_2_id = get_player(target) player_2_id = get_player(target)
# sets the creation date
created_at = datetime.now().isoformat()
competitive = duel_type competitive = duel_type
# insert the duel request # insert the duel request
CURSOR.execute( CURSOR.execute(
'INSERT INTO duels (player_1_id, player_2_id, attacker_id,last_round_dt,competitive) VALUES (?, ?, ?, ?)', 'INSERT INTO duel_requests (player_1_id, player_2_id, competitive) VALUES (?, ?, ?)',
(player_1_1d, player_2_id, competitive)
) )
def insert_player(username: str) -> int: def insert_player(username: str) -> int:

View file

@ -209,14 +209,39 @@ def duel_request(author: str, args: list[str]) -> BotResponse:
duel_type = 'competitive' duel_type = 'competitive'
db.insert_duel_request(author, target, duel_type) db.insert_duel_request(author, target, duel_type)
return { return {
'message': f'{target} You have been challenged to a {duel_type} duel by \ 'message': f'{target} You have been challenged to a {duel_type} duel by \
{author}! Reply with `accept_duel` to accept the challenge.', {author}! Reply with `accept_duel` to accept the challenge.',
'attachment_urls': None 'attachment_urls': None
} }
def accept_duel(author: str, args: list[str]) -> BotResponse:
'''Accepts a duel request from another user.'''
if len(args) == 0:
return {
'message': f'{author} Please specify a user to accept the duel from.',
'attachment_urls': None
}
target = args[0]
if not db.get_player(target):
return {
'message': f'{author} User {target} does not exist or \
has not signed up, please sign up before accepting a duel.',
'attachment_urls': None
}
if db.accept_duel_request(author, target):
return {
'message': f'{author} You have accepted the duel request from {target}.',
'attachment_urls': None
}
else:
return {
'message': f'{author} No duel request found from {target}.',
'attachment_urls': None
}
def delete_account(author: str) -> BotResponse: def delete_account(author: str) -> BotResponse:
return { return {