mirror of
https://github.com/ldericher/fftcgtool
synced 2025-01-15 15:02:59 +00:00
card sorting, opus_id "chaos" and "promo"
This commit is contained in:
parent
a359c1df4c
commit
bbae21d3b9
3 changed files with 29 additions and 9 deletions
|
@ -24,6 +24,10 @@ class Book:
|
|||
def __init__(self, cards, grid, resolution, language, num_threads):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# sort cards by element, then alphabetically
|
||||
cards.sort(key=lambda x: x.name)
|
||||
cards.sort(key=lambda x: "Multi" if len(x.elements) > 1 else x.elements[0])
|
||||
|
||||
# all card face URLs
|
||||
urls = [Book.__FACE_URL.format(card.code, language) for card in cards]
|
||||
# card back URL
|
||||
|
|
|
@ -56,6 +56,18 @@ class Card:
|
|||
def code(self):
|
||||
return f"{self.__opus}-{self.__serial}{self.__rarity}"
|
||||
|
||||
@property
|
||||
def opus(self):
|
||||
return self.__opus
|
||||
|
||||
@property
|
||||
def serial(self):
|
||||
return int(self.__serial)
|
||||
|
||||
@property
|
||||
def rarity(self):
|
||||
return self.__rarity
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.__name
|
||||
|
|
|
@ -11,24 +11,29 @@ class Opus(Cards):
|
|||
|
||||
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()}"
|
||||
params_add = {"set": [f"Opus {roman_opus_id.upper()}"]}
|
||||
self.__number = str(opus_id)
|
||||
self.__name = f"opus_{opus_id}"
|
||||
|
||||
elif opus_id == "chaos":
|
||||
api_set = "Boss Deck Chaos"
|
||||
params_add = {"set": ["Boss Deck Chaos"]}
|
||||
self.__number = "B"
|
||||
self.__name = "boss_deck_chaos"
|
||||
|
||||
elif opus_id == "promo":
|
||||
params_add = {"rarity": ["pr"]}
|
||||
self.__number = "PR"
|
||||
self.__name = "promo"
|
||||
|
||||
else:
|
||||
api_set = "?"
|
||||
params_add = {"set": ["?"]}
|
||||
self.__number = "?"
|
||||
self.__name = "?"
|
||||
|
||||
params = {
|
||||
"text": "",
|
||||
"element": ["darkness"],
|
||||
"set": [api_set],
|
||||
# "element": ["darkness"],
|
||||
**params_add
|
||||
}
|
||||
|
||||
Cards.__init__(self, params)
|
||||
|
@ -38,10 +43,9 @@ class Opus(Cards):
|
|||
if not card.code.startswith(self.__number + "-"):
|
||||
self.remove(card)
|
||||
|
||||
# sort every element alphabetically
|
||||
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])
|
||||
# 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}")
|
||||
|
|
Loading…
Reference in a new issue