返回提交历史
Modified
src/controllers/api/entratiLabConquestModeController.ts
+3
-22
Modified
src/services/inventoryService.ts
+23
-0
Modified
src/services/missionInventoryUpdateService.ts
+24
-9
XFEstudio/SpaceNinjaServer
feat: consume search pulse for doing netracells (#2675)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2675 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
03b8b610
代码差异
3 个文件
+50
-31
@@ -1,6 +1,6 @@
1
1
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
2
2
import { getJSONfromString } from "@/src/helpers/stringHelpers";
3
import { getInventory } from "@/src/services/inventoryService";
3
import { getInventory, updateEntratiVault } from "@/src/services/inventoryService";
4
4
import { getAccountIdForRequest } from "@/src/services/loginService";
5
5
import { RequestHandler } from "express";
6
6
@@ -11,26 +11,7 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res)
11
11
"EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission"
12
12
);
13
13
const body = getJSONfromString<IEntratiLabConquestModeRequest>(String(req.body));
14
if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) {
15
const EPOCH = 1734307200 * 1000; // Mondays, amirite?
16
const day = Math.trunc((Date.now() - EPOCH) / 86400000);
17
const week = Math.trunc(day / 7);
18
const weekStart = EPOCH + week * 604800000;
19
const weekEnd = weekStart + 604800000;
20
inventory.EntratiVaultCountLastPeriod = 0;
21
inventory.EntratiVaultCountResetDate = new Date(weekEnd);
22
if (inventory.EntratiLabConquestUnlocked) {
23
inventory.EntratiLabConquestUnlocked = 0;
24
inventory.EntratiLabConquestCacheScoreMission = 0;
25
inventory.EntratiLabConquestActiveFrameVariants = [];
26
}
27
if (inventory.EchoesHexConquestUnlocked) {
28
inventory.EchoesHexConquestUnlocked = 0;
29
inventory.EchoesHexConquestCacheScoreMission = 0;
30
inventory.EchoesHexConquestActiveFrameVariants = [];
31
inventory.EchoesHexConquestActiveStickers = [];
32
}
33
}
14
updateEntratiVault(inventory);
34
15
if (body.BuyMode) {
35
16
inventory.EntratiVaultCountLastPeriod! += 2;
36
17
if (body.IsEchoesDeepArchemedea) {
@@ -51,7 +32,7 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res)
51
32
}
52
33
await inventory.save();
53
34
res.json({
54
EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate),
35
EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate!),
55
36
EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod,
56
37
EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked,
57
38
EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission,
@@ -2449,3 +2449,26 @@ export const giveNemesisPetRecipe = (
2449
2449
export const getEffectiveAvatarImageType = (inventory: TInventoryDatabaseDocument): string => {
2450
2450
return inventory.ActiveAvatarImageType ?? "/Lotus/Types/StoreItems/AvatarImages/AvatarImageDefault";
2451
2451
};
2452
2453
export const updateEntratiVault = (inventory: TInventoryDatabaseDocument): void => {
2454
if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) {
2455
const EPOCH = 1734307200 * 1000; // Mondays, amirite?
2456
const day = Math.trunc((Date.now() - EPOCH) / 86400000);
2457
const week = Math.trunc(day / 7);
2458
const weekStart = EPOCH + week * 604800000;
2459
const weekEnd = weekStart + 604800000;
2460
inventory.EntratiVaultCountLastPeriod = 0;
2461
inventory.EntratiVaultCountResetDate = new Date(weekEnd);
2462
if (inventory.EntratiLabConquestUnlocked) {
2463
inventory.EntratiLabConquestUnlocked = 0;
2464
inventory.EntratiLabConquestCacheScoreMission = 0;
2465
inventory.EntratiLabConquestActiveFrameVariants = [];
2466
}
2467
if (inventory.EchoesHexConquestUnlocked) {
2468
inventory.EchoesHexConquestUnlocked = 0;
2469
inventory.EchoesHexConquestCacheScoreMission = 0;
2470
inventory.EchoesHexConquestActiveFrameVariants = [];
2471
inventory.EchoesHexConquestActiveStickers = [];
2472
}
2473
}
2474
};
@@ -39,6 +39,7 @@ import {
39
39
giveNemesisPetRecipe,
40
40
giveNemesisWeaponRecipe,
41
41
updateCurrency,
42
updateEntratiVault,
42
43
updateSyndicate
43
44
} from "@/src/services/inventoryService";
44
45
import { updateQuestKey } from "@/src/services/questService";
@@ -1084,6 +1085,22 @@ const droptableAliases: Record<string, string> = {
1084
1085
"/Lotus/Types/DropTables/WF1999DropTables/LasrianTankHardModeDropTable"
1085
1086
};
1086
1087
1088
const isEligibleForCreditReward = (rewardInfo: IRewardInfo, missions: IMission, node: IRegion): boolean => {
1089
// (E)SO should not give credits for only completing zone 1, in which case it has no rewardQualifications (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/1823)
1090
if (getRotations(rewardInfo).length == 0) {
1091
return missions.Tag == "SolNode720"; // Netracells don't use rewardQualifications but probably should give credits anyway
1092
}
1093
// The rest here might not be needed anymore, but just to be sure we don't give undue credits...
1094
return (
1095
node.missionIndex != 23 && // junction
1096
node.missionIndex != 28 && // open world
1097
missions.Tag != "SolNode761" && // the index
1098
missions.Tag != "SolNode762" && // the index
1099
missions.Tag != "SolNode763" && // the index
1100
missions.Tag != "CrewBattleNode556" // free flight
1101
);
1102
};
1103
1087
1104
//TODO: return type of partial missioninventoryupdate response
1088
1105
export const addMissionRewards = async (
1089
1106
account: TAccountDocument,
@@ -1176,15 +1193,7 @@ export const addMissionRewards = async (
1176
1193
const node = ExportRegions[missions.Tag];
1177
1194
1178
1195
//node based credit rewards for mission completion
1179
if (
1180
node.missionIndex != 23 && // junction
1181
node.missionIndex != 28 && // open world
1182
missions.Tag != "SolNode761" && // the index
1183
missions.Tag != "SolNode762" && // the index
1184
missions.Tag != "SolNode763" && // the index
1185
missions.Tag != "CrewBattleNode556" && // free flight
1186
getRotations(rewardInfo).length > 0 // (E)SO should not give credits for only completing zone 1, in which case it has no rewardQualifications (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/1823)
1187
) {
1196
if (isEligibleForCreditReward(rewardInfo, missions, node)) {
1188
1197
const levelCreditReward = getLevelCreditRewards(node);
1189
1198
missionCompletionCredits += levelCreditReward;
1190
1199
logger.debug(`levelCreditReward ${levelCreditReward}`);
@@ -1214,6 +1223,12 @@ export const addMissionRewards = async (
1214
1223
}
1215
1224
]);
1216
1225
}
1226
1227
// Consume netracells search pulse. Moved here to only cover successful completions. Discussed in https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2673
1228
if (missions.Tag == "SolNode720") {
1229
updateEntratiVault(inventory);
1230
inventory.EntratiVaultCountLastPeriod! += 1;
1231
}
1217
1232
}
1218
1233
1219
1234
if (rewardInfo.useVaultManifest) {