Enhance insert_card function to support optional power, charm, and wit parameters

This commit is contained in:
w 2025-06-22 01:42:08 -03:00
parent 7b75a7eea9
commit cce941471f

View file

@ -166,12 +166,25 @@ 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, file_id: str,
power: int =None, charm: int = None, wit: int = None) -> int:
'''Inserts a card''' '''Inserts a card'''
CURSOR.execute( if power is not None and charm is not None and wit is not None:
'INSERT INTO cards (name, rarity, file_id) VALUES (?, ?, ?)', CURSOR.execute(
(name, rarity, file_id) '''
) INSERT INTO card (name, rarity, file_id, power, charm, wit)
VALUES (?, ?, ?, ?, ?, ?)
''',
(name, rarity, file_id, power, charm, wit)
)
else:
CURSOR.execute(
'''
INSERT INTO card (name, rarity, file_id)
VALUES (?, ?, ?)
''',
(name, rarity, 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