返回提交历史
Modified
src/controllers/api/completeCalendarEventController.ts
+16
-20
Modified
src/services/inventoryService.ts
+20
-0
Modified
src/services/missionInventoryUpdateService.ts
+15
-7
XFEstudio/SpaceNinjaServer
fix: use shared count for calendar day indecies (#2265)
I'm not sure if this was always this way and I was just really confused when I initially implemented this, or if this was changed in a later version, but at least now it seems to be tracking everything correctly for 38.6.0. Closes #2264 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2265 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
444c92f0
代码差异
3 个文件
+51
-27
@@ -1,4 +1,4 @@
1
import { getCalendarProgress, getInventory } from "@/src/services/inventoryService";
1
import { checkCalendarChallengeCompletion, getCalendarProgress, getInventory } from "@/src/services/inventoryService";
2
2
import { getAccountIdForRequest } from "@/src/services/loginService";
3
3
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
4
4
import { getWorldState } from "@/src/services/worldStateService";
@@ -12,27 +12,23 @@ export const completeCalendarEventController: RequestHandler = async (req, res)
12
12
const calendarProgress = getCalendarProgress(inventory);
13
13
const currentSeason = getWorldState().KnownCalendarSeasons[0];
14
14
let inventoryChanges: IInventoryChanges = {};
15
let dayIndex = 0;
16
for (const day of currentSeason.Days) {
17
if (day.events.length == 0 || day.events[0].type != "CET_CHALLENGE") {
18
if (dayIndex == calendarProgress.SeasonProgress.LastCompletedDayIdx) {
19
if (day.events.length != 0) {
20
const selection = day.events[parseInt(req.query.CompletedEventIdx as string)];
21
if (selection.type == "CET_REWARD") {
22
inventoryChanges = (await handleStoreItemAcquisition(selection.reward!, inventory))
23
.InventoryChanges;
24
} else if (selection.type == "CET_UPGRADE") {
25
calendarProgress.YearProgress.Upgrades.push(selection.upgrade!);
26
} else if (selection.type != "CET_PLOT") {
27
throw new Error(`unexpected selection type: ${selection.type}`);
28
}
29
}
30
break;
31
}
32
++dayIndex;
15
const dayIndex = calendarProgress.SeasonProgress.LastCompletedDayIdx + 1;
16
const day = currentSeason.Days[dayIndex];
17
if (day.events.length != 0) {
18
if (day.events[0].type == "CET_CHALLENGE") {
19
throw new Error(`completeCalendarEvent should not be used for challenges`);
20
}
21
const selection = day.events[parseInt(req.query.CompletedEventIdx as string)];
22
if (selection.type == "CET_REWARD") {
23
inventoryChanges = (await handleStoreItemAcquisition(selection.reward!, inventory)).InventoryChanges;
24
} else if (selection.type == "CET_UPGRADE") {
25
calendarProgress.YearProgress.Upgrades.push(selection.upgrade!);
26
} else if (selection.type != "CET_PLOT") {
27
throw new Error(`unexpected selection type: ${selection.type}`);
33
28
}
34
29
}
35
calendarProgress.SeasonProgress.LastCompletedDayIdx++;
30
calendarProgress.SeasonProgress.LastCompletedDayIdx = dayIndex;
31
checkCalendarChallengeCompletion(calendarProgress, currentSeason);
36
32
await inventory.save();
37
33
res.json({
38
34
InventoryChanges: inventoryChanges,
@@ -84,9 +84,11 @@ import { getRandomElement, getRandomInt, getRandomWeightedReward, SRng } from ".
84
84
import { createMessage } from "./inboxService";
85
85
import { getMaxStanding, getMinStanding } from "@/src/helpers/syndicateStandingHelper";
86
86
import { getNightwaveSyndicateTag, getWorldState } from "./worldStateService";
87
import { ICalendarSeason } from "@/src/types/worldStateTypes";
87
88
import { generateNemesisProfile, INemesisProfile } from "../helpers/nemesisHelpers";
88
89
import { TAccountDocument } from "./loginService";
89
90
import { unixTimesInMs } from "../constants/timeConstants";
91
import { addString } from "../helpers/stringHelpers";
90
92
91
93
export const createInventory = async (
92
94
accountOwnerId: Types.ObjectId,
@@ -1783,6 +1785,10 @@ export const addChallenges = (
1783
1785
} else {
1784
1786
inventory.ChallengeProgress.push({ Name, Progress });
1785
1787
}
1788
1789
if (Name.startsWith("Calendar")) {
1790
addString(getCalendarProgress(inventory).SeasonProgress.ActivatedChallenges, Name);
1791
}
1786
1792
});
1787
1793
1788
1794
const affiliationMods: IAffiliationMods[] = [];
@@ -2029,6 +2035,20 @@ export const getCalendarProgress = (inventory: TInventoryDatabaseDocument): ICal
2029
2035
return inventory.CalendarProgress;
2030
2036
};
2031
2037
2038
export const checkCalendarChallengeCompletion = (
2039
calendarProgress: ICalendarProgress,
2040
currentSeason: ICalendarSeason
2041
): void => {
2042
const dayIndex = calendarProgress.SeasonProgress.LastCompletedDayIdx + 1;
2043
if (calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx >= dayIndex) {
2044
const day = currentSeason.Days[dayIndex];
2045
if (day.events.length != 0 && day.events[0].type == "CET_CHALLENGE") {
2046
//logger.debug(`already completed the challenge, skipping ahead`);
2047
calendarProgress.SeasonProgress.LastCompletedDayIdx++;
2048
}
2049
}
2050
};
2051
2032
2052
export const giveNemesisWeaponRecipe = (
2033
2053
inventory: TInventoryDatabaseDocument,
2034
2054
weaponType: string,
@@ -33,6 +33,7 @@ import {
33
33
addSkin,
34
34
addStanding,
35
35
applyClientEquipmentUpdates,
36
checkCalendarChallengeCompletion,
36
37
combineInventoryChanges,
37
38
generateRewardSeed,
38
39
getCalendarProgress,
@@ -67,7 +68,15 @@ import {
67
68
} from "@/src/helpers/nemesisHelpers";
68
69
import { Loadout } from "../models/inventoryModels/loadoutModel";
69
70
import { ILoadoutConfigDatabase } from "../types/saveLoadoutTypes";
70
import { getLiteSortie, getSortie, idToBountyCycle, idToDay, idToWeek, pushClassicBounties } from "./worldStateService";
71
import {
72
getLiteSortie,
73
getSortie,
74
getWorldState,
75
idToBountyCycle,
76
idToDay,
77
idToWeek,
78
pushClassicBounties
79
} from "./worldStateService";
71
80
import { config } from "./configService";
72
81
import libraryDailyTasks from "@/static/fixed_responses/libraryDailyTasks.json";
73
82
import { ISyndicateMissionInfo } from "../types/worldStateTypes";
@@ -620,12 +629,11 @@ export const addMissionInventoryUpdates = async (
620
629
}
621
630
case "CalendarProgress": {
622
631
const calendarProgress = getCalendarProgress(inventory);
623
for (const progress of value) {
624
const challengeName = progress.challenge.substring(progress.challenge.lastIndexOf("/") + 1);
625
calendarProgress.SeasonProgress.LastCompletedDayIdx++;
626
calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx++;
627
calendarProgress.SeasonProgress.ActivatedChallenges.push(challengeName);
628
}
632
const currentSeason = getWorldState().KnownCalendarSeasons[0];
633
calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx = currentSeason.Days.findIndex(
634
x => x.events[0].challenge == value[value.length - 1].challenge
635
);
636
checkCalendarChallengeCompletion(calendarProgress, currentSeason);
629
637
break;
630
638
}
631
639
case "duviriCaveOffers": {