Skip to main content

StarRailDamageCal

StarRailDamageCal 是一个基于崩坏:星穹铁道角色面板数据的伤害计算库。

当前仓库主要提供三类能力:

  • 将 Mihomo / 米游社角色数据转换为统一的内部模型
  • 基于角色、光锥、遗器与命座信息计算技能伤害
  • 更新本地 Excel / 映射资源文件

环境要求

  • Python 3.11+

安装

使用 uv:

uv sync --group test --group lint

使用 pdm:

pdm install -G test -G lint

快速使用

按 UID 读取公开展示柜并计算指定角色:

import asyncio

from starrail_damage_cal import DamageCal


async def main() -> None:
    data = await DamageCal.get_damage_data_by_uid(
        uid="100086290",
        avatar_name="镜流",
    )
    print(data)


asyncio.run(main())

直接使用 Mihomo 原始数据:

import asyncio
import json
from pathlib import Path

from starrail_damage_cal import DamageCal


async def main() -> None:
    mihomo_raw = json.loads(Path("test/test.json").read_text(encoding="utf-8"))
    data = await DamageCal.get_damage_data_by_mihomo_raw(
        mihomo_raw=mihomo_raw,
        avatar_name="镜流",
    )
    print(data)


asyncio.run(main())

更新资源文件

项目内置了资源更新接口,会将新版本数据覆盖到运行时目录:

import asyncio

from starrail_damage_cal.update import update_resource


async def main() -> None:
    print(await update_resource())


asyncio.run(main())

默认运行时目录是 ~/.starrail_damage_cal,也可以通过环境变量 STARRAIL_DAMAGE_CAL_DATA_DIR 指定。

测试

python -m pytest

测试默认使用仓库内的离线样例数据,不依赖在线 UID。

当前限制

  • 角色、光锥、遗器的部分条件性效果仍然采用静态假设,而不是完整战斗时序模拟
  • 如果游戏新角色尚未接入对应伤害模型,会显式抛出 UnsupportedAvatarError
  • 在线 UID 计算依赖外部数据源的可用性

Metadata

Release files for starrail_damage_cal 4.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for starrail_damage_cal 4.1.3
File Size Uploaded Provenance Actions
starrail_damage_cal-4.1.3.tar.gz 271.8 kB Without provenance Details for starrail_damage_cal-4.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for starrail_damage_cal 4.1.3
File Interpreter ABI Platform Actions
starrail_damage_cal-4.1.3-py3-none-any.whl Python 3 none any Details for starrail_damage_cal-4.1.3-py3-none-any.whl

Total release size: 577.4 kB

Release files / starrail_damage_cal-4.1.3.tar.gz

Download URL starrail_damage_cal-4.1.3.tar.gz
Size 271.8 kB
Tags Source
SHA-256 checksum
How to use checksums
392dc26abbaf954009602b7c88943fc9f9af15d2d7402bf0b619ec178488364f
BLAKE2b-256 checksum
How to use checksums
5abdd8e58d8ff8f881e0ff4c33702c78150d722959de08c72d6cd40d0cb1b42a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.26.7 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / starrail_damage_cal-4.1.3-py3-none-any.whl

Download URL starrail_damage_cal-4.1.3-py3-none-any.whl
Size 305.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f527d3e426d0281e4cccf278a9d38f90697e072768656ea8f2da420eed9dd96a
BLAKE2b-256 checksum
How to use checksums
7e628ca27c5afa8d630d75ff31d8143414b51caf806411c1083591e11c65d42a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.26.7 CPython/3.10.20 Linux/6.17.0-1008-azure

Security for starrail_damage_cal 4.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

4.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page