mirror of
https://github.com/ldericher/fftcgtool
synced 2025-01-15 23:03:00 +00:00
card element mapping more pythonic
This commit is contained in:
parent
1a3ec4ff32
commit
62440329aa
1 changed files with 11 additions and 9 deletions
|
@ -7,15 +7,17 @@ from .utils import encircle_symbol
|
||||||
|
|
||||||
|
|
||||||
class Card:
|
class Card:
|
||||||
|
__ELEMENTS_JAP = [
|
||||||
|
"火", "氷", "風", "土", "雷", "水", "光", "闇"
|
||||||
|
]
|
||||||
|
|
||||||
|
__ELEMENTS_ENG = [
|
||||||
|
"Fire", "Ice", "Wind", "Earth", "Lightning", "Water", "Light", "Darkness"
|
||||||
|
]
|
||||||
|
|
||||||
__ELEMENTS_MAP = {
|
__ELEMENTS_MAP = {
|
||||||
"火": "Fire",
|
elem_j: elem_e
|
||||||
"氷": "Ice",
|
for elem_j, elem_e in zip(__ELEMENTS_JAP, __ELEMENTS_ENG)
|
||||||
"風": "Wind",
|
|
||||||
"土": "Earth",
|
|
||||||
"雷": "Lightning",
|
|
||||||
"水": "Water",
|
|
||||||
"光": "Light",
|
|
||||||
"闇": "Darkness"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, code: Code, elements: list[str], name: str, text: str, face_url: str = "", index: int = 0):
|
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
|
# place other letter and numerical cost symbols
|
||||||
text = re.sub(r"《([a-z0-9])》", sub_encircle, text, flags=re.IGNORECASE)
|
text = re.sub(r"《([a-z0-9])》", sub_encircle, text, flags=re.IGNORECASE)
|
||||||
# place elemental cost symbols
|
# 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
|
# place dull symbols
|
||||||
text = text.replace("《ダル》", "[⤵]")
|
text = text.replace("《ダル》", "[⤵]")
|
||||||
# replace formatting hints with brackets
|
# replace formatting hints with brackets
|
||||||
|
|
Loading…
Reference in a new issue