From 9b16dc2c6a51c820368119e7c2a30d663653a641 Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Mar 2025 15:27:37 -0700 Subject: [PATCH] feat: valence fusion (#1251) Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1251 --- src/controllers/api/nemesisController.ts | 59 ++++++++++++++++++-- src/controllers/api/valenceSwapController.ts | 10 +--- src/helpers/rivenHelper.ts | 6 +- src/types/inventoryTypes/inventoryTypes.ts | 17 ++---- 4 files changed, 61 insertions(+), 31 deletions(-) diff --git a/src/controllers/api/nemesisController.ts b/src/controllers/api/nemesisController.ts index 7e1d72c7..2f604604 100644 --- a/src/controllers/api/nemesisController.ts +++ b/src/controllers/api/nemesisController.ts @@ -1,16 +1,56 @@ import { getJSONfromString } from "@/src/helpers/stringHelpers"; -import { getInventory } from "@/src/services/inventoryService"; +import { freeUpSlot, getInventory } from "@/src/services/inventoryService"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { SRng } from "@/src/services/rngService"; -import { IMongoDate } from "@/src/types/commonTypes"; -import { IInfNode } from "@/src/types/inventoryTypes/inventoryTypes"; +import { IMongoDate, IOid } from "@/src/types/commonTypes"; +import { + IInfNode, + IInnateDamageFingerprint, + InventorySlot, + TEquipmentKey +} from "@/src/types/inventoryTypes/inventoryTypes"; import { logger } from "@/src/utils/logger"; import { RequestHandler } from "express"; import { ExportRegions } from "warframe-public-export-plus"; export const nemesisController: RequestHandler = async (req, res) => { - if ((req.query.mode as string) == "s") { - const accountId = await getAccountIdForRequest(req); + const accountId = await getAccountIdForRequest(req); + if ((req.query.mode as string) == "f") { + const body = getJSONfromString(String(req.body)); + const inventory = await getInventory(accountId, 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; + const sourceFingerprint = JSON.parse(sourceWeapon.UpgradeFingerprint!) as IInnateDamageFingerprint; + + // Upgrade destination damage type if desireed + if (body.UseSourceDmgType) { + destFingerprint.buffs[0].Tag = sourceFingerprint.buffs[0].Tag; + } + + // Upgrade destination damage value + const destDamage = 0.25 + (destFingerprint.buffs[0].Value / 0x3fffffff) * (0.6 - 0.25); + const sourceDamage = 0.25 + (sourceFingerprint.buffs[0].Value / 0x3fffffff) * (0.6 - 0.25); + let newDamage = Math.max(destDamage, sourceDamage) * 1.1; + if (newDamage >= 0.58) { + newDamage = 0.6; + } + destFingerprint.buffs[0].Value = Math.trunc(((newDamage - 0.25) / (0.6 - 0.25)) * 0x3fffffff); + + // Commit fingerprint + destWeapon.UpgradeFingerprint = JSON.stringify(destFingerprint); + + // Remove source weapon + inventory[body.Category].pull({ _id: body.SourceWeapon.$oid }); + freeUpSlot(inventory, InventorySlot.WEAPONS); + + await inventory.save(); + res.json({ + InventoryChanges: { + [body.Category]: [destWeapon.toJSON()] + } + }); + } else if ((req.query.mode as string) == "s") { const inventory = await getInventory(accountId, "Nemesis NemesisAbandonedRewards"); const body = getJSONfromString(String(req.body)); body.target.fp = BigInt(body.target.fp); @@ -116,7 +156,14 @@ export const nemesisController: RequestHandler = async (req, res) => { } }; -export interface INemesisStartRequest { +interface IValenceFusionRequest { + DestWeapon: IOid; + SourceWeapon: IOid; + Category: TEquipmentKey; + UseSourceDmgType: boolean; +} + +interface INemesisStartRequest { target: { fp: number | bigint; manifest: string; diff --git a/src/controllers/api/valenceSwapController.ts b/src/controllers/api/valenceSwapController.ts index 6196c9f1..0c3976b0 100644 --- a/src/controllers/api/valenceSwapController.ts +++ b/src/controllers/api/valenceSwapController.ts @@ -1,7 +1,7 @@ import { getInventory } from "@/src/services/inventoryService"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { IOid } from "@/src/types/commonTypes"; -import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes"; +import { IInnateDamageFingerprint, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes"; import { RequestHandler } from "express"; export const valenceSwapController: RequestHandler = async (req, res) => { @@ -27,11 +27,3 @@ interface IValenceSwapRequest { WeaponCategory: TEquipmentKey; NewValenceUpgradeTag: string; } - -interface IInnateDamageFingerprint { - compat: string; - buffs: { - Tag: string; - Value: number; - }[]; -} diff --git a/src/helpers/rivenHelper.ts b/src/helpers/rivenHelper.ts index e3819b64..35426a29 100644 --- a/src/helpers/rivenHelper.ts +++ b/src/helpers/rivenHelper.ts @@ -21,11 +21,11 @@ export interface IUnveiledRivenFingerprint { lvlReq: number; rerolls?: number; pol: string; - buffs: IRivenStat[]; - curses: IRivenStat[]; + buffs: IFingerprintStat[]; + curses: IFingerprintStat[]; } -interface IRivenStat { +export interface IFingerprintStat { Tag: string; Value: number; } diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index 397ee1cc..af7898d9 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -2,7 +2,6 @@ import { Types } from "mongoose"; import { IOid, IMongoDate } from "../commonTypes"; import { - ArtifactPolarity, IColor, IItemConfig, IOperatorConfigClient, @@ -11,6 +10,7 @@ import { IEquipmentClient, IOperatorConfigDatabase } from "@/src/types/inventoryTypes/commonInventoryTypes"; +import { IFingerprintStat, RivenFingerprint } from "@/src/helpers/rivenHelper"; export type InventoryDatabaseEquipment = { [_ in TEquipmentKey]: IEquipmentDatabase[]; @@ -869,23 +869,14 @@ export interface IGetting { } export interface IRandomUpgrade { - UpgradeFingerprint: IUpgradeFingerprint; + UpgradeFingerprint: RivenFingerprint; ItemType: string; ItemId: IOid; } -export interface IUpgradeFingerprint { +export interface IInnateDamageFingerprint { compat: string; - lim: number; - lvlReq: number; - pol: ArtifactPolarity; - buffs: IBuff[]; - curses: IBuff[]; -} - -export interface IBuff { - Tag: string; - Value: number; + buffs: IFingerprintStat[]; } export enum GettingSlotOrderInfo {