import logging import roman from .cards import Cards class Opus(Cards): def __init__(self, opus_id): 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}" elif opus_id == "chaos": api_set = "Boss Deck Chaos" self.__number = "B" self.__name = "boss_deck_chaos" else: api_set = "?" self.__number = "?" self.__name = "?" params = { "text": "", "element": ["darkness"], "set": [api_set], } Cards.__init__(self, params) # remove reprints for card in self: if not card.code.startswith(self.__number + "-"): self.remove(card) # sort every element alphabetically 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