2020-09-22 17:42:57 +00:00
|
|
|
import royalnet.utils as ru
|
|
|
|
from typing import *
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from .check import Check
|
|
|
|
|
|
|
|
|
|
|
|
class TrionfoInfo:
|
|
|
|
def __init__(self,
|
|
|
|
variable: str,
|
|
|
|
title: str,
|
|
|
|
roman: str,
|
|
|
|
name: str,
|
|
|
|
objective: str,
|
|
|
|
puzzle: str,
|
2020-09-24 01:20:35 +00:00
|
|
|
check: "Check"):
|
2020-09-22 17:42:57 +00:00
|
|
|
self.variable: str = variable
|
|
|
|
self.title: str = title
|
|
|
|
self.roman: str = roman
|
|
|
|
self.name: str = name
|
|
|
|
self.objective: str = objective
|
|
|
|
self.puzzle: str = puzzle
|
2020-09-24 01:20:35 +00:00
|
|
|
self.check: "Check" = check
|
2020-09-22 17:42:57 +00:00
|
|
|
|
|
|
|
def json_anonymous(self) -> ru.JSON:
|
|
|
|
return {
|
|
|
|
"variable": self.variable,
|
|
|
|
"title": self.title,
|
|
|
|
"roman": self.roman,
|
|
|
|
"name": self.name,
|
|
|
|
"objective": self.objective,
|
|
|
|
}
|
|
|
|
|
|
|
|
def json_user(self, obj) -> ru.JSON:
|
|
|
|
status = obj.__getattribute__(self.variable)
|
|
|
|
return {
|
|
|
|
"variable": self.variable,
|
|
|
|
"title": self.title,
|
|
|
|
"roman": self.roman,
|
|
|
|
"name": self.name,
|
|
|
|
"objective": self.objective,
|
|
|
|
"puzzle": self.puzzle if status is not None else None,
|
2020-09-25 01:55:19 +00:00
|
|
|
"completed_on": status.timestamp() if status is not None else None
|
2020-09-22 17:42:57 +00:00
|
|
|
}
|