XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

feat: valence fusion (#1251)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1251

9b16dc2c
Sainan <sainan@calamity.inc>
提交于

代码差异

4 个文件 +61 -31
Modified src/controllers/api/nemesisController.ts +53 -6
@@ -1,16 +1,56 @@
1 1 import { getJSONfromString } from "@/src/helpers/stringHelpers";
2 import { getInventory } from "@/src/services/inventoryService";
2 import { freeUpSlot, getInventory } from "@/src/services/inventoryService";
3 3 import { getAccountIdForRequest } from "@/src/services/loginService";
4 4 import { SRng } from "@/src/services/rngService";
5 import { IMongoDate } from "@/src/types/commonTypes";
6 import { IInfNode } from "@/src/types/inventoryTypes/inventoryTypes";
5 import { IMongoDate, IOid } from "@/src/types/commonTypes";
6 import {
7 IInfNode,
8 IInnateDamageFingerprint,
9 InventorySlot,
10 TEquipmentKey
11 } from "@/src/types/inventoryTypes/inventoryTypes";
7 12 import { logger } from "@/src/utils/logger";
8 13 import { RequestHandler } from "express";
9 14 import { ExportRegions } from "warframe-public-export-plus";
10 15
11 16 export const nemesisController: RequestHandler = async (req, res) => {
12 if ((req.query.mode as string) == "s") {
13 const accountId = await getAccountIdForRequest(req);
17 const accountId = await getAccountIdForRequest(req);
18 if ((req.query.mode as string) == "f") {
19 const body = getJSONfromString<IValenceFusionRequest>(String(req.body));
20 const inventory = await getInventory(accountId, body.Category + " WeaponBin");
21 const destWeapon = inventory[body.Category].id(body.DestWeapon.$oid)!;
22 const sourceWeapon = inventory[body.Category].id(body.SourceWeapon.$oid)!;
23 const destFingerprint = JSON.parse(destWeapon.UpgradeFingerprint!) as IInnateDamageFingerprint;
24 const sourceFingerprint = JSON.parse(sourceWeapon.UpgradeFingerprint!) as IInnateDamageFingerprint;
25
26 // Upgrade destination damage type if desireed
27 if (body.UseSourceDmgType) {
28 destFingerprint.buffs[0].Tag = sourceFingerprint.buffs[0].Tag;
29 }
30
31 // Upgrade destination damage value
32 const destDamage = 0.25 + (destFingerprint.buffs[0].Value / 0x3fffffff) * (0.6 - 0.25);
33 const sourceDamage = 0.25 + (sourceFingerprint.buffs[0].Value / 0x3fffffff) * (0.6 - 0.25);
34 let newDamage = Math.max(destDamage, sourceDamage) * 1.1;
35 if (newDamage >= 0.58) {
36 newDamage = 0.6;
37 }
38 destFingerprint.buffs[0].Value = Math.trunc(((newDamage - 0.25) / (0.6 - 0.25)) * 0x3fffffff);
39
40 // Commit fingerprint
41 destWeapon.UpgradeFingerprint = JSON.stringify(destFingerprint);
42
43 // Remove source weapon
44 inventory[body.Category].pull({ _id: body.SourceWeapon.$oid });
45 freeUpSlot(inventory, InventorySlot.WEAPONS);
46
47 await inventory.save();
48 res.json({
49 InventoryChanges: {
50 [body.Category]: [destWeapon.toJSON()]
51 }
52 });
53 } else if ((req.query.mode as string) == "s") {
14 54 const inventory = await getInventory(accountId, "Nemesis NemesisAbandonedRewards");
15 55 const body = getJSONfromString<INemesisStartRequest>(String(req.body));
16 56 body.target.fp = BigInt(body.target.fp);
@@ -116,7 +156,14 @@ export const nemesisController: RequestHandler = async (req, res) => {
116 156 }
117 157 };
118 158
119 export interface INemesisStartRequest {
159 interface IValenceFusionRequest {
160 DestWeapon: IOid;
161 SourceWeapon: IOid;
162 Category: TEquipmentKey;
163 UseSourceDmgType: boolean;
164 }
165
166 interface INemesisStartRequest {
120 167 target: {
121 168 fp: number | bigint;
122 169 manifest: string;
Modified src/controllers/api/valenceSwapController.ts +1 -9
@@ -1,7 +1,7 @@
1 1 import { getInventory } from "@/src/services/inventoryService";
2 2 import { getAccountIdForRequest } from "@/src/services/loginService";
3 3 import { IOid } from "@/src/types/commonTypes";
4 import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
4 import { IInnateDamageFingerprint, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
5 5 import { RequestHandler } from "express";
6 6
7 7 export const valenceSwapController: RequestHandler = async (req, res) => {
@@ -27,11 +27,3 @@ interface IValenceSwapRequest {
27 27 WeaponCategory: TEquipmentKey;
28 28 NewValenceUpgradeTag: string;
29 29 }
30
31 interface IInnateDamageFingerprint {
32 compat: string;
33 buffs: {
34 Tag: string;
35 Value: number;
36 }[];
37 }
Modified src/helpers/rivenHelper.ts +3 -3
@@ -21,11 +21,11 @@ export interface IUnveiledRivenFingerprint {
21 21 lvlReq: number;
22 22 rerolls?: number;
23 23 pol: string;
24 buffs: IRivenStat[];
25 curses: IRivenStat[];
24 buffs: IFingerprintStat[];
25 curses: IFingerprintStat[];
26 26 }
27 27
28 interface IRivenStat {
28 export interface IFingerprintStat {
29 29 Tag: string;
30 30 Value: number;
31 31 }
Modified src/types/inventoryTypes/inventoryTypes.ts +4 -13
@@ -2,7 +2,6 @@
2 2 import { Types } from "mongoose";
3 3 import { IOid, IMongoDate } from "../commonTypes";
4 4 import {
5 ArtifactPolarity,
6 5 IColor,
7 6 IItemConfig,
8 7 IOperatorConfigClient,
@@ -11,6 +10,7 @@ import {
11 10 IEquipmentClient,
12 11 IOperatorConfigDatabase
13 12 } from "@/src/types/inventoryTypes/commonInventoryTypes";
13 import { IFingerprintStat, RivenFingerprint } from "@/src/helpers/rivenHelper";
14 14
15 15 export type InventoryDatabaseEquipment = {
16 16 [_ in TEquipmentKey]: IEquipmentDatabase[];
@@ -869,23 +869,14 @@ export interface IGetting {
869 869 }
870 870
871 871 export interface IRandomUpgrade {
872 UpgradeFingerprint: IUpgradeFingerprint;
872 UpgradeFingerprint: RivenFingerprint;
873 873 ItemType: string;
874 874 ItemId: IOid;
875 875 }
876 876
877 export interface IUpgradeFingerprint {
877 export interface IInnateDamageFingerprint {
878 878 compat: string;
879 lim: number;
880 lvlReq: number;
881 pol: ArtifactPolarity;
882 buffs: IBuff[];
883 curses: IBuff[];
884 }
885
886 export interface IBuff {
887 Tag: string;
888 Value: number;
879 buffs: IFingerprintStat[];
889 880 }
890 881
891 882 export enum GettingSlotOrderInfo {