This repository has been archived by the owner on Jan 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
objects.py
98 lines (77 loc) · 2.77 KB
/
objects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from enum import Enum
class Status(Enum):
ABANDONED = "ABANDONED"
ACCEPTED = "ACCEPTED"
COMPLETED = "COMPLETED"
MISSING = "MISSING"
class Quest:
def __init__(self, name=None, status=None, timestamp=None, ignored=False, serie=1):
self.name = name
self.status = status
self.timestamp = timestamp
self.serie = serie
self.ignored = ignored
def key(self):
if self.serie > 1:
return f"{self.name} ({self.serie})"
return f"{self.name}"
def compare_status(self):
if self.status is Status.COMPLETED:
return 2
else:
return 1
def __str__(self):
if self.serie > 1:
return f"{self.name} ({self.serie}) {self.status.value} {self.timestamp}"
return f"{self.name} {self.status.value} {self.timestamp}"
def __repr__(self):
return self.__str__
def __eq__(self, other):
return (
self.name == other.name
and self.status is other.status
and self.serie == other.serie
)
def __ne__(self, other):
return not self.__eq__(other)
class ChatLog:
def __init__(self, timestamp, log):
self.timestamp = timestamp
self.log = log
def __str__(self):
return f"{self.timestamp} {self.log}"
def __repr__(self):
return self.__str__()
class UsersQuest:
def __init__(self, quest_name: str, usernames: list, ignored: bool):
self.quest_name = quest_name
self.user_quests = {}
self.ignored = ignored
for username in usernames:
self.user_quests[username] = None
self.compare_status = None
self.compare_timestamp = None
def addUserQuest(self, username: str, quest: Quest):
self.user_quests[username] = quest
self.compare_status = quest.compare_status()
for username, q in self.user_quests.items():
compare_status = 1 # Missing status
if q:
compare_status = q.compare_status()
if compare_status < self.compare_status:
self.compare_status = compare_status
if not self.compare_timestamp or self.compare_timestamp < quest.timestamp:
self.compare_timestamp = quest.timestamp
def __str__(self):
return self.__repr__()
def __repr__(self):
sb = ""
for username, quest in self.user_quests.items():
if quest:
sb = f"{sb} {username:5} {quest.status.name:10}"
else:
sb = f"{sb} {username:5} {Status.MISSING.name:10}"
# return f"{self.quest_name} {self.compare_status} {self.compare_timestamp}"
return (
f"{self.quest_name:35} {sb} {self.compare_timestamp} {self.compare_status}"
)