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_ENG = [
|
||||
"Fire", "Ice", "Wind", "Earth", "Lightning", "Water", "Light", "Darkness"
|
||||
"Fire", "Ice", "Wind", "Earth", "Lightning", "Water", "Light", "Darkness",
|
||||
]
|
||||
|
||||
_ELEMENTS_MAP = {
|
||||
|
@ -49,6 +49,8 @@ def _load_text(language: Language, data: dict) -> str:
|
|||
text = text.replace("《S》", encircle_symbol("S", False))
|
||||
# place elemental cost symbols
|
||||
text = re.sub(rf"《([{''.join(_ELEMENTS_JAP)}])》", _sub_elements, text, flags=re.UNICODE)
|
||||
# place crystal symbols
|
||||
text = text.replace("《C》", "⟠")
|
||||
# place dull symbols
|
||||
text = text.replace("《ダル》", "[⤵]")
|
||||
# relocate misplaced line break markers
|
||||
|
@ -93,20 +95,37 @@ class Card:
|
|||
)
|
||||
|
||||
else:
|
||||
return cls(
|
||||
code=Code(data["Code"]),
|
||||
elements=[
|
||||
_ELEMENTS_MAP[element]
|
||||
for element in data["Element"].split("/")
|
||||
],
|
||||
content={
|
||||
code = Code(data["Code"])
|
||||
|
||||
if code.opus == "C":
|
||||
elements = ["Crystal"]
|
||||
content = {
|
||||
language: CardContent(
|
||||
_load_name(language, data),
|
||||
_load_text(language, data),
|
||||
""
|
||||
name="⟠",
|
||||
text="",
|
||||
face="",
|
||||
)
|
||||
for language in API_LANGS
|
||||
},
|
||||
}
|
||||
|
||||
else:
|
||||
elements = [
|
||||
_ELEMENTS_MAP[element]
|
||||
for element in data["Element"].split("/")
|
||||
]
|
||||
content = {
|
||||
language: CardContent(
|
||||
name=_load_name(language, data),
|
||||
text=_load_text(language, data),
|
||||
face="",
|
||||
)
|
||||
for language in API_LANGS
|
||||
}
|
||||
|
||||
return cls(
|
||||
code=code,
|
||||
elements=elements,
|
||||
content=content,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
|
|
|
@ -11,7 +11,7 @@ class Code:
|
|||
rarity: str = field(init=False, compare=False)
|
||||
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):
|
||||
match = Code.__RE.match(code_init)
|
||||
|
|
|
@ -56,17 +56,19 @@ class Opus(Cards):
|
|||
# get cards from square api
|
||||
req = requests.post(Opus.__SQUARE_API_URL, json=params)
|
||||
carddb = CardDB()
|
||||
cards = [
|
||||
cards = (
|
||||
Card.from_square_api_data(card_data)
|
||||
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
|
||||
super().__init__(name, [
|
||||
card
|
||||
for card in cards
|
||||
if card.code.opus == self.__number
|
||||
])
|
||||
super().__init__(name, cards)
|
||||
|
||||
# sort cards by opus, then serial
|
||||
self.sort(key=lambda x: x.code.serial)
|
||||
|
@ -114,7 +116,7 @@ class Opus(Cards):
|
|||
# light/darkness elemental deck
|
||||
"Light-Darkness": lambda card: card.elements == ["Light"] or card.elements == ["Darkness"],
|
||||
# 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
|
||||
|
|
Loading…
Reference in a new issue