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):
|
2021-08-04 22:17:47 +00:00
|
|
|
def __init__(self, opus_id):
|
2021-08-04 16:36:23 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2021-08-04 22:17:47 +00:00
|
|
|
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
|
|
|
|
2021-08-04 22:17:47 +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:
|
2021-08-04 22:17:47 +00:00
|
|
|
api_set = "?"
|
|
|
|
self.__number = "?"
|
|
|
|
self.__name = "?"
|
2021-08-02 23:55:12 +00:00
|
|
|
|
2021-08-03 21:41:25 +00:00
|
|
|
params = {
|
|
|
|
"text": "",
|
2021-08-04 22:17:47 +00:00
|
|
|
"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
|
|
|
|
2021-08-04 22:17:47 +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}")
|
2021-08-04 22:17:47 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
return self.__name
|
|
|
|
|
|
|
|
@property
|
|
|
|
def number(self):
|
|
|
|
return self.__number
|