All files / chart-model/src chart-option-legacy.ts

100% Statements 5/5
100% Branches 4/4
100% Functions 1/1
100% Lines 4/4

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                        600x                                                                                   2636x 2301x 2301x    
/**
 * nanasigroove's legacy (1.260 and earlier) `774:HID-*` / `774:CRA-*` option IDs and the modern ID each stands for,
 * from hitkey's option catalog (https://hitkey.nekokan.dyndns.info/option.htm). Like the legacy HSP values, they are
 * accepted in initial `#OPTION` declarations only: `#CHANGEOPTION` / channel A6 disregards old IDs, so a timed one is
 * diagnosed `initial-only-alias`.
 *
 * The judgment and note aliases (`CRA-HARD1/2`, `CRA-ULTHARD`, `CRA-2JUDGE`, `CRA-HYPER` → `NOTES_DOUBLE`,
 * `CRA-CPDOUBLE` → `NOTES_COPY`) feed `compileChartPlayOptions`. The catalog lists `CRA-2JUDGE` as `CRAZY_HELLJUDGE`
 * like `CRA-ULTHARD`; Be-Music follows it. `CRA-RHS1/2/3` have no modern alias and compile directly into a playback rate.
 * The legacy `HSP-*` values are the display
 * compiler's own; the other legacy families (`RND-*`, `GTP-*`, `GLV-*`) are not mapped.
 */
const LEGACY_OPTION_ALIASES: ReadonlyMap<string, string> = new Map(
  Object.entries({
    'HID-NORMAL': 'HIDDEN_OFF',
    'HID-HIDDEN1': 'HIDDEN_HIDDEN',
    'HID-HIDDEN2': 'HIDDEN_HIDDEN2',
    'HID-SUDDEN1': 'HIDDEN_SUDDEN',
    'HID-SUDDEN2': 'HIDDEN_SUDDEN2',
    'HID-HIDSUD1': 'HIDDEN_HID-SUD',
    'HID-HIDSUD2': 'HIDDEN_HID-SUD2',
    'HID-HIDSUD3': 'HIDDEN_HID-SUD3',
    'HID-BLINK1': 'HIDDEN_BLINK',
    'HID-BLINK2': 'HIDDEN_BLINK2',
    'HID-STEALTH': 'HIDDEN_STEALTH',
    'HID-HIDJUDGE': 'CRAZY_HIDJUDGE',
    'CRA-NORMAL': 'CRAZY_OFF',
    'CRA-STAR': 'CRAZY_STAR',
    'CRA-LINEMOVE': 'CRAZY_LINEMOVE',
    'CRA-HARD1': 'CRAZY_GOOD2BAD',
    'CRA-HARD2': 'CRAZY_GREAT2BAD',
    'CRA-ULTHARD': 'CRAZY_HELLJUDGE',
    'CRA-2JUDGE': 'CRAZY_HELLJUDGE',
    'CRA-XWAVE1': 'CRAZY_XWAVE',
    'CRA-XWAVE2': 'CRAZY_XWAVE2',
    'CRA-YWAVE1': 'CRAZY_YWAVE',
    'CRA-YWAVE2': 'CRAZY_YWAVE2',
    'CRA-XYWAVE1': 'CRAZY_XYWAVE',
    'CRA-XYWAVE2': 'CRAZY_XYWAVE2',
    'CRA-3DWAVE1': 'CRAZY_3DWAVE',
    'CRA-3DWAVE2': 'CRAZY_3DWAVE2',
    'CRA-DARK': 'CRAZY_DARK',
    'CRA-ACCEL': 'CHANGE-HS_ACCEL',
    'CRA-BRAKE': 'CHANGE-HS_BRAKE',
    'CRA-HYPER': 'NOTES_DOUBLE',
    'CRA-CPDOUBLE': 'NOTES_COPY',
  }),
);
 
/**
 * The modern declaration an exact-case legacy `774:HID-*` / `774:CRA-*` declaration stands for, or `undefined` when
 * `declaration` is not one of the mapped legacy IDs.
 */
export function resolveChartLegacyOptionAlias(declaration: string): string | undefined {
  if (!declaration.startsWith('774:')) return undefined;
  const modern = LEGACY_OPTION_ALIASES.get(declaration.slice(4));
  return modern === undefined ? undefined : `774:${modern}`;
}