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

44 lines
1.1 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):
def __init__(self, number):
2021-08-04 16:36:23 +00:00
logger = logging.getLogger(__name__)
if isinstance(number, str) and number.isnumeric():
set_name = f"Opus {roman.toRoman(int(number))}"
number = str(number)
elif number == "Boss Deck Chaos":
set_name = number
number = "B"
else:
set_name = "?"
number = "?"
2021-08-02 23:55:12 +00:00
2021-08-03 21:41:25 +00:00
params = {
"text": "",
2021-08-04 16:36:23 +00:00
# "element": ["fire"],
"set": [set_name],
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 16:36:23 +00:00
# filter out reprints
reprints = [card for card in self if not card.code.startswith(number)]
for reprint in reprints:
self.remove(reprint)
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}")