mirror of
https://github.com/ldericher/fftcgtool
synced 2025-01-15 15:02:59 +00:00
Fixes for new crystal mechanic & cards
This commit is contained in:
parent
ee4b5934b6
commit
e211e3697d
3 changed files with 42 additions and 21 deletions
|
@ -17,11 +17,11 @@ class CardContent:
|
||||||
|
|
||||||
|
|
||||||
_ELEMENTS_JAP = [
|
_ELEMENTS_JAP = [
|
||||||
"火", "氷", "風", "土", "雷", "水", "光", "闇"
|
"火", "氷", "風", "土", "雷", "水", "光", "闇",
|
||||||
]
|
]
|
||||||
|
|
||||||
_ELEMENTS_ENG = [
|
_ELEMENTS_ENG = [
|
||||||
"Fire", "Ice", "Wind", "Earth", "Lightning", "Water", "Light", "Darkness"
|
"Fire", "Ice", "Wind", "Earth", "Lightning", "Water", "Light", "Darkness",
|
||||||
]
|
]
|
||||||
|
|
||||||
_ELEMENTS_MAP = {
|
_ELEMENTS_MAP = {
|
||||||
|
@ -49,6 +49,8 @@ def _load_text(language: Language, data: dict) -> str:
|
||||||
text = text.replace("《S》", encircle_symbol("S", False))
|
text = text.replace("《S》", encircle_symbol("S", False))
|
||||||
# place elemental cost symbols
|
# place elemental cost symbols
|
||||||
text = re.sub(rf"《([{''.join(_ELEMENTS_JAP)}])》", _sub_elements, text, flags=re.UNICODE)
|
text = re.sub(rf"《([{''.join(_ELEMENTS_JAP)}])》", _sub_elements, text, flags=re.UNICODE)
|
||||||
|
# place crystal symbols
|
||||||
|
text = text.replace("《C》", "⟠")
|
||||||
# place dull symbols
|
# place dull symbols
|
||||||
text = text.replace("《ダル》", "[⤵]")
|
text = text.replace("《ダル》", "[⤵]")
|
||||||
# relocate misplaced line break markers
|
# relocate misplaced line break markers
|
||||||
|
@ -93,20 +95,37 @@ class Card:
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return cls(
|
code = Code(data["Code"])
|
||||||
code=Code(data["Code"]),
|
|
||||||
|
if code.opus == "C":
|
||||||
|
elements = ["Crystal"]
|
||||||
|
content = {
|
||||||
|
language: CardContent(
|
||||||
|
name="⟠",
|
||||||
|
text="",
|
||||||
|
face="",
|
||||||
|
)
|
||||||
|
for language in API_LANGS
|
||||||
|
}
|
||||||
|
|
||||||
|
else:
|
||||||
elements = [
|
elements = [
|
||||||
_ELEMENTS_MAP[element]
|
_ELEMENTS_MAP[element]
|
||||||
for element in data["Element"].split("/")
|
for element in data["Element"].split("/")
|
||||||
],
|
]
|
||||||
content = {
|
content = {
|
||||||
language: CardContent(
|
language: CardContent(
|
||||||
_load_name(language, data),
|
name=_load_name(language, data),
|
||||||
_load_text(language, data),
|
text=_load_text(language, data),
|
||||||
""
|
face="",
|
||||||
)
|
)
|
||||||
for language in API_LANGS
|
for language in API_LANGS
|
||||||
},
|
}
|
||||||
|
|
||||||
|
return cls(
|
||||||
|
code=code,
|
||||||
|
elements=elements,
|
||||||
|
content=content,
|
||||||
)
|
)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Code:
|
||||||
rarity: str = field(init=False, compare=False)
|
rarity: str = field(init=False, compare=False)
|
||||||
code_init: InitVar[str] = field(default="")
|
code_init: InitVar[str] = field(default="")
|
||||||
|
|
||||||
__RE = re.compile(r"([1-9][0-9]*|PR|B)-([0-9]+)([CRHLS]?)", flags=re.UNICODE)
|
__RE = re.compile(r"([1-9][0-9]*|PR|B|C)-([0-9]+)([CRHLS]?)", flags=re.UNICODE)
|
||||||
|
|
||||||
def __post_init__(self, code_init: str):
|
def __post_init__(self, code_init: str):
|
||||||
match = Code.__RE.match(code_init)
|
match = Code.__RE.match(code_init)
|
||||||
|
|
|
@ -56,17 +56,19 @@ class Opus(Cards):
|
||||||
# get cards from square api
|
# get cards from square api
|
||||||
req = requests.post(Opus.__SQUARE_API_URL, json=params)
|
req = requests.post(Opus.__SQUARE_API_URL, json=params)
|
||||||
carddb = CardDB()
|
carddb = CardDB()
|
||||||
cards = [
|
cards = (
|
||||||
Card.from_square_api_data(card_data)
|
Card.from_square_api_data(card_data)
|
||||||
for card_data in req.json()["cards"]
|
for card_data in req.json()["cards"]
|
||||||
|
)
|
||||||
|
|
||||||
|
cards = [
|
||||||
|
card
|
||||||
|
for card in cards
|
||||||
|
if card.code.opus == self.__number or not card.code.opus.isnumeric()
|
||||||
]
|
]
|
||||||
|
|
||||||
# remove reprints
|
# remove reprints
|
||||||
super().__init__(name, [
|
super().__init__(name, cards)
|
||||||
card
|
|
||||||
for card in cards
|
|
||||||
if card.code.opus == self.__number
|
|
||||||
])
|
|
||||||
|
|
||||||
# sort cards by opus, then serial
|
# sort cards by opus, then serial
|
||||||
self.sort(key=lambda x: x.code.serial)
|
self.sort(key=lambda x: x.code.serial)
|
||||||
|
@ -114,7 +116,7 @@ class Opus(Cards):
|
||||||
# light/darkness elemental deck
|
# light/darkness elemental deck
|
||||||
"Light-Darkness": lambda card: card.elements == ["Light"] or card.elements == ["Darkness"],
|
"Light-Darkness": lambda card: card.elements == ["Light"] or card.elements == ["Darkness"],
|
||||||
# multi element deck
|
# multi element deck
|
||||||
"Multi": lambda card: len(card.elements) > 1,
|
"Multi": lambda card: "Crystal" in card.elements or len(card.elements) > 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
# sort cards by element, then alphabetically
|
# sort cards by element, then alphabetically
|
||||||
|
|
Loading…
Reference in a new issue