Skip to content

Commit

Permalink
fix: in create sections the collided words and the sections of answer (
Browse files Browse the repository at this point in the history
  • Loading branch information
AyadLaouissi authored May 2, 2024
1 parent 37a2e13 commit ae520d1
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions packages/board_generator/lib/create_sections.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ void main(List<String> args) async {

// Answers
for (final word in sectionWords) {
// The word is already added
if (answers.indexWhere((answer) => answer.answer == word.answer) > -1) {
continue;
}

final allLetters = word.allLetters;

final sectionsPoint = word.getSections(sectionX, sectionY, sectionSize);
Expand Down Expand Up @@ -184,14 +179,28 @@ void main(List<String> args) async {
}
}

answers.add(
Answer(
final index = answers.indexWhere((answer) => answer.id == word.id);

if (index > -1) {
answers[index] = Answer(
id: word.id,
answer: answersMap[word.id]!,
sections: sectionsPoint,
collidedWords: collidedWords,
),
);
sections: wordsSections[word]!,
collidedWords: {
...answers[index].collidedWords,
...collidedWords,
}.toList(),
);
} else {
answers.add(
Answer(
id: word.id,
answer: answersMap[word.id]!,
sections: wordsSections[word]!,
collidedWords: collidedWords,
),
);
}
}
}
}
Expand Down

0 comments on commit ae520d1

Please sign in to comment.