intervalNameCard function

TheoryCard intervalNameCard(
  1. TheoryDraw draw
)

"Que intervalo é este?": duas notas na pauta, e o botão com o nome. Erros: a qualidade trocada (3ª menor por maior) e o intervalo de um semitom.

Implementation

TheoryCard intervalNameCard(TheoryDraw draw) {
  final interval =
      IntervalName.values[draw.rng.nextInt(IntervalName.values.length)];
  final root = _intervalRoot(draw, interval);
  final second = spellAbove(root, _numberSteps(interval), interval.semitones);
  final label = kIntervalLabels[interval]!;
  final choice = choices(
    textOption(interval.wire, label),
    [
      for (final other in [?_partnerOf(interval), ..._neighboursOf(interval)])
        textOption(other.wire, kIntervalLabels[other]!),
    ],
    [
      for (final other in IntervalName.values)
        textOption(other.wire, kIntervalLabels[other]!),
    ],
    draw.rng,
  );
  return TheoryCard(
    prompt: 'Que intervalo é este?',
    explanation: _intervalExplanation(interval, root, second),
    options: choice.options,
    correct: choice.correct,
    score: notesScore([root, second]),
  );
}