Enhance insert_card function to support optional power, charm, and wit parameters
This commit is contained in:
parent
7b75a7eea9
commit
cce941471f
1 changed files with 18 additions and 5 deletions
|
@ -166,12 +166,25 @@ def is_player_administrator(username: str) -> bool:
|
|||
|
||||
|
||||
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'''
|
||||
CURSOR.execute(
|
||||
'INSERT INTO cards (name, rarity, file_id) VALUES (?, ?, ?)',
|
||||
(name, rarity, file_id)
|
||||
)
|
||||
if power is not None and charm is not None and wit is not None:
|
||||
CURSOR.execute(
|
||||
'''
|
||||
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
|
||||
return card_id if card_id else 0
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue