refactor getAccountCheats() as an internal method
This commit is contained in:
parent
859278df37
commit
049153134f
@ -18,7 +18,7 @@ import {
|
|||||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
|
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
|
||||||
import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts";
|
import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts";
|
||||||
import { Loadout } from "../../models/inventoryModels/loadoutModel.ts";
|
import { Loadout } from "../../models/inventoryModels/loadoutModel.ts";
|
||||||
import { addMods, freeUpSlot, getInventory, getAccountCheats } from "../../services/inventoryService.ts";
|
import { addMods, freeUpSlot, getInventory } from "../../services/inventoryService.ts";
|
||||||
import { getAccountForRequest } from "../../services/loginService.ts";
|
import { getAccountForRequest } from "../../services/loginService.ts";
|
||||||
import { SRng } from "../../services/rngService.ts";
|
import { SRng } from "../../services/rngService.ts";
|
||||||
import type { IMongoDate, IOid } from "../../types/commonTypes.ts";
|
import type { IMongoDate, IOid } from "../../types/commonTypes.ts";
|
||||||
@ -30,7 +30,8 @@ import type {
|
|||||||
IUpgradeClient,
|
IUpgradeClient,
|
||||||
IWeaponSkinClient,
|
IWeaponSkinClient,
|
||||||
TEquipmentKey,
|
TEquipmentKey,
|
||||||
TNemesisFaction
|
TNemesisFaction,
|
||||||
|
IAccountCheats
|
||||||
} from "../../types/inventoryTypes/inventoryTypes.ts";
|
} from "../../types/inventoryTypes/inventoryTypes.ts";
|
||||||
import { InventorySlot, LoadoutIndex } from "../../types/inventoryTypes/inventoryTypes.ts";
|
import { InventorySlot, LoadoutIndex } from "../../types/inventoryTypes/inventoryTypes.ts";
|
||||||
import { logger } from "../../utils/logger.ts";
|
import { logger } from "../../utils/logger.ts";
|
||||||
@ -39,7 +40,9 @@ import { Types } from "mongoose";
|
|||||||
|
|
||||||
export const nemesisController: RequestHandler = async (req, res) => {
|
export const nemesisController: RequestHandler = async (req, res) => {
|
||||||
const account = await getAccountForRequest(req);
|
const account = await getAccountForRequest(req);
|
||||||
const accountCheats = await getAccountCheats(account._id.toString());
|
const cheatProperties = Object.keys({} as IAccountCheats) as Array<keyof IAccountCheats>;
|
||||||
|
const accountCheats = await getInventory(account._id.toString(), cheatProperties.join(" "));
|
||||||
|
|
||||||
if ((req.query.mode as string) == "f") {
|
if ((req.query.mode as string) == "f") {
|
||||||
const body = getJSONfromString<IValenceFusionRequest>(String(req.body));
|
const body = getJSONfromString<IValenceFusionRequest>(String(req.body));
|
||||||
const inventory = await getInventory(account._id.toString(), body.Category + " WeaponBin");
|
const inventory = await getInventory(account._id.toString(), body.Category + " WeaponBin");
|
||||||
@ -246,7 +249,7 @@ export const nemesisController: RequestHandler = async (req, res) => {
|
|||||||
const dataknifeUpgrades = inventory.DataKnives[0].Configs[dataknifeConfigIndex].Upgrades!;
|
const dataknifeUpgrades = inventory.DataKnives[0].Configs[dataknifeConfigIndex].Upgrades!;
|
||||||
for (let i = 3; i != 6; ++i) {
|
for (let i = 3; i != 6; ++i) {
|
||||||
//logger.debug(`subtracting a charge from ${dataknifeUpgrades[i]}`);
|
//logger.debug(`subtracting a charge from ${dataknifeUpgrades[i]}`);
|
||||||
if (accountCheats.nemesisAlwaysCorrect){
|
if (accountCheats.nemesisAlwaysCorrect) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const upgrade = parseUpgrade(inventory, dataknifeUpgrades[i]);
|
const upgrade = parseUpgrade(inventory, dataknifeUpgrades[i]);
|
||||||
|
|||||||
@ -26,8 +26,7 @@ import type {
|
|||||||
INemesisWeaponTargetFingerprint,
|
INemesisWeaponTargetFingerprint,
|
||||||
INemesisPetTargetFingerprint,
|
INemesisPetTargetFingerprint,
|
||||||
IDialogueDatabase,
|
IDialogueDatabase,
|
||||||
IKubrowPetPrintClient,
|
IKubrowPetPrintClient
|
||||||
IAccountCheats
|
|
||||||
} from "../types/inventoryTypes/inventoryTypes.ts";
|
} from "../types/inventoryTypes/inventoryTypes.ts";
|
||||||
import { InventorySlot, equipmentKeys } from "../types/inventoryTypes/inventoryTypes.ts";
|
import { InventorySlot, equipmentKeys } from "../types/inventoryTypes/inventoryTypes.ts";
|
||||||
import type { IGenericUpdate, IUpdateNodeIntrosResponse } from "../types/genericUpdate.ts";
|
import type { IGenericUpdate, IUpdateNodeIntrosResponse } from "../types/genericUpdate.ts";
|
||||||
@ -267,13 +266,6 @@ export const getInventory = async (
|
|||||||
return inventory;
|
return inventory;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAccountCheats = async (accountOwnerId: string): Promise<Partial<IAccountCheats>> => {
|
|
||||||
const cheatProperties = Object.keys({} as IAccountCheats) as Array<keyof IAccountCheats>;
|
|
||||||
const inventoryWithCheats = await getInventory(accountOwnerId, cheatProperties.join(" "));
|
|
||||||
|
|
||||||
return inventoryWithCheats;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const productCategoryToInventoryBin = (productCategory: string): InventorySlot | undefined => {
|
export const productCategoryToInventoryBin = (productCategory: string): InventorySlot | undefined => {
|
||||||
switch (productCategory) {
|
switch (productCategory) {
|
||||||
case "Suits":
|
case "Suits":
|
||||||
|
|||||||
@ -35,7 +35,6 @@ import {
|
|||||||
addStanding,
|
addStanding,
|
||||||
applyClientEquipmentUpdates,
|
applyClientEquipmentUpdates,
|
||||||
combineInventoryChanges,
|
combineInventoryChanges,
|
||||||
getAccountCheats,
|
|
||||||
getDialogue,
|
getDialogue,
|
||||||
giveNemesisPetRecipe,
|
giveNemesisPetRecipe,
|
||||||
giveNemesisWeaponRecipe,
|
giveNemesisWeaponRecipe,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user