返回提交历史
Modified
src/controllers/api/updateChallengeProgressController.ts
+11
-2
Modified
src/services/inventoryService.ts
+9
-0
Modified
src/services/missionInventoryUpdateService.ts
+3
-9
XFEstudio/SpaceNinjaServer
chore: handle CalendarProgress in updateChallengeProgress
4acd87aa
代码差异
3 个文件
+23
-11
@@ -1,7 +1,7 @@
1
1
import { RequestHandler } from "express";
2
2
import { getJSONfromString } from "@/src/helpers/stringHelpers";
3
3
import { getAccountForRequest } from "@/src/services/loginService";
4
import { addChallenges, getInventory } from "@/src/services/inventoryService";
4
import { addCalendarProgress, addChallenges, getInventory } from "@/src/services/inventoryService";
5
5
import { IChallengeProgress, ISeasonChallenge } from "@/src/types/inventoryTypes/inventoryTypes";
6
6
import { IAffiliationMods } from "@/src/types/purchaseTypes";
7
7
import { getEntriesUnsafe } from "@/src/utils/ts-utils";
@@ -25,13 +25,17 @@ export const updateChallengeProgressController: RequestHandler = async (req, res
25
25
);
26
26
}
27
27
for (const [key, value] of getEntriesUnsafe(challenges)) {
28
if (value === undefined) {
29
logger.error(`Challenge progress update key ${key} has no value`);
30
continue;
31
}
28
32
switch (key) {
29
33
case "ChallengesFixVersion":
30
34
inventory.ChallengesFixVersion = value;
31
35
break;
32
36
33
37
case "SeasonChallengeHistory":
34
value!.forEach(({ challenge, id }) => {
38
value.forEach(({ challenge, id }) => {
35
39
const itemIndex = inventory.SeasonChallengeHistory.findIndex(i => i.challenge === challenge);
36
40
if (itemIndex !== -1) {
37
41
inventory.SeasonChallengeHistory[itemIndex].id = id;
@@ -41,6 +45,10 @@ export const updateChallengeProgressController: RequestHandler = async (req, res
41
45
});
42
46
break;
43
47
48
case "CalendarProgress":
49
addCalendarProgress(inventory, value);
50
break;
51
44
52
case "ChallengeProgress":
45
53
case "SeasonChallengeCompletions":
46
54
case "ChallengePTS":
@@ -63,5 +71,6 @@ interface IUpdateChallengeProgressRequest {
63
71
ChallengeProgress?: IChallengeProgress[];
64
72
SeasonChallengeHistory?: ISeasonChallenge[];
65
73
SeasonChallengeCompletions?: ISeasonChallenge[];
74
CalendarProgress?: { challenge: string }[];
66
75
crossPlaySetting?: string;
67
76
}
@@ -1832,6 +1832,15 @@ export const addChallenges = (
1832
1832
return affiliationMods;
1833
1833
};
1834
1834
1835
export const addCalendarProgress = (inventory: TInventoryDatabaseDocument, value: { challenge: string }[]): void => {
1836
const calendarProgress = getCalendarProgress(inventory);
1837
const currentSeason = getWorldState().KnownCalendarSeasons[0];
1838
calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx = currentSeason.Days.findIndex(
1839
day => day.events.length != 0 && day.events[0].challenge == value[value.length - 1].challenge
1840
);
1841
checkCalendarChallengeCompletion(calendarProgress, currentSeason);
1842
};
1843
1835
1844
export const addMissionComplete = (inventory: TInventoryDatabaseDocument, { Tag, Completes, Tier }: IMission): void => {
1836
1845
const { Missions } = inventory;
1837
1846
const itemIndex = Missions.findIndex(item => item.Tag === Tag);
@@ -14,6 +14,7 @@ import { IRngResult, SRng, getRandomElement, getRandomReward } from "@/src/servi
14
14
import { equipmentKeys, IMission, ITypeCount, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
15
15
import {
16
16
addBooster,
17
addCalendarProgress,
17
18
addChallenges,
18
19
addConsumables,
19
20
addCrewShipAmmo,
@@ -33,10 +34,8 @@ import {
33
34
addSkin,
34
35
addStanding,
35
36
applyClientEquipmentUpdates,
36
checkCalendarChallengeCompletion,
37
37
combineInventoryChanges,
38
38
generateRewardSeed,
39
getCalendarProgress,
40
39
getDialogue,
41
40
giveNemesisPetRecipe,
42
41
giveNemesisWeaponRecipe,
@@ -235,7 +234,7 @@ export const addMissionInventoryUpdates = async (
235
234
}
236
235
for (const [key, value] of getEntriesUnsafe(inventoryUpdates)) {
237
236
if (value === undefined) {
238
logger.error(`Inventory update key ${key} has no value `);
237
logger.error(`Inventory update key ${key} has no value`);
239
238
continue;
240
239
}
241
240
switch (key) {
@@ -671,12 +670,7 @@ export const addMissionInventoryUpdates = async (
671
670
break;
672
671
}
673
672
case "CalendarProgress": {
674
const calendarProgress = getCalendarProgress(inventory);
675
const currentSeason = getWorldState().KnownCalendarSeasons[0];
676
calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx = currentSeason.Days.findIndex(
677
day => day.events.length != 0 && day.events[0].challenge == value[value.length - 1].challenge
678
);
679
checkCalendarChallengeCompletion(calendarProgress, currentSeason);
673
addCalendarProgress(inventory, value);
680
674
break;
681
675
}
682
676
case "duviriCaveOffers": {