This repository has been archived by the owner on Nov 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcharacters.py
253 lines (224 loc) · 5.11 KB
/
characters.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
from levels import (
Client,
ClientConfig,
LevelDefiner,
LevelNotDetected,
MyFileHandler,
MyFormatter,
MyStreamHandler,
Path,
Settings,
Sg,
bar_bbox,
bar_colors,
box,
ceil,
chunks,
compare,
copy,
datetime,
excepthook,
first_digit_dict,
floor,
font_color,
format_time,
get_duration_gold,
get_duration_xp,
get_font_name,
get_menu_pixels,
get_rotation,
get_text,
global_settings,
gold_levels,
hdlr,
importlib,
json,
level_bbox,
level_hundred_conditions,
levels_xp,
load_font,
locked_color,
locked_pixel,
log,
logger,
logging,
my_emit,
os,
requests,
rewards_bar_bbox,
rewards_bar_colors,
rfh,
second_digit_dict,
second_digit_diff,
set_text,
single_digit_dict,
single_digit_diff,
sys,
timedelta,
)
characters = [
"bödvar",
"cassidy",
"orion",
"lord vraxx",
"gnash",
"queen nai",
"hattori",
"sir roland",
"scarlet",
"thatch",
"ada",
"sentinel",
"lucien",
"teros",
"brynn",
"asuri",
"barraza",
"ember",
"azoth",
"koji",
"ulgrim",
"diana",
"jhala",
"kor",
"wu shang",
"val",
"ragnir",
"cross",
"mirage",
"nix",
"mordex",
"yumiko",
"artemis",
"caspian",
"sidra",
"xull",
"kaya",
"isaiah",
"jiro",
"lin fei",
"zariel",
"rayman",
"dusk",
"fait",
"thor",
"petra",
"vector",
"volkov",
"onyx",
"jaeyun",
"mako",
"magyar",
"reno",
"munin",
"arcadia",
"ezio",
"tezca",
"thea",
"red raptor",
"loki",
"seven",
"vivi",
"imugi",
]
level_character_matrix_width = 15
level_character_matrix = list(
[
characters[i : i + level_character_matrix_width]
for i in range(0, len(characters), level_character_matrix_width)
]
)
character_matrix_width = 13
character_matrix = []
def build_character_matrix(_characters):
global character_matrix
character_matrix = list(
[
_characters[i : i + character_matrix_width]
for i in range(0, len(_characters), character_matrix_width)
]
)
build_character_matrix(characters + ["random"])
def find_char(name):
for i, row in enumerate(character_matrix):
try:
return i + 1, row.index(name) + 1
except ValueError:
pass
def map_to_char(row, col):
return ["down"] * (row - 1) + ["right"] * (col - 1)
def parse_pos(inp):
try:
pos = tuple(map(int, inp.split()))
except ValueError:
pos = find_char(inp.lower())
if not pos:
return None
return map_to_char(*pos)
class Character:
def __init__(self, name, level=0, xp=0, unlocked=True):
self.name = name
self.level = level
self.xp = xp
self.unlocked = unlocked
def add_xp(self, xp):
gold = 0
self.xp += xp
while levels_xp[self.level] and self.xp > levels_xp[self.level]:
self.xp -= levels_xp[self.level]
self.level += 1
if self.level in gold_levels:
gold += 120
return gold
def get_xp_to_level(self, level):
return max(
sum((levels_xp[level]) for level in range(self.level, level)) - self.xp, 1
)
@property
def xp_to_next_level(self):
return self.get_xp_to_level(self.level + 1)
@property
def total_xp(self):
return sum(levels_xp[i] for i in range(self.level)) + self.xp
@property
def next_gold_level(self):
try:
return next(filter(lambda i: i in gold_levels, range(self.level + 1, 101)))
except StopIteration:
return 101
@property
def xp_to_next_gold(self):
return self.get_xp_to_level(self.next_gold_level)
def get_path_to(self, name):
orow, opos = find_char(self.name)
trow, tpos = find_char(name)
if orow == 4:
return (
(trow - orow) * ["down"]
+ (orow - trow) * ["up"]
+ (tpos - opos) * ["right"]
+ (opos - tpos) * ["left"]
)
return (
(tpos - opos) * ["right"]
+ (opos - tpos) * ["left"]
+ (trow - orow) * ["down"]
+ (orow - trow) * ["up"]
)
@staticmethod
def get_duration_for_xp(xp, maximum=15):
return ceil(min((xp + 1) / 41, maximum))
def get_duration_to_next_level(self, maximum=15):
return self.get_duration_for_xp(self.xp_to_next_level, maximum)
@property
def duration_to_next_level(self):
return self.get_duration_to_next_level()
def get_duration_to_next_gold(self, maximum=15):
return self.get_duration_for_xp(self.xp_to_next_gold, maximum)
@property
def duration_to_next_gold(self):
return self.get_duration_to_next_gold()
def __str__(self):
return f"<{self.name.capitalize()} (lvl: {self.level}, xp: {self.xp}, unlocked: {self.unlocked})>"
def __repr__(self):
return str(self)