mania-judge 0.1.0 → 0.3.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/README.md CHANGED
@@ -2,23 +2,30 @@
2
2
 
3
3
  Work in progress.
4
4
 
5
- Simulates osu!stable mania judgements.
5
+ Simulates osu!mania judgements.
6
6
 
7
7
  ## Status
8
8
 
9
+ - Score is not implemented.
10
+ - Mods: support is determined by osu-mania-io. Current tested coverage includes `HT`, `DT`, `HR`, `EZ`, and `MR`.
11
+
12
+ ### v1
13
+
9
14
  - Implemented: judgements, combo, and life.
10
- - Not implemented: score.
11
- - Tap-only: accurate in current tests except for a few life mismatches.
12
- - Hold: not expected to be exact yet because the precise stable hold algorithm is still unknown.
13
- - Hold accuracy error across 47 fixtures: `0.00%` min, `0.39%` max, `0.16%` average.
14
- - Mod coverage: `HT`, `DT`, `HR`, `EZ`, and `MR`.
15
- - Not supported: `RD`.
15
+ - Tap-only: accurate in current tests.
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.
16
18
 
17
- ## Usage
19
+ ### lazer
18
20
 
19
- ### Main entry
21
+ - Implemented: judgements.
22
+ - Tap-only: accurate in current tests.
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.
20
25
 
21
- Use the main entry if you already have `osuData`. This path does not need the parser peer dependencies.
26
+ ## Usage
27
+
28
+ ### Core simulation
22
29
 
23
30
  ```ts
24
31
  import { v1, calcAccuracy } from 'mania-judge'
@@ -33,20 +40,30 @@ if (lastFrame) {
33
40
  }
34
41
  ```
35
42
 
36
- ### Parser entries
43
+ ### Parsing `.osu` / `.osr` files
37
44
 
38
- Use these entries if you want to parse `.osu` and `.osr`. They require the peer dependencies `osu-classes`, `osu-mania-stable`, and `osu-parsers`.
45
+ Use [`osu-mania-io`](https://github.com/zzzzv/osu-mania-io) to parse beatmap and replay files, then convert the result with the adapter functions in `column.ts`:
39
46
 
40
47
  ```ts
41
- import { parse } from 'mania-judge/osu-parsers'
42
-
43
- const result = await parse(beatmapContent, replayBuffer)
44
- console.log(result.osuData)
45
- ```
46
-
47
- ```ts
48
- import { parseFromPath } from 'mania-judge/osu-parsers/node'
49
-
50
- const result = await parseFromPath('map.osu', 'score.osr')
51
- console.log(result.osuData)
48
+ import { parseBeatmap } from 'osu-mania-io/beatmap'
49
+ import { parseReplay } from 'osu-mania-io/replay'
50
+ import { applyLegacyBeatmapMods } from 'osu-mania-io/mod'
51
+ import { beatmapToNoteColumns, replayToActionColumns } from 'mania-judge'
52
+
53
+ const beatmap = parseBeatmap(osuContent)
54
+ const replay = parseReplay(osrBuffer, beatmap.difficulty.keyCount)
55
+
56
+ // Apply mods if needed.
57
+ const effective = replay.mods !== 0
58
+ ? applyLegacyBeatmapMods(beatmap, replay.mods)
59
+ : beatmap
60
+
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
+ }
52
69
  ```
package/dist/index.d.mts CHANGED
@@ -1,3 +1,159 @@
1
- import { _ as TimeLineFrame, a as HitResult, c as HoldJudgementV1, d as JudgementV1, f as JudgementV2, g as TapNote, h as TapJudgement, i as HIT_RESULTS, l as HoldJudgementV2, m as OsuData, n as BaseJudgement, o as HitResultTable, p as Note, r as Columns, s as HitWindows, t as Action, u as HoldNote } from "./types-3MDvQQxi.mjs";
2
- import { a as ActionCursor, i as truncWindows, n as compareJudgements, o as createActionCursor, r as isHoldJudgement, s as index_d_exports, t as calcAccuracy } from "./index-Zuz8HPVe.mjs";
3
- export { Action, ActionCursor, BaseJudgement, Columns, HIT_RESULTS, HitResult, HitResultTable, HitWindows, HoldJudgementV1, HoldJudgementV2, HoldNote, JudgementV1, JudgementV2, Note, OsuData, TapJudgement, TapNote, TimeLineFrame, calcAccuracy, compareJudgements, createActionCursor, isHoldJudgement, truncWindows, index_d_exports as v1 };
1
+ //#region src/types.d.ts
2
+ interface TapNote {
3
+ column: number;
4
+ start: number;
5
+ end?: undefined;
6
+ }
7
+ interface HoldNote {
8
+ column: number;
9
+ start: number;
10
+ end: number;
11
+ }
12
+ type Note = TapNote | HoldNote;
13
+ interface Action {
14
+ column: number;
15
+ press: number;
16
+ release: number;
17
+ }
18
+ type Columns<T> = T[][];
19
+ interface OsuData {
20
+ od: number;
21
+ hp: number;
22
+ speedRate: number;
23
+ windowScale: number;
24
+ noteColumns: Columns<Note>;
25
+ actionColumns: Columns<Action>;
26
+ }
27
+ declare const HIT_RESULTS: {
28
+ readonly Perfect: 0;
29
+ readonly Great: 1;
30
+ readonly Good: 2;
31
+ readonly Ok: 3;
32
+ readonly Meh: 4;
33
+ readonly Miss: 5;
34
+ };
35
+ type HitResult = (typeof HIT_RESULTS)[keyof typeof HIT_RESULTS];
36
+ type HitResultTable<T> = [T, T, T, T, T, T];
37
+ type HitWindows = HitResultTable<number>;
38
+ interface TapJudgement {
39
+ note: TapNote;
40
+ enter: number;
41
+ exit: number;
42
+ action?: Action;
43
+ result: HitResult;
44
+ }
45
+ interface TimeLineFrame {
46
+ time: number;
47
+ combo: number;
48
+ maxCombo: number;
49
+ resultCounts: HitResultTable<number>;
50
+ life: number;
51
+ }
52
+ //#endregion
53
+ //#region src/osu-v1/types.d.ts
54
+ interface HoldJudgementV1 {
55
+ note: HoldNote;
56
+ enter: number;
57
+ exit: number;
58
+ actions: Action[];
59
+ result: HitResult;
60
+ breakTime?: number;
61
+ ticks: number[];
62
+ }
63
+ type JudgementV1 = TapJudgement | HoldJudgementV1;
64
+ declare function isHoldJudgement(judgement: JudgementV1): judgement is HoldJudgementV1;
65
+ declare function countResults(judgements: JudgementV1[]): HitResultTable<number>;
66
+ declare const accTable$1: Readonly<HitResultTable<number>>;
67
+ declare function baseWindows$1(od: number): HitWindows;
68
+ //#endregion
69
+ //#region src/osu-v1/judgement.d.ts
70
+ declare function playColumn$1(notes: Note[], actions: Action[], windows: HitWindows): JudgementV1[];
71
+ declare function play$1(noteColumns: Columns<Note>, actionColumns: Columns<Action>, windows: HitWindows): Columns<JudgementV1>;
72
+ declare function playOsu$1(data: OsuData): Columns<JudgementV1>;
73
+ //#endregion
74
+ //#region src/osu-v1/health.d.ts
75
+ declare function createLifeTable(hp: number, hpMultiplierNormal?: number): HitResultTable<number>;
76
+ //#endregion
77
+ //#region src/osu-v1/timeline.d.ts
78
+ declare function generateFrames$1(judgementColumns: Columns<JudgementV1>, lifeTable: HitResultTable<number>): TimeLineFrame[];
79
+ declare function generateFramesOsu(judgementColumns: Columns<JudgementV1>, hp: number): TimeLineFrame[];
80
+ 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, play$1 as play, playColumn$1 as playColumn, playOsu$1 as playOsu };
82
+ }
83
+ //#endregion
84
+ //#region src/osu-lazer/types.d.ts
85
+ interface HoldJudgementV2 {
86
+ note: HoldNote;
87
+ headEnter: number;
88
+ headExit: number;
89
+ tailEnter: number;
90
+ tailExit: number;
91
+ actions: Action[];
92
+ headResult: HitResult;
93
+ tailResult: HitResult;
94
+ breakTime?: number;
95
+ }
96
+ type JudgementV2 = TapJudgement | HoldJudgementV2;
97
+ declare function isHoldV2(judgement: JudgementV2): judgement is HoldJudgementV2;
98
+ /** Extract the statistics result from a judgement (head result for holds). */
99
+ declare function getResult(judgement: JudgementV2): HitResult;
100
+ /** Accuracy weights matching lazer's mania scoring (Perfect=305, Great=300, etc.). */
101
+ declare const accTable: Readonly<HitResultTable<number>>;
102
+ declare function baseWindows(od: number): HitWindows;
103
+ declare function tailWindows(headWindows: Readonly<HitWindows>): HitWindows;
104
+ //#endregion
105
+ //#region src/osu-lazer/judgement.d.ts
106
+ declare function playColumn(notes: Note[], actions: Action[], windows: HitWindows, tailWindows?: HitWindows): JudgementV2[];
107
+ declare function play(noteColumns: Columns<Note>, actionColumns: Columns<Action>, windows: HitWindows, tailWindows?: HitWindows): Columns<JudgementV2>;
108
+ declare function playOsu(data: OsuData): Columns<JudgementV2>;
109
+ //#endregion
110
+ //#region src/osu-lazer/timeline.d.ts
111
+ /**
112
+ * Generate timeline frames from judgement columns.
113
+ *
114
+ * Tracks combo, max combo, and result counts over time.
115
+ * Health/life simulation is not included (use the osu-v1 variant for that).
116
+ */
117
+ declare function generateFrames(judgementColumns: Columns<JudgementV2>): TimeLineFrame[];
118
+ declare namespace index_d_exports {
119
+ export { HoldJudgementV2, JudgementV2, accTable, baseWindows, generateFrames, getResult, isHoldV2, play, playColumn, playOsu, tailWindows };
120
+ }
121
+ //#endregion
122
+ //#region src/column.d.ts
123
+ declare function createActionCursor(actions: Action[]): {
124
+ readonly time: number;
125
+ setNextTime(nextTime: number): void;
126
+ getHoldingAction(): Action | null;
127
+ getNextAction(): Action | null;
128
+ };
129
+ type ActionCursor = ReturnType<typeof createActionCursor>;
130
+ /**
131
+ * Group beatmap hit objects into per-column note arrays.
132
+ * Structurally compatible with `osu-mania-io`'s `Beatmap`.
133
+ */
134
+ declare function beatmapToNoteColumns(beatmap: {
135
+ readonly difficulty: {
136
+ readonly keyCount: number;
137
+ };
138
+ readonly hitObjects: readonly {
139
+ readonly column: number;
140
+ readonly startTime: number;
141
+ readonly endTime?: number;
142
+ }[];
143
+ }): Columns<Note>;
144
+ /**
145
+ * Convert key-state replay frames into press/release actions.
146
+ * Structurally compatible with `osu-mania-io`'s `ReplayFrame`.
147
+ */
148
+ declare function replayToActionColumns(frames: readonly {
149
+ readonly time: number;
150
+ readonly columns: readonly boolean[];
151
+ }[], keyCount: number): Columns<Action>;
152
+ //#endregion
153
+ //#region src/utils.d.ts
154
+ declare function clamp(value: number, min: number, max: number): number;
155
+ declare function difficultyRange(difficulty: number, min: number, mid: number, max: number): number;
156
+ declare function truncWindows(windows: Readonly<HitWindows>, scale?: number): HitWindows;
157
+ declare function calcAccuracy(resultCounts: Readonly<HitResultTable<number>>, accTable: Readonly<HitResultTable<number>>): number;
158
+ //#endregion
159
+ export { Action, ActionCursor, Columns, HIT_RESULTS, HitResult, HitResultTable, HitWindows, HoldNote, Note, OsuData, TapJudgement, TapNote, TimeLineFrame, beatmapToNoteColumns, calcAccuracy, clamp, createActionCursor, difficultyRange, index_d_exports as lazer, replayToActionColumns, truncWindows, index_d_exports$1 as v1 };
package/dist/index.mjs CHANGED
@@ -9,6 +9,42 @@ const HIT_RESULTS = {
9
9
  Miss: 5
10
10
  };
11
11
  //#endregion
12
+ //#region src/osu-v1/types.ts
13
+ function isHoldJudgement(judgement) {
14
+ return judgement.note.end !== void 0;
15
+ }
16
+ function countResults(judgements) {
17
+ return judgements.reduce((sum, j) => {
18
+ sum[j.result] += 1;
19
+ return sum;
20
+ }, [
21
+ 0,
22
+ 0,
23
+ 0,
24
+ 0,
25
+ 0,
26
+ 0
27
+ ]);
28
+ }
29
+ const accTable$1 = [
30
+ 1,
31
+ 1,
32
+ 2 / 3,
33
+ 1 / 3,
34
+ 1 / 6,
35
+ 0
36
+ ];
37
+ function baseWindows$1(od) {
38
+ return [
39
+ 16,
40
+ 64 - 3 * od,
41
+ 97 - 3 * od,
42
+ 127 - 3 * od,
43
+ 151 - 3 * od,
44
+ 188 - 3 * od
45
+ ];
46
+ }
47
+ //#endregion
12
48
  //#region src/column.ts
13
49
  function createActionCursor(actions) {
14
50
  let index = 0;
@@ -35,9 +71,54 @@ function createActionCursor(actions) {
35
71
  }
36
72
  };
37
73
  }
74
+ /**
75
+ * Group beatmap hit objects into per-column note arrays.
76
+ * Structurally compatible with `osu-mania-io`'s `Beatmap`.
77
+ */
78
+ function beatmapToNoteColumns(beatmap) {
79
+ const columns = Array.from({ length: beatmap.difficulty.keyCount }, () => []);
80
+ for (const hitObject of beatmap.hitObjects) columns[hitObject.column].push({
81
+ column: hitObject.column,
82
+ start: hitObject.startTime,
83
+ end: hitObject.endTime
84
+ });
85
+ return columns;
86
+ }
87
+ /**
88
+ * Convert key-state replay frames into press/release actions.
89
+ * Structurally compatible with `osu-mania-io`'s `ReplayFrame`.
90
+ */
91
+ function replayToActionColumns(frames, keyCount) {
92
+ const columns = Array.from({ length: keyCount }, () => []);
93
+ const lastPress = Array.from({ length: keyCount }, () => null);
94
+ for (const frame of frames) {
95
+ if (frame.time < 0) continue;
96
+ for (let col = 0; col < keyCount; col++) {
97
+ const pressed = frame.columns[col] ?? false;
98
+ if (pressed && lastPress[col] === null) lastPress[col] = frame.time;
99
+ else if (!pressed && lastPress[col] !== null) {
100
+ columns[col].push({
101
+ column: col,
102
+ press: lastPress[col],
103
+ release: frame.time
104
+ });
105
+ lastPress[col] = null;
106
+ }
107
+ }
108
+ }
109
+ return columns;
110
+ }
38
111
  //#endregion
39
- //#region src/extensions.ts
112
+ //#region src/utils.ts
40
113
  const epsilon = 1e-6;
114
+ function clamp(value, min, max) {
115
+ return Math.min(Math.max(value, min), max);
116
+ }
117
+ function difficultyRange(difficulty, min, mid, max) {
118
+ if (difficulty > 5) return mid + (max - mid) * ((difficulty - 5) / 5);
119
+ if (difficulty < 5) return mid + (mid - min) * ((difficulty - 5) / 5);
120
+ return mid;
121
+ }
41
122
  function truncWindows(windows, scale = 1) {
42
123
  const truncated = [...windows];
43
124
  for (let i = 0; i < truncated.length; i++) truncated[i] = Math.trunc(truncated[i] * scale + epsilon);
@@ -52,47 +133,21 @@ function calcAccuracy(resultCounts, accTable) {
52
133
  }
53
134
  return total > 0 ? acc / total : 0;
54
135
  }
55
- function compareJudgements(a, b) {
56
- if (a.exit !== b.exit) return a.exit - b.exit;
57
- if (a.note.start !== b.note.start) return a.note.start - b.note.start;
58
- return a.note.column - b.note.column;
59
- }
60
- function isHoldJudgement(judgement) {
61
- return judgement.note.end !== void 0;
62
- }
63
136
  //#endregion
64
137
  //#region src/osu-v1/judgement.ts
65
- const accTable = [
66
- 1,
67
- 1,
68
- 2 / 3,
69
- 1 / 3,
70
- 1 / 6,
71
- 0
72
- ];
73
- function baseWindows(od) {
74
- return [
75
- 16,
76
- 64 - 3 * od,
77
- 97 - 3 * od,
78
- 127 - 3 * od,
79
- 151 - 3 * od,
80
- 188 - 3 * od
81
- ];
82
- }
83
- function judgeTap(note, cursor, windows) {
138
+ function judgeTap$1(note, cursor, windows) {
84
139
  const judgement = {
85
140
  note,
86
141
  enter: Math.max(note.start - windows[HIT_RESULTS.Miss], cursor.time),
87
142
  exit: note.start + windows[HIT_RESULTS.Ok],
88
- actions: [],
143
+ action: void 0,
89
144
  result: HIT_RESULTS.Miss
90
145
  };
91
146
  while (cursor.getNextAction() && cursor.getNextAction().press < judgement.enter) cursor.setNextTime(cursor.getNextAction().press + 1);
92
147
  if (cursor.getNextAction() && cursor.getNextAction().press < judgement.exit) {
93
148
  const action = cursor.getNextAction();
94
149
  judgement.exit = action.press;
95
- judgement.actions.push(action);
150
+ judgement.action = action;
96
151
  cursor.setNextTime(action.press + 1);
97
152
  const delta = Math.abs(action.press - note.start);
98
153
  for (let i = HIT_RESULTS.Perfect; i <= HIT_RESULTS.Miss; i++) if (delta <= windows[i]) {
@@ -111,7 +166,7 @@ function generateTick(hold, action) {
111
166
  for (let t = first; t < stop; t += tickInterval) ticks.push(t);
112
167
  return ticks;
113
168
  }
114
- function judgeHold(note, cursor, windows, nextNote) {
169
+ function judgeHold$1(note, cursor, windows, lnWindows, nextNote) {
115
170
  const judgement = {
116
171
  note,
117
172
  enter: Math.max(note.start - windows[HIT_RESULTS.Miss], cursor.time),
@@ -120,14 +175,6 @@ function judgeHold(note, cursor, windows, nextNote) {
120
175
  result: HIT_RESULTS.Miss,
121
176
  ticks: []
122
177
  };
123
- const factors = [
124
- 1.2,
125
- 1.1,
126
- 1,
127
- 1,
128
- 1,
129
- 1
130
- ];
131
178
  while (cursor.getNextAction() && cursor.getNextAction().press < judgement.enter) cursor.setNextTime(cursor.getNextAction().release + 1);
132
179
  while (cursor.getNextAction() && cursor.getNextAction().release < note.end - windows[HIT_RESULTS.Meh]) {
133
180
  const action = cursor.getNextAction();
@@ -158,7 +205,7 @@ function judgeHold(note, cursor, windows, nextNote) {
158
205
  const headDelta = Math.abs(press - note.start);
159
206
  const tailDelta = Math.abs(release - note.end);
160
207
  for (let i = HIT_RESULTS.Perfect; i <= HIT_RESULTS.Ok; i++) {
161
- const window = windows[i] * factors[i];
208
+ const window = lnWindows[i];
162
209
  if (headDelta <= window && headDelta + tailDelta <= window * 2) {
163
210
  judgement.result = i;
164
211
  break;
@@ -172,38 +219,42 @@ function judgeHold(note, cursor, windows, nextNote) {
172
219
  cursor.setNextTime(note.end);
173
220
  return judgement;
174
221
  }
175
- function playColumn(notes, actions, windows) {
222
+ function playColumn$1(notes, actions, windows) {
176
223
  const judgements = [];
177
224
  const cursor = createActionCursor(actions);
225
+ const lnFactors = [
226
+ 1.2,
227
+ 1.1,
228
+ 1,
229
+ 1,
230
+ 1,
231
+ 1
232
+ ];
233
+ const lnWindows = truncWindows(windows.map((w, i) => w * lnFactors[i]), 1);
234
+ windows = truncWindows(windows, 1);
178
235
  for (let i = 0; i < notes.length; i++) {
179
236
  const note = notes[i];
180
237
  const nextNote = notes[i + 1];
181
- if (note.end === void 0) judgements.push(judgeTap(note, cursor, windows));
182
- else judgements.push(judgeHold(note, cursor, windows, nextNote));
238
+ if (note.end === void 0) judgements.push(judgeTap$1(note, cursor, windows));
239
+ else judgements.push(judgeHold$1(note, cursor, windows, lnWindows, nextNote));
183
240
  }
184
241
  return judgements;
185
242
  }
186
- function play(noteColumns, actionColumns, windows) {
243
+ function play$1(noteColumns, actionColumns, windows) {
187
244
  const judgements = [];
188
- for (let i = 0; i < noteColumns.length; i++) judgements.push(playColumn(noteColumns[i], actionColumns[i], windows));
245
+ for (let i = 0; i < noteColumns.length; i++) judgements.push(playColumn$1(noteColumns[i], actionColumns[i], windows));
189
246
  return judgements;
190
247
  }
191
- function playOsu(data) {
192
- const windows = truncWindows(baseWindows(data.od), data.windowScale);
193
- return play(data.noteColumns, data.actionColumns, windows);
194
- }
195
- //#endregion
196
- //#region src/utils.ts
197
- function clamp(value, min, max) {
198
- return Math.min(Math.max(value, min), max);
199
- }
200
- function difficultyRange(difficulty, min, mid, max) {
201
- if (difficulty > 5) return mid + (max - mid) * ((difficulty - 5) / 5);
202
- if (difficulty < 5) return mid + (mid - min) * ((difficulty - 5) / 5);
203
- return mid;
248
+ function playOsu$1(data) {
249
+ const windows = baseWindows$1(data.od).map((w) => w * data.speedRate * data.windowScale);
250
+ return play$1(data.noteColumns, data.actionColumns, windows);
204
251
  }
205
252
  //#endregion
206
253
  //#region src/osu-v1/health.ts
254
+ function compareJudgements(a, b) {
255
+ if (a.exit !== b.exit) return a.exit - b.exit;
256
+ return a.note.start - b.note.start;
257
+ }
207
258
  function getLifeIncreaseFor(result, hp, hpMultiplierNormal = 1) {
208
259
  switch (result) {
209
260
  case HIT_RESULTS.Perfect: return hpMultiplierNormal * (.0055 - hp * 5e-4);
@@ -248,7 +299,7 @@ function createLifeTable(hp, hpMultiplierNormal = 1) {
248
299
  }
249
300
  //#endregion
250
301
  //#region src/osu-v1/timeline.ts
251
- function createEvents(judgement) {
302
+ function createEvents$1(judgement) {
252
303
  const events = [{
253
304
  time: judgement.exit,
254
305
  judgement,
@@ -263,12 +314,14 @@ function createEvents(judgement) {
263
314
  });
264
315
  return events;
265
316
  }
266
- function compareEvents(left, right) {
317
+ function compareEvents$1(left, right) {
267
318
  if (left.time !== right.time) return left.time - right.time;
268
- return compareJudgements(left.judgement, right.judgement);
319
+ const a = left.judgement, b = right.judgement;
320
+ if (a.exit !== b.exit) return a.exit - b.exit;
321
+ return a.note.start - b.note.start;
269
322
  }
270
- function generateFrames(judgementColumns, lifeTable) {
271
- const sorted = judgementColumns.flat().flatMap(createEvents).sort(compareEvents);
323
+ function generateFrames$1(judgementColumns, lifeTable) {
324
+ const sorted = judgementColumns.flat().flatMap(createEvents$1).sort(compareEvents$1);
272
325
  const frames = [];
273
326
  const last = {
274
327
  time: 0,
@@ -306,19 +359,248 @@ function generateFrames(judgementColumns, lifeTable) {
306
359
  return frames;
307
360
  }
308
361
  function generateFramesOsu(judgementColumns, hp) {
309
- return generateFrames(judgementColumns, createLifeTable(hp, computeHpMultiplierNormal(judgementColumns, hp)));
362
+ return generateFrames$1(judgementColumns, createLifeTable(hp, computeHpMultiplierNormal(judgementColumns, hp)));
310
363
  }
311
364
  //#endregion
312
365
  //#region src/osu-v1/index.ts
313
366
  var osu_v1_exports = /* @__PURE__ */ __exportAll({
367
+ accTable: () => accTable$1,
368
+ baseWindows: () => baseWindows$1,
369
+ countResults: () => countResults,
370
+ createLifeTable: () => createLifeTable,
371
+ generateFrames: () => generateFrames$1,
372
+ generateFramesOsu: () => generateFramesOsu,
373
+ isHoldJudgement: () => isHoldJudgement,
374
+ play: () => play$1,
375
+ playColumn: () => playColumn$1,
376
+ playOsu: () => playOsu$1
377
+ });
378
+ //#endregion
379
+ //#region src/osu-lazer/types.ts
380
+ function isHoldV2(judgement) {
381
+ return "headResult" in judgement;
382
+ }
383
+ /** Extract the statistics result from a judgement (head result for holds). */
384
+ function getResult(judgement) {
385
+ return isHoldV2(judgement) ? judgement.headResult : judgement.result;
386
+ }
387
+ /** Accuracy weights matching lazer's mania scoring (Perfect=305, Great=300, etc.). */
388
+ const accTable = [
389
+ 305 / 305,
390
+ 300 / 305,
391
+ 200 / 305,
392
+ 100 / 305,
393
+ 50 / 305,
394
+ 0
395
+ ];
396
+ function baseWindows(od) {
397
+ return [
398
+ difficultyRange(od, 22.4, 19.4, 13.9),
399
+ difficultyRange(od, 64, 49, 34),
400
+ difficultyRange(od, 97, 82, 67),
401
+ difficultyRange(od, 127, 112, 97),
402
+ difficultyRange(od, 151, 136, 121),
403
+ difficultyRange(od, 188, 173, 158)
404
+ ];
405
+ }
406
+ /**
407
+ * Build 1.5× expanded windows for hold tail judgement.
408
+ * Matches lazer's CheckForResult which divides timeOffset by 1.5
409
+ * before comparing against the base (floor+0.5) windows:
410
+ * |delta| / 1.5 <= floor(base) + 0.5
411
+ * ⇔ |delta| <= (floor(base) + 0.5) * 1.5
412
+ */
413
+ const RELEASE_WINDOW_LENIENCE = 1.5;
414
+ function tailWindows(headWindows) {
415
+ return headWindows.map((w) => (w + .5) * RELEASE_WINDOW_LENIENCE);
416
+ }
417
+ //#endregion
418
+ //#region src/osu-lazer/judgement.ts
419
+ function judgeTap(note, cursor, windows, nextNote) {
420
+ const judgement = {
421
+ note,
422
+ enter: Math.max(note.start - windows[HIT_RESULTS.Miss], cursor.time),
423
+ exit: note.start + windows[HIT_RESULTS.Meh],
424
+ action: void 0,
425
+ result: HIT_RESULTS.Miss
426
+ };
427
+ while (cursor.getNextAction() && cursor.getNextAction().press < judgement.enter) cursor.setNextTime(cursor.getNextAction().press + 1);
428
+ if (cursor.getNextAction() && cursor.getNextAction().press <= judgement.exit) {
429
+ const action = cursor.getNextAction();
430
+ if (nextNote && action.press >= nextNote.start) {
431
+ cursor.setNextTime(action.press);
432
+ return judgement;
433
+ }
434
+ judgement.exit = action.press;
435
+ judgement.action = action;
436
+ cursor.setNextTime(action.press + 1);
437
+ const delta = Math.abs(action.press - note.start);
438
+ for (let i = HIT_RESULTS.Perfect; i <= HIT_RESULTS.Miss; i++) if (delta <= windows[i]) {
439
+ judgement.result = i;
440
+ break;
441
+ }
442
+ } else cursor.setNextTime(judgement.exit);
443
+ return judgement;
444
+ }
445
+ function judgeHold(note, cursor, windows, tailWindows, nextNote) {
446
+ const missWindow = windows[HIT_RESULTS.Miss];
447
+ const mehWindow = windows[HIT_RESULTS.Meh];
448
+ const headEnter = Math.max(note.start - missWindow, cursor.time);
449
+ const headLateDeadline = Math.min(note.start + missWindow, note.end + mehWindow);
450
+ const judgement = {
451
+ note,
452
+ headEnter,
453
+ headExit: 0,
454
+ tailEnter: 0,
455
+ tailExit: 0,
456
+ actions: [],
457
+ headResult: HIT_RESULTS.Miss,
458
+ tailResult: HIT_RESULTS.Miss
459
+ };
460
+ while (cursor.getNextAction() && cursor.getNextAction().press < headEnter) cursor.setNextTime(cursor.getNextAction().press + 1);
461
+ if (!cursor.getNextAction() || cursor.getNextAction().press > headLateDeadline) {
462
+ const autoMissTime = Math.min(note.start + mehWindow, note.end + mehWindow);
463
+ judgement.headExit = autoMissTime;
464
+ judgement.tailEnter = autoMissTime;
465
+ judgement.tailExit = autoMissTime;
466
+ cursor.setNextTime(autoMissTime);
467
+ return judgement;
468
+ }
469
+ const action = cursor.getNextAction();
470
+ if (nextNote && action.press >= nextNote.start) {
471
+ cursor.setNextTime(action.press);
472
+ return judgement;
473
+ }
474
+ judgement.actions.push(action);
475
+ const headDelta = Math.abs(action.press - note.start);
476
+ for (let i = HIT_RESULTS.Perfect; i <= HIT_RESULTS.Miss; i++) if (headDelta <= windows[i]) {
477
+ judgement.headResult = i;
478
+ break;
479
+ }
480
+ judgement.headExit = action.press;
481
+ const absTailDelta = Math.abs(action.release - note.end);
482
+ if (absTailDelta > tailWindows[HIT_RESULTS.Miss]) {
483
+ judgement.tailResult = HIT_RESULTS.Miss;
484
+ const missThreshold = Math.ceil(tailWindows[HIT_RESULTS.Miss]);
485
+ judgement.tailEnter = action.release > note.end ? note.end + missThreshold : note.end - missThreshold;
486
+ judgement.tailExit = judgement.tailEnter;
487
+ } else {
488
+ for (let i = HIT_RESULTS.Perfect; i <= HIT_RESULTS.Miss; i++) if (absTailDelta <= tailWindows[i]) {
489
+ judgement.tailResult = i;
490
+ break;
491
+ }
492
+ judgement.tailEnter = action.release;
493
+ judgement.tailExit = action.release;
494
+ }
495
+ if (judgement.headResult === HIT_RESULTS.Miss && judgement.tailResult < HIT_RESULTS.Meh) judgement.tailResult = HIT_RESULTS.Meh;
496
+ if (judgement.tailResult === HIT_RESULTS.Miss) judgement.breakTime = judgement.tailEnter;
497
+ cursor.setNextTime(action.release + 1);
498
+ return judgement;
499
+ }
500
+ function playColumn(notes, actions, windows, tailWindows) {
501
+ const judgements = [];
502
+ const cursor = createActionCursor(actions);
503
+ for (let i = 0; i < notes.length; i++) {
504
+ const note = notes[i];
505
+ const nextNote = notes[i + 1];
506
+ if (note.end === void 0) judgements.push(judgeTap(note, cursor, windows, nextNote));
507
+ else judgements.push(judgeHold(note, cursor, windows, tailWindows, nextNote));
508
+ }
509
+ return judgements;
510
+ }
511
+ function play(noteColumns, actionColumns, windows, tailWindows) {
512
+ const judgements = [];
513
+ for (let i = 0; i < noteColumns.length; i++) judgements.push(playColumn(noteColumns[i], actionColumns[i], windows, tailWindows));
514
+ return judgements;
515
+ }
516
+ function playOsu(data) {
517
+ const windows = truncWindows(baseWindows(data.od), data.speedRate * data.windowScale);
518
+ const tailW = tailWindows(windows);
519
+ return play(data.noteColumns, data.actionColumns, windows, tailW);
520
+ }
521
+ //#endregion
522
+ //#region src/osu-lazer/timeline.ts
523
+ function createEvents(judgement) {
524
+ if (!("headResult" in judgement)) return [{
525
+ time: judgement.exit,
526
+ judgement,
527
+ result: judgement.result,
528
+ affectsResultCounts: true
529
+ }];
530
+ const events = [];
531
+ events.push({
532
+ time: judgement.headExit,
533
+ judgement,
534
+ result: judgement.headResult,
535
+ affectsResultCounts: true
536
+ });
537
+ if (judgement.tailEnter !== judgement.headExit || judgement.tailResult === HIT_RESULTS.Miss) events.push({
538
+ time: judgement.tailEnter,
539
+ judgement,
540
+ result: judgement.tailResult,
541
+ affectsResultCounts: true
542
+ });
543
+ return events;
544
+ }
545
+ function compareEvents(left, right) {
546
+ if (left.time !== right.time) return left.time - right.time;
547
+ if (left.judgement.note.column !== right.judgement.note.column) return left.judgement.note.column - right.judgement.note.column;
548
+ return left.judgement.note.start - right.judgement.note.start;
549
+ }
550
+ /**
551
+ * Generate timeline frames from judgement columns.
552
+ *
553
+ * Tracks combo, max combo, and result counts over time.
554
+ * Health/life simulation is not included (use the osu-v1 variant for that).
555
+ */
556
+ function generateFrames(judgementColumns) {
557
+ const sorted = judgementColumns.flat().flatMap(createEvents).sort(compareEvents);
558
+ const frames = [];
559
+ const last = {
560
+ time: 0,
561
+ combo: 0,
562
+ maxCombo: 0,
563
+ resultCounts: [
564
+ 0,
565
+ 0,
566
+ 0,
567
+ 0,
568
+ 0,
569
+ 0
570
+ ],
571
+ life: 1
572
+ };
573
+ for (let i = 0; i < sorted.length; i++) {
574
+ const event = sorted[i];
575
+ last.time = event.time;
576
+ if (event.result < HIT_RESULTS.Miss) {
577
+ last.combo++;
578
+ if (last.combo > last.maxCombo) last.maxCombo = last.combo;
579
+ } else last.combo = 0;
580
+ if (event.affectsResultCounts) last.resultCounts[event.result]++;
581
+ if (sorted[i + 1]?.time === event.time) continue;
582
+ frames.push({
583
+ time: last.time,
584
+ combo: last.combo,
585
+ maxCombo: last.maxCombo,
586
+ resultCounts: [...last.resultCounts],
587
+ life: last.life
588
+ });
589
+ }
590
+ return frames;
591
+ }
592
+ //#endregion
593
+ //#region src/osu-lazer/index.ts
594
+ var osu_lazer_exports = /* @__PURE__ */ __exportAll({
314
595
  accTable: () => accTable,
315
596
  baseWindows: () => baseWindows,
316
- createLifeTable: () => createLifeTable,
317
597
  generateFrames: () => generateFrames,
318
- generateFramesOsu: () => generateFramesOsu,
598
+ getResult: () => getResult,
599
+ isHoldV2: () => isHoldV2,
319
600
  play: () => play,
320
601
  playColumn: () => playColumn,
321
- playOsu: () => playOsu
602
+ playOsu: () => playOsu,
603
+ tailWindows: () => tailWindows
322
604
  });
323
605
  //#endregion
324
- export { HIT_RESULTS, calcAccuracy, compareJudgements, createActionCursor, isHoldJudgement, truncWindows, osu_v1_exports as v1 };
606
+ export { HIT_RESULTS, beatmapToNoteColumns, calcAccuracy, clamp, createActionCursor, difficultyRange, osu_lazer_exports as lazer, replayToActionColumns, truncWindows, osu_v1_exports as v1 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mania-judge",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.3.0",
5
5
  "description": "Simulate osu!stable mania judgements.",
6
6
  "author": "zzzzv",
7
7
  "license": "MIT",
@@ -20,8 +20,6 @@
20
20
  ],
21
21
  "exports": {
22
22
  ".": "./dist/index.mjs",
23
- "./osu-parsers": "./dist/osu-parsers/index.mjs",
24
- "./osu-parsers/node": "./dist/osu-parsers/node.mjs",
25
23
  "./package.json": "./package.json"
26
24
  },
27
25
  "files": [
@@ -30,31 +28,22 @@
30
28
  "scripts": {
31
29
  "build": "tsdown",
32
30
  "dev": "tsdown --watch",
33
- "generate:test-json:tap-only": "node --env-file=.env --import tsx tests/generate-test-json.ts tap-only",
34
- "generate:test-json:hold": "node --env-file=.env --import tsx tests/generate-test-json.ts hold",
35
- "generate:test-json:mods": "node --env-file=.env --import tsx tests/generate-test-json.ts mods",
36
- "generate:test-files": "node --import tsx tests/generate-osu-files.ts",
31
+ "gen:stable-json:tap-only": "node --env-file=.env --import tsx tests/gen-stable-json.ts tap-only",
32
+ "gen:stable-json:hold": "node --env-file=.env --import tsx tests/gen-stable-json.ts hold",
33
+ "gen:stable-json:mods": "node --env-file=.env --import tsx tests/gen-stable-json.ts mods",
34
+ "gen:stable-json": "pnpm gen:stable-json:tap-only && pnpm gen:stable-json:hold && pnpm gen:stable-json:mods",
35
+ "gen:lazer-json:tap-only": "node --import tsx tests/gen-lazer-json.ts tap-only",
36
+ "gen:lazer-json:hold": "node --import tsx tests/gen-lazer-json.ts hold",
37
+ "gen:lazer-json:mods": "node --import tsx tests/gen-lazer-json.ts mods",
38
+ "gen:lazer-json": "pnpm gen:lazer-json:tap-only && pnpm gen:lazer-json:hold && pnpm gen:lazer-json:mods",
39
+ "gen:osu-files": "node --import tsx tests/gen-osu-files.ts",
37
40
  "test": "vitest",
38
41
  "typecheck": "tsc --noEmit",
39
42
  "prepublishOnly": "pnpm run build"
40
43
  },
41
- "peerDependencies": {
42
- "osu-classes": "^3.2.0-beta.0",
43
- "osu-mania-stable": "^5.0.1",
44
- "osu-parsers": "^4.2.0-beta.0"
45
- },
46
- "peerDependenciesMeta": {
47
- "osu-classes": {
48
- "optional": true
49
- },
50
- "osu-mania-stable": {
51
- "optional": true
52
- },
53
- "osu-parsers": {
54
- "optional": true
55
- }
56
- },
44
+
57
45
  "devDependencies": {
46
+ "osu-mania-io": "^0.1.0",
58
47
  "@types/node": "^25.5.0",
59
48
  "@typescript/native-preview": "7.0.0-dev.20260328.1",
60
49
  "jszip": "^3.10.1",
@@ -1,35 +0,0 @@
1
- import { _ as TimeLineFrame, c as HoldJudgementV1, d as JudgementV1, m as OsuData, n as BaseJudgement, o as HitResultTable, p as Note, r as Columns, s as HitWindows, t as Action } from "./types-3MDvQQxi.mjs";
2
-
3
- //#region src/osu-v1/judgement.d.ts
4
- declare const accTable: Readonly<HitResultTable<number>>;
5
- declare function baseWindows(od: number): HitWindows;
6
- declare function playColumn(notes: Note[], actions: Action[], windows: HitWindows): JudgementV1[];
7
- declare function play(noteColumns: Columns<Note>, actionColumns: Columns<Action>, windows: HitWindows): Columns<JudgementV1>;
8
- declare function playOsu(data: OsuData): Columns<JudgementV1>;
9
- //#endregion
10
- //#region src/osu-v1/health.d.ts
11
- declare function createLifeTable(hp: number, hpMultiplierNormal?: number): HitResultTable<number>;
12
- //#endregion
13
- //#region src/osu-v1/timeline.d.ts
14
- declare function generateFrames(judgementColumns: Columns<JudgementV1>, lifeTable: HitResultTable<number>): TimeLineFrame[];
15
- declare function generateFramesOsu(judgementColumns: Columns<JudgementV1>, hp: number): TimeLineFrame[];
16
- declare namespace index_d_exports {
17
- export { accTable, baseWindows, createLifeTable, generateFrames, generateFramesOsu, play, playColumn, playOsu };
18
- }
19
- //#endregion
20
- //#region src/column.d.ts
21
- declare function createActionCursor(actions: Action[]): {
22
- readonly time: number;
23
- setNextTime(nextTime: number): void;
24
- getHoldingAction(): Action | null;
25
- getNextAction(): Action | null;
26
- };
27
- type ActionCursor = ReturnType<typeof createActionCursor>;
28
- //#endregion
29
- //#region src/extensions.d.ts
30
- declare function truncWindows(windows: Readonly<HitWindows>, scale?: number): HitWindows;
31
- declare function calcAccuracy(resultCounts: Readonly<HitResultTable<number>>, accTable: Readonly<HitResultTable<number>>): number;
32
- declare function compareJudgements<T extends BaseJudgement<Note>>(a: T, b: T): number;
33
- declare function isHoldJudgement(judgement: JudgementV1): judgement is HoldJudgementV1;
34
- //#endregion
35
- export { ActionCursor as a, truncWindows as i, compareJudgements as n, createActionCursor as o, isHoldJudgement as r, index_d_exports as s, calcAccuracy as t };
@@ -1,2 +0,0 @@
1
- import { n as convertReplay, r as parseWithMods, t as convertBeatmap } from "../shared-D-sop3c6.mjs";
2
- export { convertBeatmap, convertReplay, parseWithMods as parse };
@@ -1,2 +0,0 @@
1
- import { n as convertReplay, r as parseWithMods, t as convertBeatmap } from "../shared-DJFUXeEy.mjs";
2
- export { convertBeatmap, convertReplay, parseWithMods as parse };
@@ -1,13 +0,0 @@
1
- import { m as OsuData } from "../types-3MDvQQxi.mjs";
2
- import { n as convertReplay, r as parseWithMods, t as convertBeatmap } from "../shared-D-sop3c6.mjs";
3
- import * as _$osu_mania_stable0 from "osu-mania-stable";
4
- import * as _$osu_classes0 from "osu-classes";
5
-
6
- //#region src/osu-parsers/node.d.ts
7
- declare const parseFromPath: (beatmapPath: string, replayPath: string) => Promise<{
8
- osuData: OsuData;
9
- rawBeatmap: _$osu_mania_stable0.ManiaBeatmap;
10
- rawScore: _$osu_classes0.Score;
11
- }>;
12
- //#endregion
13
- export { convertBeatmap, convertReplay, parseFromPath, parseWithMods };
@@ -1,9 +0,0 @@
1
- import { n as convertReplay, r as parseWithMods, t as convertBeatmap } from "../shared-DJFUXeEy.mjs";
2
- import { readFile } from "node:fs/promises";
3
- //#region src/osu-parsers/node.ts
4
- const parseFromPath = async (beatmapPath, replayPath) => {
5
- const [beatmapContent, replayBuffer] = await Promise.all([readFile(beatmapPath, "utf8"), readFile(replayPath)]);
6
- return parseWithMods(beatmapContent, replayBuffer);
7
- };
8
- //#endregion
9
- export { convertBeatmap, convertReplay, parseFromPath, parseWithMods };
@@ -1,15 +0,0 @@
1
- import { m as OsuData, p as Note, r as Columns, t as Action } from "./types-3MDvQQxi.mjs";
2
- import { ManiaBeatmap, ManiaReplayFrame } from "osu-mania-stable";
3
- import * as _$osu_classes0 from "osu-classes";
4
-
5
- //#region src/osu-parsers/shared.d.ts
6
- type ReplayBufferLike = ArrayBuffer | SharedArrayBuffer | Uint8Array | Buffer;
7
- declare const convertBeatmap: (beatmap: ManiaBeatmap) => Columns<Note>;
8
- declare const convertReplay: (frames: ManiaReplayFrame[], columns: number) => Columns<Action>;
9
- declare const parseWithMods: (beatmapContent: string, replayBuffer: ReplayBufferLike) => Promise<{
10
- osuData: OsuData;
11
- rawBeatmap: ManiaBeatmap;
12
- rawScore: _$osu_classes0.Score;
13
- }>;
14
- //#endregion
15
- export { convertReplay as n, parseWithMods as r, convertBeatmap as t };
@@ -1,69 +0,0 @@
1
- import { BeatmapDecoder, ScoreDecoder } from "osu-parsers";
2
- import { Hold, ManiaRuleset } from "osu-mania-stable";
3
- import { ModBitwise } from "osu-classes";
4
- //#region src/osu-parsers/shared.ts
5
- const ruleset = new ManiaRuleset();
6
- const beatmapDecoder = new BeatmapDecoder();
7
- const scoreDecoder = new ScoreDecoder();
8
- const convertBeatmap = (beatmap) => {
9
- const columnsArray = Array.from({ length: beatmap.totalColumns }, () => []);
10
- for (const hitObject of beatmap.hitObjects) {
11
- const note = {
12
- column: hitObject.column,
13
- start: hitObject.startTime,
14
- end: hitObject instanceof Hold ? hitObject.endTime : void 0
15
- };
16
- columnsArray[note.column].push(note);
17
- }
18
- return columnsArray;
19
- };
20
- const convertReplay = (frames, columns) => {
21
- const columnsArray = Array.from({ length: columns }, () => []);
22
- const lastPressTime = Array.from({ length: columns }, () => null);
23
- for (const frame of frames) {
24
- if (frame.startTime < 0) continue;
25
- for (let i = 0; i < columns; i++) if (frame.actions.has(10 + i)) {
26
- if (lastPressTime[i] === null) lastPressTime[i] = frame.startTime;
27
- } else if (lastPressTime[i] !== null) {
28
- columnsArray[i].push({
29
- column: i,
30
- press: lastPressTime[i],
31
- release: frame.startTime
32
- });
33
- lastPressTime[i] = null;
34
- }
35
- }
36
- return columnsArray;
37
- };
38
- const parseWithMods = async (beatmapContent, replayBuffer) => {
39
- const beatmap = beatmapDecoder.decodeFromString(beatmapContent, false);
40
- const score = await scoreDecoder.decodeFromBuffer(replayBuffer, true);
41
- score.info.ruleset = ruleset;
42
- const maniaBeatmap = ruleset.applyToBeatmap(beatmap);
43
- const columns = maniaBeatmap.totalColumns;
44
- const maniaFrames = ruleset.applyToReplay(score.replay, maniaBeatmap).frames;
45
- const mods = score.info.mods;
46
- const maniaBeatmapWithMods = mods === null || mods.bitwise === 0 ? maniaBeatmap : ruleset.applyToBeatmapWithMods(maniaBeatmap, mods);
47
- const osuData = {
48
- od: beatmap.difficulty.overallDifficulty,
49
- hp: beatmap.difficulty.drainRate,
50
- windowScale: 1,
51
- noteColumns: convertBeatmap(maniaBeatmapWithMods),
52
- actionColumns: convertReplay(maniaFrames, columns)
53
- };
54
- if (mods?.has(ModBitwise.Easy)) {
55
- osuData.windowScale = 1.4;
56
- osuData.hp *= .5;
57
- } else if (mods?.has(ModBitwise.HardRock)) {
58
- osuData.windowScale = 1 / 1.4;
59
- osuData.hp = Math.min(osuData.hp * 1.4, 10);
60
- } else if (mods?.has(ModBitwise.DoubleTime)) osuData.windowScale = 1.5;
61
- else if (mods?.has(ModBitwise.HalfTime)) osuData.windowScale = .75;
62
- return {
63
- osuData,
64
- rawBeatmap: maniaBeatmap,
65
- rawScore: score
66
- };
67
- };
68
- //#endregion
69
- export { convertReplay as n, parseWithMods as r, convertBeatmap as t };
@@ -1,66 +0,0 @@
1
- //#region src/types.d.ts
2
- interface TapNote {
3
- column: number;
4
- start: number;
5
- end?: undefined;
6
- }
7
- interface HoldNote {
8
- column: number;
9
- start: number;
10
- end: number;
11
- }
12
- type Note = TapNote | HoldNote;
13
- interface Action {
14
- column: number;
15
- press: number;
16
- release: number;
17
- }
18
- type Columns<T> = T[][];
19
- interface OsuData {
20
- od: number;
21
- hp: number;
22
- windowScale: number;
23
- noteColumns: Columns<Note>;
24
- actionColumns: Columns<Action>;
25
- }
26
- declare const HIT_RESULTS: {
27
- readonly Perfect: 0;
28
- readonly Great: 1;
29
- readonly Good: 2;
30
- readonly Ok: 3;
31
- readonly Meh: 4;
32
- readonly Miss: 5;
33
- };
34
- type HitResult = (typeof HIT_RESULTS)[keyof typeof HIT_RESULTS];
35
- type HitResultTable<T> = [T, T, T, T, T, T];
36
- type HitWindows = HitResultTable<number>;
37
- interface BaseJudgement<T extends Note> {
38
- note: T;
39
- enter: number;
40
- exit: number;
41
- actions: Action[];
42
- }
43
- interface TapJudgement extends BaseJudgement<TapNote> {
44
- result: HitResult;
45
- }
46
- interface HoldJudgementV1 extends BaseJudgement<HoldNote> {
47
- result: HitResult;
48
- breakTime?: number;
49
- ticks: number[];
50
- }
51
- interface HoldJudgementV2 extends BaseJudgement<HoldNote> {
52
- headResult: HitResult;
53
- tailResult: HitResult;
54
- breakTime?: number;
55
- }
56
- type JudgementV1 = TapJudgement | HoldJudgementV1;
57
- type JudgementV2 = TapJudgement | HoldJudgementV2;
58
- interface TimeLineFrame {
59
- time: number;
60
- combo: number;
61
- maxCombo: number;
62
- resultCounts: HitResultTable<number>;
63
- life: number;
64
- }
65
- //#endregion
66
- export { TimeLineFrame as _, HitResult as a, HoldJudgementV1 as c, JudgementV1 as d, JudgementV2 as f, TapNote as g, TapJudgement as h, HIT_RESULTS as i, HoldJudgementV2 as l, OsuData as m, BaseJudgement as n, HitResultTable as o, Note as p, Columns as r, HitWindows as s, Action as t, HoldNote as u };