functionByTritoneCard function

TheoryCard functionByTritoneCard(
  1. TheoryDraw draw
)

"Este acorde tem o 4º grau, o 7º ou os dois (o trítono)? Qual a função?". Só entram os acordes em que a regra decide: os que têm o trítono, os que têm só a 4ª, e os que não têm nem a 4ª nem a 7ª (o Imaj7 e o V sem sétima têm a 7ª sozinha, e ficam de fora).

Implementation

TheoryCard functionByTritoneCard(TheoryDraw draw) {
  const forms = ['I', 'ii7', 'IV', 'vi', 'V7', 'vii°'];
  final tonic = draw.tonic;
  final fits = [
    for (final form in forms)
      if (_hasTritoneRule(degreeChord(form, tonic), tonic)) form,
  ];
  final form = fits[draw.rng.nextInt(fits.length)];
  final chord = degreeChord(form, tonic);
  final word = _functionWord(chord.pitchClasses, tonic);
  final choice = choices(
    textOption(word, word),
    const [],
    _functionOptions(),
    draw.rng,
  );
  return TheoryCard(
    prompt:
        'Este acorde («0» em ${tonicName(tonic)}) tem o 4º grau, o 7º ou os '
        'dois (o trítono)? Qual é a função?',
    explanation: '${_hotDegreesOf(chord, tonic)} Logo, é $word.',
    chords: [chord],
    options: choice.options,
    correct: choice.correct,
  );
}