2021-08-02 23:37:22 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
class Card:
|
|
|
|
def __init__(self, data):
|
|
|
|
code_match = re.match(r'([0-9]+)-([0-9]+)([CRHLSB])', data["Code"])
|
|
|
|
if code_match:
|
2021-08-02 23:55:12 +00:00
|
|
|
self.__opus, self.__serial, self.__rarity = code_match.groups()
|
2021-08-02 23:37:22 +00:00
|
|
|
|
|
|
|
else:
|
2021-08-02 23:55:12 +00:00
|
|
|
code_match = re.match(r'PR-([0-9]+)', data["Code"])
|
|
|
|
if code_match:
|
|
|
|
self.__opus = "PR"
|
|
|
|
self.__serial = code_match.group(1)
|
|
|
|
self.__rarity = "P"
|
2021-08-02 23:37:22 +00:00
|
|
|
|
2021-08-02 23:55:12 +00:00
|
|
|
else:
|
|
|
|
code_match = re.match(r'B-([0-9]+)', data["Code"])
|
|
|
|
if code_match:
|
|
|
|
self.__opus = "B"
|
|
|
|
self.__serial = code_match.group(1)
|
|
|
|
self.__rarity = "B"
|
|
|
|
|
|
|
|
self.__name = data["Name_EN"]
|
|
|
|
self.__element = data["Element"]
|
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}"
|