diff --git a/src/controllers/api/nemesisController.ts b/src/controllers/api/nemesisController.ts index 2bd46dfb..bfbaa40b 100644 --- a/src/controllers/api/nemesisController.ts +++ b/src/controllers/api/nemesisController.ts @@ -1,3 +1,4 @@ +import { version_compare } from "@/src/helpers/inventoryHelpers"; import { consumeModCharge, encodeNemesisGuess, @@ -11,7 +12,7 @@ import { import { getJSONfromString } from "@/src/helpers/stringHelpers"; import { Loadout } from "@/src/models/inventoryModels/loadoutModel"; import { freeUpSlot, getInventory } from "@/src/services/inventoryService"; -import { getAccountIdForRequest } from "@/src/services/loginService"; +import { getAccountForRequest } from "@/src/services/loginService"; import { SRng } from "@/src/services/rngService"; import { IMongoDate, IOid } from "@/src/types/commonTypes"; import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes"; @@ -30,10 +31,10 @@ import { logger } from "@/src/utils/logger"; import { RequestHandler } from "express"; export const nemesisController: RequestHandler = async (req, res) => { - const accountId = await getAccountIdForRequest(req); + const account = await getAccountForRequest(req); if ((req.query.mode as string) == "f") { const body = getJSONfromString(String(req.body)); - const inventory = await getInventory(accountId, body.Category + " WeaponBin"); + const inventory = await getInventory(account._id.toString(), body.Category + " WeaponBin"); const destWeapon = inventory[body.Category].id(body.DestWeapon.$oid)!; const sourceWeapon = inventory[body.Category].id(body.SourceWeapon.$oid)!; const destFingerprint = JSON.parse(destWeapon.UpgradeFingerprint!) as IInnateDamageFingerprint; @@ -68,7 +69,7 @@ export const nemesisController: RequestHandler = async (req, res) => { } }); } else if ((req.query.mode as string) == "p") { - const inventory = await getInventory(accountId, "Nemesis"); + const inventory = await getInventory(account._id.toString(), "Nemesis"); const body = getJSONfromString(String(req.body)); const passcode = getNemesisPasscode(inventory.Nemesis!); let guessResult = 0; @@ -89,7 +90,7 @@ export const nemesisController: RequestHandler = async (req, res) => { res.json({ GuessResult: guessResult }); } else if (req.query.mode == "r") { const inventory = await getInventory( - accountId, + account._id.toString(), "Nemesis LoadOutPresets CurrentLoadOutIds DataKnives Upgrades RawUpgrades" ); const body = getJSONfromString(String(req.body)); @@ -163,16 +164,21 @@ export const nemesisController: RequestHandler = async (req, res) => { } } else if ((req.query.mode as string) == "rs") { // report spawn; POST but no application data in body - const inventory = await getInventory(accountId, "Nemesis"); + const inventory = await getInventory(account._id.toString(), "Nemesis"); inventory.Nemesis!.LastEnc = inventory.Nemesis!.MissionCount; await inventory.save(); res.json({ LastEnc: inventory.Nemesis!.LastEnc }); } else if ((req.query.mode as string) == "s") { - const inventory = await getInventory(accountId, "Nemesis"); + const inventory = await getInventory(account._id.toString(), "Nemesis"); const body = getJSONfromString(String(req.body)); body.target.fp = BigInt(body.target.fp); const manifest = getNemesisManifest(body.target.manifest); + if (account.BuildLabel && version_compare(manifest.minBuild, account.BuildLabel) < 0) { + logger.warn( + `client on version ${account.BuildLabel} provided nemesis manifest ${body.target.manifest} which was expected to require ${manifest.minBuild} or above. please file a bug report.` + ); + } let weaponIdx = -1; if (body.target.Faction != "FC_INFESTATION") { @@ -220,7 +226,7 @@ export const nemesisController: RequestHandler = async (req, res) => { }); } else if ((req.query.mode as string) == "w") { const inventory = await getInventory( - accountId, + account._id.toString(), "Nemesis LoadOutPresets CurrentLoadOutIds DataKnives Upgrades RawUpgrades" ); //const body = getJSONfromString(String(req.body));