From 424bebd30c9597362393371ceea6ef06dfb4ad49 Mon Sep 17 00:00:00 2001 From: LDericher <40151420+ldericher@users.noreply.github.com> Date: Mon, 23 Aug 2021 19:23:35 +0200 Subject: [PATCH] bug: sub_encircle matched sub_elements targets --- fftcg/card.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fftcg/card.py b/fftcg/card.py index fbb967d..f58f0aa 100644 --- a/fftcg/card.py +++ b/fftcg/card.py @@ -47,13 +47,16 @@ class Card: def sub_elements(match: re.Match): 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: # load text text = str(data[f"Text{language.key_suffix}"]) # place "S" symbols text = text.replace("《S》", encircle_symbol("S", False)) # 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 text = re.sub(rf"《([{''.join(Card.__ELEMENTS_JAP)}])》", sub_elements, text, flags=re.UNICODE) # place dull symbols @@ -72,7 +75,7 @@ class Card: Card.__ELEMENTS_MAP[element] for element in data["Element"].split("/") ], - name=data[f"Name{language.key_suffix}"], + name=load_name(language), text=load_text(language), )