XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

chore: track inventory changes when cracking relic via addMissionRewards (#1131)

Closes #1120 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1131

d5feec2c
Sainan <sainan@calamity.inc>
提交于

代码差异

2 个文件 +13 -6
Modified src/helpers/relicHelper.ts +12 -5
@@ -3,12 +3,14 @@ import { IVoidTearParticipantInfo } from "@/src/types/requestTypes";
3 3 import { ExportRelics, ExportRewards, TRarity } from "warframe-public-export-plus";
4 4 import { getRandomWeightedReward, IRngResult } from "@/src/services/rngService";
5 5 import { logger } from "@/src/utils/logger";
6 import { addMiscItems } from "@/src/services/inventoryService";
6 import { addMiscItems, combineInventoryChanges } from "@/src/services/inventoryService";
7 7 import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
8 import { IInventoryChanges } from "../types/purchaseTypes";
8 9
9 10 export const crackRelic = async (
10 11 inventory: TInventoryDatabaseDocument,
11 participant: IVoidTearParticipantInfo
12 participant: IVoidTearParticipantInfo,
13 inventoryChanges: IInventoryChanges = {}
12 14 ): Promise<IRngResult> => {
13 15 const relic = ExportRelics[participant.VoidProjection];
14 16 const weights = refinementToWeights[relic.quality];
@@ -21,15 +23,20 @@ export const crackRelic = async (
21 23 participant.Reward = reward.type;
22 24
23 25 // Remove relic
24 addMiscItems(inventory, [
26 const miscItemChanges = [
25 27 {
26 28 ItemType: participant.VoidProjection,
27 29 ItemCount: -1
28 30 }
29 ]);
31 ];
32 addMiscItems(inventory, miscItemChanges);
33 combineInventoryChanges(inventoryChanges, { MiscItems: miscItemChanges });
30 34
31 35 // Give reward
32 await handleStoreItemAcquisition(reward.type, inventory, reward.itemCount);
36 combineInventoryChanges(
37 inventoryChanges,
38 (await handleStoreItemAcquisition(reward.type, inventory, reward.itemCount)).InventoryChanges
39 );
33 40
34 41 return reward;
35 42 };
Modified src/services/missionInventoryUpdateService.ts +1 -1
@@ -405,7 +405,7 @@ export const addMissionRewards = async (
405 405 voidTearWave.Participants[0].QualifiesForReward &&
406 406 !voidTearWave.Participants[0].HaveRewardResponse
407 407 ) {
408 const reward = await crackRelic(inventory, voidTearWave.Participants[0]);
408 const reward = await crackRelic(inventory, voidTearWave.Participants[0], inventoryChanges);
409 409 MissionRewards.push({ StoreItem: reward.type, ItemCount: reward.itemCount });
410 410 }
411 411