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