chore: track inventory changes when cracking relic via addMissionRewards (#1131)
All checks were successful
Build / build (18) (push) Successful in 42s
Build / build (20) (push) Successful in 59s
Build / build (22) (push) Successful in 40s
Build Docker image / docker (push) Successful in 41s

Closes #1120

Reviewed-on: #1131
This commit is contained in:
Sainan 2025-03-09 07:43:30 -07:00
parent 1c276ce133
commit d5feec2c37
2 changed files with 13 additions and 6 deletions

View File

@ -3,12 +3,14 @@ import { IVoidTearParticipantInfo } from "@/src/types/requestTypes";
import { ExportRelics, ExportRewards, TRarity } from "warframe-public-export-plus"; import { ExportRelics, ExportRewards, TRarity } from "warframe-public-export-plus";
import { getRandomWeightedReward, IRngResult } from "@/src/services/rngService"; import { getRandomWeightedReward, IRngResult } from "@/src/services/rngService";
import { logger } from "@/src/utils/logger"; import { logger } from "@/src/utils/logger";
import { addMiscItems } from "@/src/services/inventoryService"; import { addMiscItems, combineInventoryChanges } from "@/src/services/inventoryService";
import { handleStoreItemAcquisition } from "@/src/services/purchaseService"; import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
import { IInventoryChanges } from "../types/purchaseTypes";
export const crackRelic = async ( export const crackRelic = async (
inventory: TInventoryDatabaseDocument, inventory: TInventoryDatabaseDocument,
participant: IVoidTearParticipantInfo participant: IVoidTearParticipantInfo,
inventoryChanges: IInventoryChanges = {}
): Promise<IRngResult> => { ): Promise<IRngResult> => {
const relic = ExportRelics[participant.VoidProjection]; const relic = ExportRelics[participant.VoidProjection];
const weights = refinementToWeights[relic.quality]; const weights = refinementToWeights[relic.quality];
@ -21,15 +23,20 @@ export const crackRelic = async (
participant.Reward = reward.type; participant.Reward = reward.type;
// Remove relic // Remove relic
addMiscItems(inventory, [ const miscItemChanges = [
{ {
ItemType: participant.VoidProjection, ItemType: participant.VoidProjection,
ItemCount: -1 ItemCount: -1
} }
]); ];
addMiscItems(inventory, miscItemChanges);
combineInventoryChanges(inventoryChanges, { MiscItems: miscItemChanges });
// Give reward // Give reward
await handleStoreItemAcquisition(reward.type, inventory, reward.itemCount); combineInventoryChanges(
inventoryChanges,
(await handleStoreItemAcquisition(reward.type, inventory, reward.itemCount)).InventoryChanges
);
return reward; return reward;
}; };

View File

@ -405,7 +405,7 @@ export const addMissionRewards = async (
voidTearWave.Participants[0].QualifiesForReward && voidTearWave.Participants[0].QualifiesForReward &&
!voidTearWave.Participants[0].HaveRewardResponse !voidTearWave.Participants[0].HaveRewardResponse
) { ) {
const reward = await crackRelic(inventory, voidTearWave.Participants[0]); const reward = await crackRelic(inventory, voidTearWave.Participants[0], inventoryChanges);
MissionRewards.push({ StoreItem: reward.type, ItemCount: reward.itemCount }); MissionRewards.push({ StoreItem: reward.type, ItemCount: reward.itemCount });
} }