返回提交历史
Modified
src/controllers/api/completeCalendarEventController.ts
+2
-2
Modified
src/controllers/api/inventoryController.ts
+54
-49
Modified
src/models/inventoryModels/inventoryModel.ts
+2
-2
Modified
src/services/inventoryService.ts
+36
-8
XFEstudio/XFESpaceNinjaServer
fix: skip birthdays of characters we can't talk to (#2425)
Closes #2424 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2425 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
76e61129
代码差异
4 个文件
+94
-61
@@ -1,4 +1,4 @@
1
import { checkCalendarChallengeCompletion, getCalendarProgress, getInventory } from "@/src/services/inventoryService";
1
import { checkCalendarAutoAdvance, 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";
@@ -28,7 +28,7 @@ export const completeCalendarEventController: RequestHandler = async (req, res)
28
28
}
29
29
}
30
30
calendarProgress.SeasonProgress.LastCompletedDayIdx = dayIndex;
31
checkCalendarChallengeCompletion(calendarProgress, currentSeason);
31
checkCalendarAutoAdvance(inventory, currentSeason);
32
32
await inventory.save();
33
33
res.json({
34
34
InventoryChanges: inventoryChanges,
@@ -12,6 +12,7 @@ import {
12
12
addEmailItem,
13
13
addMiscItems,
14
14
allDailyAffiliationKeys,
15
checkCalendarAutoAdvance,
15
16
cleanupInventory,
16
17
createLibraryDailyTask,
17
18
getCalendarProgress
@@ -29,6 +30,7 @@ import { unixTimesInMs } from "@/src/constants/timeConstants";
29
30
import { DailyDeal } from "@/src/models/worldStateModel";
30
31
import { EquipmentFeatures } from "@/src/types/equipmentTypes";
31
32
import { generateRewardSeed } from "@/src/services/rngService";
33
import { getWorldState } from "@/src/services/worldStateService";
32
34
33
35
export const inventoryController: RequestHandler = async (request, response) => {
34
36
const account = await getAccountForRequest(request);
@@ -111,58 +113,61 @@ export const inventoryController: RequestHandler = async (request, response) =>
111
113
}
112
114
}
113
115
114
if (inventory.CalendarProgress) {
115
const previousYearIteration = inventory.CalendarProgress.Iteration;
116
getCalendarProgress(inventory); // handle year rollover; the client expects to receive an inventory with an up-to-date CalendarProgress
117
118
// also handle sending of kiss cinematic at year rollover
119
if (
120
inventory.CalendarProgress.Iteration != previousYearIteration &&
121
inventory.DialogueHistory &&
122
inventory.DialogueHistory.Dialogues
123
) {
124
let kalymos = false;
125
for (const { dialogueName, kissEmail } of [
126
{
127
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/ArthurDialogue_rom.dialogue",
128
kissEmail: "/Lotus/Types/Items/EmailItems/ArthurKissEmailItem"
129
},
130
{
131
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/EleanorDialogue_rom.dialogue",
132
kissEmail: "/Lotus/Types/Items/EmailItems/EleanorKissEmailItem"
133
},
134
{
135
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/LettieDialogue_rom.dialogue",
136
kissEmail: "/Lotus/Types/Items/EmailItems/LettieKissEmailItem"
137
},
138
{
139
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/JabirDialogue_rom.dialogue",
140
kissEmail: "/Lotus/Types/Items/EmailItems/AmirKissEmailItem"
141
},
142
{
143
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/AoiDialogue_rom.dialogue",
144
kissEmail: "/Lotus/Types/Items/EmailItems/AoiKissEmailItem"
145
},
146
{
147
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/QuincyDialogue_rom.dialogue",
148
kissEmail: "/Lotus/Types/Items/EmailItems/QuincyKissEmailItem"
116
// TODO: Setup CalendarProgress as part of 1999 mission completion?
117
118
const previousYearIteration = inventory.CalendarProgress?.Iteration;
119
120
// We need to do the following to ensure the in-game calendar does not break:
121
getCalendarProgress(inventory); // Keep the CalendarProgress up-to-date (at least for the current year iteration) (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2364)
122
checkCalendarAutoAdvance(inventory, getWorldState().KnownCalendarSeasons[0]); // Skip birthday events for characters if we do not have them unlocked yet (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2424)
123
124
// also handle sending of kiss cinematic at year rollover
125
if (
126
inventory.CalendarProgress!.Iteration != previousYearIteration &&
127
inventory.DialogueHistory &&
128
inventory.DialogueHistory.Dialogues
129
) {
130
let kalymos = false;
131
for (const { dialogueName, kissEmail } of [
132
{
133
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/ArthurDialogue_rom.dialogue",
134
kissEmail: "/Lotus/Types/Items/EmailItems/ArthurKissEmailItem"
135
},
136
{
137
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/EleanorDialogue_rom.dialogue",
138
kissEmail: "/Lotus/Types/Items/EmailItems/EleanorKissEmailItem"
139
},
140
{
141
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/LettieDialogue_rom.dialogue",
142
kissEmail: "/Lotus/Types/Items/EmailItems/LettieKissEmailItem"
143
},
144
{
145
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/JabirDialogue_rom.dialogue",
146
kissEmail: "/Lotus/Types/Items/EmailItems/AmirKissEmailItem"
147
},
148
{
149
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/AoiDialogue_rom.dialogue",
150
kissEmail: "/Lotus/Types/Items/EmailItems/AoiKissEmailItem"
151
},
152
{
153
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/QuincyDialogue_rom.dialogue",
154
kissEmail: "/Lotus/Types/Items/EmailItems/QuincyKissEmailItem"
155
}
156
]) {
157
const dialogue = inventory.DialogueHistory.Dialogues.find(x => x.DialogueName == dialogueName);
158
if (dialogue) {
159
if (dialogue.Rank == 7) {
160
await addEmailItem(inventory, kissEmail);
161
kalymos = false;
162
break;
149
163
}
150
]) {
151
const dialogue = inventory.DialogueHistory.Dialogues.find(x => x.DialogueName == dialogueName);
152
if (dialogue) {
153
if (dialogue.Rank == 7) {
154
await addEmailItem(inventory, kissEmail);
155
kalymos = false;
156
break;
157
}
158
if (dialogue.Rank == 6) {
159
kalymos = true;
160
}
164
if (dialogue.Rank == 6) {
165
kalymos = true;
161
166
}
162
167
}
163
if (kalymos) {
164
await addEmailItem(inventory, "/Lotus/Types/Items/EmailItems/KalymosKissEmailItem");
165
}
168
}
169
if (kalymos) {
170
await addEmailItem(inventory, "/Lotus/Types/Items/EmailItems/KalymosKissEmailItem");
166
171
}
167
172
}
168
173
@@ -1216,8 +1216,8 @@ const calenderProgressSchema = new Schema<ICalendarProgress>(
1216
1216
},
1217
1217
SeasonProgress: {
1218
1218
SeasonType: { type: String, required: true },
1219
LastCompletedDayIdx: { type: Number, default: 0 },
1220
LastCompletedChallengeDayIdx: { type: Number, default: 0 },
1219
LastCompletedDayIdx: { type: Number, default: -1 },
1220
LastCompletedChallengeDayIdx: { type: Number, default: -1 },
1221
1221
ActivatedChallenges: { type: [String], default: [] }
1222
1222
}
1223
1223
},
@@ -1897,7 +1897,7 @@ export const addCalendarProgress = (inventory: TInventoryDatabaseDocument, value
1897
1897
calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx = currentSeason.Days.findIndex(
1898
1898
day => day.events.length != 0 && day.events[0].challenge == value[value.length - 1].challenge
1899
1899
);
1900
checkCalendarChallengeCompletion(calendarProgress, currentSeason);
1900
checkCalendarAutoAdvance(inventory, currentSeason);
1901
1901
};
1902
1902
1903
1903
export const addMissionComplete = (inventory: TInventoryDatabaseDocument, { Tag, Completes, Tier }: IMission): void => {
@@ -2082,8 +2082,8 @@ export const getCalendarProgress = (inventory: TInventoryDatabaseDocument): ICal
2082
2082
},
2083
2083
SeasonProgress: {
2084
2084
SeasonType: currentSeason.Season,
2085
LastCompletedDayIdx: 0,
2086
LastCompletedChallengeDayIdx: 0,
2085
LastCompletedDayIdx: -1,
2086
LastCompletedChallengeDayIdx: -1,
2087
2087
ActivatedChallenges: []
2088
2088
}
2089
2089
};
@@ -2104,16 +2104,44 @@ export const getCalendarProgress = (inventory: TInventoryDatabaseDocument): ICal
2104
2104
return inventory.CalendarProgress;
2105
2105
};
2106
2106
2107
export const checkCalendarChallengeCompletion = (
2108
calendarProgress: ICalendarProgress,
2107
export const checkCalendarAutoAdvance = (
2108
inventory: TInventoryDatabaseDocument,
2109
2109
currentSeason: ICalendarSeason
2110
2110
): void => {
2111
const dayIndex = calendarProgress.SeasonProgress.LastCompletedDayIdx + 1;
2112
if (calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx >= dayIndex) {
2111
const calendarProgress = inventory.CalendarProgress!;
2112
for (
2113
let dayIndex = calendarProgress.SeasonProgress.LastCompletedDayIdx + 1;
2114
dayIndex != currentSeason.Days.length;
2115
++dayIndex
2116
) {
2113
2117
const day = currentSeason.Days[dayIndex];
2114
if (day.events.length != 0 && day.events[0].type == "CET_CHALLENGE") {
2118
if (day.events.length == 0) {
2119
// birthday
2120
if (day.day == 1) {
2121
// kaya
2122
if ((inventory.Affiliations.find(x => x.Tag == "HexSyndicate")?.Title || 0) >= 4) {
2123
break;
2124
}
2125
logger.debug(`cannot talk to kaya, skipping birthday`);
2126
calendarProgress.SeasonProgress.LastCompletedDayIdx++;
2127
} else if (day.day == 74 || day.day == 355) {
2128
// minerva, velimir
2129
if ((inventory.Affiliations.find(x => x.Tag == "HexSyndicate")?.Title || 0) >= 5) {
2130
break;
2131
}
2132
logger.debug(`cannot talk to minerva/velimir, skipping birthday`);
2133
calendarProgress.SeasonProgress.LastCompletedDayIdx++;
2134
} else {
2135
break;
2136
}
2137
} else if (day.events[0].type == "CET_CHALLENGE") {
2138
if (calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx < dayIndex) {
2139
break;
2140
}
2115
2141
//logger.debug(`already completed the challenge, skipping ahead`);
2116
2142
calendarProgress.SeasonProgress.LastCompletedDayIdx++;
2143
} else {
2144
break;
2117
2145
}
2118
2146
}
2119
2147
};