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

56 lines
1.4 KiB
Python
Raw Normal View History

2021-08-04 16:36:23 +00:00
import logging
2021-08-04 01:39:19 +00:00
import roman
2021-08-03 17:45:35 +00:00
2021-08-03 21:41:25 +00:00
from .cards import Cards
2021-08-02 23:55:12 +00:00
2021-08-03 17:45:35 +00:00
2021-08-03 21:41:25 +00:00
class Opus(Cards):
def __init__(self, opus_id):
2021-08-04 16:36:23 +00:00
logger = logging.getLogger(__name__)
if isinstance(opus_id, str) and opus_id.isnumeric():
roman_opus_id = roman.toRoman(int(opus_id))
api_set = f"Opus {roman_opus_id.upper()}"
self.__number = str(opus_id)
self.__name = f"opus_{opus_id}"
2021-08-04 16:36:23 +00:00
elif opus_id == "chaos":
api_set = "Boss Deck Chaos"
self.__number = "B"
self.__name = "boss_deck_chaos"
2021-08-04 16:36:23 +00:00
else:
api_set = "?"
self.__number = "?"
self.__name = "?"
2021-08-02 23:55:12 +00:00
2021-08-03 21:41:25 +00:00
params = {
"text": "",
"element": ["darkness"],
"set": [api_set],
2021-08-03 21:41:25 +00:00
}
2021-08-02 23:55:12 +00:00
2021-08-03 21:41:25 +00:00
Cards.__init__(self, params)
2021-08-04 01:39:19 +00:00
# remove reprints
for card in self:
if not card.code.startswith(self.__number + "-"):
self.remove(card)
2021-08-04 16:36:23 +00:00
2021-08-04 01:39:19 +00:00
# sort every element alphabetically
2021-08-04 16:36:23 +00:00
self.sort(key=lambda x: x.code)
self.sort(key=lambda x: x.name)
self.sort(key=lambda x: "Multi" if len(x.elements) > 1 else x.elements[0])
for card in self:
logger.info(f"imported card {card}")
@property
def name(self):
return self.__name
@property
def number(self):
return self.__number