Compare commits
No commits in common. "8c5c860ef6d77ea6c5748497f9b4d807cb4e066f" and "e1e6808b0a8199085b4dd3a51764b5de4de377ba" have entirely different histories.
8c5c860ef6
...
e1e6808b0a
2 changed files with 12 additions and 40 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,19 +75,6 @@ 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.'''
|
||||||
|
@ -179,23 +166,10 @@ def is_player_administrator(username: str) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def insert_card(
|
def insert_card(
|
||||||
name: str, rarity: int, file_id: str,
|
name: str, rarity: int, file_id: str) -> int:
|
||||||
power: int =None, charm: int = None, wit: int = None) -> int:
|
|
||||||
'''Inserts a card'''
|
'''Inserts a card'''
|
||||||
if power is not None and charm is not None and wit is not None:
|
|
||||||
CURSOR.execute(
|
CURSOR.execute(
|
||||||
'''
|
'INSERT INTO cards (name, rarity, file_id) VALUES (?, ?, ?)',
|
||||||
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)
|
(name, rarity, file_id)
|
||||||
)
|
)
|
||||||
card_id = CURSOR.lastrowid
|
card_id = CURSOR.lastrowid
|
||||||
|
|
|
@ -16,11 +16,9 @@ You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see https://www.gnu.org/licenses/.
|
along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ALTER TABLE card
|
CREATE TABLE IF NOT EXISTS card_stats (
|
||||||
ADD COLUMN power INTEGER NOT NULL DEFAULT (abs(random() % 9999));
|
card_id INTEGER PRIMARY KEY,
|
||||||
|
power INTEGER NOT NULL DEFAULT abs(random() % 9999),
|
||||||
ALTER TABLE card
|
charm INTEGER NOT NULL DEFAULT abs(random() % 9999),,
|
||||||
ADD COLUMN charm INTEGER NOT NULL DEFAULT (abs(random() % 9999));
|
FOREIGN KEY(card_id) REFERENCES card(id)
|
||||||
|
)
|
||||||
ALTER TABLE card
|
|
||||||
ADD COLUMN wit INTEGER NOT NULL DEFAULT (abs(random() % 9999));
|
|
Loading…
Add table
Reference in a new issue