Add paimon
This commit is contained in:
parent
7da333ea29
commit
5536d2e0c7
69
commands/paimon.py
Normal file
69
commands/paimon.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import argparse
|
||||||
|
import csv
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument(
|
||||||
|
"output", help="Path of the output CSV file", type=argparse.FileType("w")
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
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(
|
||||||
|
args.output,
|
||||||
|
["ID", "PV", "ATQ", "DEF", "Taux CRIT", "DGT CRIT", "EM", "Energy Cost"],
|
||||||
|
)
|
||||||
|
|
||||||
|
out.writeheader()
|
||||||
|
|
||||||
|
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"),
|
||||||
|
}
|
||||||
|
)
|
14
poetry.lock
generated
14
poetry.lock
generated
@ -164,14 +164,14 @@ files = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "click"
|
name = "click"
|
||||||
version = "8.1.6"
|
version = "8.1.7"
|
||||||
description = "Composable command line interface toolkit"
|
description = "Composable command line interface toolkit"
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
files = [
|
files = [
|
||||||
{file = "click-8.1.6-py3-none-any.whl", hash = "sha256:fa244bb30b3b5ee2cae3da8f55c9e5e0c0e86093306301fb418eb9dc40fbded5"},
|
{file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"},
|
||||||
{file = "click-8.1.6.tar.gz", hash = "sha256:48ee849951919527a045bfe3bf7baa8a959c423134e1a5b98c05c20ba75a1cbd"},
|
{file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
@ -462,14 +462,14 @@ six = ">=1.1.0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "types-beautifulsoup4"
|
name = "types-beautifulsoup4"
|
||||||
version = "4.12.0.5"
|
version = "4.12.0.6"
|
||||||
description = "Typing stubs for beautifulsoup4"
|
description = "Typing stubs for beautifulsoup4"
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = "*"
|
python-versions = "*"
|
||||||
files = [
|
files = [
|
||||||
{file = "types-beautifulsoup4-4.12.0.5.tar.gz", hash = "sha256:d9be456416a62a5b9740559592e1063a69d4b0a1b83911d878558c8ae8e07074"},
|
{file = "types-beautifulsoup4-4.12.0.6.tar.gz", hash = "sha256:045ab285d3e540186e16133612f43f67e31f910e6d7578906b43a0ad8f811347"},
|
||||||
{file = "types_beautifulsoup4-4.12.0.5-py3-none-any.whl", hash = "sha256:718364c8e6787884501c700b1d22b6c0a8711bf9d6c9bf96e1fba81495bc46a8"},
|
{file = "types_beautifulsoup4-4.12.0.6-py3-none-any.whl", hash = "sha256:3da00d754e73afae0ec2793253af0cb9aa1ff2c730e34b31c60313da781b4f6f"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
@ -547,4 +547,4 @@ zstd = ["zstandard (>=0.18.0)"]
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.10"
|
python-versions = "^3.10"
|
||||||
content-hash = "cf789ca28135f09cad9ca85300eec0a0d8ebc1a1e5e7467c679a522926f29466"
|
content-hash = "0ee018b5fd25b6edb3c80d801eb9669bbf35092b2e38cb80014674cad1d08dec"
|
||||||
|
@ -17,8 +17,8 @@ black = "^23.7.0"
|
|||||||
flake8 = "^6.1.0"
|
flake8 = "^6.1.0"
|
||||||
flake8-alphabetize = "^0.0.21"
|
flake8-alphabetize = "^0.0.21"
|
||||||
flake8-black = "^0.3.6"
|
flake8-black = "^0.3.6"
|
||||||
mypy = "^1.5.0"
|
mypy = "^1.5.1"
|
||||||
types-beautifulsoup4 = "^4.12.0.5"
|
types-beautifulsoup4 = "^4.12.0.6"
|
||||||
types-requests = "^2.31.0.2"
|
types-requests = "^2.31.0.2"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
|
Loading…
Reference in New Issue
Block a user