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

24 lines
704 B
Python
Raw Normal View History

2021-08-03 21:41:25 +00:00
import requests
from .card import Card
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-04 01:39:19 +00:00
list.__init__(self)
2021-08-03 21:41:25 +00:00
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 02:03:24 +00:00
req = requests.post(Cards.__API_URL, json=params)
self.extend([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)