CrystTCG-DB-AngeU/model/progress.py

87 lines
2.4 KiB
Python
Raw Normal View History

from typing import Optional, Tuple
from .constants import FrameType
2023-10-10 12:01:34 +08:00
class Link:
cost: int
# condition: [Omega, Sigma, Any]
# example: "Omega, Sigma, Sigma, 2" -> (1, 2, 2)
condition: Tuple[int, int, int]
effect: str
2023-10-23 23:35:02 +08:00
effect_tran:str
2023-10-10 12:01:34 +08:00
2023-10-23 23:35:02 +08:00
def __init__(self, cost: int, condition: Tuple[int, int, int], effect: str,effect_tran:str) -> None:
2023-10-10 12:01:34 +08:00
self.cost = cost
self.condition = condition
self.effect = effect
2023-10-23 23:35:02 +08:00
self.effect_tran = effect_tran
2023-10-10 12:01:34 +08:00
def __json__(self):
return {
"cost": self.cost,
2023-10-10 13:47:00 +08:00
"condition": [FrameType.Omega.value] * self.condition[0]
+ [FrameType.Sigma.value] * self.condition[1]
+ [FrameType.Any.value] * self.condition[2],
2023-10-10 12:01:34 +08:00
"effect": self.effect,
2023-10-23 23:35:02 +08:00
"effect_tran": self.effect_tran,
2023-10-10 12:01:34 +08:00
}
class Ex:
name: str
effect: str
2023-10-23 23:35:02 +08:00
name_tran:str
effect_tran: str
2023-10-10 12:01:34 +08:00
2023-10-23 23:35:02 +08:00
def __init__(self, name: str, effect: str,name_tran:str,effect_tran:str) -> None:
2023-10-10 12:01:34 +08:00
self.name = name
self.effect = effect
2023-10-23 23:35:02 +08:00
self.name_tran = name_tran
self.effect_tran = effect_tran
2023-10-10 12:01:34 +08:00
def __json__(self):
2023-10-23 23:35:02 +08:00
return {"name": self.name, "effect": self.effect,"name_tran":self.name_tran,"effect_tran":self.effect_tran}
2023-10-10 12:01:34 +08:00
class ProgressAttr:
character: str
2023-10-23 23:35:02 +08:00
character_tran: str
2023-10-10 12:01:34 +08:00
link: Optional[Link]
ex: Optional[Ex]
def __init__(
self,
character: str,
2023-10-23 23:35:02 +08:00
character_tran: str,
2023-10-10 12:01:34 +08:00
link: Optional[Link],
ex: Optional[Ex],
) -> None:
self.character = character
2023-10-23 23:35:02 +08:00
self.character_tran = character_tran
2023-10-10 12:01:34 +08:00
self.link = link
self.ex = ex
def __json__(self):
return {
"character": self.character,
2023-10-23 23:35:02 +08:00
"character_tran": self.character_tran,
2023-10-10 12:01:34 +08:00
"link": self.link.__json__() if self.link else None,
"ex": self.ex.__json__() if self.ex else None,
}
def __text__(self) -> str:
text = ""
if self.ex:
text += f"[EX] {self.ex.name} {self.ex.effect}\n"
if self.link:
condition = (
["Ω" for _ in range(self.link.condition[0])]
+ ["Σ" for _ in range(self.link.condition[1])]
+ [str(self.link.condition[2])]
)
2023-10-10 15:46:30 +08:00
text += f"[Link-{self.link.cost}] {condition} {self.link.effect}\n"
2023-10-10 12:01:34 +08:00
return text