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/enka/stats.py
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
from collections import defaultdict
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
|
|
7
|
+
from akef.errors import MissingGameData
|
|
8
|
+
from akef.enka.gamedata import GameData, slot_of
|
|
9
|
+
|
|
10
|
+
STR, AGI, INT, WILL = 39, 40, 41, 42
|
|
11
|
+
HP, ATK, DEF = 1, 2, 3
|
|
12
|
+
MAIN, SUB = 10000, 10001
|
|
13
|
+
ETHER_DMG = 55
|
|
14
|
+
|
|
15
|
+
PART = {
|
|
16
|
+
"BaseAddition": "base",
|
|
17
|
+
"BaseMultiplier": "ratio",
|
|
18
|
+
"BaseFinalMultiplier": "delta",
|
|
19
|
+
"BaseFinalAddition": "delta",
|
|
20
|
+
"Addition": "delta",
|
|
21
|
+
}
|
|
22
|
+
ATTR_FIELD = {STR: "strength", AGI: "agility", INT: "intellect", WILL: "will"}
|
|
23
|
+
LABEL = {
|
|
24
|
+
1: "HP", 2: "ATK", 3: "DEF", 9: "Crit Rate", 10: "Crit DMG", 17: "Basic Attack DMG", 28: "Ultimate DMG",
|
|
25
|
+
29: "Treatment Bonus", 32: "Battle Skill DMG", 33: "Combo Skill DMG", 39: "Strength", 40: "Agility",
|
|
26
|
+
41: "Intellect", 42: "Will", 44: "Ult Gain", 50: "Physical DMG", 51: "Heat DMG", 52: "Electric DMG",
|
|
27
|
+
53: "Cryo DMG", 54: "Nature DMG", 61: "DMG vs. Staggered", 87: "Arts Intensity",
|
|
28
|
+
}
|
|
29
|
+
GROUP_LABEL = {
|
|
30
|
+
frozenset({52, 53}): "Cryo & Electric DMG",
|
|
31
|
+
frozenset({51, 54}): "Heat & Nature DMG",
|
|
32
|
+
frozenset({51, 52, 53, 54}): "Arts DMG",
|
|
33
|
+
frozenset({28, 32, 33}): "All Skill DMG",
|
|
34
|
+
frozenset({4, 5, 6, 7, 48, 60}): "DMG Reduction",
|
|
35
|
+
}
|
|
36
|
+
FLAT = {HP, ATK, DEF, STR, AGI, INT, WILL, 87, MAIN, SUB}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass
|
|
40
|
+
class Stats:
|
|
41
|
+
strength: int = 0
|
|
42
|
+
agility: int = 0
|
|
43
|
+
intellect: int = 0
|
|
44
|
+
will: int = 0
|
|
45
|
+
hp: int = 0
|
|
46
|
+
atk: int = 0
|
|
47
|
+
defense: int = 0
|
|
48
|
+
crit_rate: float = 0
|
|
49
|
+
crit_dmg: float = 0
|
|
50
|
+
arts_intensity: float = 0
|
|
51
|
+
treatment_bonus: float = 0
|
|
52
|
+
treatment_received: float = 0
|
|
53
|
+
ult_gain: float = 0
|
|
54
|
+
stagger_dmg: float = 0
|
|
55
|
+
physical_dmg: float = 0
|
|
56
|
+
heat_dmg: float = 0
|
|
57
|
+
electric_dmg: float = 0
|
|
58
|
+
cryo_dmg: float = 0
|
|
59
|
+
nature_dmg: float = 0
|
|
60
|
+
basic_attack_dmg: float = 0
|
|
61
|
+
battle_skill_dmg: float = 0
|
|
62
|
+
combo_skill_dmg: float = 0
|
|
63
|
+
ultimate_dmg: float = 0
|
|
64
|
+
main_attribute: str = ""
|
|
65
|
+
sub_attribute: str = ""
|
|
66
|
+
|
|
67
|
+
def percent(self, name: str) -> str:
|
|
68
|
+
# half up to one decimal like the game. game keeps fewer digits so 216.2499986 still shows 216.3
|
|
69
|
+
value = getattr(self, name) * 100
|
|
70
|
+
return f"{math.floor(value * 10 + 0.5 + 1e-4) / 10:.1f}%"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@dataclass
|
|
74
|
+
class GearLine:
|
|
75
|
+
name: str
|
|
76
|
+
value: float
|
|
77
|
+
percent: bool
|
|
78
|
+
level: int = 0
|
|
79
|
+
max_level: int = 3
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def text(self) -> str:
|
|
83
|
+
if self.percent:
|
|
84
|
+
return f"+{(self.value + 1e-4) * 100:.1f}%"
|
|
85
|
+
return f"+{math.floor(self.value):,}"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@dataclass
|
|
89
|
+
class GearStats:
|
|
90
|
+
slot: str
|
|
91
|
+
defense: int = 0
|
|
92
|
+
lines: list[GearLine] = field(default_factory=list)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@dataclass
|
|
96
|
+
class Loadout:
|
|
97
|
+
avatar: dict
|
|
98
|
+
level: int = 1
|
|
99
|
+
potential: int = 0
|
|
100
|
+
attr_nodes: list[str] = field(default_factory=list)
|
|
101
|
+
passive_nodes: list[str] = field(default_factory=list)
|
|
102
|
+
weapon: dict | None = None
|
|
103
|
+
weapon_level: int = 1
|
|
104
|
+
weapon_skill_levels: list[int] = field(default_factory=list)
|
|
105
|
+
gear: list[tuple[dict, dict[str, int]]] = field(default_factory=list)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class Sheet:
|
|
109
|
+
def __init__(self, main: int, sub: int):
|
|
110
|
+
self.main = main
|
|
111
|
+
self.sub = sub
|
|
112
|
+
self.parts: dict[tuple[int, str], float] = defaultdict(float)
|
|
113
|
+
self.atk_total_ratio = 0.0
|
|
114
|
+
|
|
115
|
+
def add(self, stat, value: float, formula: str = "BaseAddition") -> None:
|
|
116
|
+
stat = int(stat)
|
|
117
|
+
if stat == MAIN:
|
|
118
|
+
stat = self.main
|
|
119
|
+
elif stat == SUB:
|
|
120
|
+
stat = self.sub
|
|
121
|
+
self.parts[(stat, PART.get(formula, "base"))] += value
|
|
122
|
+
|
|
123
|
+
def flat(self, stat: int) -> int:
|
|
124
|
+
p = self.parts
|
|
125
|
+
return math.floor(p[(stat, "base")] * (1 + p[(stat, "ratio")]) + p[(stat, "delta")])
|
|
126
|
+
|
|
127
|
+
def sum(self, stat: int) -> float:
|
|
128
|
+
return self.parts[(stat, "base")] + self.parts[(stat, "delta")]
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def weapon_skill_levels(data: GameData, weapon: dict, refine: int, breakthrough: int, gem_terms=()) -> list[int]:
|
|
132
|
+
none = [{"lowerBound": 0, "upperBound": 0}] * 3
|
|
133
|
+
by_refine = data.refine_bounds.get(weapon["TalentTemplateId"], {}).get(str(refine)) or none
|
|
134
|
+
by_break = data.break_bounds[weapon["BreakthroughTemplateId"]][str(breakthrough)]
|
|
135
|
+
extra = {}
|
|
136
|
+
for term_id, cost in gem_terms:
|
|
137
|
+
term = data.gem_terms.get(str(term_id))
|
|
138
|
+
if term:
|
|
139
|
+
extra[term["TagId"]] = cost
|
|
140
|
+
levels = []
|
|
141
|
+
for i, skill_id in enumerate(weapon["SkillList"]):
|
|
142
|
+
lower = by_refine[i]["lowerBound"] + by_break[i]["lowerBound"]
|
|
143
|
+
upper = by_refine[i]["upperBound"] + by_break[i]["upperBound"]
|
|
144
|
+
tag = data.skills[str(skill_id)]["TagId"]
|
|
145
|
+
levels.append(min(lower + extra.get(tag, 0), upper))
|
|
146
|
+
return levels
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def skill_effect(data: GameData, skill_id, level: int, avatar: dict | None = None) -> tuple[str, str]:
|
|
150
|
+
props = [(int(s), p) for s, p in data.skills[str(skill_id)]["PropMap"].items() if int(s) != ETHER_DMG]
|
|
151
|
+
if not props or level < 1:
|
|
152
|
+
return "", ""
|
|
153
|
+
stat, prop = props[0]
|
|
154
|
+
value = prop["Values"][min(level, len(prop["Values"])) - 1]
|
|
155
|
+
if stat in (MAIN, SUB):
|
|
156
|
+
attr = avatar and avatar["MainAttrId" if stat == MAIN else "SubAttrId"]
|
|
157
|
+
name = LABEL.get(attr, "Main Attribute" if stat == MAIN else "Secondary Attribute")
|
|
158
|
+
else:
|
|
159
|
+
name = LABEL.get(stat, "")
|
|
160
|
+
if prop["Formula"] == "BaseMultiplier" or stat not in FLAT:
|
|
161
|
+
return name, f"+{(value + 1e-4) * 100:.1f}%"
|
|
162
|
+
return name, f"+{math.floor(value):,}"
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def gear_slots(item: dict, enhance: dict[str, int]):
|
|
166
|
+
# an affix spread over several stat ids shares one enhance slot, so reuse the slot while values repeat
|
|
167
|
+
previous, key = None, 1
|
|
168
|
+
for index, mod in enumerate(item["AttrModifiers"]):
|
|
169
|
+
level = enhance.get(str(key))
|
|
170
|
+
same = level is not None and level < len(mod["Values"]) and mod["Values"][level] == previous
|
|
171
|
+
key = key if same else min(index, 3)
|
|
172
|
+
value = mod["Values"][enhance.get(str(key), 0) or 0]
|
|
173
|
+
previous = value
|
|
174
|
+
yield key, mod, value
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def gear_stats(loadout: Loadout) -> list[GearStats]:
|
|
178
|
+
out = []
|
|
179
|
+
for item, enhance in loadout.gear:
|
|
180
|
+
groups: dict[int, list] = {}
|
|
181
|
+
defense = 0.0
|
|
182
|
+
for key, mod, value in gear_slots(item, enhance):
|
|
183
|
+
if key == 0:
|
|
184
|
+
defense += value
|
|
185
|
+
else:
|
|
186
|
+
groups.setdefault(key, []).append((mod, value))
|
|
187
|
+
lines = []
|
|
188
|
+
for key in sorted(groups):
|
|
189
|
+
mods = groups[key]
|
|
190
|
+
mod, value = mods[0]
|
|
191
|
+
stat, formula = mod["AttrType"], mod["Formula"]
|
|
192
|
+
ids = frozenset(m["AttrType"] for m, _ in mods)
|
|
193
|
+
if stat in (MAIN, SUB):
|
|
194
|
+
attr = loadout.avatar["MainAttrId"] if stat == MAIN else loadout.avatar["SubAttrId"]
|
|
195
|
+
name = LABEL[attr]
|
|
196
|
+
else:
|
|
197
|
+
name = GROUP_LABEL.get(ids) or LABEL.get(stat, str(stat))
|
|
198
|
+
if formula == "BaseFinalMultiplier":
|
|
199
|
+
value = 1 - value
|
|
200
|
+
percent = formula == "BaseMultiplier" or (stat not in FLAT and stat not in (MAIN, SUB))
|
|
201
|
+
lines.append(GearLine(name, value, percent, enhance.get(str(key), 0) or 0, len(mod["Values"]) - 1))
|
|
202
|
+
out.append(GearStats(slot_of(item["Icon"]), math.floor(defense), lines))
|
|
203
|
+
return out
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _corrections(sheet: Sheet, loadout: Loadout) -> None:
|
|
207
|
+
latest = set(loadout.passive_nodes)
|
|
208
|
+
sid = loadout.avatar["StrId"]
|
|
209
|
+
will, intellect = sheet.flat(WILL), sheet.flat(INT)
|
|
210
|
+
if sid == "chr_0020_meurs":
|
|
211
|
+
if f"{sid}_passive_skill_0_1" in latest:
|
|
212
|
+
sheet.add(DEF, math.floor(will / 10), "Addition")
|
|
213
|
+
elif f"{sid}_passive_skill_0_2" in latest:
|
|
214
|
+
sheet.add(DEF, math.floor(will / 10) * 1.2, "Addition")
|
|
215
|
+
elif sid == "chr_0015_lifeng":
|
|
216
|
+
if f"{sid}_passive_skill_0_1" in latest:
|
|
217
|
+
sheet.atk_total_ratio += (intellect + will) * 0.001
|
|
218
|
+
elif f"{sid}_passive_skill_0_2" in latest:
|
|
219
|
+
sheet.atk_total_ratio += (intellect + will) * 0.0015
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def calculate(data: GameData, loadout: Loadout) -> Stats:
|
|
223
|
+
excel = loadout.avatar
|
|
224
|
+
sheet = Sheet(excel["MainAttrId"], excel["SubAttrId"])
|
|
225
|
+
level = max(loadout.level, 1)
|
|
226
|
+
|
|
227
|
+
for stat, growth in excel["BaseAttributes"].items():
|
|
228
|
+
sheet.add(stat, growth["BaseValue"] + growth["AddValue"] * (level - 1))
|
|
229
|
+
sheet.add(HP, excel["BaseHpByLevel"][level - 1])
|
|
230
|
+
sheet.add(ATK, excel["BaseAtkByLevel"][level - 1])
|
|
231
|
+
sheet.add(44, 1)
|
|
232
|
+
sheet.add(10, 0.5)
|
|
233
|
+
|
|
234
|
+
for pot in excel["PotAttributes"]:
|
|
235
|
+
if loadout.potential >= pot["Level"]:
|
|
236
|
+
for stat, attr in pot["Attrs"].items():
|
|
237
|
+
sheet.add(stat, attr["Value"], attr["Formula"])
|
|
238
|
+
|
|
239
|
+
weapon = loadout.weapon
|
|
240
|
+
if weapon:
|
|
241
|
+
sheet.add(ATK, data.curves[weapon["LevelTemplateId"]][max(loadout.weapon_level, 1) - 1])
|
|
242
|
+
for skill_id, level_ in zip(weapon["SkillList"], loadout.weapon_skill_levels):
|
|
243
|
+
if level_ < 1:
|
|
244
|
+
continue
|
|
245
|
+
for stat, prop in data.skills[str(skill_id)]["PropMap"].items():
|
|
246
|
+
if int(stat) == ETHER_DMG:
|
|
247
|
+
continue
|
|
248
|
+
sheet.add(stat, prop["Values"][min(level_, len(prop["Values"])) - 1], prop["Formula"])
|
|
249
|
+
|
|
250
|
+
suits: dict[str, int] = defaultdict(int)
|
|
251
|
+
for item, enhance in loadout.gear:
|
|
252
|
+
if item["SuitId"]:
|
|
253
|
+
suits[item["SuitId"]] += 1
|
|
254
|
+
for _, mod, value in gear_slots(item, enhance):
|
|
255
|
+
sheet.add(mod["AttrType"], value, mod["Formula"])
|
|
256
|
+
for suit, count in suits.items():
|
|
257
|
+
if count >= 3:
|
|
258
|
+
for stat, prop in data.skills[str(data.suits[suit]["SkillId"])]["PropMap"].items():
|
|
259
|
+
sheet.add(stat, prop["Values"][0], prop["Formula"])
|
|
260
|
+
|
|
261
|
+
unlocked = set(loadout.attr_nodes)
|
|
262
|
+
for node, attrs in excel["AttributeNodes"].items():
|
|
263
|
+
if node in unlocked:
|
|
264
|
+
for stat, value in attrs.items():
|
|
265
|
+
sheet.add(stat, value)
|
|
266
|
+
|
|
267
|
+
sheet.add(HP, sheet.flat(STR) * 5)
|
|
268
|
+
sheet.add(30, sheet.flat(WILL) * 0.001, "Addition")
|
|
269
|
+
sheet.atk_total_ratio += sheet.flat(sheet.main) * 0.005 + sheet.flat(sheet.sub) * 0.002
|
|
270
|
+
_corrections(sheet, loadout)
|
|
271
|
+
|
|
272
|
+
p = sheet.parts
|
|
273
|
+
atk = math.floor((p[(ATK, "base")] * (1 + p[(ATK, "ratio")]) + p[(ATK, "delta")]) * (1 + sheet.atk_total_ratio))
|
|
274
|
+
return Stats(
|
|
275
|
+
strength=sheet.flat(STR),
|
|
276
|
+
agility=sheet.flat(AGI),
|
|
277
|
+
intellect=sheet.flat(INT),
|
|
278
|
+
will=sheet.flat(WILL),
|
|
279
|
+
hp=sheet.flat(HP),
|
|
280
|
+
atk=atk,
|
|
281
|
+
defense=sheet.flat(DEF),
|
|
282
|
+
crit_rate=sheet.sum(9),
|
|
283
|
+
crit_dmg=sheet.sum(10),
|
|
284
|
+
# the game drops the fraction instead of rounding
|
|
285
|
+
arts_intensity=math.floor(sheet.sum(87) + 1e-6),
|
|
286
|
+
treatment_bonus=sheet.sum(29),
|
|
287
|
+
treatment_received=sheet.sum(30),
|
|
288
|
+
ult_gain=sheet.sum(44),
|
|
289
|
+
stagger_dmg=sheet.sum(61),
|
|
290
|
+
physical_dmg=sheet.sum(50),
|
|
291
|
+
heat_dmg=sheet.sum(51),
|
|
292
|
+
electric_dmg=sheet.sum(52),
|
|
293
|
+
cryo_dmg=sheet.sum(53),
|
|
294
|
+
nature_dmg=sheet.sum(54),
|
|
295
|
+
basic_attack_dmg=sheet.sum(17),
|
|
296
|
+
battle_skill_dmg=sheet.sum(32),
|
|
297
|
+
combo_skill_dmg=sheet.sum(33),
|
|
298
|
+
ultimate_dmg=sheet.sum(28),
|
|
299
|
+
main_attribute=ATTR_FIELD.get(sheet.main, ""),
|
|
300
|
+
sub_attribute=ATTR_FIELD.get(sheet.sub, ""),
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def require(found, kind: str, name):
|
|
305
|
+
if found is None:
|
|
306
|
+
raise MissingGameData(kind, name)
|
|
307
|
+
return found
|
akef/errors.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AkefError(Exception):
|
|
5
|
+
def __init__(self, message: str = "", code: int | None = None):
|
|
6
|
+
super().__init__(message)
|
|
7
|
+
self.message = message
|
|
8
|
+
self.code = code
|
|
9
|
+
|
|
10
|
+
def __repr__(self) -> str:
|
|
11
|
+
return f"{type(self).__name__}(code={self.code!r}, message={self.message!r})"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class NetworkError(AkefError):
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AuthError(AkefError):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class APIError(AkefError):
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class NoRoleError(AkefError):
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class AlreadyCheckedIn(APIError):
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class UnknownCharacter(AkefError):
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class GameDataError(AkefError):
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class MissingGameData(GameDataError):
|
|
43
|
+
def __init__(self, kind: str, name):
|
|
44
|
+
super().__init__(f"no {kind} {name!r} in Enka's data yet, try again after Enka updates")
|
|
45
|
+
self.kind = kind
|
|
46
|
+
self.name = name
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class PlayerNotFound(AkefError):
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class ShowcaseEmpty(AkefError):
|
|
54
|
+
pass
|
akef/models/__init__.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from akef.models.account import Account, BasicUser, Profile, Role, Social
|
|
2
|
+
from akef.models.base import Model, Progress, Tag
|
|
3
|
+
from akef.models.card import (
|
|
4
|
+
Achievements,
|
|
5
|
+
Base,
|
|
6
|
+
BattlePass,
|
|
7
|
+
BestRecord,
|
|
8
|
+
Card,
|
|
9
|
+
Character,
|
|
10
|
+
ContractChar,
|
|
11
|
+
ContractDetail,
|
|
12
|
+
ContractHistory,
|
|
13
|
+
ContractRun,
|
|
14
|
+
ContractStage,
|
|
15
|
+
CrisisContract,
|
|
16
|
+
DailyMission,
|
|
17
|
+
Dungeon,
|
|
18
|
+
Domain,
|
|
19
|
+
Enemy,
|
|
20
|
+
Equip,
|
|
21
|
+
Gem,
|
|
22
|
+
IndieHard,
|
|
23
|
+
Indicator,
|
|
24
|
+
IndieHardGroup,
|
|
25
|
+
Medal,
|
|
26
|
+
RecordChar,
|
|
27
|
+
Settlement,
|
|
28
|
+
SpaceShip,
|
|
29
|
+
Stamina,
|
|
30
|
+
WarEchoes,
|
|
31
|
+
Weapon,
|
|
32
|
+
WeeklyMission,
|
|
33
|
+
)
|
|
34
|
+
from akef.models.extra import Inventory, Notice, Owned, WikiBlock, WikiCell, WikiEntry, WikiItem, WikiLink, WikiSection
|
|
35
|
+
from akef.models.game import Attendance, Award, Banner, BannerItem, CheckIn, Day, Enums, Reward
|
|
36
|
+
from akef.models.pulls import LIMITED, OPERATOR_BANNERS, Pity, Pull, Pulls, since_last
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
"Inventory",
|
|
40
|
+
"Notice",
|
|
41
|
+
"Owned",
|
|
42
|
+
"WikiBlock",
|
|
43
|
+
"WikiCell",
|
|
44
|
+
"WikiEntry",
|
|
45
|
+
"WikiItem",
|
|
46
|
+
"WikiLink",
|
|
47
|
+
"WikiSection",
|
|
48
|
+
"LIMITED",
|
|
49
|
+
"OPERATOR_BANNERS",
|
|
50
|
+
"Pity",
|
|
51
|
+
"Pull",
|
|
52
|
+
"Pulls",
|
|
53
|
+
"since_last",
|
|
54
|
+
"Account",
|
|
55
|
+
"Achievements",
|
|
56
|
+
"Attendance",
|
|
57
|
+
"Award",
|
|
58
|
+
"Banner",
|
|
59
|
+
"BannerItem",
|
|
60
|
+
"Base",
|
|
61
|
+
"BasicUser",
|
|
62
|
+
"BattlePass",
|
|
63
|
+
"BestRecord",
|
|
64
|
+
"Card",
|
|
65
|
+
"Character",
|
|
66
|
+
"CheckIn",
|
|
67
|
+
"ContractChar",
|
|
68
|
+
"ContractDetail",
|
|
69
|
+
"ContractHistory",
|
|
70
|
+
"ContractRun",
|
|
71
|
+
"ContractStage",
|
|
72
|
+
"CrisisContract",
|
|
73
|
+
"DailyMission",
|
|
74
|
+
"Dungeon",
|
|
75
|
+
"Day",
|
|
76
|
+
"Domain",
|
|
77
|
+
"Enemy",
|
|
78
|
+
"Enums",
|
|
79
|
+
"Equip",
|
|
80
|
+
"Gem",
|
|
81
|
+
"IndieHard",
|
|
82
|
+
"Indicator",
|
|
83
|
+
"IndieHardGroup",
|
|
84
|
+
"Medal",
|
|
85
|
+
"RecordChar",
|
|
86
|
+
"Model",
|
|
87
|
+
"Profile",
|
|
88
|
+
"Progress",
|
|
89
|
+
"Reward",
|
|
90
|
+
"Role",
|
|
91
|
+
"Settlement",
|
|
92
|
+
"Social",
|
|
93
|
+
"SpaceShip",
|
|
94
|
+
"Stamina",
|
|
95
|
+
"Tag",
|
|
96
|
+
"WarEchoes",
|
|
97
|
+
"Weapon",
|
|
98
|
+
"WeeklyMission",
|
|
99
|
+
]
|
akef/models/account.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pydantic import ConfigDict, Field
|
|
4
|
+
|
|
5
|
+
from akef.models.base import Model, Timestamp
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class AgeGate(Model):
|
|
9
|
+
region_code: str = ""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Account(Model):
|
|
13
|
+
model_config = ConfigDict(extra="ignore")
|
|
14
|
+
|
|
15
|
+
hg_id: str
|
|
16
|
+
email: str = ""
|
|
17
|
+
nick_name: str = ""
|
|
18
|
+
age_gate: AgeGate = Field(default_factory=AgeGate)
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def region(self) -> str:
|
|
22
|
+
return self.age_gate.region_code
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Role(Model):
|
|
26
|
+
uid: str = Field(alias="roleId")
|
|
27
|
+
server_id: str
|
|
28
|
+
nickname: str = ""
|
|
29
|
+
level: int = 0
|
|
30
|
+
is_default: bool = False
|
|
31
|
+
is_banned: bool = False
|
|
32
|
+
server_type: str = ""
|
|
33
|
+
server_name: str = ""
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def game_role(self) -> str:
|
|
37
|
+
return f"3_{self.uid}_{self.server_id}"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class Pendant(Model):
|
|
41
|
+
id: int = 0
|
|
42
|
+
icon_url: str = ""
|
|
43
|
+
title: str = ""
|
|
44
|
+
description: str = ""
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class BasicUser(Model):
|
|
48
|
+
id: str
|
|
49
|
+
nickname: str = ""
|
|
50
|
+
profile: str = ""
|
|
51
|
+
avatar: str = ""
|
|
52
|
+
gender: int = 0
|
|
53
|
+
created_at: Timestamp = None
|
|
54
|
+
latest_login_at: Timestamp = None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class UserInfo(Model):
|
|
58
|
+
basic_user: BasicUser
|
|
59
|
+
pendant: Pendant | None = None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Social(Model):
|
|
63
|
+
follow: int = 0
|
|
64
|
+
fans: int = 0
|
|
65
|
+
liked: int = 0
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class Profile(Model):
|
|
69
|
+
user: UserInfo
|
|
70
|
+
user_rts: Social = Field(default_factory=Social)
|
|
71
|
+
|
|
72
|
+
@property
|
|
73
|
+
def id(self) -> str:
|
|
74
|
+
return self.user.basic_user.id
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def nickname(self) -> str:
|
|
78
|
+
return self.user.basic_user.nickname
|
akef/models/base.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, BeforeValidator, ConfigDict
|
|
7
|
+
from pydantic.alias_generators import to_camel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _timestamp(value):
|
|
11
|
+
if isinstance(value, datetime) or value is None:
|
|
12
|
+
return value
|
|
13
|
+
# skport sends unix seconds as strings and "0" when there's nothing
|
|
14
|
+
if str(value) in ("", "0"):
|
|
15
|
+
return None
|
|
16
|
+
return datetime.fromtimestamp(int(value), tz=timezone.utc)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
Timestamp = Annotated[datetime | None, BeforeValidator(_timestamp)]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Model(BaseModel):
|
|
23
|
+
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True, extra="allow")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Tag(Model):
|
|
27
|
+
key: str = ""
|
|
28
|
+
value: str = ""
|
|
29
|
+
|
|
30
|
+
def __str__(self) -> str:
|
|
31
|
+
return self.value
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Progress(Model):
|
|
35
|
+
count: int = 0
|
|
36
|
+
total: int = 0
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def done(self) -> bool:
|
|
40
|
+
return self.total > 0 and self.count >= self.total
|