fix(nemesis): subtract charge from installed mods instead of ideal mods
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build / build (pull_request) Successful in 53s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build / build (pull_request) Successful in 53s
				
			Because oull might substitute one of them.
This commit is contained in:
		
							parent
							
								
									271f5bd47a
								
							
						
					
					
						commit
						9841e05f70
					
				@ -8,16 +8,15 @@ import {
 | 
			
		||||
    getKnifeUpgrade,
 | 
			
		||||
    getNemesisManifest,
 | 
			
		||||
    getNemesisPasscode,
 | 
			
		||||
    getNemesisPasscodeModTypes,
 | 
			
		||||
    GUESS_CORRECT,
 | 
			
		||||
    GUESS_INCORRECT,
 | 
			
		||||
    GUESS_NEUTRAL,
 | 
			
		||||
    GUESS_NONE,
 | 
			
		||||
    GUESS_WILDCARD,
 | 
			
		||||
    IKnifeResponse
 | 
			
		||||
    IKnifeResponse,
 | 
			
		||||
    parseUpgrade
 | 
			
		||||
} from "@/src/helpers/nemesisHelpers";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
 | 
			
		||||
import { freeUpSlot, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountForRequest } from "@/src/services/loginService";
 | 
			
		||||
@ -215,7 +214,19 @@ export const nemesisController: RequestHandler = async (req, res) => {
 | 
			
		||||
                        }
 | 
			
		||||
                    ];
 | 
			
		||||
                    inventory.Nemesis!.Weakened = true;
 | 
			
		||||
                    await consumePasscodeModCharges(inventory, response);
 | 
			
		||||
 | 
			
		||||
                    // Subtract a charge from all requiem mods installed on parazon
 | 
			
		||||
                    const loadout = (await Loadout.findById(inventory.LoadOutPresets, "DATAKNIFE"))!;
 | 
			
		||||
                    const dataknifeLoadout = loadout.DATAKNIFE.id(
 | 
			
		||||
                        inventory.CurrentLoadOutIds[LoadoutIndex.DATAKNIFE].$oid
 | 
			
		||||
                    );
 | 
			
		||||
                    const dataknifeConfigIndex = dataknifeLoadout?.s?.mod ?? 0;
 | 
			
		||||
                    const dataknifeUpgrades = inventory.DataKnives[0].Configs[dataknifeConfigIndex].Upgrades!;
 | 
			
		||||
                    for (let i = 3; i != 6; ++i) {
 | 
			
		||||
                        //logger.debug(`subtracting a charge from ${dataknifeUpgrades[i]}`);
 | 
			
		||||
                        const upgrade = parseUpgrade(inventory, dataknifeUpgrades[i]);
 | 
			
		||||
                        consumeModCharge(response, inventory, upgrade, dataknifeUpgrades);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                // Guess was incorrect, increase rank
 | 
			
		||||
@ -380,18 +391,3 @@ interface IKnife {
 | 
			
		||||
    AttachedUpgrades: IUpgradeClient[];
 | 
			
		||||
    HiddenWhenHolstered: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const consumePasscodeModCharges = async (
 | 
			
		||||
    inventory: TInventoryDatabaseDocument,
 | 
			
		||||
    response: IKnifeResponse
 | 
			
		||||
): Promise<void> => {
 | 
			
		||||
    const loadout = (await Loadout.findById(inventory.LoadOutPresets, "DATAKNIFE"))!;
 | 
			
		||||
    const dataknifeLoadout = loadout.DATAKNIFE.id(inventory.CurrentLoadOutIds[LoadoutIndex.DATAKNIFE].$oid);
 | 
			
		||||
    const dataknifeConfigIndex = dataknifeLoadout?.s?.mod ?? 0;
 | 
			
		||||
    const dataknifeUpgrades = inventory.DataKnives[0].Configs[dataknifeConfigIndex].Upgrades!;
 | 
			
		||||
    const modTypes = getNemesisPasscodeModTypes(inventory.Nemesis!);
 | 
			
		||||
    for (const modType of modTypes) {
 | 
			
		||||
        const upgrade = getKnifeUpgrade(inventory, dataknifeUpgrades, modType);
 | 
			
		||||
        consumeModCharge(response, inventory, upgrade, dataknifeUpgrades);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -237,7 +237,7 @@ export const getNemesisPasscode = (nemesis: { fp: bigint; Faction: TNemesisFacti
 | 
			
		||||
    return passcode;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const requiemMods: readonly string[] = [
 | 
			
		||||
/*const requiemMods: readonly string[] = [
 | 
			
		||||
    "/Lotus/Upgrades/Mods/Immortal/ImmortalOneMod",
 | 
			
		||||
    "/Lotus/Upgrades/Mods/Immortal/ImmortalTwoMod",
 | 
			
		||||
    "/Lotus/Upgrades/Mods/Immortal/ImmortalThreeMod",
 | 
			
		||||
@ -246,7 +246,7 @@ const requiemMods: readonly string[] = [
 | 
			
		||||
    "/Lotus/Upgrades/Mods/Immortal/ImmortalSixMod",
 | 
			
		||||
    "/Lotus/Upgrades/Mods/Immortal/ImmortalSevenMod",
 | 
			
		||||
    "/Lotus/Upgrades/Mods/Immortal/ImmortalEightMod"
 | 
			
		||||
];
 | 
			
		||||
];*/
 | 
			
		||||
 | 
			
		||||
export const antivirusMods: readonly string[] = [
 | 
			
		||||
    "/Lotus/Upgrades/Mods/Immortal/AntivirusOneMod",
 | 
			
		||||
@ -259,12 +259,12 @@ export const antivirusMods: readonly string[] = [
 | 
			
		||||
    "/Lotus/Upgrades/Mods/Immortal/AntivirusEightMod"
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
export const getNemesisPasscodeModTypes = (nemesis: { fp: bigint; Faction: TNemesisFaction }): string[] => {
 | 
			
		||||
/*export const getNemesisPasscodeModTypes = (nemesis: { fp: bigint; Faction: TNemesisFaction }): string[] => {
 | 
			
		||||
    const passcode = getNemesisPasscode(nemesis);
 | 
			
		||||
    return nemesis.Faction == "FC_INFESTATION"
 | 
			
		||||
        ? passcode.map(i => antivirusMods[i])
 | 
			
		||||
        : passcode.map(i => requiemMods[i]);
 | 
			
		||||
};
 | 
			
		||||
};*/
 | 
			
		||||
 | 
			
		||||
// Symbols; 0-7 are the normal requiem mods.
 | 
			
		||||
export const GUESS_NONE = 8;
 | 
			
		||||
@ -343,6 +343,27 @@ export const getKnifeUpgrade = (
 | 
			
		||||
    throw new Error(`${type} does not seem to be installed on parazon?!`);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const parseUpgrade = (
 | 
			
		||||
    inventory: TInventoryDatabaseDocument,
 | 
			
		||||
    str: string
 | 
			
		||||
): { ItemId: IOid; ItemType: string } => {
 | 
			
		||||
    if (str.length == 24) {
 | 
			
		||||
        const upgrade = inventory.Upgrades.id(str);
 | 
			
		||||
        if (upgrade) {
 | 
			
		||||
            return {
 | 
			
		||||
                ItemId: { $oid: str },
 | 
			
		||||
                ItemType: upgrade.ItemType
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
        throw new Error(`Could not resolve oid ${str}`);
 | 
			
		||||
    } else {
 | 
			
		||||
        return {
 | 
			
		||||
            ItemId: { $oid: "000000000000000000000000" },
 | 
			
		||||
            ItemType: str
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const consumeModCharge = (
 | 
			
		||||
    response: IKnifeResponse,
 | 
			
		||||
    inventory: TInventoryDatabaseDocument,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user