1
0
Fork 0
mirror of https://github.com/ldericher/fftcgtool synced 2025-01-15 23:03:00 +00:00
fftcgtool/fftcg/card.py

42 lines
1.3 KiB
Python
Raw Normal View History

2021-08-02 23:37:22 +00:00
import re
class Card:
def __init__(self, data):
2021-08-03 17:45:35 +00:00
if not data:
self.__opus = "0"
self.__serial = "000"
self.__rarity = "X"
self.__element = None
self.__description = None
2021-08-02 23:37:22 +00:00
else:
2021-08-03 17:45:35 +00:00
if str(data["Code"])[0].isnumeric():
self.__opus, self.__serial, self.__rarity = \
re.match(r'([0-9]+)-([0-9]+)([CRHLS])', data["Code"]).groups()
elif str(data["Code"]).startswith("PR"):
self.__opus, self.__serial = \
re.match(r'(PR)-([0-9]+)', data["Code"]).groups()
self.__rarity = ""
elif str(data["Code"]).startswith("B"):
self.__opus, self.__serial = \
re.match(r'(B)-([0-9]+)', data["Code"]).groups()
self.__rarity = ""
2021-08-02 23:37:22 +00:00
2021-08-02 23:55:12 +00:00
else:
2021-08-03 17:45:35 +00:00
self.__opus, self.__serial, self.__rarity = \
"?", "???", "?"
self.__name = data["Name_EN"]
self.__element = data["Element"].split("/")
self.__description = data["Text_EN"]
2021-08-02 23:37:22 +00:00
def __str__(self):
2021-08-02 23:55:12 +00:00
return f"'{self.__name}' ({self.__element}, {self.get_id()})"
2021-08-02 23:37:22 +00:00
# 6-048C
def get_id(self):
2021-08-02 23:55:12 +00:00
return f"{self.__opus}-{self.__serial}{self.__rarity}"