recard 0.2.0__tar.gz
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.
- recard-0.2.0/LICENSE +21 -0
- recard-0.2.0/PKG-INFO +114 -0
- recard-0.2.0/README.md +95 -0
- recard-0.2.0/pyproject.toml +42 -0
- recard-0.2.0/recard/__init__.py +29 -0
- recard-0.2.0/recard/assets/backgrounds/ANEMO.png +0 -0
- recard-0.2.0/recard/assets/backgrounds/CRYO.png +0 -0
- recard-0.2.0/recard/assets/backgrounds/DENDRO.png +0 -0
- recard-0.2.0/recard/assets/backgrounds/ELECTRO.png +0 -0
- recard-0.2.0/recard/assets/backgrounds/ERROR.png +0 -0
- recard-0.2.0/recard/assets/backgrounds/GEO.png +0 -0
- recard-0.2.0/recard/assets/backgrounds/PYRO.png +0 -0
- recard-0.2.0/recard/assets/backgrounds/hydro.png +0 -0
- recard-0.2.0/recard/assets/constant/closed/ADAPT.png +0 -0
- recard-0.2.0/recard/assets/constant/closed/CLOSED.png +0 -0
- recard-0.2.0/recard/assets/constant/closed/CLOSE_CONST_ANEMO.png +0 -0
- recard-0.2.0/recard/assets/constant/closed/CLOSE_CONST_CRYO.png +0 -0
- recard-0.2.0/recard/assets/constant/closed/CLOSE_CONST_DENDRO.png +0 -0
- recard-0.2.0/recard/assets/constant/closed/CLOSE_CONST_ELECTRO.png +0 -0
- recard-0.2.0/recard/assets/constant/closed/CLOSE_CONST_ERROR.png +0 -0
- recard-0.2.0/recard/assets/constant/closed/CLOSE_CONST_GEO.png +0 -0
- recard-0.2.0/recard/assets/constant/closed/CLOSE_CONST_GYDRO.png +0 -0
- recard-0.2.0/recard/assets/constant/closed/CLOSE_CONST_PYRO.png +0 -0
- recard-0.2.0/recard/assets/constant/const_adapt.png +0 -0
- recard-0.2.0/recard/assets/constant/maska_constant.png +0 -0
- recard-0.2.0/recard/assets/constant/open/ADAPT.png +0 -0
- recard-0.2.0/recard/assets/constant/open/OPEN_CONST_ANEMO.png +0 -0
- recard-0.2.0/recard/assets/constant/open/OPEN_CONST_CRYO.png +0 -0
- recard-0.2.0/recard/assets/constant/open/OPEN_CONST_DENDRO.png +0 -0
- recard-0.2.0/recard/assets/constant/open/OPEN_CONST_ELECTRO.png +0 -0
- recard-0.2.0/recard/assets/constant/open/OPEN_CONST_ERROR.png +0 -0
- recard-0.2.0/recard/assets/constant/open/OPEN_CONST_GEO.png +0 -0
- recard-0.2.0/recard/assets/constant/open/OPEN_CONST_GYDRO.png +0 -0
- recard-0.2.0/recard/assets/constant/open/OPEN_CONST_PYRO.png +0 -0
- recard-0.2.0/recard/assets/fonts/Genshin_Impact.ttf +0 -0
- recard-0.2.0/recard/assets/icons/FRIENDS.png +0 -0
- recard-0.2.0/recard/assets/icons/anemo.png +0 -0
- recard-0.2.0/recard/assets/icons/atk.png +0 -0
- recard-0.2.0/recard/assets/icons/cd.png +0 -0
- recard-0.2.0/recard/assets/icons/cr.png +0 -0
- recard-0.2.0/recard/assets/icons/cryo.png +0 -0
- recard-0.2.0/recard/assets/icons/def.png +0 -0
- recard-0.2.0/recard/assets/icons/dendro.png +0 -0
- recard-0.2.0/recard/assets/icons/electro.png +0 -0
- recard-0.2.0/recard/assets/icons/em.png +0 -0
- recard-0.2.0/recard/assets/icons/er.png +0 -0
- recard-0.2.0/recard/assets/icons/geo.png +0 -0
- recard-0.2.0/recard/assets/icons/hp.png +0 -0
- recard-0.2.0/recard/assets/icons/hydro.png +0 -0
- recard-0.2.0/recard/assets/icons/no_data.png +0 -0
- recard-0.2.0/recard/assets/icons/phys.png +0 -0
- recard-0.2.0/recard/assets/icons/pyro.png +0 -0
- recard-0.2.0/recard/assets/icons/stars/Star1.png +0 -0
- recard-0.2.0/recard/assets/icons/stars/Star2.png +0 -0
- recard-0.2.0/recard/assets/icons/stars/Star3.png +0 -0
- recard-0.2.0/recard/assets/icons/stars/Star4.png +0 -0
- recard-0.2.0/recard/assets/icons/stars/Star5.png +0 -0
- recard-0.2.0/recard/assets/icons/stars/bg.png +0 -0
- recard-0.2.0/recard/assets/icons/stars/c_stars_4.png +0 -0
- recard-0.2.0/recard/assets/icons/stars/c_stars_5.png +0 -0
- recard-0.2.0/recard/assets/images/AVATAR.png +0 -0
- recard-0.2.0/recard/assets/images/AVATAR_MASK.png +0 -0
- recard-0.2.0/recard/assets/images/CHARTER_4.png +0 -0
- recard-0.2.0/recard/assets/images/CHARTER_5.png +0 -0
- recard-0.2.0/recard/assets/images/CHARTER_MASK.png +0 -0
- recard-0.2.0/recard/assets/logo.png +0 -0
- recard-0.2.0/recard/assets/talents/10.png +0 -0
- recard-0.2.0/recard/assets/talents/ADAPT.png +0 -0
- recard-0.2.0/recard/assets/talents/bg.png +0 -0
- recard-0.2.0/recard/cards/__init__.py +0 -0
- recard-0.2.0/recard/cards/artifacts.py +170 -0
- recard-0.2.0/recard/cards/build.py +62 -0
- recard-0.2.0/recard/cards/character_card.py +237 -0
- recard-0.2.0/recard/cards/hoyolab_character_detail.py +469 -0
- recard-0.2.0/recard/cards/watermark.py +64 -0
- recard-0.2.0/recard/client.py +170 -0
- recard-0.2.0/recard/data/__init__.py +0 -0
- recard-0.2.0/recard/data/avatars.json +4036 -0
- recard-0.2.0/recard/data/char.json +4036 -0
- recard-0.2.0/recard/data/data.json +869 -0
- recard-0.2.0/recard/data/new.json +6183 -0
- recard-0.2.0/recard/data/update_data.py +10 -0
- recard-0.2.0/recard/services/__init__.py +0 -0
- recard-0.2.0/recard/services/enka.py +58 -0
- recard-0.2.0/recard/services/net.py +99 -0
- recard-0.2.0/recard.egg-info/PKG-INFO +114 -0
- recard-0.2.0/recard.egg-info/SOURCES.txt +89 -0
- recard-0.2.0/recard.egg-info/dependency_links.txt +1 -0
- recard-0.2.0/recard.egg-info/requires.txt +7 -0
- recard-0.2.0/recard.egg-info/top_level.txt +1 -0
- recard-0.2.0/setup.cfg +4 -0
recard-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HATheekshana
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
recard-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: recard
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Async Genshin Impact character card generator (Enka.Network showcase -> image), styled after zenka for ZZZ.
|
|
5
|
+
Author: HATheekshana
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/HATheekshana/recard
|
|
8
|
+
Keywords: genshin,genshin-impact,enka,card,zenka
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: aiohttp<4,>=3.12
|
|
13
|
+
Requires-Dist: Pillow>=10.0
|
|
14
|
+
Requires-Dist: enka<3,>=2.5.20
|
|
15
|
+
Provides-Extra: fast-dns
|
|
16
|
+
Requires-Dist: aiodns>=3.2.0; extra == "fast-dns"
|
|
17
|
+
Requires-Dist: pycares<4.4.0; extra == "fast-dns"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# recard
|
|
21
|
+
|
|
22
|
+
Async Genshin Impact character card generator, built the same way you'd use
|
|
23
|
+
[`zenka`](https://pypi.org/project/zenka/) for Zenless Zone Zero: give it a
|
|
24
|
+
UID, get back rendered card images.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install ./recard # local build, see "Installing" below
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import asyncio
|
|
32
|
+
import recard
|
|
33
|
+
|
|
34
|
+
async def main():
|
|
35
|
+
async with recard.Client() as client:
|
|
36
|
+
# list everything currently in the player's public showcase
|
|
37
|
+
showcase = await client.get_api(700000000)
|
|
38
|
+
for char in showcase:
|
|
39
|
+
print(char.id, char.name, char.element)
|
|
40
|
+
|
|
41
|
+
# render one character by name
|
|
42
|
+
result = await client.card(700000000, "Hu Tao")
|
|
43
|
+
for card in result.cards:
|
|
44
|
+
card.card.save(f"{card.name}.png") # card.card is a PIL.Image
|
|
45
|
+
|
|
46
|
+
# ...or by exact avatar ID, same call shape
|
|
47
|
+
result = await client.card(700000000, 10000046)
|
|
48
|
+
|
|
49
|
+
# or render the whole showcase at once
|
|
50
|
+
result = await client.card(700000000)
|
|
51
|
+
for card in result.cards:
|
|
52
|
+
card.card.save(f"{card.name}.png")
|
|
53
|
+
|
|
54
|
+
asyncio.run(main())
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## How it works / limitations
|
|
58
|
+
|
|
59
|
+
- Uses [enka-py](https://github.com/seriaati/enka-py), installed automatically
|
|
60
|
+
as the `enka` dependency. Public `Client.get_api()` and `Client.card()`
|
|
61
|
+
calls keep the same interface and return types.
|
|
62
|
+
- Only characters available in the player's public Enka showcase can be
|
|
63
|
+
rendered. No HoYoLAB login or cookie fallback is included.
|
|
64
|
+
- Character names, artwork, namecards, talents, constellations, weapons,
|
|
65
|
+
and artifacts come from enka-py's enriched models. The four bundled
|
|
66
|
+
metadata JSON files are no longer needed or shipped.
|
|
67
|
+
- enka-py downloads its metadata on first use into `.enka_py/assets`
|
|
68
|
+
under the process working directory, which must be writable. First use
|
|
69
|
+
needs an internet connection. Refresh assets after game patches:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
async with recard.Client() as client:
|
|
73
|
+
await client.update_assets()
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The command `python -m recard.data.update_data` also performs this refresh.
|
|
77
|
+
Updates depend on the upstream asset sources supporting the new characters.
|
|
78
|
+
- Network and parsing errors now propagate instead of appearing as an empty
|
|
79
|
+
showcase. An empty public showcase still returns an empty list; requesting
|
|
80
|
+
a missing character raises `recard.CharacterNotFound`.
|
|
81
|
+
- Custom splash art is read from
|
|
82
|
+
`~/.recard/custom_splash/<char_id>.(png|jpg|jpeg|webp)`.
|
|
83
|
+
- Internal JSON-path constructor options and placeholder HoYoLAB hooks were
|
|
84
|
+
removed. Integrations using those internals should use the public Client.
|
|
85
|
+
|
|
86
|
+
## Installing
|
|
87
|
+
|
|
88
|
+
This isn't published to PyPI yet. Until then:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install ./recard
|
|
92
|
+
# or, for local editing:
|
|
93
|
+
pip install -e ./recard
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Once published:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pip install recard
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
The code in this repository is MIT-licensed - see `LICENSE`.
|
|
105
|
+
|
|
106
|
+
**Note on bundled assets:** `recard/assets/` ships
|
|
107
|
+
fonts, icons, and character art from Genshin Impact,
|
|
108
|
+
© COGNOSPHERE PTE. LTD. / HoYoverse. These are included for card
|
|
109
|
+
rendering purposes only, are not covered by this project's MIT license,
|
|
110
|
+
and all rights to them remain with their original owner. This project
|
|
111
|
+
is an unofficial fan tool and is not affiliated with or endorsed by
|
|
112
|
+
HoYoverse.
|
|
113
|
+
|
|
114
|
+
The enka-py dependency has its own GPL-3.0 license; see its repository for details.
|
recard-0.2.0/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# recard
|
|
2
|
+
|
|
3
|
+
Async Genshin Impact character card generator, built the same way you'd use
|
|
4
|
+
[`zenka`](https://pypi.org/project/zenka/) for Zenless Zone Zero: give it a
|
|
5
|
+
UID, get back rendered card images.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install ./recard # local build, see "Installing" below
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
import asyncio
|
|
13
|
+
import recard
|
|
14
|
+
|
|
15
|
+
async def main():
|
|
16
|
+
async with recard.Client() as client:
|
|
17
|
+
# list everything currently in the player's public showcase
|
|
18
|
+
showcase = await client.get_api(700000000)
|
|
19
|
+
for char in showcase:
|
|
20
|
+
print(char.id, char.name, char.element)
|
|
21
|
+
|
|
22
|
+
# render one character by name
|
|
23
|
+
result = await client.card(700000000, "Hu Tao")
|
|
24
|
+
for card in result.cards:
|
|
25
|
+
card.card.save(f"{card.name}.png") # card.card is a PIL.Image
|
|
26
|
+
|
|
27
|
+
# ...or by exact avatar ID, same call shape
|
|
28
|
+
result = await client.card(700000000, 10000046)
|
|
29
|
+
|
|
30
|
+
# or render the whole showcase at once
|
|
31
|
+
result = await client.card(700000000)
|
|
32
|
+
for card in result.cards:
|
|
33
|
+
card.card.save(f"{card.name}.png")
|
|
34
|
+
|
|
35
|
+
asyncio.run(main())
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## How it works / limitations
|
|
39
|
+
|
|
40
|
+
- Uses [enka-py](https://github.com/seriaati/enka-py), installed automatically
|
|
41
|
+
as the `enka` dependency. Public `Client.get_api()` and `Client.card()`
|
|
42
|
+
calls keep the same interface and return types.
|
|
43
|
+
- Only characters available in the player's public Enka showcase can be
|
|
44
|
+
rendered. No HoYoLAB login or cookie fallback is included.
|
|
45
|
+
- Character names, artwork, namecards, talents, constellations, weapons,
|
|
46
|
+
and artifacts come from enka-py's enriched models. The four bundled
|
|
47
|
+
metadata JSON files are no longer needed or shipped.
|
|
48
|
+
- enka-py downloads its metadata on first use into `.enka_py/assets`
|
|
49
|
+
under the process working directory, which must be writable. First use
|
|
50
|
+
needs an internet connection. Refresh assets after game patches:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
async with recard.Client() as client:
|
|
54
|
+
await client.update_assets()
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The command `python -m recard.data.update_data` also performs this refresh.
|
|
58
|
+
Updates depend on the upstream asset sources supporting the new characters.
|
|
59
|
+
- Network and parsing errors now propagate instead of appearing as an empty
|
|
60
|
+
showcase. An empty public showcase still returns an empty list; requesting
|
|
61
|
+
a missing character raises `recard.CharacterNotFound`.
|
|
62
|
+
- Custom splash art is read from
|
|
63
|
+
`~/.recard/custom_splash/<char_id>.(png|jpg|jpeg|webp)`.
|
|
64
|
+
- Internal JSON-path constructor options and placeholder HoYoLAB hooks were
|
|
65
|
+
removed. Integrations using those internals should use the public Client.
|
|
66
|
+
|
|
67
|
+
## Installing
|
|
68
|
+
|
|
69
|
+
This isn't published to PyPI yet. Until then:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install ./recard
|
|
73
|
+
# or, for local editing:
|
|
74
|
+
pip install -e ./recard
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Once published:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install recard
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
The code in this repository is MIT-licensed - see `LICENSE`.
|
|
86
|
+
|
|
87
|
+
**Note on bundled assets:** `recard/assets/` ships
|
|
88
|
+
fonts, icons, and character art from Genshin Impact,
|
|
89
|
+
© COGNOSPHERE PTE. LTD. / HoYoverse. These are included for card
|
|
90
|
+
rendering purposes only, are not covered by this project's MIT license,
|
|
91
|
+
and all rights to them remain with their original owner. This project
|
|
92
|
+
is an unofficial fan tool and is not affiliated with or endorsed by
|
|
93
|
+
HoYoverse.
|
|
94
|
+
|
|
95
|
+
The enka-py dependency has its own GPL-3.0 license; see its repository for details.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "recard"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Async Genshin Impact character card generator (Enka.Network showcase -> image), styled after zenka for ZZZ."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "HATheekshana" }]
|
|
13
|
+
keywords = ["genshin", "genshin-impact", "enka", "card", "zenka"]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"aiohttp>=3.12,<4",
|
|
16
|
+
"Pillow>=10.0",
|
|
17
|
+
"enka>=2.5.20,<3",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.optional-dependencies]
|
|
21
|
+
# Faster/more reliable DNS resolution - genuinely optional: net.py already
|
|
22
|
+
# falls back to aiohttp's default resolver when this isn't installed.
|
|
23
|
+
# Needs a C compiler on some platforms (notably Windows without MSVC Build
|
|
24
|
+
# Tools), so it's kept out of the required dependency list.
|
|
25
|
+
fast-dns = [
|
|
26
|
+
"aiodns>=3.2.0",
|
|
27
|
+
"pycares<4.4.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/HATheekshana/recard"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools]
|
|
34
|
+
include-package-data = true
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.packages.find]
|
|
37
|
+
include = ["recard*"]
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.package-data]
|
|
40
|
+
recard = [
|
|
41
|
+
"assets/**/*",
|
|
42
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
recard - Genshin Impact character card generator.
|
|
3
|
+
|
|
4
|
+
Same usage pattern as zenka (the ZZZ card library):
|
|
5
|
+
|
|
6
|
+
import asyncio
|
|
7
|
+
import recard
|
|
8
|
+
|
|
9
|
+
async def main():
|
|
10
|
+
async with recard.Client() as client:
|
|
11
|
+
result = await client.card(700000000, character="Hu Tao")
|
|
12
|
+
for card in result.cards:
|
|
13
|
+
card.card.save(f"{card.name}.png")
|
|
14
|
+
|
|
15
|
+
asyncio.run(main())
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from .client import Card, CardResult, CharacterNotFound, Client, ShowcaseCharacter
|
|
19
|
+
|
|
20
|
+
__version__ = "0.2.0"
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"Client",
|
|
24
|
+
"ShowcaseCharacter",
|
|
25
|
+
"Card",
|
|
26
|
+
"CardResult",
|
|
27
|
+
"CharacterNotFound",
|
|
28
|
+
"__version__",
|
|
29
|
+
]
|
|
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
|
|
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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import logging
|
|
3
|
+
from io import BytesIO
|
|
4
|
+
from PIL import Image, ImageDraw, ImageFont
|
|
5
|
+
|
|
6
|
+
from pathlib import Path as _Path
|
|
7
|
+
_PKG_ROOT = _Path(__file__).resolve().parent.parent
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger("recard")
|
|
10
|
+
|
|
11
|
+
# Stat Mapping for icons (Local files)
|
|
12
|
+
STAT_MAP = {
|
|
13
|
+
"FIGHT_PROP_HP": "hp", "FIGHT_PROP_HP_PERCENT": "hp",
|
|
14
|
+
"FIGHT_PROP_ATTACK": "atk", "FIGHT_PROP_ATTACK_PERCENT": "atk",
|
|
15
|
+
"FIGHT_PROP_DEFENSE": "def", "FIGHT_PROP_DEFENSE_PERCENT": "def",
|
|
16
|
+
"FIGHT_PROP_ELEMENT_MASTERY": "em", "FIGHT_PROP_CHARGE_EFFICIENCY": "er",
|
|
17
|
+
"FIGHT_PROP_CRITICAL": "cr", "FIGHT_PROP_CRITICAL_HURT": "cd",
|
|
18
|
+
"FIGHT_PROP_FIRE_ADD_HURT": "pyro", "FIGHT_PROP_WATER_ADD_HURT": "hydro",
|
|
19
|
+
"FIGHT_PROP_GRASS_ADD_HURT": "dendro", "FIGHT_PROP_ELEC_ADD_HURT": "electro",
|
|
20
|
+
"FIGHT_PROP_ICE_ADD_HURT": "cryo", "FIGHT_PROP_WIND_ADD_HURT": "anemo",
|
|
21
|
+
"FIGHT_PROP_ROCK_ADD_HURT": "geo", "FIGHT_PROP_PHYSICAL_ADD_HURT": "phys"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# Flower, Feather, Sands, Goblet, Circlet
|
|
25
|
+
EQUIP_ORDER = ["EQUIP_BRACER", "EQUIP_NECKLACE", "EQUIP_SHOES", "EQUIP_RING", "EQUIP_DRESS"]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _compute_cv(main_data, sub_stats):
|
|
29
|
+
"""CV (crit value) = CR% * 2 + CD%, summed across the main stat (only
|
|
30
|
+
relevant for circlets, whose main stat can itself be CR or CD) and all
|
|
31
|
+
substats. Both crit stats stack additively across an artifact, so this
|
|
32
|
+
is just a running total, not an average."""
|
|
33
|
+
cr = 0.0
|
|
34
|
+
cd = 0.0
|
|
35
|
+
|
|
36
|
+
main_prop = main_data.get("mainPropId")
|
|
37
|
+
if main_prop == "FIGHT_PROP_CRITICAL":
|
|
38
|
+
cr += main_data.get("statValue", 0) or 0
|
|
39
|
+
elif main_prop == "FIGHT_PROP_CRITICAL_HURT":
|
|
40
|
+
cd += main_data.get("statValue", 0) or 0
|
|
41
|
+
|
|
42
|
+
for stat in sub_stats:
|
|
43
|
+
prop_id = stat.get("appendPropId")
|
|
44
|
+
if prop_id == "FIGHT_PROP_CRITICAL":
|
|
45
|
+
cr += stat.get("statValue", 0) or 0
|
|
46
|
+
elif prop_id == "FIGHT_PROP_CRITICAL_HURT":
|
|
47
|
+
cd += stat.get("statValue", 0) or 0
|
|
48
|
+
|
|
49
|
+
return cr * 2 + cd
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async def draw_artifact_card(session, base_image, x, y, art_data, font):
|
|
53
|
+
draw = ImageDraw.Draw(base_image)
|
|
54
|
+
CARD_W, CARD_H = 330, 200
|
|
55
|
+
ICONS_PATH = f"{_PKG_ROOT}/assets/icons/"
|
|
56
|
+
STARS_PATH = f"{_PKG_ROOT}/assets/icons/stars/"
|
|
57
|
+
|
|
58
|
+
# 1. Background Card - Using a slightly more transparent fill for that glassmorphism look
|
|
59
|
+
draw.rounded_rectangle([x, y, x + CARD_W, y + CARD_H], radius=12, fill=(0, 0, 0, 80), outline=(255, 255, 255, 40))
|
|
60
|
+
|
|
61
|
+
flat = art_data.get("flat", {})
|
|
62
|
+
relic_core = art_data.get("reliquary", {})
|
|
63
|
+
main_data = flat.get("reliquaryMainstat", {})
|
|
64
|
+
sub_stats = flat.get("reliquarySubstats", [])
|
|
65
|
+
|
|
66
|
+
# 2. Artifact Piece Icon (The Gear piece)
|
|
67
|
+
icon_name = flat.get("icon")
|
|
68
|
+
# Live HoYoLAB data (character/detail fallback) gives a full,
|
|
69
|
+
# directly-fetchable CDN URL - it's hash-named, so it can't be
|
|
70
|
+
# reconstructed as an enka.network/ui/... path the way Enka's own
|
|
71
|
+
# semantic icon names can.
|
|
72
|
+
icon_url = flat.get("icon_url") or (f"https://enka.network/ui/{icon_name}.png" if icon_name else None)
|
|
73
|
+
if icon_url:
|
|
74
|
+
url = icon_url
|
|
75
|
+
async with session.get(url) as response:
|
|
76
|
+
if response.status == 200:
|
|
77
|
+
img_data = await response.read()
|
|
78
|
+
art_img = Image.open(BytesIO(img_data)).convert("RGBA").resize((140, 140), Image.Resampling.LANCZOS)
|
|
79
|
+
# Icon background
|
|
80
|
+
base_image.paste(art_img, (x + 15, y + 30), art_img)
|
|
81
|
+
|
|
82
|
+
# 4. Rarity Stars (NEW)
|
|
83
|
+
rarity = flat.get("rankLevel", 5)
|
|
84
|
+
try:
|
|
85
|
+
# 1. Open and convert
|
|
86
|
+
star_img = Image.open(f"{STARS_PATH}Star{rarity}.png").convert("RGBA")
|
|
87
|
+
|
|
88
|
+
# 2. Resize directly to the target size (Re-assigning the variable!)
|
|
89
|
+
star_img = star_img.resize((98, 28), Image.Resampling.LANCZOS)
|
|
90
|
+
|
|
91
|
+
# 3. Paste
|
|
92
|
+
base_image.paste(star_img, (x + 30, y + 140), star_img)
|
|
93
|
+
except Exception as e:
|
|
94
|
+
logger.warning("Error loading star image Star%s.png: %s", rarity, e)
|
|
95
|
+
# 3. Main Stat Icon - PASTE THIS LAST so it's on top
|
|
96
|
+
main_prop = main_data.get("mainPropId")
|
|
97
|
+
if main_prop:
|
|
98
|
+
icon_key = STAT_MAP.get(main_prop, "atk").lower()
|
|
99
|
+
try:
|
|
100
|
+
# We move the main stat icon to the top right of the gear box
|
|
101
|
+
m_icon = Image.open(f"{ICONS_PATH}{icon_key}.png").convert("RGBA").resize((28, 28))
|
|
102
|
+
base_image.paste(m_icon, (x + 10, y + 10), m_icon)
|
|
103
|
+
except Exception:
|
|
104
|
+
pass
|
|
105
|
+
|
|
106
|
+
# 4. Sub-Stat Grid
|
|
107
|
+
grid_x = x + 150
|
|
108
|
+
for i, stat in enumerate(sub_stats[:4]):
|
|
109
|
+
col, row = i % 1, i // 1
|
|
110
|
+
bx = grid_x + (col * 135)
|
|
111
|
+
by = y + 15 + (row * 45)
|
|
112
|
+
|
|
113
|
+
# Substat box
|
|
114
|
+
draw.rounded_rectangle([bx, by, bx + 170, by + 38], radius=10, fill=(20, 20, 30, 150))
|
|
115
|
+
|
|
116
|
+
prop_id = stat.get("appendPropId")
|
|
117
|
+
icon_file = STAT_MAP.get(prop_id, "atk").lower()
|
|
118
|
+
try:
|
|
119
|
+
s_icon = Image.open(f"{ICONS_PATH}{icon_file}.png").convert("RGBA").resize((22, 22))
|
|
120
|
+
base_image.paste(s_icon, (bx + 8, by + 8), s_icon)
|
|
121
|
+
except Exception:
|
|
122
|
+
pass
|
|
123
|
+
|
|
124
|
+
val = stat.get("statValue")
|
|
125
|
+
is_percent = any(k in prop_id for k in ["PERCENT", "CRITICAL", "EFFICIENCY", "HURT"])
|
|
126
|
+
val_str = f"+{val}%" if is_percent else f"+{val}"
|
|
127
|
+
draw.text((bx + 55, by + 19), val_str, font=font, fill=(255, 255, 255), anchor="lm")
|
|
128
|
+
|
|
129
|
+
# 5. Main Stat Value - bottom left of the card (where the level used to sit).
|
|
130
|
+
if main_prop:
|
|
131
|
+
main_val = main_data.get("statValue")
|
|
132
|
+
is_percent = any(k in main_prop for k in ["PERCENT", "CRITICAL", "EFFICIENCY", "HURT"])
|
|
133
|
+
main_val_str = f"{main_val}%" if is_percent else f"{int(main_val)}"
|
|
134
|
+
draw.text((x + 5, y + CARD_H - 15), main_val_str, font=font, fill=(255, 255, 255), anchor="lm", stroke_width=1, stroke_fill=(0, 0, 0))
|
|
135
|
+
|
|
136
|
+
# 6. Enhancement level - bottom right of the card.
|
|
137
|
+
raw_level = relic_core.get("level", 1)
|
|
138
|
+
display_level = f"+{raw_level - 1}"
|
|
139
|
+
draw.text((x + CARD_W - 185, y + CARD_H - 15), display_level, font=font, fill=(255, 204, 0), stroke_width=1, stroke_fill=(0, 0, 0), anchor="rm")
|
|
140
|
+
|
|
141
|
+
# 7. CV (crit value) score - top right of the card. Drawn last, on top
|
|
142
|
+
# of everything else (icon/stars/grid), so it's never painted over.
|
|
143
|
+
cv_score = _compute_cv(main_data, sub_stats)
|
|
144
|
+
cv_text = f"CV{cv_score:.1f}"
|
|
145
|
+
draw.text((x + CARD_W - 185, y + 25), cv_text, font=font, fill=(255, 255, 255), stroke_width=1, stroke_fill=(0, 0, 0), anchor="rm")
|
|
146
|
+
|
|
147
|
+
async def draw_horizontal_artifacts(session, background, char_data, start_x, start_y, font):
|
|
148
|
+
"""
|
|
149
|
+
Finds all artifacts for a single character and draws them in a
|
|
150
|
+
horizontal row (Flower -> Feather -> Sands -> Goblet -> Circlet).
|
|
151
|
+
"""
|
|
152
|
+
# Filter only relics (artifacts)
|
|
153
|
+
relics = [e for e in char_data.get("equipList", []) if "reliquary" in e]
|
|
154
|
+
|
|
155
|
+
# Sort by EQUIP_ORDER
|
|
156
|
+
sorted_relics = sorted(
|
|
157
|
+
relics,
|
|
158
|
+
key=lambda x: EQUIP_ORDER.index(x.get("flat", {}).get("equipType", ""))
|
|
159
|
+
if x.get("flat", {}).get("equipType") in EQUIP_ORDER else 99
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
tasks = []
|
|
163
|
+
spacing_x = 345
|
|
164
|
+
|
|
165
|
+
for i, art in enumerate(sorted_relics[:5]):
|
|
166
|
+
curr_x = start_x + (i * spacing_x)
|
|
167
|
+
tasks.append(draw_artifact_card(session, background, curr_x, start_y, art, font))
|
|
168
|
+
|
|
169
|
+
if tasks:
|
|
170
|
+
await asyncio.gather(*tasks)
|