1
0
Fork 0
mirror of https://github.com/ldericher/fftcgtool synced 2025-01-15 15:02:59 +00:00
fftcgtool/fftcg/opus.py
2021-08-09 05:44:12 +02:00

53 lines
1.3 KiB
Python

import logging
import roman
from .cards import Cards
class Opus(Cards):
def __init__(self, opus_id: str):
logger = logging.getLogger(__name__)
if opus_id.isnumeric():
roman_opus_id = roman.toRoman(int(opus_id))
params = {"set": [f"Opus {roman_opus_id.upper()}"]}
self.__number = opus_id
self.__name = f"opus_{opus_id}"
elif opus_id == "chaos":
params = {"set": ["Boss Deck Chaos"]}
self.__number = "B"
self.__name = "boss_deck_chaos"
elif opus_id == "promo":
params = {"rarity": ["pr"]}
self.__number = "PR"
self.__name = "promo"
else:
params = {"set": ["?"]}
self.__number = "?"
self.__name = "?"
Cards.__init__(self, params)
# remove reprints
for card in self:
if not card.code.startswith(self.__number + "-"):
self.remove(card)
# sort cards by opus, then serial
self.sort(key=lambda x: x.serial)
self.sort(key=lambda x: x.opus)
for card in self:
logger.info(f"imported card {card}")
@property
def name(self) -> str:
return self.__name
@property
def number(self) -> str:
return self.__number