akef 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- akef/__init__.py +19 -0
- akef/cache.py +36 -0
- akef/client.py +578 -0
- akef/constants.py +17 -0
- akef/enka/__init__.py +13 -0
- akef/enka/build.py +175 -0
- akef/enka/client.py +60 -0
- akef/enka/gamedata.py +196 -0
- akef/enka/player.py +61 -0
- akef/enka/profile.py +337 -0
- akef/enka/skport.py +259 -0
- akef/enka/stats.py +307 -0
- akef/errors.py +54 -0
- akef/models/__init__.py +99 -0
- akef/models/account.py +78 -0
- akef/models/base.py +40 -0
- akef/models/card.py +664 -0
- akef/models/extra.py +207 -0
- akef/models/game.py +113 -0
- akef/models/pulls.py +149 -0
- akef/py.typed +0 -0
- akef/signing.py +20 -0
- akef/wiki.py +193 -0
- akef-0.3.0.dist-info/METADATA +289 -0
- akef-0.3.0.dist-info/RECORD +28 -0
- akef-0.3.0.dist-info/WHEEL +5 -0
- akef-0.3.0.dist-info/licenses/LICENSE +21 -0
- akef-0.3.0.dist-info/top_level.txt +1 -0
akef/models/card.py
ADDED
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
|
|
6
|
+
from pydantic import Field
|
|
7
|
+
|
|
8
|
+
from akef.models.base import Model, Progress, Tag, Timestamp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def tier_unlocked(node: str, latest: list[str]) -> bool:
|
|
12
|
+
# passive/base lines only report their highest tier, everything below it is unlocked too
|
|
13
|
+
line, _, tier = node.rpartition("_")
|
|
14
|
+
for top_node in latest:
|
|
15
|
+
head, _, top = top_node.rpartition("_")
|
|
16
|
+
if head == line and tier.isdigit() and top.isdigit() and int(tier) <= int(top):
|
|
17
|
+
return True
|
|
18
|
+
return False
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Skill(Model):
|
|
22
|
+
id: str
|
|
23
|
+
name: str = ""
|
|
24
|
+
type: Tag = Field(default_factory=Tag)
|
|
25
|
+
element: Tag = Field(default_factory=Tag, alias="property")
|
|
26
|
+
icon_url: str = ""
|
|
27
|
+
desc: str = ""
|
|
28
|
+
desc_params: dict[str, str] = {}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Talent(Model):
|
|
32
|
+
id: str
|
|
33
|
+
name: str = ""
|
|
34
|
+
icon_url: str = ""
|
|
35
|
+
locked_icon_url: str = ""
|
|
36
|
+
desc: str = ""
|
|
37
|
+
desc_params: dict[str, str] = {}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class CharacterData(Model):
|
|
41
|
+
id: str
|
|
42
|
+
name: str = ""
|
|
43
|
+
avatar_sq_url: str = ""
|
|
44
|
+
avatar_rt_url: str = ""
|
|
45
|
+
illustration_url: str = ""
|
|
46
|
+
rarity: Tag = Field(default_factory=Tag)
|
|
47
|
+
profession: Tag = Field(default_factory=Tag)
|
|
48
|
+
element: Tag = Field(default_factory=Tag, alias="property")
|
|
49
|
+
weapon_type: Tag = Field(default_factory=Tag)
|
|
50
|
+
skills: list[Skill] = []
|
|
51
|
+
tags: list[str] = []
|
|
52
|
+
ability_talents: list[Talent] = []
|
|
53
|
+
combat_talents: list[Talent] = []
|
|
54
|
+
cultivation_talents: list[Talent] = []
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class SkillLevel(Model):
|
|
58
|
+
skill_id: str
|
|
59
|
+
level: int = 0
|
|
60
|
+
max_level: int = 0
|
|
61
|
+
skill_form_type: str = ""
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class Suit(Model):
|
|
65
|
+
id: str
|
|
66
|
+
name: str = ""
|
|
67
|
+
skill_id: str = ""
|
|
68
|
+
skill_desc: str = ""
|
|
69
|
+
skill_desc_params: dict[str, str] = {}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class EquipData(Model):
|
|
73
|
+
id: str
|
|
74
|
+
name: str = ""
|
|
75
|
+
icon_url: str = ""
|
|
76
|
+
rarity: Tag = Field(default_factory=Tag)
|
|
77
|
+
type: Tag = Field(default_factory=Tag)
|
|
78
|
+
level: Tag = Field(default_factory=Tag)
|
|
79
|
+
properties: list[str] = []
|
|
80
|
+
is_accessory: bool = False
|
|
81
|
+
suit: Suit | None = None
|
|
82
|
+
function: str = ""
|
|
83
|
+
pkg: str = ""
|
|
84
|
+
base_attr_value: int = 0
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Equip(Model):
|
|
88
|
+
equip_id: str
|
|
89
|
+
equip_data: EquipData
|
|
90
|
+
enhance: dict[str, int] = {}
|
|
91
|
+
can_enhance: bool = False
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def name(self) -> str:
|
|
95
|
+
return self.equip_data.name
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class TacticalItemData(Model):
|
|
99
|
+
id: str
|
|
100
|
+
name: str = ""
|
|
101
|
+
icon_url: str = ""
|
|
102
|
+
rarity: Tag = Field(default_factory=Tag)
|
|
103
|
+
active_effect_type: Tag = Field(default_factory=Tag)
|
|
104
|
+
active_effect: str = ""
|
|
105
|
+
passive_effect: str = ""
|
|
106
|
+
active_effect_params: dict[str, str] = {}
|
|
107
|
+
passive_effect_params: dict[str, str] = {}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class TacticalItem(Model):
|
|
111
|
+
tactical_item_id: str
|
|
112
|
+
tactical_item_data: TacticalItemData
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
def name(self) -> str:
|
|
116
|
+
return self.tactical_item_data.name
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class WeaponSkillInfo(Model):
|
|
120
|
+
skill: Tag = Field(default_factory=Tag)
|
|
121
|
+
max_level: int = 0
|
|
122
|
+
gem_tag_id: str = ""
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class WeaponData(Model):
|
|
126
|
+
id: str
|
|
127
|
+
name: str = ""
|
|
128
|
+
icon_url: str = ""
|
|
129
|
+
rarity: Tag = Field(default_factory=Tag)
|
|
130
|
+
type: Tag = Field(default_factory=Tag)
|
|
131
|
+
function: str = ""
|
|
132
|
+
description: str = ""
|
|
133
|
+
skills: list[Tag] = []
|
|
134
|
+
skill_infos: list[WeaponSkillInfo] = []
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class WeaponSkill(Model):
|
|
138
|
+
key: str
|
|
139
|
+
name: str = ""
|
|
140
|
+
level: int = 0
|
|
141
|
+
current_max_level: int = 0
|
|
142
|
+
current_base_level: int = 0
|
|
143
|
+
gem_term_id: str = ""
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class GemData(Model):
|
|
147
|
+
term_id: str = ""
|
|
148
|
+
name: str = ""
|
|
149
|
+
icon: str = ""
|
|
150
|
+
template_id: str = ""
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class GemTerm(Model):
|
|
154
|
+
id: str
|
|
155
|
+
name: str = ""
|
|
156
|
+
cost: int = 0
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class Gem(Model):
|
|
160
|
+
id: str
|
|
161
|
+
icon: str = ""
|
|
162
|
+
gem_data: GemData | None = None
|
|
163
|
+
terms: list[GemTerm] = []
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def name(self) -> str:
|
|
167
|
+
return self.gem_data.name if self.gem_data else ""
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class Weapon(Model):
|
|
171
|
+
weapon_data: WeaponData
|
|
172
|
+
level: int = 0
|
|
173
|
+
refine_level: int = 0
|
|
174
|
+
breakthrough_level: int = 0
|
|
175
|
+
gem: Gem | None = None
|
|
176
|
+
skills: list[WeaponSkill] = []
|
|
177
|
+
wiki_item_id: str = ""
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def name(self) -> str:
|
|
181
|
+
return self.weapon_data.name
|
|
182
|
+
|
|
183
|
+
@property
|
|
184
|
+
def rarity(self) -> int:
|
|
185
|
+
return int(self.weapon_data.rarity.value or 0)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class TalentNodes(Model):
|
|
189
|
+
latest_break_node: str = ""
|
|
190
|
+
attr_nodes: list[str] = []
|
|
191
|
+
latest_passive_skill_nodes: list[str] = []
|
|
192
|
+
latest_factory_skill_nodes: list[str] = []
|
|
193
|
+
latest_spaceship_skill_nodes: list[str] = []
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class Character(Model):
|
|
197
|
+
id: str
|
|
198
|
+
char_data: CharacterData
|
|
199
|
+
level: int = 0
|
|
200
|
+
evolve_phase: int = 0
|
|
201
|
+
potential_level: int = 0
|
|
202
|
+
user_skills: dict[str, SkillLevel] = {}
|
|
203
|
+
body_equip: Equip | None = None
|
|
204
|
+
arm_equip: Equip | None = None
|
|
205
|
+
first_accessory: Equip | None = None
|
|
206
|
+
second_accessory: Equip | None = None
|
|
207
|
+
tactical_item: TacticalItem | None = None
|
|
208
|
+
weapon: Weapon | None = None
|
|
209
|
+
talent: TalentNodes | None = None
|
|
210
|
+
gender: str = ""
|
|
211
|
+
own_ts: Timestamp = None
|
|
212
|
+
wiki_item_id: str = ""
|
|
213
|
+
|
|
214
|
+
@property
|
|
215
|
+
def name(self) -> str:
|
|
216
|
+
return self.char_data.name
|
|
217
|
+
|
|
218
|
+
@property
|
|
219
|
+
def rarity(self) -> int:
|
|
220
|
+
return int(self.char_data.rarity.value or 0)
|
|
221
|
+
|
|
222
|
+
@property
|
|
223
|
+
def element(self) -> str:
|
|
224
|
+
return self.char_data.element.value
|
|
225
|
+
|
|
226
|
+
@property
|
|
227
|
+
def profession(self) -> str:
|
|
228
|
+
return self.char_data.profession.value
|
|
229
|
+
|
|
230
|
+
@property
|
|
231
|
+
def equips(self) -> list[Equip]:
|
|
232
|
+
slots = (self.body_equip, self.arm_equip, self.first_accessory, self.second_accessory)
|
|
233
|
+
return [e for e in slots if e is not None]
|
|
234
|
+
|
|
235
|
+
def skill_level(self, skill_id: str) -> int:
|
|
236
|
+
found = self.user_skills.get(skill_id)
|
|
237
|
+
return found.level if found else 0
|
|
238
|
+
|
|
239
|
+
@property
|
|
240
|
+
def talents(self) -> list[Talent]:
|
|
241
|
+
d = self.char_data
|
|
242
|
+
return [
|
|
243
|
+
*sorted(d.ability_talents, key=lambda t: t.id),
|
|
244
|
+
*sorted(d.combat_talents, key=lambda t: t.id),
|
|
245
|
+
*sorted(d.cultivation_talents, key=lambda t: t.id),
|
|
246
|
+
]
|
|
247
|
+
|
|
248
|
+
def talent_unlocked(self, talent_id: str) -> bool:
|
|
249
|
+
nodes = self.talent
|
|
250
|
+
if nodes is None:
|
|
251
|
+
return False
|
|
252
|
+
if talent_id in nodes.attr_nodes:
|
|
253
|
+
return True
|
|
254
|
+
latest = nodes.latest_passive_skill_nodes + nodes.latest_spaceship_skill_nodes + nodes.latest_factory_skill_nodes
|
|
255
|
+
return tier_unlocked(talent_id, latest)
|
|
256
|
+
|
|
257
|
+
@property
|
|
258
|
+
def unlocked_talents(self) -> list[Talent]:
|
|
259
|
+
return [t for t in self.talents if self.talent_unlocked(t.id)]
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class Mission(Model):
|
|
263
|
+
id: str = ""
|
|
264
|
+
description: str = ""
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
class Base(Model):
|
|
268
|
+
uid: str = Field(alias="roleId")
|
|
269
|
+
name: str = ""
|
|
270
|
+
server_name: str = ""
|
|
271
|
+
level: int = 0
|
|
272
|
+
world_level: int = 0
|
|
273
|
+
exp: int = 0
|
|
274
|
+
gender: int = 0
|
|
275
|
+
avatar_url: str = ""
|
|
276
|
+
main_mission: Mission = Field(default_factory=Mission)
|
|
277
|
+
char_num: int = 0
|
|
278
|
+
weapon_num: int = 0
|
|
279
|
+
doc_num: int = 0
|
|
280
|
+
create_time: Timestamp = None
|
|
281
|
+
save_time: Timestamp = None
|
|
282
|
+
last_login_time: Timestamp = None
|
|
283
|
+
|
|
284
|
+
@property
|
|
285
|
+
def awakening_days(self) -> int:
|
|
286
|
+
if self.create_time is None:
|
|
287
|
+
return 0
|
|
288
|
+
return (datetime.now(timezone.utc) - self.create_time).days + 1
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
class Stamina(Model):
|
|
292
|
+
current: int = Field(0, alias="curStamina")
|
|
293
|
+
max: int = Field(0, alias="maxStamina")
|
|
294
|
+
full_at: Timestamp = Field(None, alias="maxTs")
|
|
295
|
+
|
|
296
|
+
@property
|
|
297
|
+
def is_full(self) -> bool:
|
|
298
|
+
return self.current >= self.max
|
|
299
|
+
|
|
300
|
+
@property
|
|
301
|
+
def seconds_left(self) -> int:
|
|
302
|
+
if self.full_at is None or self.is_full:
|
|
303
|
+
return 0
|
|
304
|
+
return max(0, int((self.full_at - datetime.now(timezone.utc)).total_seconds()))
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
class BattlePass(Model):
|
|
308
|
+
cur_level: int = 0
|
|
309
|
+
max_level: int = 0
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
class DailyMission(Model):
|
|
313
|
+
current: int = Field(0, alias="dailyActivation")
|
|
314
|
+
max: int = Field(0, alias="maxDailyActivation")
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
class WeeklyMission(Model):
|
|
318
|
+
score: int = 0
|
|
319
|
+
total: int = 0
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class Credit(Model):
|
|
323
|
+
count: int = 0
|
|
324
|
+
total: int = 0
|
|
325
|
+
has_today: bool = False
|
|
326
|
+
next_refresh_ts: Timestamp = None
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
class AchievementData(Model):
|
|
330
|
+
id: str
|
|
331
|
+
name: str = ""
|
|
332
|
+
init_icon: str = ""
|
|
333
|
+
plated_icon: str = ""
|
|
334
|
+
cate: str = ""
|
|
335
|
+
cate_name: str = ""
|
|
336
|
+
init_level: int = 0
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
class Medal(Model):
|
|
340
|
+
achievement_data: AchievementData
|
|
341
|
+
level: int = 0
|
|
342
|
+
is_plated: bool = False
|
|
343
|
+
obtain_ts: Timestamp = None
|
|
344
|
+
|
|
345
|
+
@property
|
|
346
|
+
def name(self) -> str:
|
|
347
|
+
return self.achievement_data.name.strip('"')
|
|
348
|
+
|
|
349
|
+
@property
|
|
350
|
+
def icon(self) -> str:
|
|
351
|
+
data = self.achievement_data
|
|
352
|
+
return data.plated_icon if self.is_plated and data.plated_icon else data.init_icon
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
class Achievements(Model):
|
|
356
|
+
count: int = 0
|
|
357
|
+
medals: list[Medal] = Field([], alias="achieveMedals")
|
|
358
|
+
display: dict[str, str] = {}
|
|
359
|
+
|
|
360
|
+
@property
|
|
361
|
+
def showcased(self) -> list[Medal]:
|
|
362
|
+
by_id = {m.achievement_data.id: m for m in self.medals}
|
|
363
|
+
return [by_id[i] for _, i in sorted(self.display.items(), key=lambda kv: int(kv[0])) if i in by_id]
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
class RoomChar(Model):
|
|
367
|
+
char_id: str
|
|
368
|
+
physical_strength: float = 0
|
|
369
|
+
favorability: int = 0
|
|
370
|
+
avatar_url: str = ""
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
class Room(Model):
|
|
374
|
+
id: str = ""
|
|
375
|
+
type: int = 0
|
|
376
|
+
level: int = 0
|
|
377
|
+
chars: list[RoomChar] = []
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
class SpaceShip(Model):
|
|
381
|
+
rooms: list[Room] = []
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
class Settlement(Model):
|
|
385
|
+
id: str
|
|
386
|
+
name: str = ""
|
|
387
|
+
level: int = 0
|
|
388
|
+
exp: int = 0
|
|
389
|
+
exp_to_level_up: int = 0
|
|
390
|
+
remain_money: int = 0
|
|
391
|
+
money_max: int = 0
|
|
392
|
+
officer_char_ids: str = ""
|
|
393
|
+
officer_char_avatar: str = ""
|
|
394
|
+
is_final_max_level: bool = False
|
|
395
|
+
last_tick_time: Timestamp = None
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
class Area(Model):
|
|
399
|
+
level_id: str
|
|
400
|
+
name: str = ""
|
|
401
|
+
puzzle_count: Progress = Field(default_factory=Progress)
|
|
402
|
+
trchest_count: Progress = Field(default_factory=Progress)
|
|
403
|
+
equip_trchest_count: Progress = Field(default_factory=Progress)
|
|
404
|
+
piece_count: Progress = Field(default_factory=Progress)
|
|
405
|
+
blackbox_count: Progress = Field(default_factory=Progress)
|
|
406
|
+
trstar_count: Progress = Field(default_factory=Progress)
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
class Domain(Model):
|
|
410
|
+
domain_id: str
|
|
411
|
+
name: str = ""
|
|
412
|
+
level: int = 0
|
|
413
|
+
settlements: list[Settlement] = []
|
|
414
|
+
money: Progress = Field(default_factory=Progress, alias="moneyMgr")
|
|
415
|
+
areas: list[Area] = Field([], alias="levels")
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
class CrisisContract(Model):
|
|
419
|
+
id: str
|
|
420
|
+
name: str = ""
|
|
421
|
+
highest: int = 0
|
|
422
|
+
challenge_count: int = 0
|
|
423
|
+
achieve: Medal | None = None
|
|
424
|
+
weekly_mission: Progress = Field(default_factory=Progress)
|
|
425
|
+
indicator_mission: Progress = Field(default_factory=Progress)
|
|
426
|
+
stage_mission: Progress = Field(default_factory=Progress)
|
|
427
|
+
kv_image: str = ""
|
|
428
|
+
header_image: str = ""
|
|
429
|
+
start_at_ts: Timestamp = None
|
|
430
|
+
end_at_ts: Timestamp = None
|
|
431
|
+
gameplay_end_at_ts: Timestamp = None
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
class EchoStage(Model):
|
|
435
|
+
name: str = ""
|
|
436
|
+
star: int = 0
|
|
437
|
+
plus_task: bool = False
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
class EchoWeek(Model):
|
|
441
|
+
id: str
|
|
442
|
+
name: str = ""
|
|
443
|
+
stars: int = 0
|
|
444
|
+
all_plus_tasks: bool = False
|
|
445
|
+
start_ts: Timestamp = None
|
|
446
|
+
end_ts: Timestamp = None
|
|
447
|
+
dungeon_groups: list[EchoStage] = []
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
class EchoSeason(Model):
|
|
451
|
+
id: str
|
|
452
|
+
name: str = ""
|
|
453
|
+
stars: int = 0
|
|
454
|
+
all_plus_tasks: bool = False
|
|
455
|
+
kv_image: str = ""
|
|
456
|
+
header_image: str = ""
|
|
457
|
+
start_ts: Timestamp = None
|
|
458
|
+
end_ts: Timestamp = None
|
|
459
|
+
weeks: list[EchoWeek] = []
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
class WarEchoes(Model):
|
|
463
|
+
seasons: list[EchoSeason] = []
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
class Enemy(Model):
|
|
467
|
+
id: str
|
|
468
|
+
name: str = ""
|
|
469
|
+
desc: str = ""
|
|
470
|
+
level: int = 0
|
|
471
|
+
image_url: str = ""
|
|
472
|
+
ability: str = ""
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
class RecordChar(Model):
|
|
476
|
+
char_id: str
|
|
477
|
+
level: int = 0
|
|
478
|
+
evolve_phase: int = 0
|
|
479
|
+
potential_level: int = 0
|
|
480
|
+
avatar_url: str = ""
|
|
481
|
+
element: Tag = Field(default_factory=Tag, alias="property")
|
|
482
|
+
rarity: Tag = Field(default_factory=Tag)
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
class BestRecord(Model):
|
|
486
|
+
chars: list[RecordChar] = []
|
|
487
|
+
cleared_at: Timestamp = Field(None, alias="ts")
|
|
488
|
+
# despite the name this is how long the clear took, in seconds
|
|
489
|
+
seconds: int = Field(0, alias="passTs")
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
class Dungeon(Model):
|
|
493
|
+
id: str
|
|
494
|
+
name: str = ""
|
|
495
|
+
is_pass: bool = False
|
|
496
|
+
desc: str = ""
|
|
497
|
+
feature: str = ""
|
|
498
|
+
recommend_level: int = 0
|
|
499
|
+
enemies: list[Enemy] = []
|
|
500
|
+
best_record: BestRecord | None = None
|
|
501
|
+
|
|
502
|
+
@property
|
|
503
|
+
def rules(self) -> list[str]:
|
|
504
|
+
text = re.sub(r"<@[^>]*>|</>", "", self.feature)
|
|
505
|
+
return [line.strip(" -") for line in text.splitlines() if line.strip(" -")]
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
class DungeonPair(Model):
|
|
509
|
+
normal_dungeon: Dungeon | None = None
|
|
510
|
+
hard_dungeon: Dungeon | None = None
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
class IndieHardGroup(Model):
|
|
514
|
+
id: str
|
|
515
|
+
name: str = ""
|
|
516
|
+
pic: str = ""
|
|
517
|
+
dungeon_groups: list[DungeonPair] = []
|
|
518
|
+
activity_name: str = ""
|
|
519
|
+
is_in_activity: bool = False
|
|
520
|
+
activity_start_ts: Timestamp = None
|
|
521
|
+
activity_end_ts: Timestamp = None
|
|
522
|
+
achieve: Medal | None = None
|
|
523
|
+
|
|
524
|
+
@property
|
|
525
|
+
def cleared(self) -> tuple[int, int]:
|
|
526
|
+
normal = sum(1 for p in self.dungeon_groups if p.normal_dungeon and p.normal_dungeon.is_pass)
|
|
527
|
+
hard = sum(1 for p in self.dungeon_groups if p.hard_dungeon and p.hard_dungeon.is_pass)
|
|
528
|
+
return normal, hard
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
class IndieHard(Model):
|
|
532
|
+
groups: list[IndieHardGroup] = Field([], alias="indieHardGroups")
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
class QuickAccess(Model):
|
|
536
|
+
name: str = ""
|
|
537
|
+
icon: str = ""
|
|
538
|
+
link: str = ""
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
class CardConfig(Model):
|
|
542
|
+
char_ids: list[str] = []
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
class Card(Model):
|
|
546
|
+
base: Base
|
|
547
|
+
chars: list[Character] = []
|
|
548
|
+
achieve: Achievements = Field(default_factory=Achievements)
|
|
549
|
+
space_ship: SpaceShip = Field(default_factory=SpaceShip)
|
|
550
|
+
domain: list[Domain] = []
|
|
551
|
+
stamina: Stamina = Field(default_factory=Stamina, alias="dungeon")
|
|
552
|
+
battle_pass: BattlePass = Field(default_factory=BattlePass, alias="bpSystem")
|
|
553
|
+
daily: DailyMission = Field(default_factory=DailyMission, alias="dailyMission")
|
|
554
|
+
weekly: WeeklyMission = Field(default_factory=WeeklyMission, alias="weeklyMission")
|
|
555
|
+
credit: Credit = Field(default_factory=Credit)
|
|
556
|
+
crisis_contract: list[CrisisContract] = []
|
|
557
|
+
war_echoes: WarEchoes = Field(default_factory=WarEchoes)
|
|
558
|
+
indie_hard: IndieHard = Field(default_factory=IndieHard)
|
|
559
|
+
config: CardConfig = Field(default_factory=CardConfig)
|
|
560
|
+
seek_suspicion: Progress = Field(default_factory=Progress)
|
|
561
|
+
quickaccess: list[QuickAccess] = []
|
|
562
|
+
current_ts: Timestamp = None
|
|
563
|
+
|
|
564
|
+
@property
|
|
565
|
+
def uid(self) -> str:
|
|
566
|
+
return self.base.uid
|
|
567
|
+
|
|
568
|
+
def sanity_at(self, value: int) -> datetime | None:
|
|
569
|
+
# recovery speed comes from how long the rest takes, so no regen rate is hard coded
|
|
570
|
+
s = self.stamina
|
|
571
|
+
if value <= s.current:
|
|
572
|
+
return self.current_ts or datetime.now(timezone.utc)
|
|
573
|
+
if value > s.max or s.full_at is None or self.current_ts is None:
|
|
574
|
+
return None
|
|
575
|
+
per_point = (s.full_at - self.current_ts) / (s.max - s.current)
|
|
576
|
+
return self.current_ts + per_point * (value - s.current)
|
|
577
|
+
|
|
578
|
+
@property
|
|
579
|
+
def showcased(self) -> list[Character]:
|
|
580
|
+
by_id = {c.id: c for c in self.chars}
|
|
581
|
+
return [by_id[i] for i in self.config.char_ids if i in by_id]
|
|
582
|
+
|
|
583
|
+
@property
|
|
584
|
+
def name(self) -> str:
|
|
585
|
+
return self.base.name
|
|
586
|
+
|
|
587
|
+
def character(self, name_or_id: str) -> Character | None:
|
|
588
|
+
wanted = name_or_id.lower()
|
|
589
|
+
return next((c for c in self.chars if c.id == name_or_id or c.name.lower() == wanted), None)
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
PARAM = re.compile(r"\{(?:@[^@}]*@)?(-?)(\w+):(0(?:\.0+)?)(%?)\}")
|
|
593
|
+
TAG = re.compile(r"</?(?:color[^>]*|[@#][^>]*)?>")
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
def fill(desc: str, params: dict[str, str]) -> str:
|
|
597
|
+
# game text keeps numbers as {name:0%} with the values sent apart, and colours as <color=...> tags
|
|
598
|
+
def value(m):
|
|
599
|
+
raw = params.get(m.group(2))
|
|
600
|
+
if raw is None:
|
|
601
|
+
return m.group(0)
|
|
602
|
+
number = float(raw) * (-1 if m.group(1) else 1) * (100 if m.group(4) else 1)
|
|
603
|
+
places = len(m.group(3)) - 2 if "." in m.group(3) else 0
|
|
604
|
+
return f"{number:.{places}f}{m.group(4)}"
|
|
605
|
+
return TAG.sub("", PARAM.sub(value, desc or "")).strip()
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
class ContractChar(Model):
|
|
609
|
+
char_id: str
|
|
610
|
+
level: int = 0
|
|
611
|
+
potential_level: int = 0
|
|
612
|
+
avatar_url: str = ""
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
class ContractRun(Model):
|
|
616
|
+
id: str = ""
|
|
617
|
+
chars: list[ContractChar] = []
|
|
618
|
+
played_at: Timestamp = Field(None, alias="ts")
|
|
619
|
+
seconds: int = Field(0, alias="passTs")
|
|
620
|
+
cleared: bool = Field(False, alias="isPass")
|
|
621
|
+
score: int = Field(0, alias="indicatorCount")
|
|
622
|
+
waves: int = Field(0, alias="passWave")
|
|
623
|
+
is_best: bool = False
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
class ContractHistory(Model):
|
|
627
|
+
records: list[ContractRun] = []
|
|
628
|
+
best_record: ContractRun | None = None
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
class Indicator(Model):
|
|
632
|
+
id: str
|
|
633
|
+
icon: str = ""
|
|
634
|
+
name: str = ""
|
|
635
|
+
desc: str = ""
|
|
636
|
+
desc_params: dict[str, str] = {}
|
|
637
|
+
has_award: bool = False
|
|
638
|
+
type: int = 0
|
|
639
|
+
depends: list[str] = []
|
|
640
|
+
score: int = 0
|
|
641
|
+
is_unlock: bool = False
|
|
642
|
+
|
|
643
|
+
@property
|
|
644
|
+
def text(self) -> str:
|
|
645
|
+
return fill(self.desc, self.desc_params)
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
class ContractStage(Model):
|
|
649
|
+
id: str = ""
|
|
650
|
+
name: str = ""
|
|
651
|
+
desc: str = ""
|
|
652
|
+
enemies: list[Enemy] = []
|
|
653
|
+
recommend_level: int = 0
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
class ContractDetail(Model):
|
|
657
|
+
status: CrisisContract
|
|
658
|
+
history: ContractHistory = Field(default_factory=ContractHistory)
|
|
659
|
+
indicators: list[Indicator] = []
|
|
660
|
+
stage: ContractStage = Field(default_factory=ContractStage, alias="dungeon")
|
|
661
|
+
|
|
662
|
+
@property
|
|
663
|
+
def best(self) -> ContractRun | None:
|
|
664
|
+
return self.history.best_record or next((r for r in self.history.records if r.is_best), None)
|