39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
import 'package:pokedex/filters.dart';
|
|
import 'package:pokedex/pokemon.dart';
|
|
|
|
class SessionData {
|
|
static bool darkMode = false;
|
|
static int highest = 9;
|
|
static int _cachedHighest = -1;
|
|
|
|
static void resetHighestGenCache() {
|
|
_cachedHighest = -1;
|
|
}
|
|
|
|
static int highestGenID() {
|
|
if (_cachedHighest != -1) return _cachedHighest;
|
|
List<Generation> gens = [];
|
|
|
|
if (highest >= 9) gens.add(Generation.Nine);
|
|
if (highest >= 8) gens.add(Generation.Eight);
|
|
if (highest >= 7) gens.add(Generation.Seven);
|
|
if (highest >= 6) gens.add(Generation.Six);
|
|
if (highest >= 5) gens.add(Generation.Five);
|
|
if (highest >= 4) gens.add(Generation.Four);
|
|
if (highest >= 3) gens.add(Generation.Three);
|
|
if (highest >= 2) gens.add(Generation.Two);
|
|
if (highest >= 1) gens.add(Generation.One);
|
|
|
|
int max = 0;
|
|
// Iterate over the list, and get the count of all pokemon from a specific generation
|
|
for (var gen in gens) {
|
|
for (var pokemon in Pokemon.values) {
|
|
if (pokemon.generation == gen) max++;
|
|
}
|
|
}
|
|
|
|
_cachedHighest = max;
|
|
|
|
return max;
|
|
}
|
|
}
|