Compare commits

..

No commits in common. "1984b67523b621599c2400fe4ef3c516af57816f" and "d2a4e0b1fe36f1d517ad7efe5a92566e47cae530" have entirely different histories.

3 changed files with 11 additions and 3 deletions

View file

@ -58,6 +58,7 @@ def add_card(
card_id = insert_card(
stripped_name,
rarity,
RARITY_TO_WEIGHT[rarity],
file_id
)
return card_id, file_id

View file

@ -150,11 +150,12 @@ def is_player_administrator(username: str) -> bool:
def insert_card(
name: str, rarity: int, file_id: str) -> int:
name: str, rarity: int, weight: float, file_id: str) -> int:
'''Inserts a card'''
CURSOR.execute(
'INSERT INTO cards (name, rarity, file_id) VALUES (?, ?, ?)',
(name, rarity, file_id)
'INSERT INTO cards (name, rarity, weight, file_id) VALUES \
(?, ?, ?, ?)',
(name, rarity, weight, file_id)
)
card_id = CURSOR.lastrowid
return card_id if card_id else 0

View file

@ -120,6 +120,12 @@ in order: name, rarity',
be a number between 1 and 5',
'attachment_urls': None
}
if not (is_float(arguments[2]) and 0.0 < float(arguments[2]) <= 1.0):
return {
'message': f'{author} Invalid drop weight: \'{arguments[2]}\' \
must be a decimal value between 0.0 and 1.0',
'attachment_urls': None
}
card_id, file_id = add_card(
name=arguments[0],