diff --git a/bot/db_utils.py b/bot/db_utils.py index b8d00b1..933ec48 100644 --- a/bot/db_utils.py +++ b/bot/db_utils.py @@ -1,5 +1,5 @@ # 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 # 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'] } +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: '''Retrieve a player ID by username, or return None if not found.'''