degreeChordCard function

TheoryCard degreeChordCard(
  1. TheoryDraw draw
)

"Que acorde é o V7 em Si♭?": a cifra, nos botões (na grafia do app ou do curso). Erros: os acordes dos graus vizinhos (o grau de cima ou o de baixo).

Implementation

TheoryCard degreeChordCard(TheoryDraw draw) {
  final i = draw.rng.nextInt(_degreeChordPool.length);
  final (degree, position) = _degreeChordPool[i];
  final chord = degreeChord(degree, draw.tonic);
  final name = tonicName(draw.tonic);
  final choice = choices(
    chordOption(chord),
    [
      for (final j in [i - 1, i + 1])
        if (j >= 0 && j < _degreeChordPool.length)
          chordOption(_poolChord(j, draw.tonic)),
    ],
    [
      for (var j = 0; j < _degreeChordPool.length; j++)
        chordOption(_poolChord(j, draw.tonic)),
    ],
    draw.rng,
  );
  return TheoryCard(
    prompt: 'Que acorde é o $degree em $name?',
    explanation:
        'O $degree em $name é «0»: o $position.º grau da escala é a fundamental.',
    chords: [chord],
    options: choice.options,
    correct: choice.correct,
  );
}