cheat: extraRelicRewards (2)
This commit is contained in:
		
							parent
							
								
									ab802025e4
								
							
						
					
					
						commit
						38f192ed84
					
				@ -9,13 +9,12 @@ import { addMiscItems, combineInventoryChanges } from "../services/inventoryServ
 | 
			
		||||
import { handleStoreItemAcquisition } from "../services/purchaseService.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../types/purchaseTypes.ts";
 | 
			
		||||
import { config } from "../services/configService.ts";
 | 
			
		||||
import { log } from "winston";
 | 
			
		||||
 | 
			
		||||
export const crackRelic = async (
 | 
			
		||||
    inventory: TInventoryDatabaseDocument,
 | 
			
		||||
    participant: IVoidTearParticipantInfo,
 | 
			
		||||
    inventoryChanges: IInventoryChanges = {}
 | 
			
		||||
): Promise<IRngResult> => {
 | 
			
		||||
): Promise<IRngResult[]> => {
 | 
			
		||||
    const relic = ExportRelics[participant.VoidProjection];
 | 
			
		||||
    let weights = refinementToWeights[relic.quality];
 | 
			
		||||
    if (relic.quality == "VPQ_SILVER" && inventory.exceptionalRelicsAlwaysGiveBronzeReward) {
 | 
			
		||||
@ -39,6 +38,28 @@ export const crackRelic = async (
 | 
			
		||||
    logger.debug(`relic rolled`, reward);
 | 
			
		||||
    participant.Reward = reward.type;
 | 
			
		||||
 | 
			
		||||
    const allRewards: IRngResult[] = [reward];
 | 
			
		||||
    if (inventory.extraRelicRewards !== undefined && inventory.extraRelicRewards >= 1) {
 | 
			
		||||
        for (let i = 0; i < inventory.extraRelicRewards; i++) {
 | 
			
		||||
            logger.debug(`adding ${inventory.extraRelicRewards} extra relic rewards, now is ${i}`);
 | 
			
		||||
            let extraReward = getRandomWeightedReward(
 | 
			
		||||
                ExportRewards[relic.rewardManifest][0] as { type: string; itemCount: number; rarity: TRarity }[],
 | 
			
		||||
                weights
 | 
			
		||||
            )!;
 | 
			
		||||
            if (
 | 
			
		||||
                config.relicRewardItemCountMultiplier !== undefined &&
 | 
			
		||||
                (config.relicRewardItemCountMultiplier ?? 1) != 1
 | 
			
		||||
            ) {
 | 
			
		||||
                extraReward = {
 | 
			
		||||
                    ...extraReward,
 | 
			
		||||
                    itemCount: extraReward.itemCount * config.relicRewardItemCountMultiplier
 | 
			
		||||
                };
 | 
			
		||||
            }
 | 
			
		||||
            logger.debug(`extra relic rolled`, extraReward);
 | 
			
		||||
            allRewards.push(extraReward);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Remove relic
 | 
			
		||||
    const miscItemChanges = [
 | 
			
		||||
        {
 | 
			
		||||
@ -50,32 +71,36 @@ export const crackRelic = async (
 | 
			
		||||
    combineInventoryChanges(inventoryChanges, { MiscItems: miscItemChanges });
 | 
			
		||||
 | 
			
		||||
    // Give reward
 | 
			
		||||
    combineInventoryChanges(
 | 
			
		||||
        inventoryChanges,
 | 
			
		||||
        (await handleStoreItemAcquisition(reward.type, inventory, reward.itemCount)).InventoryChanges
 | 
			
		||||
    );
 | 
			
		||||
    for (const reward of allRewards as (IRngResult & { rarity: string })[]) {
 | 
			
		||||
        combineInventoryChanges(
 | 
			
		||||
            inventoryChanges,
 | 
			
		||||
            (await handleStoreItemAcquisition(reward.type, inventory, reward.itemCount)).InventoryChanges
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (inventory.crackRelicForPlatinum) {
 | 
			
		||||
        let platinumReward = 0;
 | 
			
		||||
        switch (reward.rarity) {
 | 
			
		||||
            case "COMMON":
 | 
			
		||||
                platinumReward = inventory.relicPlatinumCommon ?? 2;
 | 
			
		||||
                break;
 | 
			
		||||
            case "UNCOMMON":
 | 
			
		||||
                platinumReward = inventory.relicPlatinumUncommon ?? 5;
 | 
			
		||||
                break;
 | 
			
		||||
            case "RARE":
 | 
			
		||||
                platinumReward = inventory.relicPlatinumRare ?? 12;
 | 
			
		||||
                break;
 | 
			
		||||
            case "LEGENDARY":
 | 
			
		||||
                logger.warn(`got a legendary reward for a relic!`);
 | 
			
		||||
                break;
 | 
			
		||||
        for (const reward of allRewards as (IRngResult & { rarity: string })[]) {
 | 
			
		||||
            switch (reward.rarity) {
 | 
			
		||||
                case "COMMON":
 | 
			
		||||
                    platinumReward = inventory.relicPlatinumCommon ?? 2;
 | 
			
		||||
                    break;
 | 
			
		||||
                case "UNCOMMON":
 | 
			
		||||
                    platinumReward = inventory.relicPlatinumUncommon ?? 5;
 | 
			
		||||
                    break;
 | 
			
		||||
                case "RARE":
 | 
			
		||||
                    platinumReward = inventory.relicPlatinumRare ?? 12;
 | 
			
		||||
                    break;
 | 
			
		||||
                case "LEGENDARY":
 | 
			
		||||
                    logger.warn(`got a legendary reward for a relic!`);
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
            logger.debug(`adding ${platinumReward} platinum to inventory for a ${reward.rarity} reward`);
 | 
			
		||||
            inventory.PremiumCredits += platinumReward;
 | 
			
		||||
        }
 | 
			
		||||
        logger.debug(`adding ${platinumReward} platinum to inventory for a ${reward.rarity} reward`);
 | 
			
		||||
        inventory.PremiumCredits += platinumReward;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return reward;
 | 
			
		||||
    return allRewards;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const refinementToWeights = {
 | 
			
		||||
 | 
			
		||||
@ -1379,23 +1379,10 @@ export const addMissionRewards = async (
 | 
			
		||||
        voidTearWave.Participants[0].QualifiesForReward &&
 | 
			
		||||
        !voidTearWave.Participants[0].HaveRewardResponse
 | 
			
		||||
    ) {
 | 
			
		||||
        const reward = await crackRelic(inventory, voidTearWave.Participants[0], inventoryChanges);
 | 
			
		||||
        MissionRewards.push({ StoreItem: reward.type, ItemCount: reward.itemCount });
 | 
			
		||||
 | 
			
		||||
        if ((inventory.extraRelicRewards ?? 0) >= 1) {
 | 
			
		||||
            for (let i = 0; i != inventory.extraRelicRewards; ++i) {
 | 
			
		||||
                //give a relic that will be removed later in crackRelic()
 | 
			
		||||
                const miscItemChanges = [
 | 
			
		||||
                    {
 | 
			
		||||
                        ItemType: voidTearWave.Participants[0].VoidProjection,
 | 
			
		||||
                        ItemCount: 1
 | 
			
		||||
                    }
 | 
			
		||||
                ];
 | 
			
		||||
                addMiscItems(inventory, miscItemChanges);
 | 
			
		||||
                const reward = await crackRelic(inventory, voidTearWave.Participants[0], inventoryChanges);
 | 
			
		||||
                MissionRewards.push({ StoreItem: reward.type, ItemCount: reward.itemCount });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        const rewards = await crackRelic(inventory, voidTearWave.Participants[0], inventoryChanges);
 | 
			
		||||
        rewards.forEach(reward => {
 | 
			
		||||
            MissionRewards.push({ StoreItem: reward.type, ItemCount: reward.itemCount });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (strippedItems) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user