返回提交历史
Modified
src/controllers/api/inventoryController.ts
+5
-6
XFEstudio/SpaceNinjaServer
chore: avoid using .find multiple times when ticking argon crystals (#4242)
Tho technically we're still using `.find` multiple times indirectly via `addMiscItems`, but that's an improvement for another day, maybe... Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4242 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
c3b8a045
代码差异
1 个文件
+5
-6
@@ -102,13 +102,11 @@ export const inventoryController: RequestHandler = async (request, response) =>
102
102
const lastLoginDay = Math.trunc(inventory.NextRefill.getTime() / 86400000) - 1;
103
103
const daysPassed = today - lastLoginDay;
104
104
105
if (inventory.noArgonCrystalDecay) {
106
inventory.FoundToday = undefined;
107
} else {
105
if (!inventory.noArgonCrystalDecay) {
106
let numArgonCrystals =
107
inventory.MiscItems.find(x => x.ItemType == "/Lotus/Types/Items/MiscItems/ArgonCrystal")
108
?.ItemCount ?? 0;
108
109
for (let i = 0; i != daysPassed; ++i) {
109
const numArgonCrystals =
110
inventory.MiscItems.find(x => x.ItemType == "/Lotus/Types/Items/MiscItems/ArgonCrystal")
111
?.ItemCount ?? 0;
112
110
if (numArgonCrystals == 0) {
113
111
break;
114
112
}
@@ -132,6 +130,7 @@ export const inventoryController: RequestHandler = async (request, response) =>
132
130
ItemCount: numDecayingArgonCrystalsToRemove * -1
133
131
}
134
132
]);
133
numArgonCrystals -= numDecayingArgonCrystalsToRemove;
135
134
// All stable argon crystals are now decaying
136
135
inventory.FoundToday = undefined;
137
136
}