Skip to content

Commit

Permalink
Updated banner history
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed May 27, 2022
1 parent d8a7ac5 commit 6cbbf95
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 17 deletions.
66 changes: 66 additions & 0 deletions assets/db/banners_history.json
Expand Up @@ -761,6 +761,72 @@
"sacrificial-fragments"
],
"version": 2.5
},
{
"type": "character",
"from": "2022-03-30T00:00:00",
"until": "2022-04-19T00:00:00",
"itemKeys": [
"kamisato-ayato",
"sucrose",
"xiangling",
"yun-jin"
],
"version": 2.6
},
{
"type": "character",
"from": "2022-03-30T00:00:00",
"until": "2022-04-19T00:00:00",
"itemKeys": [
"venti",
"sucrose",
"xiangling",
"yun-jin"
],
"version": 2.6
},
{
"type": "weapon",
"from": "2022-03-30T00:00:00",
"until": "2022-04-19T00:00:00",
"itemKeys": [
"haran-geppaku-futsu",
"elegy-for-the-end",
"the-flute",
"sacrificial-greatsword",
"dragons-bane",
"the-widsith",
"rust"
],
"version": 2.6
},
{
"type": "character",
"from": "2022-04-19T00:00:00",
"until": "2022-05-31T00:00:00",
"itemKeys": [
"kamisato-ayaka",
"razor",
"rosaria",
"sayu"
],
"version": 2.6
},
{
"type": "weapon",
"from": "2022-04-19T00:00:00",
"until": "2022-05-31T00:00:00",
"itemKeys": [
"mistsplitter-reforged",
"the-unforged",
"favonius-sword",
"the-bell",
"favonius-lance",
"favonius-codex",
"favonius-warbow"
],
"version": 2.6
}
]
}
32 changes: 15 additions & 17 deletions lib/infrastructure/genshin_service.dart
Expand Up @@ -1353,23 +1353,21 @@ class GenshinServiceImpl implements GenshinService {
}

List<ChartTopItemModel> _getTopCharts(bool mostReruns, ChartType type, BannerHistoryItemType bannerType, List<ItemCommonWithName> items) {
final grouped = _bannerHistoryFile.banners.where((el) => el.type == bannerType).expand((el) => el.itemKeys).groupListsBy((el) => el).entries;

final selected = <ItemCommonWithQuantity>[];
for (final g in grouped) {
if (mostReruns && selected.isNotEmpty && selected.every((el) => el.quantity > g.value.length)) {
continue;
} else if (!mostReruns && selected.isNotEmpty && selected.every((el) => el.quantity < g.value.length)) {
continue;
}

final element = items.firstWhereOrNull((el) => el.key == g.key);
if (element == null) {
continue;
}

selected.add(ItemCommonWithQuantity(g.key, element.image, g.value.length));
}
final selected = _bannerHistoryFile.banners
.where((el) => el.type == bannerType)
.expand((el) => el.itemKeys)
.groupListsBy((el) => el)
.entries
.map((g) {
final element = items.firstWhereOrNull((el) => el.key == g.key);
if (element == null) {
return null;
}
return ItemCommonWithQuantity(g.key, element.image, g.value.length);
})
.where((el) => el != null)
.map((e) => e!)
.toList();

if (mostReruns) {
selected.sort((x, y) => y.quantity.compareTo(x.quantity));
Expand Down

0 comments on commit 6cbbf95

Please sign in to comment.