chore: track inventory changes when cracking relic via addMissionRewards (#1131)
Closes #1120 Reviewed-on: #1131
This commit is contained in:
parent
1c276ce133
commit
d5feec2c37
@ -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;
|
||||||
};
|
};
|
||||||
|
@ -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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user