Add duel request functionality and update duel table schema
This commit is contained in:
parent
614da6cd07
commit
e5c7196fa9
2 changed files with 32 additions and 1 deletions
|
@ -181,6 +181,31 @@ def do_help(author: str) -> BotResponse:
|
||||||
'attachment_urls': None
|
'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:
|
def delete_account(author: str) -> BotResponse:
|
||||||
return {
|
return {
|
||||||
|
@ -325,6 +350,11 @@ def generate_response(notification: ParsedNotification) -> BotResponse | None:
|
||||||
res = delete_account(author)
|
res = delete_account(author)
|
||||||
case 'confirm_delete_account':
|
case 'confirm_delete_account':
|
||||||
res = confirm_delete(author)
|
res = confirm_delete(author)
|
||||||
|
case 'duel_request':
|
||||||
|
res = duel_request(
|
||||||
|
author,
|
||||||
|
notification['arguments']
|
||||||
|
)
|
||||||
case _:
|
case _:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -29,5 +29,6 @@ CREATE TABLE duel (
|
||||||
last_round_dt TEXT,
|
last_round_dt TEXT,
|
||||||
is_finished BOOLEAN NOT NULL DEFAULT 0,
|
is_finished BOOLEAN NOT NULL DEFAULT 0,
|
||||||
points INTEGER NOT NULL DEFAULT 0,
|
points INTEGER NOT NULL DEFAULT 0,
|
||||||
winner_id INTEGER
|
winner_id INTEGER,
|
||||||
|
accepted BOOLEAN NOT NULL DEFAULT 0
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue