66 lines
1.7 KiB
Python
Executable File
66 lines
1.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import csv
|
|
import json
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
import urllib.request
|
|
import zipfile
|
|
|
|
STATIC_TYPE = ["hp", "atk", "def", "em"]
|
|
|
|
|
|
def compute_base(data, type: str, base: float = 0.0):
|
|
boost = 0
|
|
|
|
if type in data:
|
|
if type in STATIC_TYPE:
|
|
base = data[type][-1]
|
|
else:
|
|
base = data[type][-1] * 100
|
|
|
|
if f"{type}Percent" in data:
|
|
if type in STATIC_TYPE:
|
|
boost = base * data[f"{type}Percent"][-1]
|
|
else:
|
|
boost = data[f"{type}Percent"][-1] * 100
|
|
|
|
return round(base + boost)
|
|
|
|
|
|
main, message = urllib.request.urlretrieve(
|
|
"https://github.com/MadeBaruna/paimon-moe/archive/refs/heads/main.zip"
|
|
)
|
|
|
|
CHAR_DATA_TMP = tempfile.mkdtemp()
|
|
CHAR_DATA_OUT = os.path.join(CHAR_DATA_TMP, "paimon-moe-main/src/data/characterData")
|
|
|
|
with zipfile.ZipFile(main) as zip:
|
|
zip.extractall(CHAR_DATA_TMP)
|
|
|
|
out = csv.DictWriter(
|
|
sys.stdout,
|
|
["ID", "PV", "ATQ", "DEF", "Taux CRIT", "DGT CRIT", "EM", "Energy Cost"],
|
|
)
|
|
|
|
out.writeheader()
|
|
sys.stdout.flush()
|
|
|
|
for file in sorted(os.listdir(CHAR_DATA_OUT)):
|
|
with open(os.path.join(CHAR_DATA_OUT, file)) as character:
|
|
data = json.load(character)
|
|
out.writerow(
|
|
{
|
|
"ID": data["id"],
|
|
"PV": compute_base(data, "hp"),
|
|
"ATQ": compute_base(data, "atk"),
|
|
"DEF": compute_base(data, "def"),
|
|
"Taux CRIT": compute_base(data, "critRate", 5.0),
|
|
"DGT CRIT": compute_base(data, "critDamage", 50.0),
|
|
"EM": compute_base(data, "em"),
|
|
"Energy Cost": data["burst"]["skillStats"][-1][-1][0]
|
|
- compute_base(data, "er"),
|
|
}
|
|
)
|
|
sys.stdout.flush()
|