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

63 lines
1.5 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-09 05:01: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:40:32 +00:00
def __init__(self, opus_id: str):
super().__init__()
2021-08-04 16:36:23 +00:00
logger = logging.getLogger(__name__)
2021-08-04 22:40:32 +00:00
if opus_id.isnumeric():
2021-08-09 12:03:45 +00:00
self.__name = f"Opus {roman.toRoman(int(opus_id)).upper()}"
2021-08-04 22:40:32 +00:00
self.__number = opus_id
2021-08-09 12:03:45 +00:00
self.__filename = f"opus_{opus_id}"
params = {"set": [self.__name]}
2021-08-04 16:36:23 +00:00
elif opus_id == "chaos":
2021-08-09 12:03:45 +00:00
self.__name = "Boss Deck Chaos"
self.__number = "B"
2021-08-09 12:03:45 +00:00
self.__filename = "boss_deck_chaos"
params = {"set": [self.__name]}
2021-08-04 16:36:23 +00:00
elif opus_id == "promo":
2021-08-09 12:03:45 +00:00
self.__name = "Promo"
self.__number = "PR"
2021-08-09 12:03:45 +00:00
self.__filename = "promo"
params = {"rarity": ["pr"]}
2021-08-04 16:36:23 +00:00
else:
self.__name = "?"
2021-08-09 12:03:45 +00:00
self.__number = "?"
self.__filename = "?"
params = {"set": "?"}
2021-08-02 23:55:12 +00:00
self._load(params)
2021-08-04 01:39:19 +00:00
# remove reprints
for card in self:
if not card.code.opus == self.__number:
self.remove(card)
2021-08-04 16:36:23 +00:00
# sort cards by opus, then serial
self.sort(key=lambda x: x.code.serial)
self.sort(key=lambda x: x.code.opus)
2021-08-04 16:36:23 +00:00
for card in self:
logger.info(f"imported card {card}")
@property
2021-08-09 02:03:24 +00:00
def name(self) -> str:
return self.__name
@property
2021-08-09 02:03:24 +00:00
def number(self) -> str:
return self.__number
2021-08-09 12:03:45 +00:00
@property
def filename(self) -> str:
return self.__filename