1
0
Fork 0
mirror of https://github.com/ldericher/fftcgtool synced 2025-01-15 23:03:00 +00:00
fftcgtool/fftcg/cards.py

39 lines
1 KiB
Python
Raw Normal View History

2021-08-03 21:41:25 +00:00
import requests
2021-08-09 05:01:25 +00:00
from .card import Card
2021-08-03 21:41:25 +00:00
2021-08-09 03:32:05 +00:00
class Cards(list[Card]):
2021-08-04 01:39:19 +00:00
__API_URL = "https://fftcg.square-enix-games.com/de/get-cards"
2021-08-03 21:41:25 +00:00
2021-08-18 11:49:34 +00:00
def __init__(self, name):
super().__init__()
self.__name = name
def __str__(self) -> str:
return f"[{', '.join(str(card) for card in self)}]"
2021-08-18 14:52:32 +00:00
def _load(self, params: dict[str, any]) -> None:
2021-08-09 02:03:24 +00:00
# required params:
# text
# supported params:
# [str] text, language, code, multicard="○"|"", ex_burst="○"|"", special="《S》"|""
# [array] type, element, cost, rarity, power, category_1, set
# [int] exactmatch=0|1
2021-08-04 01:39:19 +00:00
2021-08-09 03:44:12 +00:00
if "text" not in params:
params["text"] = ""
2021-08-09 02:03:24 +00:00
req = requests.post(Cards.__API_URL, json=params)
self.clear()
self.extend([Card.from_data(card_data, "EN") for card_data in req.json()["cards"]])
2021-08-18 14:52:32 +00:00
@property
def name(self) -> str:
return self.__name
@property
def file_name(self) -> str:
return self.name.lower().replace(" ", "_")