All files / skin-beatoraja/src/scene play-text.ts

100% Statements 5/5
100% Branches 6/6
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                                              14x 5x 5x   12x    
import type { CourseView } from '@be-music/player-scene-model';
import { resolveBeatorajaCourseText } from './course.ts';
import {
  resolveBeatorajaSkinText,
  resolveBeatorajaChartText,
  type BeatorajaSkinTextInput,
  type BeatorajaChartTextInput,
} from './chart-text.ts';
 
/** What a play skin's texts read. */
export interface BeatorajaPlayTextInput {
  /** The chart being played. */
  readonly chart?: BeatorajaChartTextInput;
  readonly skin?: BeatorajaSkinTextInput;
  /** The running course, when the play is one of its stages. */
  readonly course?: CourseView;
}
 
/**
 * A play skin's text (`text[].ref`): the running course's stage titles (150-159), the chart's song texts and the
 * skin's own; `undefined` for another id.
 */
export function resolveBeatorajaPlayText(id: number, input: BeatorajaPlayTextInput): string | undefined {
  if (input.course !== undefined) {
    const courseText = resolveBeatorajaCourseText(id, input.course);
    if (courseText !== undefined) return courseText;
  }
  return resolveBeatorajaChartText(id, input.chart) ?? resolveBeatorajaSkinText(id, input.skin);
}