返回提交历史
Modified
src/controllers/api/getVoidProjectionRewardsController.ts
+40
-11
Modified
src/services/missionInventoryUpdateService.ts
+1
-1
Modified
src/types/requestTypes.ts
+4
-4
XFEstudio/SpaceNinjaServer
feat: handle getVoidProjectionRewards request from U27.3 (#4150)
Closes #4149 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4150 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
cc49ad27
代码差异
3 个文件
+45
-16
@@ -8,13 +8,26 @@ import { logger } from "../../utils/logger.ts";
8
8
9
9
export const getVoidProjectionRewardsController: RequestHandler = async (req, res) => {
10
10
const accountId = await getAccountIdForRequest(req);
11
const data = getJSONfromString<IVoidProjectionRewardRequest>(String(req.body));
11
const data = getJSONfromString<IVoidProjectionRewardRequest | IVoidProjectionRewardsLegacyRequest>(
12
String(req.body)
13
);
12
14
logger.debug(`getVoidProjectionRewards request:`, data);
13
15
14
if (data.ParticipantInfo.QualifiesForReward && !data.ParticipantInfo.HaveRewardResponse) {
16
const currentWave = "CurrentWave" in data ? data.CurrentWave : data.VoidTearParticipantsCurrWave.Wave;
17
const participantInfo =
18
"ParticipantInfo" in data
19
? data.ParticipantInfo
20
: data.VoidTearParticipantsCurrWave.Participants.find(p => p.AccountId == accountId);
21
22
if (
23
participantInfo &&
24
participantInfo.QualifiesForReward &&
25
!participantInfo.HaveRewardResponse &&
26
!participantInfo.Reward
27
) {
15
28
const inventory = await getInventory(accountId, undefined);
16
const reward = await crackRelic(inventory, data.ParticipantInfo);
17
if (!inventory.MissionRelicRewards || inventory.MissionRelicRewards.length >= data.CurrentWave) {
29
const reward = await crackRelic(inventory, participantInfo);
30
if (!inventory.MissionRelicRewards || inventory.MissionRelicRewards.length >= currentWave) {
18
31
inventory.MissionRelicRewards = [];
19
32
}
20
33
inventory.MissionRelicRewards.push({ ItemType: reward.type, ItemCount: reward.itemCount });
@@ -24,12 +37,17 @@ export const getVoidProjectionRewardsController: RequestHandler = async (req, re
24
37
await inventory.save();
25
38
}
26
39
27
const response: IVoidProjectionRewardResponse = {
28
CurrentWave: data.CurrentWave,
29
ParticipantInfo: data.ParticipantInfo,
30
DifficultyTier: data.DifficultyTier
31
};
32
res.json(response);
40
if ("CurrentWave" in data) {
41
res.json({
42
CurrentWave: data.CurrentWave,
43
ParticipantInfo: data.ParticipantInfo,
44
DifficultyTier: data.DifficultyTier
45
} satisfies IVoidProjectionRewardResponse);
46
} else {
47
res.json({
48
VoidTearParticipantsCurrWave: data.VoidTearParticipantsCurrWave
49
} satisfies IVoidProjectionRewardsLegacyResponse);
50
}
33
51
};
34
52
35
53
interface IVoidProjectionRewardRequest {
@@ -40,9 +58,20 @@ interface IVoidProjectionRewardRequest {
40
58
DifficultyTier: number;
41
59
VoidProjectionRemovalHash: string;
42
60
}
43
44
61
interface IVoidProjectionRewardResponse {
45
62
CurrentWave: number;
46
63
ParticipantInfo: IVoidTearParticipantInfo;
47
64
DifficultyTier: number;
48
65
}
66
67
// Legacy format seen in U27.3, unsure when it changed
68
interface IVoidProjectionRewardsLegacyRequest {
69
VoidTearParticipantsCurrWave: IVoidTearWaveInfo;
70
VoidTearParticipantsPrevWave?: IVoidTearWaveInfo;
71
VoidTier: string;
72
VoidProjectionRemovalHash: string;
73
}
74
75
interface IVoidProjectionRewardsLegacyResponse {
76
VoidTearParticipantsCurrWave: IVoidTearWaveInfo;
77
}
@@ -1781,7 +1781,7 @@ export const addMissionRewards = async (
1781
1781
}
1782
1782
1783
1783
if (voidTearWave && voidTearWave.Participants[0].QualifiesForReward) {
1784
if (!voidTearWave.Participants[0].HaveRewardResponse) {
1784
if (!voidTearWave.Participants[0].HaveRewardResponse && !voidTearWave.Participants[0].Reward) {
1785
1785
// non-endless fissure in solo mode; giving reward now
1786
1786
const reward = await crackRelic(inventory, voidTearWave.Participants[0], inventoryChanges);
1787
1787
MissionRewards.push({ StoreItem: reward.type, ItemCount: reward.itemCount });
@@ -282,7 +282,7 @@ interface IUpgradeOperation {
282
282
283
283
export interface IVoidTearWaveInfo {
284
284
Wave: number;
285
IsFinalWave: boolean;
285
IsFinalWave?: boolean; // not in U27.3
286
286
Participants: IVoidTearParticipantInfo[];
287
287
}
288
288
@@ -290,14 +290,14 @@ export interface IVoidTearParticipantInfo {
290
290
AccountId: string;
291
291
Name: string;
292
292
ChosenRewardOwner: string;
293
MissionHash: string;
293
MissionHash?: string;
294
294
VoidProjection: string;
295
295
Reward: string;
296
296
QualifiesForReward: boolean;
297
HaveRewardResponse: boolean;
297
HaveRewardResponse?: boolean;
298
298
RewardsMultiplier: number;
299
299
RewardProjection: string;
300
HardModeReward: ITypeCount;
300
HardModeReward?: ITypeCount;
301
301
}
302
302
303
303
export interface IKeyChainRequest {