From b27ff16ce399b9fce5b969d3be03667dabd92096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Sun, 14 May 2023 12:29:29 +0800 Subject: [PATCH] :tada: Initial commit --- .deepsource.toml | 17 + .gitignore | 177 ++++ .gitmodules | 3 + LICENSE | 21 + README.md | 5 + genshin_artifact | 1 + genshin_artifact_function/Cargo.lock | 991 ++++++++++++++++++ genshin_artifact_function/Cargo.toml | 15 + genshin_artifact_function/src/lib.rs | 161 +++ pyproject.toml | 29 + python_genshin_artifact/__init__.py | 0 python_genshin_artifact/calculator.py | 9 + python_genshin_artifact/models/__init__.py | 0 python_genshin_artifact/models/artifact.py | 12 + python_genshin_artifact/models/buff.py | 7 + python_genshin_artifact/models/calculator.py | 20 + .../models/characterInfo.py | 12 + .../models/damage/__init__.py | 0 .../models/damage/analysis.py | 40 + .../models/damage/result.py | 9 + python_genshin_artifact/models/element.py | 0 python_genshin_artifact/models/enemy.py | 13 + python_genshin_artifact/models/skill.py | 8 + python_genshin_artifact/models/weapon.py | 9 + 24 files changed, 1559 insertions(+) create mode 100644 .deepsource.toml create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 LICENSE create mode 100644 README.md create mode 160000 genshin_artifact create mode 100644 genshin_artifact_function/Cargo.lock create mode 100644 genshin_artifact_function/Cargo.toml create mode 100644 genshin_artifact_function/src/lib.rs create mode 100644 pyproject.toml create mode 100644 python_genshin_artifact/__init__.py create mode 100644 python_genshin_artifact/calculator.py create mode 100644 python_genshin_artifact/models/__init__.py create mode 100644 python_genshin_artifact/models/artifact.py create mode 100644 python_genshin_artifact/models/buff.py create mode 100644 python_genshin_artifact/models/calculator.py create mode 100644 python_genshin_artifact/models/characterInfo.py create mode 100644 python_genshin_artifact/models/damage/__init__.py create mode 100644 python_genshin_artifact/models/damage/analysis.py create mode 100644 python_genshin_artifact/models/damage/result.py create mode 100644 python_genshin_artifact/models/element.py create mode 100644 python_genshin_artifact/models/enemy.py create mode 100644 python_genshin_artifact/models/skill.py create mode 100644 python_genshin_artifact/models/weapon.py diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..879f24f --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,17 @@ +version = 1 + +[[analyzers]] +name = "rust" + + [analyzers.meta] + msrv = "stable" + +[[analyzers]] +name = "python" + + [analyzers.meta] + runtime_version = "3.x.x" + max_line_length = 120 + +[[transformers]] +name = "black" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a54c30 --- /dev/null +++ b/.gitignore @@ -0,0 +1,177 @@ +# Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ + +# Rust +# Generated by Cargo +# will have compiled files and executables +debug/ +# target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..79511f9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "genshin_artifact"] + path = genshin_artifact + url = https://github.com/wormtql/genshin_artifact.git diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6286ba0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 PaiGram + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..2529929 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Python-Genshin-Aartifact + +A Python library that binds to +[Genshin Artifact](https://github.com/wormtql/genshin_artifact) +damage calculation and analysis engine. diff --git a/genshin_artifact b/genshin_artifact new file mode 160000 index 0000000..7e01877 --- /dev/null +++ b/genshin_artifact @@ -0,0 +1 @@ +Subproject commit 7e01877c222f1355840bc6f4c031fb0efc2f9cd9 diff --git a/genshin_artifact_function/Cargo.lock b/genshin_artifact_function/Cargo.lock new file mode 100644 index 0000000..e49ea6d --- /dev/null +++ b/genshin_artifact_function/Cargo.lock @@ -0,0 +1,991 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "askama" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb98f10f371286b177db5eeb9a6e5396609555686a35e1d4f7b9a9c6d8af0139" +dependencies = [ + "askama_derive", + "askama_escape", + "askama_shared", +] + +[[package]] +name = "askama_derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87bf87e6e8b47264efa9bde63d6225c6276a52e05e91bf37eaa8afd0032d6b71" +dependencies = [ + "askama_shared", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "askama_escape" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" + +[[package]] +name = "askama_shared" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf722b94118a07fcbc6640190f247334027685d4e218b794dbfe17c32bf38ed0" +dependencies = [ + "askama_escape", + "humansize", + "mime", + "mime_guess", + "nom", + "num-traits", + "percent-encoding", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", + "toml", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "cpufeatures" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "genshin_artifact_function" +version = "0.1.0" +dependencies = [ + "mona", + "mona_wasm", + "pyo3", + "serde", + "serde_json", +] + +[[package]] +name = "getrandom" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "humansize" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" + +[[package]] +name = "indoc" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "js-sys" +version = "0.3.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mona" +version = "0.1.0" +dependencies = [ + "askama", + "askama_escape", + "console_error_panic_hook", + "getrandom", + "lazy_static", + "mona_derive", + "num", + "num-derive", + "num-traits", + "pest", + "pest_derive", + "rand", + "rustc-hash", + "serde", + "serde_json", + "smallvec", + "strum 0.23.0", + "strum_macros 0.23.1", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "mona_derive" +version = "0.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "mona_dsl" +version = "0.1.0" +dependencies = [ + "lazy_static", + "mona", + "pest", + "pest_derive", + "serde", + "serde_json", + "smallvec", + "strum 0.24.1", + "strum_macros 0.24.3", +] + +[[package]] +name = "mona_wasm" +version = "0.1.0" +dependencies = [ + "askama", + "askama_escape", + "console_error_panic_hook", + "getrandom", + "lazy_static", + "mona", + "mona_dsl", + "num", + "num-derive", + "num-traits", + "rand", + "rustc-hash", + "serde", + "serde_json", + "smallvec", + "strum 0.23.0", + "strum_macros 0.23.1", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pest" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" +dependencies = [ + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "pest_meta" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pyo3" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b1ac5b3731ba34fdaa9785f8d74d17448cd18f30cf19e0c7e7b1fdb5272109" +dependencies = [ + "cfg-if", + "indoc", + "libc", + "memoffset", + "parking_lot", + "pyo3-build-config", + "pyo3-ffi", + "pyo3-macros", + "unindent", +] + +[[package]] +name = "pyo3-build-config" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cb946f5ac61bb61a5014924910d936ebd2b23b705f7a4a3c40b05c720b079a3" +dependencies = [ + "once_cell", + "target-lexicon", +] + +[[package]] +name = "pyo3-ffi" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd4d7c5337821916ea2a1d21d1092e8443cf34879e53a0ac653fbb98f44ff65c" +dependencies = [ + "libc", + "pyo3-build-config", +] + +[[package]] +name = "pyo3-macros" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d39c55dab3fc5a4b25bbd1ac10a2da452c4aca13bb450f22818a002e29648d" +dependencies = [ + "proc-macro2", + "pyo3-macros-backend", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97daff08a4c48320587b5224cc98d609e3c27b6d437315bd40b605c98eeb5918" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustversion" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "serde" +version = "1.0.163" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.163" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "serde_json" +version = "1.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "strum" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae14b91c7d11c9a851d3fbc80a963198998c2a64eec840477fa92d8ce9b70bb" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum_macros" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb0dc7ee9c15cea6199cde9a127fa16a4c5819af85395457ad72d68edc85a38" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" + +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "ucd-trie" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unindent" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4" +dependencies = [ + "cfg-if", + "serde", + "serde_json", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.15", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb" + +[[package]] +name = "web-sys" +version = "0.3.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b5f940c7edfdc6d12126d98c9ef4d1b3d470011c47c76a6581df47ad9ba721" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" diff --git a/genshin_artifact_function/Cargo.toml b/genshin_artifact_function/Cargo.toml new file mode 100644 index 0000000..9c4ca02 --- /dev/null +++ b/genshin_artifact_function/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "genshin_artifact_function" +version = "0.1.0" +edition = "2021" + +[lib] +name = "genshin_artifact_function" +crate-type = ["cdylib"] + +[dependencies] +pyo3 = { version = "0.18.3", features = ["extension-module"] } +mona_wasm = { path = "../genshin_artifact/mona_wasm" } +mona = { path = "../genshin_artifact/mona_core" } +serde="1.0" +serde_json = "1.0" \ No newline at end of file diff --git a/genshin_artifact_function/src/lib.rs b/genshin_artifact_function/src/lib.rs new file mode 100644 index 0000000..ea795f9 --- /dev/null +++ b/genshin_artifact_function/src/lib.rs @@ -0,0 +1,161 @@ +use mona::artifacts::{Artifact, ArtifactList}; +use mona::artifacts::effect_config::ArtifactEffectConfig; +use mona::attribute::{AttributeUtils, ComplicatedAttributeGraph, SimpleAttributeGraph2}; +use mona::buffs::{Buff, BuffConfig}; +use mona::character::{Character, CharacterName}; +use mona::character::characters::damage; +use mona::character::skill_config::CharacterSkillConfig; +use mona::common::Element; +use mona::damage::{ComplicatedDamageBuilder, DamageAnalysis, DamageContext, SimpleDamageBuilder}; +use mona::damage::transformative_damage::TransformativeDamage; +use mona::enemies::Enemy; +use mona::utils; +use mona::weapon::Weapon; +use mona_wasm::applications::common::{BuffInterface, CharacterInterface, EnemyInterface, SkillInterface, WeaponInterface}; +use mona_wasm::CalculatorInterface; +use pyo3::prelude::*; +use serde::{Deserialize, Serialize, Serializer}; +use serde_json::Value; + +#[derive(Serialize, Deserialize)] +pub struct CalculatorConfigInterface { + pub character: CharacterInterface, + pub weapon: WeaponInterface, + pub buffs: Vec, + pub artifacts: Vec, + pub artifact_config: Option, + pub skill: SkillInterface, + pub enemy: Option, +} + +#[derive(Serialize, Deserialize)] +struct TransformativeDamageBridge { + swirl_cryo: f64, + swirl_hydro: f64, + swirl_pyro: f64, + swirl_electro: f64, + overload: f64, + electro_charged: f64, + shatter: f64, + superconduct: f64, + bloom: f64, + hyperbloom: f64, + burgeon: f64, + burning: f64, + crystallize: f64, +} + + +impl From for TransformativeDamageBridge { + fn from(damage: TransformativeDamage) -> Self { + Self { + swirl_cryo: damage.swirl_cryo, + swirl_hydro: damage.swirl_hydro, + swirl_pyro: damage.swirl_pyro, + swirl_electro: damage.swirl_electro, + overload: damage.overload, + electro_charged: damage.electro_charged, + shatter: damage.shatter, + superconduct: damage.superconduct, + bloom: damage.bloom, + hyperbloom: damage.hyperbloom, + burgeon: damage.burgeon, + burning: damage.burning, + crystallize: damage.crystallize, + } + } +} + + +#[pyfunction] +pub fn get_damage_analysis(value_str: String) -> PyResult { + let input: CalculatorConfigInterface = serde_json::from_str(&*value_str).unwrap(); + + + let character: Character = input.character.to_character(); + let weapon = input.weapon.to_weapon(&character); + + let buffs: Vec>> = input.buffs.iter().map(|x| x.to_buff()).collect(); + let artifacts: Vec<&Artifact> = input.artifacts.iter().collect(); + + + let artifact_config = match input.artifact_config { + Some(x) => x, + None => Default::default() + }; + + let enemy = if let Some(x) = input.enemy { + x.to_enemy() + } else { + Default::default() + }; + + let result = CalculatorInterface::get_damage_analysis_internal( + &character, + &weapon, + &buffs, + artifacts, + &artifact_config, + input.skill.index, + &input.skill.config, + &enemy, + None, + ); + + let result_str = serde_json::to_string(&result).unwrap(); + Ok(result_str) +} + +#[pyfunction] +pub fn get_transformative_damage(value_str: String) -> PyResult { + utils::set_panic_hook(); + let input: CalculatorConfigInterface = serde_json::from_str(&*value_str).unwrap(); + + let character: Character = input.character.to_character(); + let weapon = input.weapon.to_weapon(&character); + + let buffs: Vec<_> = input.buffs.iter().map(|x| x.to_buff()).collect(); + let artifacts: Vec<&Artifact> = input.artifacts.iter().collect(); + + let artifact_config = match input.artifact_config { + Some(x) => x, + None => Default::default() + }; + + let enemy = if let Some(x) = input.enemy { + x.to_enemy() + } else { + Default::default() + }; + + let attribute = AttributeUtils::create_attribute_from_big_config( + &ArtifactList { + artifacts: &artifacts + }, + &artifact_config, + &character, + &weapon, + &buffs, + ); + + let context: DamageContext<'_, SimpleAttributeGraph2> = DamageContext { + character_common_data: &character.common_data, + enemy: &enemy, + attribute: &attribute, + }; + + let result = context.transformative(); + let bridge = TransformativeDamageBridge::from(result); + let result_str = serde_json::to_string(&bridge).unwrap(); + Ok(result_str) +} + + + + +#[pymodule] +fn genshin_artifact_function(py: Python<'_>, m: &PyModule) -> PyResult<()> { + m.add_function(wrap_pyfunction!(get_damage_analysis, m)?)?; + m.add_function(wrap_pyfunction!(get_transformative_damage, m)?)?; + Ok(()) +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2a31cc8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,29 @@ +[tool.poetry] +name = "Python-Genshin-Aartifact" +version = "0.1.0" +description = "A Python library that binds to Genshin Artifact damage calculation and analysis engine." +authors = ["luoshuijs"] +license = "MIT license" +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.8" +pydantic = "^1.10.7" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + + +[tool.pytest.ini_options] +asyncio_mode = "auto" +log_cli = true +log_cli_level = "INFO" +log_cli_format = "%(message)s" +log_cli_date_format = "%Y-%m-%d %H:%M:%S" + + +[tool.black] +include = '\.pyi?$' +line-length = 120 +target-version = ['py38'] \ No newline at end of file diff --git a/python_genshin_artifact/__init__.py b/python_genshin_artifact/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python_genshin_artifact/calculator.py b/python_genshin_artifact/calculator.py new file mode 100644 index 0000000..9231228 --- /dev/null +++ b/python_genshin_artifact/calculator.py @@ -0,0 +1,9 @@ +from genshin_artifact_function import get_damage_analysis as _get_damage_analysis + +from python_genshin_artifact.models.characterInfo import CharacterInfo +from python_genshin_artifact.models.damage.analysis import DamageAnalysis + + +def get_damage_analysis(value: CharacterInfo) -> DamageAnalysis: + ret = _get_damage_analysis(value=value.json()) + return DamageAnalysis.parse_raw(ret) diff --git a/python_genshin_artifact/models/__init__.py b/python_genshin_artifact/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python_genshin_artifact/models/artifact.py b/python_genshin_artifact/models/artifact.py new file mode 100644 index 0000000..5d8f65e --- /dev/null +++ b/python_genshin_artifact/models/artifact.py @@ -0,0 +1,12 @@ +from typing import List, Tuple + +from pydantic import BaseModel + + +class ArtifactInfo(BaseModel): + set_name: str + slot: str + level: int + sub_stats: List[Tuple[str, float]] + main_stat: Tuple[str, float] + id: int diff --git a/python_genshin_artifact/models/buff.py b/python_genshin_artifact/models/buff.py new file mode 100644 index 0000000..5068de9 --- /dev/null +++ b/python_genshin_artifact/models/buff.py @@ -0,0 +1,7 @@ +from pydantic import BaseModel + + +class BuffInfo(BaseModel): + name: str + config: str + star:int diff --git a/python_genshin_artifact/models/calculator.py b/python_genshin_artifact/models/calculator.py new file mode 100644 index 0000000..22caca6 --- /dev/null +++ b/python_genshin_artifact/models/calculator.py @@ -0,0 +1,20 @@ +from typing import List, Optional + +from pydantic import BaseModel + +from python_genshin_artifact.models.artifact import ArtifactInfo +from python_genshin_artifact.models.buff import BuffInfo +from python_genshin_artifact.models.characterInfo import CharacterInfo +from python_genshin_artifact.models.enemy import EnemyInfo +from python_genshin_artifact.models.skill import SkillInfo +from python_genshin_artifact.models.weapon import WeaponInfo + + +class CalculatorConfig(BaseModel): + character: CharacterInfo + weapon: WeaponInfo + buffs: List[BuffInfo] = [] + artifact: List[ArtifactInfo] = [] + artifact_config: Optional[str] = None + skill: SkillInfo + enemy: Optional[EnemyInfo] = None diff --git a/python_genshin_artifact/models/characterInfo.py b/python_genshin_artifact/models/characterInfo.py new file mode 100644 index 0000000..af593d5 --- /dev/null +++ b/python_genshin_artifact/models/characterInfo.py @@ -0,0 +1,12 @@ +from pydantic import BaseModel + + +class CharacterInfo(BaseModel): + name: str + level: int + ascend: bool + constellation: int + skill1: int + skill2: int + skill3: int + params: str = "NoConfig" diff --git a/python_genshin_artifact/models/damage/__init__.py b/python_genshin_artifact/models/damage/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python_genshin_artifact/models/damage/analysis.py b/python_genshin_artifact/models/damage/analysis.py new file mode 100644 index 0000000..085338d --- /dev/null +++ b/python_genshin_artifact/models/damage/analysis.py @@ -0,0 +1,40 @@ +from typing import Dict, Optional + +from pydantic import BaseModel, Field + +from python_genshin_artifact.models.damage.result import DamageResult + + +class DamageAnalysis(BaseModel): + atk: Dict[str, float] + atk_ratio: Dict[str, float] + hp: Dict[str, float] + hp_ratio: Dict[str, float] + def_: Dict[str, float] = Field(alias='def') + def_ratio: Dict[str, float] + em: Dict[str, float] + em_ratio: Dict[str, float] + extra_damage: Dict[str, float] + bonus: Dict[str, float] + critical: Dict[str, float] + critical_damage: Dict[str, float] + melt_enhance: Dict[str, float] + vaporize_enhance: Dict[str, float] + healing_bonus: Dict[str, float] + shield_strength: Dict[str, float] + spread_compose: Dict[str, float] + aggravate_compose: Dict[str, float] + + def_minus: Dict[str, float] + def_penetration: Dict[str, float] + res_minus: Dict[str, float] + + element: str + is_heal: bool + is_shield: bool + + normal: DamageResult + melt: Optional[DamageResult] + vaporize: Optional[DamageResult] + spread: Optional[DamageResult] + aggravate: Optional[DamageResult] diff --git a/python_genshin_artifact/models/damage/result.py b/python_genshin_artifact/models/damage/result.py new file mode 100644 index 0000000..11a6f33 --- /dev/null +++ b/python_genshin_artifact/models/damage/result.py @@ -0,0 +1,9 @@ +from pydantic import BaseModel + +class DamageResult(BaseModel): + critical: float + non_critical: float + expectation: float + + is_heal: bool + is_shield: bool \ No newline at end of file diff --git a/python_genshin_artifact/models/element.py b/python_genshin_artifact/models/element.py new file mode 100644 index 0000000..e69de29 diff --git a/python_genshin_artifact/models/enemy.py b/python_genshin_artifact/models/enemy.py new file mode 100644 index 0000000..d023544 --- /dev/null +++ b/python_genshin_artifact/models/enemy.py @@ -0,0 +1,13 @@ +from pydantic import BaseModel + + +class EnemyInfo(BaseModel): + level: int + electro_res: float + pyro_res: float + hydro_res: float + cryo_res: float + geo_res: float + anemo_res: float + dendro_res: float + physical_res: float diff --git a/python_genshin_artifact/models/skill.py b/python_genshin_artifact/models/skill.py new file mode 100644 index 0000000..1b57f2c --- /dev/null +++ b/python_genshin_artifact/models/skill.py @@ -0,0 +1,8 @@ + + +from pydantic import BaseModel + + +class SkillInfo(BaseModel): + index: str + config: str = "NoConfig" diff --git a/python_genshin_artifact/models/weapon.py b/python_genshin_artifact/models/weapon.py new file mode 100644 index 0000000..1f87678 --- /dev/null +++ b/python_genshin_artifact/models/weapon.py @@ -0,0 +1,9 @@ +from pydantic import BaseModel + + +class WeaponInfo(BaseModel): + name: str + level: int + ascend: bool + refine: int + params: str