Skip to content

Commit

Permalink
Fix item stat didn't respect priority
Browse files Browse the repository at this point in the history
  • Loading branch information
narumi147 committed Aug 14, 2024
1 parent cc0b5dc commit 33425bd
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions lib/app/modules/statistics/item_stat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@ class _ItemStatTabState extends State<ItemStatTab> {
shownItems.clear();
final emptyPlan = SvtStatus();
emptyPlan.cur.favorite = true;
db.curUser.servants.forEach((no, svtStat) {
if (!svtStat.favorite) return;
if (!db.gameData.servantsWithDup.containsKey(no)) {
print('No $no: ${db.gameData.servantsWithDup.length}');
return;
for (final (collectionNo, svtStat) in db.curUser.servants.items) {
if (!svtStat.favorite) continue;
if (!db.settings.filters.svtFilterData.priority.matchOne(svtStat.priority)) continue;
final svt = db.gameData.servantsWithDup[collectionNo];
if (svt == null) {
print('No $collectionNo: ${db.gameData.servantsWithDup.length}');
continue;
}
final svt = db.gameData.servantsWithDup[no]!;
final detail = db.itemCenter.calcOneSvt(svt, emptyPlan.cur, svtStat.cur);
Maths.sumDict(
[
Expand All @@ -172,30 +173,29 @@ class _ItemStatTabState extends State<ItemStatTab> {
],
inPlace: true,
);
});
}
if (svtParts.contain(4)) {
shownItems.addDict(db.itemCenter.calcClassBoardCostAll(SvtMatCostDetailType.consumed));
}

Maths.sumDict([shownItems, if (includeOwnedItems) db.curUser.items], inPlace: true);
shownItems.removeWhere((key, value) {
return value <= 0;
});
shownItems.removeWhere((key, value) => value <= 0);
}

void calculateDemand() {
shownItems.clear();
if (svtParts.options.isEmpty) {
shownItems = Map.of(db.itemCenter.statSvtDemands);
} else {
db.curUser.servants.forEach((no, svtStat) {
if (!svtStat.favorite) return;
final svt = db.gameData.servantsWithDup[no];
for (final (collectionNo, svtStat) in db.curUser.servants.items) {
if (!svtStat.favorite) continue;
final svt = db.gameData.servantsWithDup[collectionNo];
if (svt == null) {
print('No $no: ${db.gameData.servantsWithDup.length}');
return;
print('No $collectionNo: ${db.gameData.servantsWithDup.length}');
continue;
}
final detail = db.itemCenter.calcOneSvt(svt, svtStat.cur, db.curUser.svtPlanOf(no));
if (!db.settings.filters.svtFilterData.priority.matchOne(svtStat.priority)) continue;
final detail = db.itemCenter.calcOneSvt(svt, svtStat.cur, db.curUser.svtPlanOf(collectionNo));
Maths.sumDict(
[
shownItems,
Expand All @@ -206,7 +206,7 @@ class _ItemStatTabState extends State<ItemStatTab> {
],
inPlace: true,
);
});
}
}
if (svtParts.contain(4)) {
shownItems.addDict(db.itemCenter.calcClassBoardCostAll(SvtMatCostDetailType.demands));
Expand All @@ -216,8 +216,6 @@ class _ItemStatTabState extends State<ItemStatTab> {
if (subtractOwnedItems) Maths.multiplyDict(db.curUser.items, -1),
if (subtractEventItems) Maths.multiplyDict(db.itemCenter.statObtain, -1),
], inPlace: true);
shownItems.removeWhere((key, value) {
return value <= 0;
});
shownItems.removeWhere((key, value) => value <= 0);
}
}

0 comments on commit 33425bd

Please sign in to comment.