makeGuess method
void
makeGuess()
Implementation
void makeGuess() {
var newScore = 0;
for (var i = 0; i < pictures.length; i++) {
if (i > 0 && i < pictures.length - 1) {
if (pictures[i].left == pictures[i - 1].name) {
newScore += 1;
}
if (pictures[i].right == pictures[i + 1].name) {
newScore += 1;
}
} else if (i == 0) {
if (pictures[i].right == pictures[i + 1].name) {
newScore += 1;
}
} else if (i == pictures.length - 1) {
if (pictures[i].left == pictures[i - 1].name) {
newScore += 1;
}
}
}
if (picCurrentNum > numberOfTestsPIC) {
pictureTimesList.add(seconds);
pictureScoreList.add(newScore);
pictureMovesList.add(moves);
sWidget.eventLogger.testEnded();
pictureSequenceScore =
sWidget.activity.calculateScore({'pairs': pictureScoreList});
var pictureSequenceResult = RPPictureSequenceResult.fromResults(
pictureMovesList,
pictureScoreList,
pictureTimesList,
memorySecondList,
pictureSequenceScore,
original,
pictures);
sWidget.onResultChange(pictureSequenceResult.results);
if (sWidget.activity.includeResults) {
picTimer?.cancel();
sWidget.eventLogger.resultsShown();
setState(() {
finished = true;
});
} else {
picTimer?.cancel();
sWidget.eventLogger.resultsShown();
setState(() {
finished = true;
});
}
} else {
pictureScoreList.add(seconds);
pictureMovesList.add(moves);
picTimer?.cancel();
resetTest();
}
}