1
0
Fork 0
mirror of https://github.com/ldericher/fftcgtool synced 2025-01-15 15:02:59 +00:00

card element mapping more pythonic

This commit is contained in:
Jörn-Michael Miehe 2021-08-23 14:56:09 +02:00
parent 1a3ec4ff32
commit 62440329aa

View file

@ -7,15 +7,17 @@ from .utils import encircle_symbol
class Card:
__ELEMENTS_JAP = [
"", "", "", "", "", "", "", ""
]
__ELEMENTS_ENG = [
"Fire", "Ice", "Wind", "Earth", "Lightning", "Water", "Light", "Darkness"
]
__ELEMENTS_MAP = {
"": "Fire",
"": "Ice",
"": "Wind",
"": "Earth",
"": "Lightning",
"": "Water",
"": "Light",
"": "Darkness"
elem_j: elem_e
for elem_j, elem_e in zip(__ELEMENTS_JAP, __ELEMENTS_ENG)
}
def __init__(self, code: Code, elements: list[str], name: str, text: str, face_url: str = "", index: int = 0):
@ -51,7 +53,7 @@ class Card:
# place other letter and numerical cost symbols
text = re.sub(r"《([a-z0-9])》", sub_encircle, text, flags=re.IGNORECASE)
# place elemental cost symbols
text = re.sub(rf"《([{''.join(Card.__ELEMENTS_MAP.keys())}])》", sub_elements, text, flags=re.IGNORECASE)
text = re.sub(rf"《([{''.join(Card.__ELEMENTS_JAP)}])》", sub_elements, text, flags=re.IGNORECASE)
# place dull symbols
text = text.replace("《ダル》", "[⤵]")
# replace formatting hints with brackets