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

bug: sub_encircle matched sub_elements targets

This commit is contained in:
Jörn-Michael Miehe 2021-08-23 19:23:35 +02:00
parent 2afb07cb8c
commit 424bebd30c

View file

@ -47,13 +47,16 @@ class Card:
def sub_elements(match: re.Match): def sub_elements(match: re.Match):
return encircle_symbol(Card.__ELEMENTS_MAP[match.group(1)], False) return encircle_symbol(Card.__ELEMENTS_MAP[match.group(1)], False)
def load_name(language: Language) -> str:
return data[f"Name{language.key_suffix}"]
def load_text(language: Language) -> str: def load_text(language: Language) -> str:
# load text # load text
text = str(data[f"Text{language.key_suffix}"]) text = str(data[f"Text{language.key_suffix}"])
# place "S" symbols # place "S" symbols
text = text.replace("《S》", encircle_symbol("S", False)) text = text.replace("《S》", encircle_symbol("S", False))
# place other letter and numerical cost symbols # place other letter and numerical cost symbols
text = re.sub(r"《([\w])》", sub_encircle, text, flags=re.UNICODE) text = re.sub(r"《([a-z0-9])》", sub_encircle, text, flags=re.IGNORECASE | re.UNICODE)
# place elemental cost symbols # place elemental cost symbols
text = re.sub(rf"《([{''.join(Card.__ELEMENTS_JAP)}])》", sub_elements, text, flags=re.UNICODE) text = re.sub(rf"《([{''.join(Card.__ELEMENTS_JAP)}])》", sub_elements, text, flags=re.UNICODE)
# place dull symbols # place dull symbols
@ -72,7 +75,7 @@ class Card:
Card.__ELEMENTS_MAP[element] Card.__ELEMENTS_MAP[element]
for element in data["Element"].split("/") for element in data["Element"].split("/")
], ],
name=data[f"Name{language.key_suffix}"], name=load_name(language),
text=load_text(language), text=load_text(language),
) )