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

25 lines
745 B
Python
Raw Normal View History

2021-08-03 21:41:25 +00:00
import requests
2021-08-09 04:33:33 +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-09 03:32:05 +00:00
def __init__(self, params: dict[str, any]):
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)
2021-08-09 04:47:59 +00:00
super().__init__([Card(card_data) for card_data in req.json()["cards"]])
2021-08-03 21:41:25 +00:00
2021-08-09 02:03:24 +00:00
def __str__(self) -> str:
2021-08-04 01:39:19 +00:00
return "\n".join(str(card) for card in self)