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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | 21x 21x 21x 21x 21x 21x | import {
CLEAR_LAMP_SHORT_LABELS,
describeBestRecord,
describeCourseCard,
describeDanRanks,
formatPlayVariantLabel,
resolveStageOrientation,
resolveChartRowFacts,
resolveChartStats,
resolveClearLampLight,
type BeMusicSelectLayout,
type BestRecordSummary,
type LibraryEntry,
type LibraryCourse,
type LibraryFolder,
type BeMusicSelectFrame,
type BeMusicSurface,
selectListRows,
} from '@be-music/player-skin-sdk';
import { PORTRAIT_SELECT_LAYOUT, README_CHIP, resolvePortraitSelectCard } from './layout.ts';
import { ACCENT, INK, LINE, MUTED, PANEL, TEXT, css, stat, text } from './theme.ts';
/** Where the song list sits; the player uses the same numbers to tell which row was clicked. */
export const SELECT_LAYOUT: BeMusicSelectLayout = { listX: 322, listTop: 92, listBottomInset: 28, rowHeight: 28 };
/** Fade to black after a chart is picked. */
export const SELECT_OUTRO_MS = 300;
const MARGIN = 16;
const PANEL_W = 290;
/** The landscape card's height: the chart's facts, the player's best on it, then PLAY and AUTO. */
const PANEL_H = 348;
/**
* The select screen. Landscape: the focused chart's card and buttons on the left, the song list on the right. Portrait
* (the skin's `portraitStage`, while a phone or tablet is held upright): the card across the top and the list under it.
* The host tells the two apart by the surface's size, and so does Plain — the size can change between two draws when
* the screen rotates, so nothing here is worked out once and kept.
*/
export function drawSelect(surface: BeMusicSurface<'2d'>, frame: BeMusicSelectFrame): void {
const { context: ctx, width, height } = surface;
const portrait = resolveStageOrientation(surface) === 'portrait';
ctx.fillStyle = INK;
ctx.fillRect(0, 0, width, height);
text(ctx, 'MUSIC SELECT', MARGIN, 24, { size: 14, weight: 800 });
// The player's dan ranks after the heading (`7K 七段 · 14K 初段`), sharing the strip with the folder label.
const danRanks = describeDanRanks(frame.danRanks);
const headerW = width - MARGIN * 2 - 140;
if (danRanks !== '') {
text(ctx, 'DAN', MARGIN + 132, 24, { size: 9, weight: 800, color: MUTED });
text(ctx, danRanks, MARGIN + 158, 24, { size: 11, weight: 800, maxWidth: headerW / 2 - 26, nowMs: frame.nowMs });
}
text(ctx, frame.folderLabel ?? `${frame.totalCharts} charts`, width - MARGIN, 24, {
size: 11,
color: MUTED,
align: 'right',
maxWidth: danRanks !== '' ? headerW / 2 - 8 : headerW,
nowMs: frame.nowMs,
});
if (portrait) {
drawPortraitCard(ctx, frame, width);
drawList(ctx, frame, width, PORTRAIT_SELECT_LAYOUT, drawPortraitRow);
} else {
drawFocusedSong(ctx, frame);
drawList(ctx, frame, width, SELECT_LAYOUT, drawRow);
}
// The search box, in the strip under the list (`listBottomInset` keeps it free). Clicking it starts typing there;
// while the player types, the host's field sits over it and shows the text.
const searchY = portrait ? PORTRAIT_SELECT_LAYOUT.listTop - 26 : 68;
const searchX = portrait ? MARGIN : SELECT_LAYOUT.listX;
const searchW = width - MARGIN - searchX;
ctx.strokeStyle = LINE;
ctx.lineWidth = 1;
ctx.strokeRect(searchX + 0.5, searchY - 17.5, searchW - 1, 35);
text(ctx, 'SEARCH', searchX + 8, searchY, { size: 9, weight: 800, color: MUTED });
if (!frame.searchEditing) {
text(ctx, frame.searchQuery || 'Title / artist / genre', searchX + 60, searchY, {
size: 11,
color: frame.searchQuery ? TEXT : MUTED,
maxWidth: searchW - 68,
});
}
frame.hit(searchX + 56, searchY - 18, searchW - 56, 36, frame.actions.activateSearch, 'text');
// After a pick, darken the screen over the outro.
if (frame.launchAt !== undefined) {
const t = Math.min(1, (frame.nowMs - frame.launchAt) / SELECT_OUTRO_MS);
ctx.fillStyle = `rgba(0, 0, 0, ${t})`;
ctx.fillRect(0, 0, width, height);
}
}
/** The left card: title, artist, the chart's key facts, the PLAY / AUTO buttons, and README at its top right. */
function drawFocusedSong(ctx: CanvasRenderingContext2D, frame: BeMusicSelectFrame): void {
const chartEntry = frame.focusedChart;
const x = MARGIN;
const y = 56;
ctx.fillStyle = PANEL;
ctx.fillRect(x, y, PANEL_W, PANEL_H);
if (!chartEntry) {
if (frame.focusedCourse !== undefined) {
drawCourse(ctx, frame, frame.focusedCourse, x + 16, y, PANEL_W - 32);
drawCardButtons(ctx, frame, x, y);
return;
}
text(ctx, 'Pick a folder', x + 16, y + 28, { size: 14, color: MUTED });
return;
}
// Genre, title, artist — the order every built-in skin uses.
const { nowMs } = frame;
const lift = chartEntry.genre ? 12 : 0;
const textW = PANEL_W - 32;
// README at the top right, on the genre line: the first line keeps clear of it.
const chipW = README_CHIP.w + 8;
readmeChip(ctx, frame, { x: x + PANEL_W - 16 - README_CHIP.w, y: y + 13, ...README_CHIP });
if (chartEntry.genre)
text(ctx, chartEntry.genre, x + 16, y + 22, { size: 10, color: MUTED, maxWidth: textW - chipW, nowMs });
const titleW = chartEntry.genre ? textW : textW - chipW;
text(ctx, chartEntry.title, x + 16, y + 28 + lift, { size: 18, weight: 800, maxWidth: titleW, nowMs });
text(ctx, chartEntry.artist ?? '', x + 16, y + 52 + lift, { size: 11, color: MUTED, maxWidth: textW, nowMs });
// Three columns of facts; each value keeps to its column (a wide BPM range or gimmick list scrolls).
const facts = resolveChartRowFacts(chartEntry);
const narrow = { maxWidth: 86, nowMs };
const wide = { maxWidth: 84, nowMs };
stat(ctx, 'MODE', formatPlayVariantLabel(chartEntry), x + 16, y + 92, narrow);
stat(ctx, 'LEVEL', String(chartEntry.playLevel ?? '-'), x + 110, y + 92, { maxWidth: 72, nowMs });
stat(ctx, 'BPM', facts.bpm, x + 190, y + 92, wide);
stat(ctx, 'NOTES', facts.notes, x + 16, y + 140, narrow);
stat(ctx, 'LENGTH', facts.length, x + 110, y + 140, { maxWidth: 72, nowMs });
stat(ctx, 'GIMMICKS', facts.tags.join(' ') || '-', x + 190, y + 140, wide);
// The judge rank (#RANK / #DEFEXRANK) on a third row, beside the player's best DJ Rank and lamp; their EX score and
// rate, BP and play count on a fourth.
stat(ctx, 'JUDGE', resolveChartStats(chartEntry).judgeRank, x + 16, y + 188, narrow);
const record = describeBestRecord(frame.chartBestRecord(chartEntry), chartEntry.totalNotes);
stat(ctx, 'RANK', record?.rank ?? '-', x + 110, y + 188, { maxWidth: 72, nowMs });
// A touch wider than the column, so FULL COMBO fits squeezed instead of scrolling.
lampStat(ctx, frame, record, x + 190, y + 188, { maxWidth: 88, nowMs });
stat(ctx, 'EX SCORE', describeExScore(record), x + 16, y + 236, narrow);
stat(ctx, 'BP', record?.missCount !== undefined ? String(record.missCount) : '-', x + 110, y + 236, {
maxWidth: 72,
nowMs,
});
stat(ctx, 'PLAYS', String(record?.playCount ?? 0), x + 190, y + 236, wide);
drawCardButtons(ctx, frame, x, y);
}
/** PLAY and AUTO along the foot of the landscape card at (`x`, `y`). */
function drawCardButtons(ctx: CanvasRenderingContext2D, frame: BeMusicSelectFrame, x: number, y: number): void {
button(ctx, frame, 'PLAY', x + 16, y + PANEL_H - 64, 160, frame.actions.play, true);
button(ctx, frame, 'AUTO', x + 186, y + PANEL_H - 64, 88, frame.actions.autoPlay, false);
}
/**
* The player's best lamp as a fact (`CLEAR` over `HARD`), in its lamp's colour: FAILED blinks and a full combo
* cycles its hues (`resolveClearLampLight`). `NO PLAY` in grey without a record.
*/
function lampStat(
ctx: CanvasRenderingContext2D,
frame: BeMusicSelectFrame,
record: BestRecordSummary | undefined,
x: number,
y: number,
options: { maxWidth: number; nowMs: number; labelSize?: number },
): void {
text(ctx, 'CLEAR', x, y, { size: options.labelSize ?? 9, color: MUTED, weight: 700 });
const lamp = record?.lamp ?? 'NO_PLAY';
if (lamp === 'NO_PLAY') {
text(ctx, 'NO PLAY', x, y + 16, { size: 16, color: MUTED, maxWidth: options.maxWidth });
return;
}
const light = resolveClearLampLight(lamp, frame.nowMs);
// The alpha goes on `globalAlpha` and back, not through `save` / `restore`, which would undo the font `text` keeps.
const base = ctx.globalAlpha;
ctx.globalAlpha = base * light.alpha;
text(ctx, CLEAR_LAMP_SHORT_LABELS[lamp], x, y + 16, { size: 16, color: css(light.color), ...options });
ctx.globalAlpha = base;
}
/** The best EX score and its rate (`1708 85.40%`), `-` without one. */
function describeExScore(record: BestRecordSummary | undefined): string {
if (record?.exScore === undefined) return '-';
return record.rateLabel !== undefined ? `${record.exScore} ${record.rateLabel}` : String(record.exScore);
}
/** README: a small button that opens the chart's README, muted and without a hit area on a chart that has none. */
function readmeChip(
ctx: CanvasRenderingContext2D,
frame: BeMusicSelectFrame,
rect: { x: number; y: number; w: number; h: number },
): void {
const enabled = frame.hasReadme === true;
ctx.fillStyle = INK;
ctx.fillRect(rect.x, rect.y, rect.w, rect.h);
ctx.strokeStyle = LINE;
ctx.strokeRect(rect.x + 0.5, rect.y + 0.5, rect.w - 1, rect.h - 1);
text(ctx, 'README', rect.x + rect.w / 2, rect.y + rect.h / 2, {
size: 10,
weight: 800,
align: 'center',
...(enabled ? {} : { color: MUTED }),
});
if (enabled) frame.hit(rect.x, rect.y - 4, rect.w, rect.h + 8, frame.actions.toggleReadme);
}
/**
* The portrait card: the same contents as the landscape one, given the stage's width — the track in larger type, the
* facts in three wider columns, and thumb-sized buttons (see {@link resolvePortraitSelectCard}).
*/
function drawPortraitCard(ctx: CanvasRenderingContext2D, frame: BeMusicSelectFrame, width: number): void {
const {
card,
factColumns: [c0, c1, c2],
factWidth,
factRows: [r0, r1, r2],
play,
auto,
readme,
} = resolvePortraitSelectCard(width);
ctx.fillStyle = PANEL;
ctx.fillRect(card.x, card.y, card.w, card.h);
const chartEntry = frame.focusedChart;
const left = card.x + 16;
if (!chartEntry) {
if (frame.focusedCourse !== undefined) {
drawCourse(ctx, frame, frame.focusedCourse, left, card.y, card.w - 32);
button(ctx, frame, 'PLAY', play.x, play.y, play.w, frame.actions.play, true, play.h);
button(ctx, frame, 'AUTO', auto.x, auto.y, auto.w, frame.actions.autoPlay, false, auto.h);
return;
}
text(ctx, 'Pick a folder', left, card.y + 28, { size: 14, color: MUTED });
return;
}
const { nowMs } = frame;
const textW = card.w - 32;
const lift = chartEntry.genre ? 12 : 0;
// README at the top right, on the genre line: the first line keeps clear of it.
const chipW = readme.w + 8;
readmeChip(ctx, frame, readme);
if (chartEntry.genre)
text(ctx, chartEntry.genre, left, card.y + 20, { size: 10, color: MUTED, maxWidth: textW - chipW, nowMs });
const titleW = chartEntry.genre ? textW : textW - chipW;
text(ctx, chartEntry.title, left, card.y + 30 + lift, { size: 20, weight: 800, maxWidth: titleW, nowMs });
// The judge rank (#RANK / #DEFEXRANK) at the end of the artist line: the card has no room for a third row of facts.
const right = card.x + card.w - 16;
const artistY = card.y + 56 + lift;
const judgeRank = resolveChartStats(chartEntry).judgeRank;
text(ctx, judgeRank, right, artistY, { size: 12, weight: 800, align: 'right' });
const judgeWidth = ctx.measureText(judgeRank).width;
text(ctx, 'JUDGE', right - judgeWidth - 6, artistY, { size: 10, color: MUTED, align: 'right' });
const judgeLeft = right - judgeWidth - 6 - ctx.measureText('JUDGE').width;
text(ctx, chartEntry.artist ?? '', left, artistY, {
size: 12,
color: MUTED,
maxWidth: Math.max(40, judgeLeft - left - 12),
nowMs,
});
const facts = resolveChartRowFacts(chartEntry);
const fit = { maxWidth: factWidth, nowMs, labelSize: 10 };
stat(ctx, 'MODE', formatPlayVariantLabel(chartEntry), c0, r0, fit);
stat(ctx, 'LEVEL', String(chartEntry.playLevel ?? '-'), c1, r0, fit);
stat(ctx, 'BPM', facts.bpm, c2, r0, fit);
stat(ctx, 'NOTES', facts.notes, c0, r1, fit);
stat(ctx, 'LENGTH', facts.length, c1, r1, fit);
stat(ctx, 'GIMMICKS', facts.tags.join(' ') || '-', c2, r1, fit);
// The player's best on the chart: lamp, DJ Rank, and the best EX score and its rate.
const record = describeBestRecord(frame.chartBestRecord(chartEntry), chartEntry.totalNotes);
lampStat(ctx, frame, record, c0, r2, fit);
stat(ctx, 'RANK', record?.rank ?? '-', c1, r2, fit);
stat(ctx, 'EX SCORE', describeExScore(record), c2, r2, fit);
button(ctx, frame, 'PLAY', play.x, play.y, play.w, frame.actions.play, true, play.h);
button(ctx, frame, 'AUTO', auto.x, auto.y, auto.w, frame.actions.autoPlay, false, auto.h);
}
/** A focused course in place of a song: its name, its kind and stage count, and its stages (as many as fit). */
function drawCourse(
ctx: CanvasRenderingContext2D,
frame: BeMusicSelectFrame,
course: NonNullable<BeMusicSelectFrame['focusedCourse']>,
x: number,
y: number,
width: number,
): void {
const { nowMs } = frame;
const card = describeCourseCard(course, frame.courseBestRecord?.(course));
text(ctx, card.title, x, y + 28, { size: 18, weight: 800, maxWidth: width, nowMs });
text(ctx, card.detail, x, y + 52, { size: 11, color: MUTED, maxWidth: width, nowMs });
card.stages.slice(0, 6).forEach((stage, index) => {
// A stage missing from the collection is drawn faint; a random course's stages are drawn when it starts.
const missing = course.random === undefined && course.stages[index]?.chart === undefined;
text(ctx, `${index + 1}. ${stage}`, x, y + 86 + index * 22, {
size: 12,
maxWidth: width,
nowMs,
...(missing ? { color: MUTED } : {}),
});
});
}
function button(
ctx: CanvasRenderingContext2D,
frame: BeMusicSelectFrame,
label: string,
x: number,
y: number,
w: number,
action: () => void,
primary: boolean,
h = 40,
): void {
ctx.fillStyle = primary ? ACCENT : INK;
ctx.fillRect(x, y, w, h);
ctx.strokeStyle = primary ? ACCENT : LINE;
ctx.strokeRect(x + 0.5, y + 0.5, w - 1, h - 1);
text(ctx, label, x + w / 2, y + h / 2, { size: 14, weight: 800, align: 'center' });
frame.hit(x, y, w, h, action);
}
/** How faint a course that cannot start is drawn in the list. */
const DISABLED_ALPHA = 0.4;
/** Draws one list row, its text centred on `midY`. */
type RowDrawer = (
ctx: CanvasRenderingContext2D,
entry: LibraryEntry,
x: number,
midY: number,
w: number,
nowMs: number | undefined,
) => void;
/**
* The visible window of the list: one row per entry, the selected one highlighted. The rows follow `layout` — the
* same numbers the skin declares, which the host hit-tests taps and clicks with.
*/
function drawList(
ctx: CanvasRenderingContext2D,
frame: BeMusicSelectFrame,
width: number,
layout: BeMusicSelectLayout,
drawEntry: RowDrawer,
): void {
const { listX, listTop, rowHeight } = layout;
const rowW = width - listX - MARGIN;
// Rows follow the list's pull (`frame.listScroll`), fading where they slide past the window's edge.
for (const { entryIndex: index, slot, alpha } of selectListRows(frame, rowHeight)) {
const entry = frame.entries[index]!;
const y = listTop + slot * rowHeight;
const selected = index === frame.selectedIndex;
ctx.save();
ctx.globalAlpha *= alpha;
ctx.fillStyle = selected ? ACCENT : index % 2 === 0 ? PANEL : INK;
ctx.fillRect(listX, y, rowW, rowHeight - 2);
// The best clear lamp as a bar of colour along the row's leading edge, rippling down the list.
const lamp = entryLamp(frame, entry);
if (lamp !== undefined && lamp !== 'NO_PLAY') {
const light = resolveClearLampLight(lamp, frame.nowMs, index * 0.07);
ctx.globalAlpha *= light.alpha;
ctx.fillStyle = css(light.color);
ctx.fillRect(listX, y, 4, rowHeight - 2);
ctx.globalAlpha /= light.alpha || 1;
}
// A course that cannot start (a stage missing) is drawn faint, as a disabled control is.
if (entry.kind === 'course' && !entry.course.playable) ctx.globalAlpha *= DISABLED_ALPHA;
drawEntry(ctx, entry, listX, y + (rowHeight - 2) / 2, rowW, selected ? frame.nowMs : undefined);
ctx.restore();
}
}
function drawRow(
ctx: CanvasRenderingContext2D,
entry: LibraryEntry,
x: number,
midY: number,
w: number,
/** The frame clock on the selected row, whose long texts scroll; other rows just clip theirs. */
nowMs: number | undefined,
): void {
const dim = nowMs !== undefined ? TEXT : MUTED;
if (entry.kind === 'folder') {
text(ctx, `▸ ${entry.folder.label}`, x + 12, midY, { size: 12, weight: 700, maxWidth: w - 120, nowMs });
text(ctx, describeFolderSize(entry.folder), x + w - 12, midY, { size: 11, color: dim, align: 'right' });
return;
}
if (entry.kind === 'course') {
text(ctx, entry.course.definition.name, x + 44, midY, { size: 12, weight: 700, maxWidth: w - 300, nowMs });
text(ctx, describeCourse(entry.course), x + w - 12, midY, { size: 11, color: dim, align: 'right', maxWidth: 236 });
return;
}
const chartEntry = entry.chart;
const facts = resolveChartRowFacts(chartEntry);
text(ctx, String(chartEntry.playLevel ?? '-'), x + 22, midY, { size: 12, weight: 800, align: 'center' });
text(ctx, chartEntry.title, x + 44, midY, { size: 12, weight: 700, maxWidth: w - 300, nowMs });
text(ctx, `${facts.notes} NOTES ${facts.length} ${facts.bpm} BPM`, x + w - 12, midY, {
size: 11,
color: dim,
align: 'right',
maxWidth: 236,
nowMs,
});
}
/**
* A portrait row: too narrow for the landscape row's one line, so the title takes a line of its own and the facts go
* under it, both beside the level.
*/
function drawPortraitRow(
ctx: CanvasRenderingContext2D,
entry: LibraryEntry,
x: number,
midY: number,
w: number,
nowMs: number | undefined,
): void {
const dim = nowMs !== undefined ? TEXT : MUTED;
const textW = w - 56;
if (entry.kind === 'folder') {
text(ctx, `▸ ${entry.folder.label}`, x + 12, midY - 8, { size: 13, weight: 700, maxWidth: w - 24, nowMs });
text(ctx, describeFolderSize(entry.folder), x + 12, midY + 9, { size: 10, color: dim });
return;
}
if (entry.kind === 'course') {
text(ctx, entry.course.definition.name, x + 44, midY - 8, { size: 13, weight: 700, maxWidth: textW, nowMs });
text(ctx, describeCourse(entry.course), x + 44, midY + 9, { size: 10, color: dim, maxWidth: textW });
return;
}
const chartEntry = entry.chart;
const facts = resolveChartRowFacts(chartEntry);
text(ctx, String(chartEntry.playLevel ?? '-'), x + 22, midY, { size: 13, weight: 800, align: 'center' });
text(ctx, chartEntry.title, x + 44, midY - 8, { size: 13, weight: 700, maxWidth: textW, nowMs });
text(ctx, `${facts.notes} NOTES ${facts.length} ${facts.bpm} BPM`, x + 44, midY + 9, {
size: 10,
color: dim,
maxWidth: textW,
nowMs,
});
}
/** The player's best lamp on a bar's chart or course, when the host keeps one. */
function entryLamp(frame: BeMusicSelectFrame, entry: LibraryEntry): BestRecordSummary['lamp'] | undefined {
if (entry.kind === 'chart') return frame.chartBestRecord(entry.chart)?.lamp;
if (entry.kind === 'course') return frame.courseBestRecord?.(entry.course)?.lamp;
return undefined;
}
/** A folder bar's size: its charts, or its courses for a course folder. */
function describeFolderSize(folder: LibraryFolder): string {
return folder.courses !== undefined ? `${folder.courses.length} courses` : `${folder.charts.length} charts`;
}
/** A course bar's facts: its kind, its stage count, and how many stages are missing from the collection. */
function describeCourse(course: LibraryCourse): string {
const missing = course.stages.filter((stage) => stage.chart === undefined).length;
const kind = course.definition.kind === 'grade' ? 'DAN' : course.definition.kind.toUpperCase();
return `${kind} ${course.stages.length} STAGES${missing > 0 ? ` ${missing} MISSING` : ''}`;
}
|