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 | 316x 316x 69x 68x 60x 1x 1x 1x | import { resolveChartLongNoteMode, type LongNoteMode } from '@be-music/chart-model';
import type { BeMusicJSON } from '@be-music/chart-source';
import type { CourseConstraint } from './definition.ts';
/**
* Applies a course's long-note constraint (`ln` / `cn` / `hcn`) to a stage chart that leaves its long-note mode
* undefined, as beatoraja forces `lnmode` for such charts. A chart that names its own mode (`#LNMODE`, HDX LONGMODE, bmson `ln_type`)
* keeps it. Returns the chart unchanged when nothing applies, else a copy. Hosts apply it to each stage chart they play,
* and the Leaderboard to the stage charts it stitches a NONSTOP run from again, so both get the same chart.
*/
export function applyCourseLongNoteConstraint(
json: BeMusicJSON,
constraints: readonly CourseConstraint[],
): BeMusicJSON {
const mode = constraints.includes('ln')
? 1
: constraints.includes('cn')
? 2
: constraints.includes('hcn')
? 3
: undefined;
return mode === undefined ? json : applyUndefinedLongNoteMode(json, mode);
}
/**
* Gives a chart that leaves its long-note mode undefined the mode `mode` (beatoraja `ChartInformation.lnmode`: the
* player's LN / CN / HCN choice, or a course constraint). A chart that names its own mode keeps it.
*/
export function applyUndefinedLongNoteMode(json: BeMusicJSON, mode: LongNoteMode): BeMusicJSON {
if (json.sourceFormat === 'bms') {
if (json.bms.lnMode !== undefined || resolveChartLongNoteMode(json) !== 1) return json;
return { ...json, bms: { ...json.bms, lnMode: mode } };
}
const lnType = json.bmson.info.lnType;
Iif (lnType !== undefined && lnType !== 0) return json;
return { ...json, bmson: { ...json.bmson, info: { ...json.bmson.info, lnType: mode } } };
}
|