4201 providing emoji options for the game based on vocabulary analytics (#4425)

* update sorting token method to not shuffle

* change linkedhashset to simpler list/set operation
This commit is contained in:
avashilling 2025-10-21 13:19:20 -04:00 committed by GitHub
parent 4d9806f41f
commit 188db715dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -160,18 +160,26 @@ class PracticeSelection {
return [];
}
final List<PangeaToken> activityTokens = [];
//remove duplicates
final seenTexts = <String>{};
tokens.retainWhere((token) => seenTexts.add(token.text.content.toLowerCase()));
if (tokens.length > 8) {
// Remove the last third (floored) of tokens, only greater than 8 items so at least 5 remain
final int removeCount = (tokens.length / 3).floor();
final int keepCount = tokens.length - removeCount;
tokens.removeRange(keepCount, tokens.length);
}
//shuffle leftover list so if there are enough, each activity gets different tokens
tokens.shuffle();
final List<PangeaToken> activityTokens = [];
for (final t in tokens) {
if (activityTokens.length >= _maxQueueLength) {
break;
}
if (!activityTokens.any(
(token) =>
token.text.content.toLowerCase() == t.text.content.toLowerCase(),
)) {
activityTokens.add(t);
}
activityTokens.add(t);
}
return [