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 库包位置决定,不读取环境变量。

测试

python -m pytest

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

当前限制

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

版本号规则

版本号采用 游戏主版本.游戏次版本.维护版本。例如游戏 4.6 对应 4.6.0,同一游戏版本下的修复与小更新依次使用 4.6.1、4.6.2,维护版本可以继续递增至 4.6.23。游戏升级至 4.7 时使用 4.7.0。

发布前同步内置游戏数据,并保持 pyproject.toml 与 starrail_damage_cal/version.py 的版本一致。数据清单 version.json 保留数据源实际版本,维护更新不伪造数据版本。

Metadata

Release files for starrail_damage_cal 4.6.0

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.6.0
File Size Uploaded Provenance Actions
starrail_damage_cal-4.6.0.tar.gz 305.1 kB Without provenance Details for starrail_damage_cal-4.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 647.7 kB

Release files / starrail_damage_cal-4.6.0.tar.gz

Download URL starrail_damage_cal-4.6.0.tar.gz
Size 305.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7f76422f8038762ff7c777097444e2799a1cde982d05305155cf94e95ba15e3d
BLAKE2b-256 checksum
How to use checksums
b442baf9aa4091af8aabc81a5fa43c9c6b1a794ab8e008d1e80bb14e775cfc95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.2 CPython/3.11.16 Linux/6.17.0-1022-azure

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

Download URL starrail_damage_cal-4.6.0-py3-none-any.whl
Size 342.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
936b1188fe2e915b5264049103b7df7a349391ee8ef12dad16145e6325ea0c13
BLAKE2b-256 checksum
How to use checksums
6b7ef28d070b208af60f59175487ed2877755a11a63d24b688c034f62fd73a2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.2 CPython/3.11.16 Linux/6.17.0-1022-azure

Security for starrail_damage_cal 4.6.0

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.6.0 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