Skip to content

Commit

Permalink
[Infrastructure] Added a getItemAscensionStatsForCharts method
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed May 18, 2022
1 parent 0c16646 commit 59887ac
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/infrastructure/genshin_service.dart
Expand Up @@ -1069,6 +1069,33 @@ class GenshinServiceImpl implements GenshinService {
return charts;
}

@override
List<ChartAscensionStatModel> getItemAscensionStatsForCharts(ItemType itemType) {
if (itemType != ItemType.character && itemType != ItemType.weapon) {
throw Exception('ItemType = $itemType is not Not supported');
}

final stats = itemType == ItemType.character ? getCharacterPossibleAscensionStats() : getWeaponPossibleAscensionStats();
return stats.map(
(stat) {
int count = 0;
switch (itemType) {
case ItemType.character:
count = _charactersFile.characters.where((el) => el.subStatType == stat).length;
break;
case ItemType.weapon:
count = _weaponsFile.weapons.where((el) => el.secondaryStat == stat).length;
break;
default:
throw Exception('ItemType = $itemType is not Not supported');
}

return ChartAscensionStatModel(type: stat, itemType: itemType, quantity: count);
},
).toList()
..sort((x, y) => y.quantity.compareTo(x.quantity));
}

//TODO: CALL THIS METHOD IN THE MAIN PAGE
@override
List<CharacterBirthdayModel> getCharacterBirthdays({int? month, int? day}) {
Expand Down

0 comments on commit 59887ac

Please sign in to comment.