akef-cards 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_cards/__init__.py +12 -0
- akef_cards/client.py +256 -0
- akef_cards/contract.py +112 -0
- akef_cards/data/faces.json +177 -0
- akef_cards/data/icons/ASSAULT.png +0 -0
- akef_cards/data/icons/Agi.png +0 -0
- akef_cards/data/icons/Atk.png +0 -0
- akef_cards/data/icons/CASTER.png +0 -0
- akef_cards/data/icons/ComboSkillDamageIncrease.png +0 -0
- akef_cards/data/icons/CriticalDamageIncrease.png +0 -0
- akef_cards/data/icons/CriticalRate.png +0 -0
- akef_cards/data/icons/CrystDamageIncrease.png +0 -0
- akef_cards/data/icons/DEFENDER.png +0 -0
- akef_cards/data/icons/DamageToBrokenUnitIncrease.png +0 -0
- akef_cards/data/icons/Def.png +0 -0
- akef_cards/data/icons/FireDamageIncrease.png +0 -0
- akef_cards/data/icons/GUARD.png +0 -0
- akef_cards/data/icons/HealOutputIncrease.png +0 -0
- akef_cards/data/icons/HealTakenIncrease.png +0 -0
- akef_cards/data/icons/MaxHp.png +0 -0
- akef_cards/data/icons/NaturalDamageIncrease.png +0 -0
- akef_cards/data/icons/NormalAttackDamageIncrease.png +0 -0
- akef_cards/data/icons/NormalSkillDamageIncrease.png +0 -0
- akef_cards/data/icons/PhysicalAndSpellInflictionEnhance.png +0 -0
- akef_cards/data/icons/PhysicalDamageIncrease.png +0 -0
- akef_cards/data/icons/PoiseDamageOutputScalar.png +0 -0
- akef_cards/data/icons/PulseDamageIncrease.png +0 -0
- akef_cards/data/icons/SUPPORTER.png +0 -0
- akef_cards/data/icons/Str.png +0 -0
- akef_cards/data/icons/UltimateSkillDamageIncrease.png +0 -0
- akef_cards/data/icons/UltimateSpGainScalar.png +0 -0
- akef_cards/data/icons/VANGUARD.png +0 -0
- akef_cards/data/icons/Will.png +0 -0
- akef_cards/data/icons/Wisd.png +0 -0
- akef_cards/data/text.json +2900 -0
- akef_cards/draw.py +304 -0
- akef_cards/errors.py +7 -0
- akef_cards/factory.py +87 -0
- akef_cards/fonts/Barlow-Bold.ttf +0 -0
- akef_cards/fonts/Barlow-Medium.ttf +0 -0
- akef_cards/fonts/Barlow-Regular.ttf +0 -0
- akef_cards/fonts/Barlow-SemiBold.ttf +0 -0
- akef_cards/fonts/FiraSans-Bold.ttf +0 -0
- akef_cards/fonts/FiraSans-Medium.ttf +0 -0
- akef_cards/fonts/FiraSans-Regular.ttf +0 -0
- akef_cards/fonts/FiraSans-SemiBold.ttf +0 -0
- akef_cards/fonts/NotoSansJP.ttf +0 -0
- akef_cards/fonts/NotoSansKR.ttf +0 -0
- akef_cards/fonts/NotoSansSC.ttf +0 -0
- akef_cards/fonts/NotoSansTC.ttf +0 -0
- akef_cards/fonts/NotoSansThai.ttf +0 -0
- akef_cards/fonts/OFL-FiraSans.txt +93 -0
- akef_cards/fonts/OFL-Noto.txt +93 -0
- akef_cards/fonts/OFL.txt +93 -0
- akef_cards/framing.py +30 -0
- akef_cards/gacha.py +59 -0
- akef_cards/i18n.py +126 -0
- akef_cards/images.py +158 -0
- akef_cards/live.py +69 -0
- akef_cards/memo.py +26 -0
- akef_cards/monument.py +99 -0
- akef_cards/py.typed +0 -0
- akef_cards/roster.py +61 -0
- akef_cards/sources/__init__.py +0 -0
- akef_cards/sources/skport.py +300 -0
- akef_cards/templates/__init__.py +28 -0
- akef_cards/templates/compare.py +217 -0
- akef_cards/templates/compare_styles.py +226 -0
- akef_cards/templates/contract_board.py +125 -0
- akef_cards/templates/contract_detail.py +140 -0
- akef_cards/templates/contract_midnight.py +81 -0
- akef_cards/templates/factory_board.py +169 -0
- akef_cards/templates/flex.py +72 -0
- akef_cards/templates/ingame.py +179 -0
- akef_cards/templates/live_board.py +156 -0
- akef_cards/templates/live_parts.py +57 -0
- akef_cards/templates/monument_board.py +115 -0
- akef_cards/templates/monument_event.py +209 -0
- akef_cards/templates/parts.py +301 -0
- akef_cards/templates/profile.py +251 -0
- akef_cards/templates/profile_midnight.py +168 -0
- akef_cards/templates/profile_poster.py +183 -0
- akef_cards/templates/pulls_board.py +166 -0
- akef_cards/templates/pulls_poster.py +210 -0
- akef_cards/templates/roster_board.py +129 -0
- akef_cards/templates/showcase.py +524 -0
- akef_cards/templates/talents.py +184 -0
- akef_cards/templates/wiki_board.py +131 -0
- akef_cards/templates/wiki_pages.py +293 -0
- akef_cards-0.3.0.dist-info/METADATA +442 -0
- akef_cards-0.3.0.dist-info/RECORD +97 -0
- akef_cards-0.3.0.dist-info/WHEEL +5 -0
- akef_cards-0.3.0.dist-info/licenses/LICENSE +21 -0
- akef_cards-0.3.0.dist-info/licenses/akef_cards/fonts/OFL-FiraSans.txt +93 -0
- akef_cards-0.3.0.dist-info/licenses/akef_cards/fonts/OFL-Noto.txt +93 -0
- akef_cards-0.3.0.dist-info/licenses/akef_cards/fonts/OFL.txt +93 -0
- akef_cards-0.3.0.dist-info/top_level.txt +1 -0
akef_cards/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from akef_cards.client import Cards
|
|
2
|
+
from akef_cards.contract import ContractDetail, Contracts
|
|
3
|
+
from akef_cards.errors import CardError
|
|
4
|
+
from akef_cards.factory import Factory
|
|
5
|
+
from akef_cards.gacha import PullHistory
|
|
6
|
+
from akef_cards.images import ImageCache
|
|
7
|
+
from akef_cards.live import Live, Meter
|
|
8
|
+
from akef_cards.monument import Event, Monument, Stage
|
|
9
|
+
from akef_cards.roster import Roster
|
|
10
|
+
from akef_cards.templates import TEMPLATES
|
|
11
|
+
|
|
12
|
+
__version__ = "0.3.0"
|
akef_cards/client.py
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import io
|
|
5
|
+
import warnings
|
|
6
|
+
|
|
7
|
+
from PIL import Image
|
|
8
|
+
|
|
9
|
+
from akef.enka import Build, Enka, EnkaProfile, GameData, Player
|
|
10
|
+
from akef.enka.gamedata import language as language_code
|
|
11
|
+
from akef.wiki import WikiPage, WikiPart, wiki_page
|
|
12
|
+
|
|
13
|
+
from akef_cards.contract import ContractDetail, Contracts
|
|
14
|
+
from akef_cards.draw import blur_uid
|
|
15
|
+
from akef_cards.errors import CardError
|
|
16
|
+
from akef_cards.factory import Factory
|
|
17
|
+
from akef_cards.framing import pages
|
|
18
|
+
from akef_cards.gacha import PullHistory
|
|
19
|
+
from akef_cards.i18n import language, supported
|
|
20
|
+
from akef_cards.images import DEFAULT_MB, ImageCache, load_art
|
|
21
|
+
from akef_cards.live import Live
|
|
22
|
+
from akef_cards.memo import Recent
|
|
23
|
+
from akef_cards.monument import Event, Monument
|
|
24
|
+
from akef_cards.roster import Roster
|
|
25
|
+
from akef_cards.sources.skport import (
|
|
26
|
+
contract_detail_from_skport,
|
|
27
|
+
contracts_from_skport,
|
|
28
|
+
factory_from_skport,
|
|
29
|
+
live_from_skport,
|
|
30
|
+
monument_from_skport,
|
|
31
|
+
pulls_from_skport,
|
|
32
|
+
roster_from_skport,
|
|
33
|
+
)
|
|
34
|
+
from akef_cards.templates import CONTRACT, FACTORY, LIVE, PROFILES, PULLS, TEMPLATES, COMPARE, contract_detail, monument_board, monument_event, roster_board, wiki_board, wiki_pages
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _short(lang: str) -> str:
|
|
38
|
+
try:
|
|
39
|
+
return language_code(lang)[0]
|
|
40
|
+
except ValueError:
|
|
41
|
+
return lang
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
WIKI_PARTS = {
|
|
45
|
+
WikiPart.OVERVIEW: wiki_board.render,
|
|
46
|
+
WikiPart.SKILLS: wiki_pages.render_skills,
|
|
47
|
+
WikiPart.TALENTS: wiki_pages.render_talents,
|
|
48
|
+
WikiPart.GROWTH: wiki_pages.render_growth,
|
|
49
|
+
WikiPart.PROFILE: wiki_pages.render_profile,
|
|
50
|
+
WikiPart.LORE: wiki_pages.render_lore,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Cards:
|
|
55
|
+
def __init__(
|
|
56
|
+
self,
|
|
57
|
+
*,
|
|
58
|
+
data: GameData | None = None,
|
|
59
|
+
images: ImageCache | None = None,
|
|
60
|
+
lang: str = "en",
|
|
61
|
+
cache: bool = True,
|
|
62
|
+
kept_cards: int = 8,
|
|
63
|
+
cache_mb: float | None = DEFAULT_MB,
|
|
64
|
+
):
|
|
65
|
+
try:
|
|
66
|
+
language_code(lang)
|
|
67
|
+
except ValueError:
|
|
68
|
+
warnings.warn(f"language {lang!r} is not supported, drawing cards in English", stacklevel=2)
|
|
69
|
+
lang = "en"
|
|
70
|
+
else:
|
|
71
|
+
if _short(lang) not in supported():
|
|
72
|
+
warnings.warn(f"card labels aren't translated into {lang!r} yet, they'll be in English", stacklevel=2)
|
|
73
|
+
self.source = Enka(data=data or GameData(lang=lang), cache=cache)
|
|
74
|
+
self.data = self.source.data
|
|
75
|
+
self.images = images or ImageCache(max_mb=cache_mb)
|
|
76
|
+
self.cache = cache
|
|
77
|
+
self._drawn = Recent(kept_cards if cache else 0)
|
|
78
|
+
|
|
79
|
+
def clear_cache(self) -> None:
|
|
80
|
+
self.source.clear_cache()
|
|
81
|
+
self._drawn.clear()
|
|
82
|
+
|
|
83
|
+
async def _draw(self, key, urls, fn, *args, **kwargs) -> Image.Image:
|
|
84
|
+
key = (self.data.locale, key) if key is not None else None
|
|
85
|
+
hit = self._drawn.get(key) if key is not None else None
|
|
86
|
+
if hit is not None:
|
|
87
|
+
return hit.copy()
|
|
88
|
+
images = await self.images.get(urls)
|
|
89
|
+
# the worker thread gets a copy of this context, so the template sees the language and the uid switch
|
|
90
|
+
language.set(self.data.locale)
|
|
91
|
+
blur_uid.set(bool(kwargs.get("hide_uid")))
|
|
92
|
+
image = await asyncio.to_thread(fn, *args, images, **kwargs)
|
|
93
|
+
if key is not None and all(u in images for u in urls if u):
|
|
94
|
+
self._drawn.put(key, image)
|
|
95
|
+
return image.copy()
|
|
96
|
+
|
|
97
|
+
async def __aenter__(self) -> "Cards":
|
|
98
|
+
await self.data.load()
|
|
99
|
+
return self
|
|
100
|
+
|
|
101
|
+
async def __aexit__(self, *exc) -> None:
|
|
102
|
+
pass
|
|
103
|
+
|
|
104
|
+
async def enka(self, uid: int | str) -> EnkaProfile:
|
|
105
|
+
return await self.source.profile(uid)
|
|
106
|
+
|
|
107
|
+
async def skport(self, card, character, *, stats: bool = True) -> Build:
|
|
108
|
+
return await self.source.build(card, character, stats=stats)
|
|
109
|
+
|
|
110
|
+
def skport_player(self, card) -> Player:
|
|
111
|
+
return self.source.player(card)
|
|
112
|
+
|
|
113
|
+
async def render_profile(
|
|
114
|
+
self,
|
|
115
|
+
player: Player,
|
|
116
|
+
*,
|
|
117
|
+
template: int = 1,
|
|
118
|
+
grid: str = "4x2",
|
|
119
|
+
hidden: bool = False,
|
|
120
|
+
) -> list[Image.Image]:
|
|
121
|
+
module = _pick(PROFILES, template, "profile")
|
|
122
|
+
urls = player.urls()
|
|
123
|
+
return [
|
|
124
|
+
await self._draw(("profile", template, grid, i, hidden, repr(player)), urls, module.render, player,
|
|
125
|
+
grid=grid, page=i, hide_uid=hidden)
|
|
126
|
+
for i in range(len(pages(player, grid)))
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
def skport_live(self, card) -> Live:
|
|
130
|
+
return live_from_skport(card)
|
|
131
|
+
|
|
132
|
+
async def render_live(self, live: Live, *, template: int = 1, hidden: bool = False) -> Image.Image:
|
|
133
|
+
module = _pick(LIVE, template, "live")
|
|
134
|
+
return await self._draw(("live", template, hidden, repr(live)), live.urls(), module, live, hide_uid=hidden)
|
|
135
|
+
|
|
136
|
+
def skport_monument(self, card, monument) -> Monument:
|
|
137
|
+
return monument_from_skport(card, monument)
|
|
138
|
+
|
|
139
|
+
async def render_monument(self, monument: Monument, *, hidden: bool = False) -> Image.Image:
|
|
140
|
+
key = ("monument", hidden, repr(monument))
|
|
141
|
+
return await self._draw(key, monument.urls(), monument_board.render_overview, monument, hide_uid=hidden)
|
|
142
|
+
|
|
143
|
+
async def render_monument_event(self, monument: Monument, event=None, *, template: int = 1,
|
|
144
|
+
hidden: bool = False):
|
|
145
|
+
draw = _pick(monument_event.TEMPLATES, template, "monument event")
|
|
146
|
+
many = isinstance(event, (list, tuple))
|
|
147
|
+
wanted = list(event) if many else [event]
|
|
148
|
+
events = [monument_event.latest(monument) if e is None else e if isinstance(e, Event) else monument.event(e)
|
|
149
|
+
for e in wanted]
|
|
150
|
+
cards = [await self._draw(("monument_event", template, e.name, hidden, repr(monument)), monument.urls(e),
|
|
151
|
+
draw, monument, e, hide_uid=hidden) for e in events]
|
|
152
|
+
return cards if many else cards[0]
|
|
153
|
+
|
|
154
|
+
def skport_factory(self, card) -> Factory:
|
|
155
|
+
return factory_from_skport(card)
|
|
156
|
+
|
|
157
|
+
async def render_factory(self, factory: Factory, *, template: int = 1, hidden: bool = False) -> Image.Image:
|
|
158
|
+
draw = _pick(FACTORY, template, "factory")
|
|
159
|
+
return await self._draw(("factory", template, hidden, repr(factory)), factory.urls(), draw, factory,
|
|
160
|
+
hide_uid=hidden)
|
|
161
|
+
|
|
162
|
+
async def skport_pulls(self, card, pulls, *, after=None) -> PullHistory:
|
|
163
|
+
await self.data.load()
|
|
164
|
+
return pulls_from_skport(self.data, card, pulls, after)
|
|
165
|
+
|
|
166
|
+
async def render_pulls(self, history: PullHistory, *, template: int = 1, hidden: bool = False) -> Image.Image:
|
|
167
|
+
module = _pick(PULLS, template, "pull history")
|
|
168
|
+
return await self._draw(("pulls", template, hidden, repr(history)), history.urls(), module.render, history,
|
|
169
|
+
hide_uid=hidden)
|
|
170
|
+
|
|
171
|
+
def skport_contract(self, card) -> Contracts:
|
|
172
|
+
return contracts_from_skport(card)
|
|
173
|
+
|
|
174
|
+
async def render_contract(self, contracts: Contracts, *, template: int = 1, hidden: bool = False) -> Image.Image:
|
|
175
|
+
module = _pick(CONTRACT, template, "contract")
|
|
176
|
+
return await self._draw(("contract", template, hidden, repr(contracts)), contracts.urls(), module.render,
|
|
177
|
+
contracts, hide_uid=hidden)
|
|
178
|
+
|
|
179
|
+
def skport_contract_detail(self, card, detail) -> ContractDetail:
|
|
180
|
+
return contract_detail_from_skport(card, detail)
|
|
181
|
+
|
|
182
|
+
async def render_contract_detail(self, detail: ContractDetail, *, template: int = 1,
|
|
183
|
+
hidden: bool = False) -> Image.Image:
|
|
184
|
+
draw = _pick(contract_detail.TEMPLATES, template, "contract detail")
|
|
185
|
+
return await self._draw(("contract_detail", template, hidden, repr(detail)), detail.urls(), draw, detail,
|
|
186
|
+
hide_uid=hidden)
|
|
187
|
+
|
|
188
|
+
def skport_roster(self, card) -> Roster:
|
|
189
|
+
return roster_from_skport(card)
|
|
190
|
+
|
|
191
|
+
async def render_roster(self, roster: Roster, *, hidden: bool = False) -> Image.Image:
|
|
192
|
+
return await self._draw(("roster", hidden, repr(roster)), roster.urls(), roster_board.render, roster,
|
|
193
|
+
hide_uid=hidden)
|
|
194
|
+
|
|
195
|
+
def wiki(self, item, index: dict | None = None) -> WikiPage:
|
|
196
|
+
return wiki_page(item, index)
|
|
197
|
+
|
|
198
|
+
async def render_wiki(self, page: WikiPage, part: WikiPart | str = WikiPart.OVERVIEW, *,
|
|
199
|
+
template: int = 1) -> Image.Image:
|
|
200
|
+
try:
|
|
201
|
+
part = WikiPart(part)
|
|
202
|
+
except ValueError:
|
|
203
|
+
raise ValueError(f"unknown wiki part {part!r}, pick one of {[p.value for p in WikiPart]}") from None
|
|
204
|
+
if template not in (1, 2):
|
|
205
|
+
raise ValueError(f"unknown wiki template {template!r}, pick 1 (light) or 2 (dark)")
|
|
206
|
+
return await self._draw(("wiki", part.value, template, repr(page)), page.urls(), WIKI_PARTS[part], page,
|
|
207
|
+
hide_uid=False, dark=template == 2)
|
|
208
|
+
|
|
209
|
+
async def render_wiki_pages(self, page: WikiPage, parts=None, *, template: int = 1) -> list[Image.Image]:
|
|
210
|
+
wanted = [WikiPart(p) for p in parts] if parts else page.parts
|
|
211
|
+
return [await self.render_wiki(page, part, template=template) for part in wanted]
|
|
212
|
+
|
|
213
|
+
async def render(self, build: Build, *, template: int = 1, art=None, hidden: bool = False) -> Image.Image:
|
|
214
|
+
module = _pick(TEMPLATES, template, "card")
|
|
215
|
+
key = ("card", template, hidden, art, repr(build)) if art is None or isinstance(art, str) else None
|
|
216
|
+
return await self._draw(key, build.urls(), _with_art, module, build, await load_art(art), hide_uid=hidden)
|
|
217
|
+
|
|
218
|
+
async def render_compare(self, first, second, characters, *, template: int = 1,
|
|
219
|
+
hidden: bool = False) -> list[Image.Image]:
|
|
220
|
+
draw = _pick(COMPARE, template, "compare")
|
|
221
|
+
one, two = [p if isinstance(p, EnkaProfile) else await self.enka(p) for p in (first, second)]
|
|
222
|
+
wanted = [characters] if isinstance(characters, str) else list(characters)
|
|
223
|
+
pairs, missing = [], []
|
|
224
|
+
for name in wanted:
|
|
225
|
+
a, b = one.build(str(name)), two.build(str(name))
|
|
226
|
+
if a is None or b is None:
|
|
227
|
+
missing.append(str(name))
|
|
228
|
+
elif all(a.id != pa.id for pa, _ in pairs):
|
|
229
|
+
pairs.append((a, b))
|
|
230
|
+
if not pairs:
|
|
231
|
+
raise CardError(f"none of {wanted} are showcased on both accounts")
|
|
232
|
+
if missing:
|
|
233
|
+
warnings.warn(f"not showcased on both accounts, skipped: {', '.join(missing)}", stacklevel=2)
|
|
234
|
+
return [await self._draw(("compare", template, hidden, repr(a), repr(b)), a.urls() + b.urls(), draw, a, b,
|
|
235
|
+
hide_uid=hidden) for a, b in pairs]
|
|
236
|
+
|
|
237
|
+
async def render_bytes(self, build: Build, *, format: str = "PNG", **kwargs) -> io.BytesIO:
|
|
238
|
+
image = await self.render(build, **kwargs)
|
|
239
|
+
out = io.BytesIO()
|
|
240
|
+
image.save(out, format=format, quality=92)
|
|
241
|
+
out.seek(0)
|
|
242
|
+
out.name = f"card.{format.lower()}"
|
|
243
|
+
return out
|
|
244
|
+
|
|
245
|
+
async def update(self) -> bool:
|
|
246
|
+
return await self.source.update()
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def _pick(table, template, what):
|
|
250
|
+
if template not in table:
|
|
251
|
+
raise ValueError(f"no {what} template {template!r}, pick one of {sorted(table)}")
|
|
252
|
+
return table[template]
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def _with_art(render, build, art, images, *, hide_uid):
|
|
256
|
+
return render(build, images, art=art, hide_uid=hide_uid)
|
akef_cards/contract.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
|
|
6
|
+
from akef_cards.live import Meter
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class Contract:
|
|
11
|
+
name: str
|
|
12
|
+
best: int
|
|
13
|
+
attempts: int
|
|
14
|
+
art: str
|
|
15
|
+
missions: list[Meter]
|
|
16
|
+
medal: str = ""
|
|
17
|
+
medal_level: int = 0
|
|
18
|
+
plated: bool = False
|
|
19
|
+
starts: datetime | None = None
|
|
20
|
+
ends: datetime | None = None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class Contracts:
|
|
25
|
+
name: str
|
|
26
|
+
uid: str
|
|
27
|
+
level: int
|
|
28
|
+
region: str
|
|
29
|
+
avatar: str
|
|
30
|
+
current: Contract | None
|
|
31
|
+
past: list[Contract] = field(default_factory=list)
|
|
32
|
+
now: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
|
33
|
+
|
|
34
|
+
def urls(self) -> list[str]:
|
|
35
|
+
out = [self.avatar]
|
|
36
|
+
for c in ([self.current] if self.current else []) + self.past:
|
|
37
|
+
out += [c.art, c.medal]
|
|
38
|
+
return [u for u in out if u]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class Fighter:
|
|
43
|
+
name: str
|
|
44
|
+
portrait: str
|
|
45
|
+
art: str = ""
|
|
46
|
+
element: str = ""
|
|
47
|
+
element_icon: str = ""
|
|
48
|
+
profession: str = ""
|
|
49
|
+
rarity: int = 0
|
|
50
|
+
level: int = 0
|
|
51
|
+
potential: int = 0
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass
|
|
55
|
+
class Run:
|
|
56
|
+
team: list[Fighter]
|
|
57
|
+
seconds: int
|
|
58
|
+
waves: int
|
|
59
|
+
score: int
|
|
60
|
+
cleared: bool
|
|
61
|
+
best: bool = False
|
|
62
|
+
when: datetime | None = None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@dataclass
|
|
66
|
+
class Buff:
|
|
67
|
+
name: str
|
|
68
|
+
icon: str
|
|
69
|
+
text: str
|
|
70
|
+
score: int
|
|
71
|
+
unlocked: bool = True
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def kind(self) -> str:
|
|
75
|
+
return self.name.split(":", 1)[0].strip() if ":" in self.name else ""
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def short(self) -> str:
|
|
79
|
+
return self.name.split(":", 1)[-1].strip()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@dataclass
|
|
83
|
+
class Foe:
|
|
84
|
+
name: str
|
|
85
|
+
icon: str
|
|
86
|
+
level: int = 0
|
|
87
|
+
ability: str = ""
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@dataclass
|
|
91
|
+
class ContractDetail:
|
|
92
|
+
name: str
|
|
93
|
+
uid: str
|
|
94
|
+
level: int
|
|
95
|
+
region: str
|
|
96
|
+
avatar: str
|
|
97
|
+
contract: Contract
|
|
98
|
+
runs: list[Run] = field(default_factory=list)
|
|
99
|
+
buffs: list[Buff] = field(default_factory=list)
|
|
100
|
+
foes: list[Foe] = field(default_factory=list)
|
|
101
|
+
now: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def best(self) -> Run | None:
|
|
105
|
+
return next((r for r in self.runs if r.best), max(self.runs, key=lambda r: r.score, default=None))
|
|
106
|
+
|
|
107
|
+
def urls(self) -> list[str]:
|
|
108
|
+
out = [self.avatar, self.contract.art, self.contract.medal]
|
|
109
|
+
for r in self.runs:
|
|
110
|
+
out += [f.portrait for f in r.team] + [f.art for f in r.team] + [f.element_icon for f in r.team]
|
|
111
|
+
out += [b.icon for b in self.buffs] + [f.icon for f in self.foes]
|
|
112
|
+
return list(dict.fromkeys(u for u in out if u))
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
{
|
|
2
|
+
"chr_0002_endminm": [
|
|
3
|
+
0.46,
|
|
4
|
+
0.26,
|
|
5
|
+
0.3
|
|
6
|
+
],
|
|
7
|
+
"chr_0003_endminf": [
|
|
8
|
+
0.48,
|
|
9
|
+
0.3,
|
|
10
|
+
0.3
|
|
11
|
+
],
|
|
12
|
+
"chr_0004_pelica": [
|
|
13
|
+
0.565,
|
|
14
|
+
0.355,
|
|
15
|
+
0.3
|
|
16
|
+
],
|
|
17
|
+
"chr_0005_chen": [
|
|
18
|
+
0.52,
|
|
19
|
+
0.307,
|
|
20
|
+
0.3
|
|
21
|
+
],
|
|
22
|
+
"chr_0006_wolfgd": [
|
|
23
|
+
0.49,
|
|
24
|
+
0.19,
|
|
25
|
+
0.3
|
|
26
|
+
],
|
|
27
|
+
"chr_0007_ikut": [
|
|
28
|
+
0.48,
|
|
29
|
+
0.2,
|
|
30
|
+
0.3
|
|
31
|
+
],
|
|
32
|
+
"chr_0009_azrila": [
|
|
33
|
+
0.515,
|
|
34
|
+
0.335,
|
|
35
|
+
0.3
|
|
36
|
+
],
|
|
37
|
+
"chr_0011_seraph": [
|
|
38
|
+
0.42,
|
|
39
|
+
0.355,
|
|
40
|
+
0.3
|
|
41
|
+
],
|
|
42
|
+
"chr_0012_avywen": [
|
|
43
|
+
0.55,
|
|
44
|
+
0.39,
|
|
45
|
+
0.3
|
|
46
|
+
],
|
|
47
|
+
"chr_0013_aglina": [
|
|
48
|
+
0.48,
|
|
49
|
+
0.35,
|
|
50
|
+
0.3
|
|
51
|
+
],
|
|
52
|
+
"chr_0014_aurora": [
|
|
53
|
+
0.515,
|
|
54
|
+
0.19,
|
|
55
|
+
0.3
|
|
56
|
+
],
|
|
57
|
+
"chr_0015_lifeng": [
|
|
58
|
+
0.497,
|
|
59
|
+
0.43,
|
|
60
|
+
0.3
|
|
61
|
+
],
|
|
62
|
+
"chr_0016_laevat": [
|
|
63
|
+
0.46,
|
|
64
|
+
0.26,
|
|
65
|
+
0.3
|
|
66
|
+
],
|
|
67
|
+
"chr_0017_yvonne": [
|
|
68
|
+
0.515,
|
|
69
|
+
0.355,
|
|
70
|
+
0.3
|
|
71
|
+
],
|
|
72
|
+
"chr_0018_dapan": [
|
|
73
|
+
0.43,
|
|
74
|
+
0.32,
|
|
75
|
+
0.3
|
|
76
|
+
],
|
|
77
|
+
"chr_0019_karin": [
|
|
78
|
+
0.52,
|
|
79
|
+
0.265,
|
|
80
|
+
0.3
|
|
81
|
+
],
|
|
82
|
+
"chr_0020_meurs": [
|
|
83
|
+
0.295,
|
|
84
|
+
0.228,
|
|
85
|
+
0.3
|
|
86
|
+
],
|
|
87
|
+
"chr_0021_whiten": [
|
|
88
|
+
0.49,
|
|
89
|
+
0.28,
|
|
90
|
+
0.3
|
|
91
|
+
],
|
|
92
|
+
"chr_0022_bounda": [
|
|
93
|
+
0.505,
|
|
94
|
+
0.18,
|
|
95
|
+
0.3
|
|
96
|
+
],
|
|
97
|
+
"chr_0023_antal": [
|
|
98
|
+
0.6,
|
|
99
|
+
0.16,
|
|
100
|
+
0.3
|
|
101
|
+
],
|
|
102
|
+
"chr_0024_deepfin": [
|
|
103
|
+
0.46,
|
|
104
|
+
0.25,
|
|
105
|
+
0.3
|
|
106
|
+
],
|
|
107
|
+
"chr_0025_ardelia": [
|
|
108
|
+
0.48,
|
|
109
|
+
0.33,
|
|
110
|
+
0.3
|
|
111
|
+
],
|
|
112
|
+
"chr_0026_lastrite": [
|
|
113
|
+
0.48,
|
|
114
|
+
0.355,
|
|
115
|
+
0.3
|
|
116
|
+
],
|
|
117
|
+
"chr_0027_tangtang": [
|
|
118
|
+
0.51,
|
|
119
|
+
0.33,
|
|
120
|
+
0.3
|
|
121
|
+
],
|
|
122
|
+
"chr_0028_wulfa": [
|
|
123
|
+
0.52,
|
|
124
|
+
0.39,
|
|
125
|
+
0.3
|
|
126
|
+
],
|
|
127
|
+
"chr_0029_pograni": [
|
|
128
|
+
0.43,
|
|
129
|
+
0.29,
|
|
130
|
+
0.3
|
|
131
|
+
],
|
|
132
|
+
"chr_0030_zhuangfy": [
|
|
133
|
+
0.45,
|
|
134
|
+
0.31,
|
|
135
|
+
0.3
|
|
136
|
+
],
|
|
137
|
+
"chr_0031_mifu": [
|
|
138
|
+
0.5,
|
|
139
|
+
0.35,
|
|
140
|
+
0.3
|
|
141
|
+
],
|
|
142
|
+
"chr_0032_lizhiyan": [
|
|
143
|
+
0.505,
|
|
144
|
+
0.305,
|
|
145
|
+
0.3
|
|
146
|
+
],
|
|
147
|
+
"chr_0033_camille": [
|
|
148
|
+
0.5,
|
|
149
|
+
0.315,
|
|
150
|
+
0.3
|
|
151
|
+
],
|
|
152
|
+
"chr_0034_typhoea": [
|
|
153
|
+
0.42,
|
|
154
|
+
0.375,
|
|
155
|
+
0.3
|
|
156
|
+
],
|
|
157
|
+
"chr_0035_liino": [
|
|
158
|
+
0.644,
|
|
159
|
+
0.37,
|
|
160
|
+
0.3
|
|
161
|
+
],
|
|
162
|
+
"chr_0036_jsspsi": [
|
|
163
|
+
0.39,
|
|
164
|
+
0.335,
|
|
165
|
+
0.3
|
|
166
|
+
],
|
|
167
|
+
"chr_0037_minghe": [
|
|
168
|
+
0.48,
|
|
169
|
+
0.244,
|
|
170
|
+
0.3
|
|
171
|
+
],
|
|
172
|
+
"chr_0038_purrche": [
|
|
173
|
+
0.44,
|
|
174
|
+
0.34,
|
|
175
|
+
0.3
|
|
176
|
+
]
|
|
177
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|