All files / app-leaderboard/src/scores long-notes.ts

100% Statements 5/5
100% Branches 6/6
100% Functions 3/3
100% Lines 3/3

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              2192x                 125x 122x    
import type { BeMusicReplay } from '@be-music/player-engine/replay';
 
/**
 * Whether a replay's chart had long notes: the notes the engine resolved and recorded as `long` (from `#LNTYPE` /
 * `#LNOBJ` / channels `5x` / `6x`, or bmson lengths). FREE ZONE notes are recorded as their own type and do not count.
 */
export function replayHasLongNotes(chart: Pick<BeMusicReplay['chart'], 'notes'>): boolean {
  return chart.notes.some((note) => note.type === 'long');
}
 
/**
 * The value a chart's `hasLongNotes` should take after a play, or `undefined` when it stays. Unknown (charts registered
 * before it was kept) takes the play's answer; once one play had long notes the chart has them, since `#RANDOM`
 * outcomes can differ.
 */
export function nextHasLongNotes(stored: boolean | null, played: boolean): boolean | undefined {
  if (stored === null) return played;
  return !stored && played ? true : undefined;
}