返回提交历史
Modified
src/controllers/api/inventoryController.ts
+8
-1
Modified
src/services/inventoryService.ts
+20
-0
XFEstudio/SpaceNinjaServer
feat: cleanup some problems in inventories at daily reset (#1767)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1767 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
ad2f143f
代码差异
2 个文件
+28
-1
@@ -14,7 +14,12 @@ import {
14
14
ExportVirtuals
15
15
} from "warframe-public-export-plus";
16
16
import { applyCheatsToInfestedFoundry, handleSubsumeCompletion } from "@/src/services/infestedFoundryService";
17
import { addMiscItems, allDailyAffiliationKeys, createLibraryDailyTask } from "@/src/services/inventoryService";
17
import {
18
addMiscItems,
19
allDailyAffiliationKeys,
20
cleanupInventory,
21
createLibraryDailyTask
22
} from "@/src/services/inventoryService";
18
23
import { logger } from "@/src/utils/logger";
19
24
import { catBreadHash } from "@/src/helpers/stringHelpers";
20
25
@@ -79,6 +84,8 @@ export const inventoryController: RequestHandler = async (request, response) =>
79
84
}
80
85
}
81
86
87
cleanupInventory(inventory);
88
82
89
inventory.NextRefill = new Date((Math.trunc(Date.now() / 86400000) + 1) * 86400000);
83
90
await inventory.save();
84
91
}
@@ -1769,3 +1769,23 @@ export const setupKahlSyndicate = (inventory: TInventoryDatabaseDocument): void
1769
1769
Tag: "KahlSyndicate"
1770
1770
});
1771
1771
};
1772
1773
export const cleanupInventory = (inventory: TInventoryDatabaseDocument): void => {
1774
let index = inventory.MiscItems.findIndex(x => x.ItemType == "");
1775
if (index != -1) {
1776
inventory.MiscItems.splice(index, 1);
1777
}
1778
1779
index = inventory.Affiliations.findIndex(x => x.Tag == "KahlSyndicate");
1780
if (index != -1 && !inventory.Affiliations[index].WeeklyMissions) {
1781
logger.debug(`KahlSyndicate seems broken, removing it and setting up again`);
1782
inventory.Affiliations.splice(index, 1);
1783
setupKahlSyndicate(inventory);
1784
}
1785
1786
const LibrarySyndicate = inventory.Affiliations.find(x => x.Tag == "LibrarySyndicate");
1787
if (LibrarySyndicate && LibrarySyndicate.FreeFavorsEarned) {
1788
logger.debug(`removing FreeFavorsEarned from LibrarySyndicate`);
1789
LibrarySyndicate.FreeFavorsEarned = undefined;
1790
}
1791
};