WIP: dueling_v1 #64

Draft
waifu wants to merge 15 commits from dueling_v1 into dev
2 changed files with 32 additions and 1 deletions
Showing only changes of commit e5c7196fa9 - Show all commits

View file

@ -181,6 +181,31 @@ def do_help(author: str) -> BotResponse:
'attachment_urls': None
}
def duel_request(author: str, args: list[str]) -> BotResponse:
'''Sends a duel request to another user.'''
if len(args) == 0:
return {
'message': f'{author} Please specify a user to duel.',
'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 challenging to a duel.',
'attachment_urls': None
}
duel_type = 'casual'
if len(args) == 1 and args[0] == "competitive":
duel_type = 'competitive'
db.insert_duel_request(author, target, duel_type)
return {
'message': f'{target} You have been challenged to a {duel_type} duel by \
{author}! Reply with `accept_duel` to accept the challenge.',
'attachment_urls': None
}
def delete_account(author: str) -> BotResponse:
return {
@ -325,6 +350,11 @@ def generate_response(notification: ParsedNotification) -> BotResponse | None:
res = delete_account(author)
case 'confirm_delete_account':
res = confirm_delete(author)
case 'duel_request':
res = duel_request(
author,
notification['arguments']
)
case _:
pass

View file

@ -29,5 +29,6 @@ CREATE TABLE duel (
last_round_dt TEXT,
is_finished BOOLEAN NOT NULL DEFAULT 0,
points INTEGER NOT NULL DEFAULT 0,
winner_id INTEGER
winner_id INTEGER,
accepted BOOLEAN NOT NULL DEFAULT 0
);