Compare commits

..

No commits in common. "fc45c688e8e1a59739374d1f6d2c62c061af20c2" and "40f018a83b3d7ab9224c0623c4f7f78ade677d59" have entirely different histories.

3 changed files with 14 additions and 5 deletions

View file

@ -51,6 +51,7 @@ def add_card(name: str, rarity: int, weight: float, image_url: str) -> tuple[int
card_id = db_utils.insert_card( card_id = db_utils.insert_card(
stripped_name, stripped_name,
rarity, rarity,
float(weight),
file_id file_id
) )

View file

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

View file

@ -107,10 +107,10 @@ dumbass.',
'attachment_urls': None 'attachment_urls': None
} }
if len(arguments) != 2: if len(arguments) != 3:
return { return {
'message': f'{author} Please specify the following attributes \ 'message': f'{author} Please specify the following attributes \
in order: name, rarity', in order: name, rarity, weight',
'attachment_urls': None 'attachment_urls': None
} }
@ -120,10 +120,17 @@ in order: name, rarity',
be a number between 1 and 5', be a number between 1 and 5',
'attachment_urls': None '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( card_id, file_id = add_card(
name=arguments[0], name=arguments[0],
rarity=int(arguments[1]), rarity=int(arguments[1]),
weight=float(arguments[2]),
image_url=image_url image_url=image_url
) )
return { return {