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:
parent
4d9806f41f
commit
188db715dd
1 changed files with 15 additions and 7 deletions
|
|
@ -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 [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue