mania-judge 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +79 -34
- package/README.zh-CN.md +107 -0
- package/dist/index.d.mts +87 -16
- package/dist/index.mjs +701 -259
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zzzzv
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,69 +1,114 @@
|
|
|
1
1
|
# mania-judge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Simulates osu!mania judgements, combo, life and ScoreV1 from `.osu` + `.osr` data.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The design goal is a **faithful reproduction of osu!stable** rather than an approximation:
|
|
6
|
+
judgement is evaluated per column (each column only talks to its own notes and its own
|
|
7
|
+
input), and the whole run is judged first, then combo / life / score are derived from the
|
|
8
|
+
resulting judgement list.
|
|
9
|
+
|
|
10
|
+
- [中文说明](./README.zh-CN.md)
|
|
11
|
+
- [osu!v1 判定逻辑](./doc/osu-v1-mania-judgement.md)(中文)
|
|
12
|
+
- [osu!v1 时间轴逻辑](./doc/osu-v1-timeline.md)(中文)
|
|
6
13
|
|
|
7
14
|
## Status
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
Work in progress. Numbers below come from 97 replay fixtures (7K–18K mania maps) that are
|
|
17
|
+
compared against the counts / score / combo stored in the `.osr` header.
|
|
18
|
+
|
|
19
|
+
### v1 (osu!stable)
|
|
20
|
+
|
|
21
|
+
**Judgement** — column-based state machine driven by the replay's raw frame times.
|
|
22
|
+
|
|
23
|
+
- 90 / 97 fixtures match the header's six-tier counts exactly.
|
|
24
|
+
- The remaining 7 fixtures differ by 1–5 events out of 1.5k–14k objects (all 7K maps).
|
|
25
|
+
The same rule set is implemented by
|
|
26
|
+
[osumania4k_replay_analyser](https://github.com/SWt0619/osumania4k_replay_analyser),
|
|
27
|
+
which agrees with this library on 0 / 181,577 objects — so the residual is shared rule
|
|
28
|
+
deviation, not an implementation gap between the two.
|
|
29
|
+
|
|
30
|
+
**Timeline** — combo / life / ScoreV1 derived from the judgement list.
|
|
11
31
|
|
|
12
|
-
|
|
32
|
+
| Item | Exact | Note |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| max combo | 73 / 97 | the rest are off by ±1 |
|
|
35
|
+
| ScoreV1 | 43 / 97 | the rest are off by a median of ±50 (≈0.01%), worst 1136 (0.15%) |
|
|
36
|
+
| life | — | `.osr` does not store the process HP bar, so there is no ground truth |
|
|
13
37
|
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
- Hold: validated by accuracy-only tests with average error capped at 0.002 and max error capped at 0.004.
|
|
17
|
-
- Mods fixtures: accuracy-only tests cap average error at 0.002 and max error at 0.004.
|
|
38
|
+
Judgement and timeline are tested separately (`tests/osu-v1-judgement.test.ts`,
|
|
39
|
+
`tests/osu-v1-timeline.test.ts`), with exact assertions and no tolerance.
|
|
18
40
|
|
|
19
41
|
### lazer
|
|
20
42
|
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
- Hold: validated by accuracy-only tests with average error capped at 0.001 and max error capped at 0.002.
|
|
24
|
-
- Mods fixtures: accuracy-only tests cap average error at 0.0005 and max error at 0.002.
|
|
43
|
+
**tap-only is exact**: 38 / 38 fixtures match the header's six-tier counts, max combo exact on
|
|
44
|
+
37 / 38.
|
|
25
45
|
|
|
26
|
-
|
|
46
|
+
Long notes are implemented (head and tail judged separately, break → repress supported, tail capped
|
|
47
|
+
to Meh when the head was missed or the body broke) but **not exact yet**:
|
|
48
|
+
|
|
49
|
+
| Group | Exact | Total \|Δ\| | Per fixture |
|
|
50
|
+
| --- | --- | --- | --- |
|
|
51
|
+
| hold | 1 / 31 | 726 | ≈ 23 events |
|
|
52
|
+
| mods | 0 / 12 | 348 | ≈ 29 events |
|
|
27
53
|
|
|
28
|
-
|
|
54
|
+
The residual is pure misclassification between Perfect / Great / Good: the number of events and the
|
|
55
|
+
Miss / Meh totals match, and the error is the same size in both directions. It points at the timing
|
|
56
|
+
edge cases of the tail rather than at the event structure.
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
29
59
|
|
|
30
60
|
```ts
|
|
31
61
|
import { v1, calcAccuracy } from 'mania-judge'
|
|
32
62
|
|
|
33
63
|
const judgements = v1.playOsu(osuData)
|
|
34
|
-
const frames = v1.generateFramesOsu(judgements, osuData.hp)
|
|
35
|
-
const
|
|
64
|
+
const frames = v1.generateFramesOsu(judgements, osuData.hp, ['HR'])
|
|
65
|
+
const last = frames.at(-1)!
|
|
36
66
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
console.log(lastFrame.resultCounts, lastFrame.maxCombo, lastFrame.life, accuracy)
|
|
40
|
-
}
|
|
67
|
+
console.log(last.resultCounts, last.maxCombo, last.life, last.score)
|
|
68
|
+
console.log(calcAccuracy(last.resultCounts, v1.accTable))
|
|
41
69
|
```
|
|
42
70
|
|
|
43
|
-
|
|
71
|
+
The third argument of `generateFramesOsu` is the replay's mod list; it only affects ScoreV1
|
|
72
|
+
(`NF` / `EZ` / `HT` halve the score).
|
|
44
73
|
|
|
45
|
-
|
|
74
|
+
```ts
|
|
75
|
+
// ScoreV1 on its own
|
|
76
|
+
const score = v1.calculateScoreV1(judgements.flat(), ['DT'])
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Loading a replay
|
|
80
|
+
|
|
81
|
+
This library has no runtime dependencies and does not touch files: it takes plain data, and
|
|
82
|
+
`createOsuData` accepts **any** object shape-compatible with `BeatmapLike` / `ReplayLike`.
|
|
83
|
+
With [`osu-mania-io`](https://github.com/zzzzv/osu-mania-io):
|
|
46
84
|
|
|
47
85
|
```ts
|
|
48
86
|
import { parseBeatmap } from 'osu-mania-io/beatmap'
|
|
49
87
|
import { parseReplay } from 'osu-mania-io/replay'
|
|
50
88
|
import { applyLegacyBeatmapMods } from 'osu-mania-io/mod'
|
|
51
|
-
import {
|
|
89
|
+
import { createOsuData } from 'mania-judge'
|
|
52
90
|
|
|
53
91
|
const beatmap = parseBeatmap(osuContent)
|
|
54
92
|
const replay = parseReplay(osrBuffer, beatmap.difficulty.keyCount)
|
|
55
93
|
|
|
56
|
-
//
|
|
94
|
+
// where mods get applied is up to you; the modded beatmap carries speedMultiplier / hitWindowScale
|
|
57
95
|
const effective = replay.mods !== 0
|
|
58
|
-
? applyLegacyBeatmapMods(beatmap, replay.mods)
|
|
96
|
+
? (applyLegacyBeatmapMods(beatmap, replay.mods) ?? beatmap)
|
|
59
97
|
: beatmap
|
|
60
98
|
|
|
61
|
-
const osuData =
|
|
62
|
-
od: effective.difficulty.overallDifficulty,
|
|
63
|
-
hp: effective.difficulty.hpDrainRate,
|
|
64
|
-
speedRate: 'speedMultiplier' in effective ? effective.speedMultiplier : 1,
|
|
65
|
-
windowScale: 'hitWindowScale' in effective ? effective.hitWindowScale : 1,
|
|
66
|
-
noteColumns: beatmapToNoteColumns(effective),
|
|
67
|
-
actionColumns: replayToActionColumns(replay.frames, beatmap.difficulty.keyCount),
|
|
68
|
-
}
|
|
99
|
+
const osuData = createOsuData(effective, replay)
|
|
69
100
|
```
|
|
101
|
+
|
|
102
|
+
Mod application stays outside the library on purpose: it needs the mod table, not the judging
|
|
103
|
+
engine.
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
- Fixtures are generated from a local osu! install: `node --env-file=.env --import tsx tests/gen-stable-json.ts <tap-only|hold|mods>`.
|
|
108
|
+
- `pnpm test` runs the whole suite. Judgement and timeline tests assert exact equality, so
|
|
109
|
+
the failing cases are the current known gaps and are meant to be read as a to-do list.
|
|
110
|
+
|
|
111
|
+
## Credits
|
|
112
|
+
|
|
113
|
+
Thanks to [uuUlazis/osumania-replay-analyzer](https://github.com/uuUlazis/osumania-replay-analyzer):
|
|
114
|
+
the osu!stable judgement and scoring rules implemented here are ported from that project.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# mania-judge
|
|
2
|
+
|
|
3
|
+
从 `.osu` + `.osr` 数据复现 osu!mania 的判定、连击、血量与 ScoreV1。
|
|
4
|
+
|
|
5
|
+
设计目标是**精确复刻 osu!stable**,而不是近似:判定按列计算(每一列只与自己的物件、
|
|
6
|
+
自己的输入发生关系),并且先完成全部判定,再据此派生连击 / 血量 / 分数。
|
|
7
|
+
|
|
8
|
+
- [English](./README.md)
|
|
9
|
+
- [osu!v1 判定逻辑](./doc/osu-v1-mania-judgement.md)
|
|
10
|
+
- [osu!v1 时间轴逻辑](./doc/osu-v1-timeline.md)
|
|
11
|
+
|
|
12
|
+
## 现状
|
|
13
|
+
|
|
14
|
+
仍在开发中。下面的数字来自 97 张回放样本(7K–18K 的 mania 谱面),对照的是 `.osr`
|
|
15
|
+
文件头里记录的判定计数 / 分数 / 连击。
|
|
16
|
+
|
|
17
|
+
### v1(osu!stable)
|
|
18
|
+
|
|
19
|
+
**判定** —— 按列推进的状态机,驱动时钟来自回放的原始帧时间。
|
|
20
|
+
|
|
21
|
+
- **90 / 97** 张谱的六档判定计数与回放头完全一致。
|
|
22
|
+
- 剩下 7 张各差 1–5 个事件(物件总数 1.5k–14k,全部是 7K 谱)。同一套规则在
|
|
23
|
+
[osumania4k_replay_analyser](https://github.com/SWt0619/osumania4k_replay_analyser) 里
|
|
24
|
+
与本库逐物件比对是 **0 / 181,577** 差异,所以这部分残差是「两边共用的规则与 stable
|
|
25
|
+
的偏差」,不是两个实现之间的差异。
|
|
26
|
+
|
|
27
|
+
**时间轴** —— 由判定结果派生连击 / 血量 / ScoreV1。
|
|
28
|
+
|
|
29
|
+
| 项目 | 完全一致 | 说明 |
|
|
30
|
+
| --- | --- | --- |
|
|
31
|
+
| 最大连击 | 73 / 97 | 其余差 ±1 |
|
|
32
|
+
| ScoreV1 | 43 / 97 | 其余中位偏差 ±50(约 0.01%),最大 1136(0.15%) |
|
|
33
|
+
| 血量 | — | `.osr` 不记录过程血条,没有真值可用 |
|
|
34
|
+
|
|
35
|
+
判定层与时间轴层的测试是分开的(`tests/osu-v1-judgement.test.ts`、
|
|
36
|
+
`tests/osu-v1-timeline.test.ts`),都使用精确断言、不留容差。
|
|
37
|
+
|
|
38
|
+
### lazer
|
|
39
|
+
|
|
40
|
+
**tap-only 已经是准的**:38 / 38 张谱的六档计数与回放头完全一致,最大连击 37 / 38 张精确。
|
|
41
|
+
|
|
42
|
+
长条已实现(头尾分开判定、支持断条后补按、头 miss 或断条时尾部封顶到 Meh),但**还不精确**:
|
|
43
|
+
|
|
44
|
+
| 分组 | 完全一致 | \|Δ\| 合计 | 每张谱 |
|
|
45
|
+
| --- | --- | --- | --- |
|
|
46
|
+
| hold | 1 / 31 | 726 | 约 23 个事件 |
|
|
47
|
+
| mods | 0 / 12 | 348 | 约 29 个事件 |
|
|
48
|
+
|
|
49
|
+
残差是纯粹的「Perfect / Great / Good 之间的错档」:事件总数对得上、Miss 与 Meh 的总数也对得上,
|
|
50
|
+
且两个方向的误差大小相当。这说明问题在尾判的时间边界细节,而不是事件结构。
|
|
51
|
+
|
|
52
|
+
## 用法
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { v1, calcAccuracy } from 'mania-judge'
|
|
56
|
+
|
|
57
|
+
const judgements = v1.playOsu(osuData)
|
|
58
|
+
const frames = v1.generateFramesOsu(judgements, osuData.hp, ['HR'])
|
|
59
|
+
const last = frames.at(-1)!
|
|
60
|
+
|
|
61
|
+
console.log(last.resultCounts, last.maxCombo, last.life, last.score)
|
|
62
|
+
console.log(calcAccuracy(last.resultCounts, v1.accTable))
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`generateFramesOsu` 的第三个参数是回放的 mod 列表,只影响 ScoreV1(`NF` / `EZ` / `HT`
|
|
66
|
+
会把分数减半)。
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
// 单独算 ScoreV1
|
|
70
|
+
const score = v1.calculateScoreV1(judgements.flat(), ['DT'])
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 从文件加载回放
|
|
74
|
+
|
|
75
|
+
本库没有运行时依赖、也不碰文件,只接收普通数据;`createOsuData` 接受任何与
|
|
76
|
+
`BeatmapLike` / `ReplayLike` 结构兼容的对象,不绑定具体解析库。用
|
|
77
|
+
[`osu-mania-io`](https://github.com/zzzzv/osu-mania-io) 的话:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { parseBeatmap } from 'osu-mania-io/beatmap'
|
|
81
|
+
import { parseReplay } from 'osu-mania-io/replay'
|
|
82
|
+
import { applyLegacyBeatmapMods } from 'osu-mania-io/mod'
|
|
83
|
+
import { createOsuData } from 'mania-judge'
|
|
84
|
+
|
|
85
|
+
const beatmap = parseBeatmap(osuContent)
|
|
86
|
+
const replay = parseReplay(osrBuffer, beatmap.difficulty.keyCount)
|
|
87
|
+
|
|
88
|
+
// mod 应用在哪一层由你决定;应用后的谱面会带 speedMultiplier / hitWindowScale
|
|
89
|
+
const effective = replay.mods !== 0
|
|
90
|
+
? (applyLegacyBeatmapMods(beatmap, replay.mods) ?? beatmap)
|
|
91
|
+
: beatmap
|
|
92
|
+
|
|
93
|
+
const osuData = createOsuData(effective, replay)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
mod 计算刻意留在库外:它需要的是 mod 表,不是判定引擎。
|
|
97
|
+
|
|
98
|
+
## 开发
|
|
99
|
+
|
|
100
|
+
- 样本生成:`node --env-file=.env --import tsx tests/gen-stable-json.ts <tap-only|hold|mods>`(需要本机 osu! 安装目录)。
|
|
101
|
+
- `pnpm test` 跑全量。判定层与时间轴层都是精确断言,**失败用例就是当前的已知差异清单**,
|
|
102
|
+
应当当作待办来读,而不是把断言放宽。
|
|
103
|
+
|
|
104
|
+
## 致谢
|
|
105
|
+
|
|
106
|
+
感谢 [uuUlazis/osumania-replay-analyzer](https://github.com/uuUlazis/osumania-replay-analyzer),
|
|
107
|
+
本项目的 osu!stable 判定与计分规则参考该项目实现。
|
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,13 @@ interface OsuData {
|
|
|
23
23
|
windowScale: number;
|
|
24
24
|
noteColumns: Columns<Note>;
|
|
25
25
|
actionColumns: Columns<Action>;
|
|
26
|
+
/**
|
|
27
|
+
* 回放原始帧时间(毫秒,升序)。
|
|
28
|
+
*
|
|
29
|
+
* 判定是在这些帧上推进的,必须有:每个物件的结算时刻是「不早于边界的第一帧」,
|
|
30
|
+
* 少了帧表就只能按边界本身结算,结果会差档。用 `replayToFrameTimes` 从回放帧里取。
|
|
31
|
+
*/
|
|
32
|
+
frameTimes: readonly number[];
|
|
26
33
|
}
|
|
27
34
|
declare const HIT_RESULTS: {
|
|
28
35
|
readonly Perfect: 0;
|
|
@@ -48,6 +55,8 @@ interface TimeLineFrame {
|
|
|
48
55
|
maxCombo: number;
|
|
49
56
|
resultCounts: HitResultTable<number>;
|
|
50
57
|
life: number;
|
|
58
|
+
/** ScoreV1(0 ~ 1,000,000);只有 osu-v1 时间轴会填 */
|
|
59
|
+
score?: number;
|
|
51
60
|
}
|
|
52
61
|
//#endregion
|
|
53
62
|
//#region src/osu-v1/types.d.ts
|
|
@@ -66,19 +75,42 @@ declare function countResults(judgements: JudgementV1[]): HitResultTable<number>
|
|
|
66
75
|
declare const accTable$1: Readonly<HitResultTable<number>>;
|
|
67
76
|
declare function baseWindows$1(od: number): HitWindows;
|
|
68
77
|
//#endregion
|
|
69
|
-
//#region src/osu-v1/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
//#region src/osu-v1/frames.d.ts
|
|
79
|
+
/**
|
|
80
|
+
* 精确模式:按列重演 stable 的 mania 判定状态机。
|
|
81
|
+
*
|
|
82
|
+
* `frameTimes` 是回放原始帧时间(升序)。判定里所有「当前时刻」都取
|
|
83
|
+
* 「不早于边界的第一帧」,这样事件驱动和 stable 的逐帧扫描等价。
|
|
84
|
+
* 不传时退化成用边界本身当时刻(只适合做近似估计)。
|
|
85
|
+
*/
|
|
86
|
+
declare function playColumnFrames(notes: readonly Note[], actions: readonly Action[], windows: HitWindows, frameTimes: readonly number[]): JudgementV1[];
|
|
87
|
+
declare function playFrames(noteColumns: Columns<Note>, actionColumns: Columns<Action>, windows: HitWindows, frameTimes: readonly number[]): Columns<JudgementV1>;
|
|
88
|
+
declare function playOsuFrames(data: OsuData): Columns<JudgementV1>;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/osu-v1/score.d.ts
|
|
91
|
+
type ScoreEventKind = 'judge' | 'tick' | 'break';
|
|
92
|
+
interface ScoreAccumulator {
|
|
93
|
+
/** 喂入一次事件,必须是判定产出顺序 */
|
|
94
|
+
push: (kind: ScoreEventKind, result: HitResult) => void;
|
|
95
|
+
/** 当前 ScoreV1 原始累加值(未取整) */
|
|
96
|
+
readonly raw: number;
|
|
97
|
+
/** 取整后的分数 */
|
|
98
|
+
readonly score: number;
|
|
99
|
+
readonly combo: number;
|
|
100
|
+
readonly health: number;
|
|
101
|
+
}
|
|
102
|
+
declare function createScoreAccumulator(total: number, mods?: readonly string[]): ScoreAccumulator;
|
|
103
|
+
/** ScoreV1(0 ~ 1,000,000) */
|
|
104
|
+
declare function calculateScoreV1(judgements: readonly JudgementV1[], mods?: readonly string[]): number;
|
|
73
105
|
//#endregion
|
|
74
106
|
//#region src/osu-v1/health.d.ts
|
|
75
107
|
declare function createLifeTable(hp: number, hpMultiplierNormal?: number): HitResultTable<number>;
|
|
76
108
|
//#endregion
|
|
77
109
|
//#region src/osu-v1/timeline.d.ts
|
|
78
|
-
declare function generateFrames$1(judgementColumns: Columns<JudgementV1>, lifeTable: HitResultTable<number
|
|
79
|
-
declare function generateFramesOsu(judgementColumns: Columns<JudgementV1>, hp: number): TimeLineFrame[];
|
|
110
|
+
declare function generateFrames$1(judgementColumns: Columns<JudgementV1>, lifeTable: HitResultTable<number>, mods?: readonly string[]): TimeLineFrame[];
|
|
111
|
+
declare function generateFramesOsu(judgementColumns: Columns<JudgementV1>, hp: number, mods?: readonly string[]): TimeLineFrame[];
|
|
80
112
|
declare namespace index_d_exports$1 {
|
|
81
|
-
export { HoldJudgementV1, JudgementV1, accTable$1 as accTable, baseWindows$1 as baseWindows, countResults, createLifeTable, generateFrames$1 as generateFrames, generateFramesOsu, isHoldJudgement,
|
|
113
|
+
export { HoldJudgementV1, JudgementV1, ScoreAccumulator, ScoreEventKind, accTable$1 as accTable, baseWindows$1 as baseWindows, calculateScoreV1, countResults, createLifeTable, createScoreAccumulator, generateFrames$1 as generateFrames, generateFramesOsu, isHoldJudgement, playColumnFrames, playFrames, playOsuFrames as playOsu, playOsuFrames };
|
|
82
114
|
}
|
|
83
115
|
//#endregion
|
|
84
116
|
//#region src/osu-lazer/types.d.ts
|
|
@@ -103,8 +135,8 @@ declare function baseWindows(od: number): HitWindows;
|
|
|
103
135
|
declare function tailWindows(headWindows: Readonly<HitWindows>): HitWindows;
|
|
104
136
|
//#endregion
|
|
105
137
|
//#region src/osu-lazer/judgement.d.ts
|
|
106
|
-
declare function playColumn(notes: Note[], actions: Action[], windows: HitWindows,
|
|
107
|
-
declare function play(noteColumns: Columns<Note>, actionColumns: Columns<Action>, windows: HitWindows,
|
|
138
|
+
declare function playColumn(notes: Note[], actions: Action[], windows: HitWindows, tails?: HitWindows): JudgementV2[];
|
|
139
|
+
declare function play(noteColumns: Columns<Note>, actionColumns: Columns<Action>, windows: HitWindows, tails?: HitWindows): Columns<JudgementV2>;
|
|
108
140
|
declare function playOsu(data: OsuData): Columns<JudgementV2>;
|
|
109
141
|
//#endregion
|
|
110
142
|
//#region src/osu-lazer/timeline.d.ts
|
|
@@ -120,13 +152,14 @@ declare namespace index_d_exports {
|
|
|
120
152
|
}
|
|
121
153
|
//#endregion
|
|
122
154
|
//#region src/column.d.ts
|
|
123
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Extract the replay's raw frame timeline (ms, ascending, deduped).
|
|
157
|
+
* osu!stable judges on these frames, so the exact settle time of every object
|
|
158
|
+
* is "the first frame at or after the boundary" — not the boundary itself.
|
|
159
|
+
*/
|
|
160
|
+
declare function replayToFrameTimes(frames: readonly {
|
|
124
161
|
readonly time: number;
|
|
125
|
-
|
|
126
|
-
getHoldingAction(): Action | null;
|
|
127
|
-
getNextAction(): Action | null;
|
|
128
|
-
};
|
|
129
|
-
type ActionCursor = ReturnType<typeof createActionCursor>;
|
|
162
|
+
}[]): number[];
|
|
130
163
|
/**
|
|
131
164
|
* Group beatmap hit objects into per-column note arrays.
|
|
132
165
|
* Structurally compatible with `osu-mania-io`'s `Beatmap`.
|
|
@@ -150,10 +183,48 @@ declare function replayToActionColumns(frames: readonly {
|
|
|
150
183
|
readonly columns: readonly boolean[];
|
|
151
184
|
}[], keyCount: number): Columns<Action>;
|
|
152
185
|
//#endregion
|
|
186
|
+
//#region src/osu-data.d.ts
|
|
187
|
+
/**
|
|
188
|
+
* 结构化的谱面接口:只依赖判定真正用到的字段,不绑定任何解析库。
|
|
189
|
+
* 如果已经把 mod 应用过(例如 `applyLegacyBeatmapMods`),它会额外带上
|
|
190
|
+
* `speedMultiplier` / `hitWindowScale`,这里会一并读出来。
|
|
191
|
+
*/
|
|
192
|
+
interface BeatmapLike {
|
|
193
|
+
readonly difficulty: {
|
|
194
|
+
readonly keyCount: number;
|
|
195
|
+
readonly overallDifficulty: number;
|
|
196
|
+
readonly hpDrainRate: number;
|
|
197
|
+
};
|
|
198
|
+
readonly hitObjects: readonly {
|
|
199
|
+
readonly column: number;
|
|
200
|
+
readonly startTime: number;
|
|
201
|
+
readonly endTime?: number;
|
|
202
|
+
}[];
|
|
203
|
+
readonly speedMultiplier?: number;
|
|
204
|
+
readonly hitWindowScale?: number;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 结构化的回放接口:`columns` 是这一帧每列的按键状态。
|
|
208
|
+
*/
|
|
209
|
+
interface ReplayLike {
|
|
210
|
+
readonly frames: readonly {
|
|
211
|
+
readonly time: number;
|
|
212
|
+
readonly columns: readonly boolean[];
|
|
213
|
+
}[];
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* 把「已解析的谱面 + 回放」组装成判定输入。
|
|
217
|
+
*
|
|
218
|
+
* 本库不解析 `.osu` / `.osr`,也不做 mod 计算,所以传进来的 `beatmap` 应当
|
|
219
|
+
* 已经是应用过 mod 的那一份(`speedMultiplier` / `hitWindowScale` 会被读取;
|
|
220
|
+
* `overallDifficulty` / `hpDrainRate` 也用应用后的值)。
|
|
221
|
+
*/
|
|
222
|
+
declare function createOsuData(beatmap: BeatmapLike, replay: ReplayLike): OsuData;
|
|
223
|
+
//#endregion
|
|
153
224
|
//#region src/utils.d.ts
|
|
154
225
|
declare function clamp(value: number, min: number, max: number): number;
|
|
155
226
|
declare function difficultyRange(difficulty: number, min: number, mid: number, max: number): number;
|
|
156
227
|
declare function truncWindows(windows: Readonly<HitWindows>, scale?: number): HitWindows;
|
|
157
228
|
declare function calcAccuracy(resultCounts: Readonly<HitResultTable<number>>, accTable: Readonly<HitResultTable<number>>): number;
|
|
158
229
|
//#endregion
|
|
159
|
-
export { Action,
|
|
230
|
+
export { Action, BeatmapLike, Columns, HIT_RESULTS, HitResult, HitResultTable, HitWindows, type HoldJudgementV1, type HoldJudgementV2, HoldNote, type JudgementV1, type JudgementV2, Note, OsuData, ReplayLike, TapJudgement, TapNote, TimeLineFrame, beatmapToNoteColumns, calcAccuracy, clamp, createOsuData, difficultyRange, index_d_exports as lazer, replayToActionColumns, replayToFrameTimes, truncWindows, index_d_exports$1 as v1 };
|