Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | 3390x 9625x 2922x 14x 14x 99x 99x 99x 855x 855x 635x 99x | import type { LongNoteMode } from '@be-music/chart-model';
/**
* The chart-side inputs a ruleset needs, in a form both the live engine and the replay simulator can produce.
*
* The rulesets used to read a `ReplayChart` directly, which tied them to the offline replay path. The live engine
* has the same facts available (a resolved `BeMusicJSON` plus its prepared note arrays) but in a different shape,
* so the ruleset tables now take this neutral record and each caller supplies an adapter. Everything here is
* chart-derived and fixed for the whole play — per-play choices (gauge, judge algorithm) travel separately in
* `ResolveRulesetOptions`.
*/
export interface RulesetChartFacts {
/** An LRX chart's rank and TOTAL read as a BMS chart's: only bmson differs. */
sourceFormat: 'bms' | 'bmson' | 'lrx';
/** Engine lane display mode (`resolveLaneDisplayMode` output) — picks beatoraja's per-mode window tables. */
laneMode: string;
/**
* Raw `#TOTAL` (absolute) / bmson `info.total` (a percentage of the ruleset's default TOTAL). Absent when the chart
* specified none; each ruleset applies its own default.
*/
total?: number;
/** Override for a mixed-format stitched chart; absent on ordinary charts. */
totalUnit?: 'absolute' | 'percent';
/** Chart-level long-note mode after `#LNMODE` / `info.ln_type` resolution. */
lnMode: LongNoteMode;
judgeRank: RulesetJudgeRankFacts;
notes: RulesetNoteCounts;
}
export interface RulesetJudgeRankFacts {
/** Initial judgerank on the internal LR2 percent axis (VERY HARD 25 / HARD 50 / NORMAL 75 / EASY 100). */
percent: number;
/** Raw `#RANK` when the chart specified one. */
sourceRank?: number;
/** Raw `#DEFEXRANK` (BMS) / `info.judge_rank` (bmson), in the `100 = NORMAL` unit. */
sourceExRank?: number;
/** Dynamic `#EXRANKxx` changes (channel `A0`) in chart order, in the same unit as `sourceExRank`. */
timeline?: ReadonlyArray<{ timeUs: number; exRankValue: number }>;
/** A stitched LR2 NONSTOP chart's later stages taking over the judge rank with their `#RANK`, in time order. */
stageRanks?: ReadonlyArray<RulesetStageRank>;
}
/**
* A later NONSTOP stage's `#RANK` setting the judge windows from `timeUs` on: as a chart opening with it does
* (`'chart'`), or by LR2's NONSTOP rank table (`'lr2-nonstop'`, `resolveLR2NonstopRankWindowsMs`). The legacy BMS tables apply only to LR2; mixed bmson courses
* also carry `bmson` (raw judge_rank) and `bms-exrank` units and apply stage windows to LR2 and beatoraja.
*/
export interface RulesetStageRank {
timeUs: number;
rank: number;
table: 'chart' | 'lr2-nonstop' | 'bmson' | 'bms-exrank' | 'bms-exrank-change';
}
/**
* Scorable-note tallies split the way the note-count rules need them: a long note counts once under LN styles and
* twice under charge styles, so the long notes are grouped by the mode the CHART declared and each ruleset decides
* what to do with them. Mines, invisibles, and free-zone notes are excluded — they are never scorable.
*/
export interface RulesetNoteCounts {
/** Scorable notes with no tail. */
normal: number;
/** Long notes keyed by their chart-declared mode (1 LN / 2 CN / 3 HCN). */
long: Readonly<Record<LongNoteMode, number>>;
}
export function createEmptyRulesetNoteCounts(): RulesetNoteCounts {
return { normal: 0, long: { 1: 0, 2: 0, 3: 0 } };
}
/** Total scorable note OBJECTS — every long note counts once. LR2 uses this count for TOTAL; beatoraja counts charge tails too. */
export function countBaseNotes(notes: RulesetNoteCounts): number {
return notes.normal + notes.long[1] + notes.long[2] + notes.long[3];
}
/** `chart` without the notes `removed` counts (none below zero): the notes a play leaves out of judging. */
export function withoutRulesetNotes(
chart: RulesetChartFacts,
removed: RulesetNoteCounts | undefined,
): RulesetChartFacts {
if (removed === undefined) return chart;
const long = chart.notes.long;
return {
...chart,
notes: {
normal: Math.max(0, chart.notes.normal - removed.normal),
long: {
1: Math.max(0, long[1] - removed.long[1]),
2: Math.max(0, long[2] - removed.long[2]),
3: Math.max(0, long[3] - removed.long[3]),
},
},
};
}
/** Counts `notes` (scorable play notes) as the ruleset facts do: a note with a tail is a long note of its mode. */
export function countRulesetNotesOf(
notes: Iterable<{ seconds: number; endSeconds?: number; longNoteMode?: LongNoteMode }>,
chartLNMode: LongNoteMode,
): RulesetNoteCounts {
const long: Record<LongNoteMode, number> = { 1: 0, 2: 0, 3: 0 };
let normal = 0;
for (const note of notes) {
const hasTail =
typeof note.endSeconds === 'number' && Number.isFinite(note.endSeconds) && note.endSeconds > note.seconds;
if (hasTail) long[note.longNoteMode ?? chartLNMode] += 1;
else normal += 1;
}
return { normal, long };
}
|