get cards function
This commit is contained in:
parent
cce941471f
commit
8c5c860ef6
1 changed files with 14 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
# Kemoverse - a gacha-style bot for the Fediverse.
|
# Kemoverse - a gacha-style bot for the Fediverse.
|
||||||
# Copyright © 2025 Waifu VD15, Moon, and contributors.
|
# Copyright © 2025 Waifu, VD15, Moon, and contributors.
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -75,6 +75,19 @@ def get_random_card() -> Card | None:
|
||||||
'image_url': chosen['file_id']
|
'image_url': chosen['file_id']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_cards(card_ids: list[int]) -> list[tuple]:
|
||||||
|
'''
|
||||||
|
Retrieves stats for a list of card IDs.
|
||||||
|
Returns a list of tuples: (id, name, rarity, file_id, power, charm, wit, ...)
|
||||||
|
'''
|
||||||
|
if not card_ids:
|
||||||
|
return []
|
||||||
|
|
||||||
|
placeholders = ','.join('?' for _ in card_ids)
|
||||||
|
query = f'SELECT * FROM cards WHERE id IN ({placeholders})'
|
||||||
|
|
||||||
|
CURSOR.execute(query, card_ids)
|
||||||
|
return CURSOR.fetchall()
|
||||||
|
|
||||||
def get_player(username: str) -> int:
|
def get_player(username: str) -> int:
|
||||||
'''Retrieve a player ID by username, or return None if not found.'''
|
'''Retrieve a player ID by username, or return None if not found.'''
|
||||||
|
|
Loading…
Add table
Reference in a new issue