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

59 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):
2021-08-04 22:40:32 +00:00
def __init__(self, opus_id: str):
2021-08-04 16:36:23 +00:00
logger = logging.getLogger(__name__)
2021-08-09 03:32:05 +00:00
params: dict[str, any] = {
"text": "",
# "element": ["darkness"],
}
2021-08-04 22:40:32 +00:00
if opus_id.isnumeric():
roman_opus_id = roman.toRoman(int(opus_id))
2021-08-09 03:32:05 +00:00
params |= {"set": [f"Opus {roman_opus_id.upper()}"]}
2021-08-04 22:40:32 +00:00
self.__number = opus_id
self.__name = f"opus_{opus_id}"
2021-08-04 16:36:23 +00:00
elif opus_id == "chaos":
2021-08-09 03:32:05 +00:00
params |= {"set": ["Boss Deck Chaos"]}
self.__number = "B"
self.__name = "boss_deck_chaos"
2021-08-04 16:36:23 +00:00
elif opus_id == "promo":
2021-08-09 03:32:05 +00:00
params |= {"rarity": ["pr"]}
self.__number = "PR"
self.__name = "promo"
2021-08-04 16:36:23 +00:00
else:
2021-08-09 03:32:05 +00:00
params |= {"set": ["?"]}
self.__number = "?"
self.__name = "?"
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
# sort cards by opus, then serial
self.sort(key=lambda x: x.serial)
self.sort(key=lambda x: x.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