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

XFESpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/XFESpaceNinjaServer

feat: identify & repair railjack armaments (#1686)

Closes #1676 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1686 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

66e34b7b
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

3 个文件 +72 -27
Modified src/controllers/api/crewShipIdentifySalvageController.ts +50 -19
@@ -1,33 +1,64 @@
1 import { addCrewShipSalvagedWeaponSkin, addCrewShipRawSalvage, getInventory } from "@/src/services/inventoryService";
1 import {
2 addCrewShipSalvagedWeaponSkin,
3 addCrewShipRawSalvage,
4 getInventory,
5 addEquipment
6 } from "@/src/services/inventoryService";
2 7 import { getAccountIdForRequest } from "@/src/services/loginService";
3 8 import { RequestHandler } from "express";
4 import { ICrewShipComponentFingerprint } from "@/src/types/inventoryTypes/inventoryTypes";
5 import { ExportCustoms } from "warframe-public-export-plus";
9 import { ICrewShipComponentFingerprint, IInnateDamageFingerprint } from "@/src/types/inventoryTypes/inventoryTypes";
10 import { ExportCustoms, ExportRailjackWeapons, ExportUpgrades } from "warframe-public-export-plus";
6 11 import { getJSONfromString } from "@/src/helpers/stringHelpers";
7 12 import { IInventoryChanges } from "@/src/types/purchaseTypes";
8 13 import { getRandomInt } from "@/src/services/rngService";
14 import { IFingerprintStat } from "@/src/helpers/rivenHelper";
9 15
10 16 export const crewShipIdentifySalvageController: RequestHandler = async (req, res) => {
11 17 const accountId = await getAccountIdForRequest(req);
12 const inventory = await getInventory(accountId, "CrewShipSalvagedWeaponSkins CrewShipRawSalvage");
18 const inventory = await getInventory(
19 accountId,
20 "CrewShipSalvagedWeaponSkins CrewShipSalvagedWeapons CrewShipRawSalvage"
21 );
13 22 const payload = getJSONfromString<ICrewShipIdentifySalvageRequest>(String(req.body));
14 23
15 const meta = ExportCustoms[payload.ItemType];
16 let upgradeFingerprint: ICrewShipComponentFingerprint = { compat: payload.ItemType, buffs: [] };
17 if (meta.subroutines) {
18 upgradeFingerprint = {
19 SubroutineIndex: getRandomInt(0, meta.subroutines.length - 1),
20 ...upgradeFingerprint
21 };
22 }
23 for (const upgrade of meta.randomisedUpgrades!) {
24 upgradeFingerprint.buffs.push({ Tag: upgrade.tag, Value: Math.trunc(Math.random() * 0x40000000) });
24 const inventoryChanges: IInventoryChanges = {};
25 if (payload.ItemType in ExportCustoms) {
26 const meta = ExportCustoms[payload.ItemType];
27 let upgradeFingerprint: ICrewShipComponentFingerprint = { compat: payload.ItemType, buffs: [] };
28 if (meta.subroutines) {
29 upgradeFingerprint = {
30 SubroutineIndex: getRandomInt(0, meta.subroutines.length - 1),
31 ...upgradeFingerprint
32 };
33 }
34 for (const upgrade of meta.randomisedUpgrades!) {
35 upgradeFingerprint.buffs.push({ Tag: upgrade.tag, Value: Math.trunc(Math.random() * 0x40000000) });
36 }
37 addCrewShipSalvagedWeaponSkin(
38 inventory,
39 payload.ItemType,
40 JSON.stringify(upgradeFingerprint),
41 inventoryChanges
42 );
43 } else {
44 const meta = ExportRailjackWeapons[payload.ItemType];
45 const upgradeType = meta.defaultUpgrades![0].ItemType;
46 const upgradeMeta = ExportUpgrades[upgradeType];
47 const buffs: IFingerprintStat[] = [];
48 for (const buff of upgradeMeta.upgradeEntries!) {
49 buffs.push({
50 Tag: buff.tag,
51 Value: Math.trunc(Math.random() * 0x40000000)
52 });
53 }
54 addEquipment(inventory, "CrewShipSalvagedWeapons", payload.ItemType, undefined, inventoryChanges, {
55 UpgradeType: upgradeType,
56 UpgradeFingerprint: JSON.stringify({
57 compat: payload.ItemType,
58 buffs
59 } satisfies IInnateDamageFingerprint)
60 });
25 61 }
26 const inventoryChanges: IInventoryChanges = addCrewShipSalvagedWeaponSkin(
27 inventory,
28 payload.ItemType,
29 JSON.stringify(upgradeFingerprint)
30 );
31 62
32 63 inventoryChanges.CrewShipRawSalvage = [
33 64 {
Modified src/controllers/api/guildTechController.ts +21 -7
@@ -15,6 +15,7 @@ import { ExportDojoRecipes } from "warframe-public-export-plus";
15 15 import { getAccountIdForRequest } from "@/src/services/loginService";
16 16 import {
17 17 addCrewShipWeaponSkin,
18 addEquipment,
18 19 addItem,
19 20 addMiscItems,
20 21 addRecipes,
@@ -382,18 +383,31 @@ interface IGuildTechContributeRequest {
382 383 const claimSalvagedComponent = (inventory: TInventoryDatabaseDocument, itemId: string): IInventoryChanges => {
383 384 // delete personal tech project
384 385 const personalTechProjectIndex = inventory.PersonalTechProjects.findIndex(x => x.CategoryItemId?.equals(itemId));
385 if (personalTechProjectIndex != -1) {
386 inventory.PersonalTechProjects.splice(personalTechProjectIndex, 1);
387 }
386 const personalTechProject = inventory.PersonalTechProjects[personalTechProjectIndex];
387 inventory.PersonalTechProjects.splice(personalTechProjectIndex, 1);
388
389 const category = personalTechProject.ProductCategory! as "CrewShipWeapons" | "CrewShipWeaponSkins";
390 const salvageCategory = category == "CrewShipWeapons" ? "CrewShipSalvagedWeapons" : "CrewShipSalvagedWeaponSkins";
388 391
389 392 // find salved part & delete it
390 const crewShipSalvagedWeaponSkinsIndex = inventory.CrewShipSalvagedWeaponSkins.findIndex(x => x._id.equals(itemId));
391 const crewShipWeaponSkin = inventory.CrewShipSalvagedWeaponSkins[crewShipSalvagedWeaponSkinsIndex];
392 inventory.CrewShipSalvagedWeaponSkins.splice(crewShipSalvagedWeaponSkinsIndex, 1);
393 const salvageIndex = inventory[salvageCategory].findIndex(x => x._id.equals(itemId));
394 const salvageItem = inventory[category][salvageIndex];
395 inventory[salvageCategory].splice(salvageIndex, 1);
393 396
394 397 // add final item
395 398 const inventoryChanges = {
396 ...addCrewShipWeaponSkin(inventory, crewShipWeaponSkin.ItemType, crewShipWeaponSkin.UpgradeFingerprint),
399 ...(category == "CrewShipWeaponSkins"
400 ? addCrewShipWeaponSkin(inventory, salvageItem.ItemType, salvageItem.UpgradeFingerprint)
401 : addEquipment(
402 inventory,
403 category,
404 salvageItem.ItemType,
405 undefined,
406 {},
407 {
408 UpgradeFingerprint: salvageItem.UpgradeFingerprint
409 }
410 )),
397 411 ...occupySlot(inventory, InventorySlot.RJ_COMPONENT_AND_ARMAMENTS, false)
398 412 };
399 413
Modified src/services/inventoryService.ts +1 -1
@@ -1083,7 +1083,7 @@ export const addEquipment = (
1083 1083 Configs: [],
1084 1084 XP: 0,
1085 1085 ModularParts: modularParts,
1086 IsNew: category != "CrewShipWeapons" ? true : undefined
1086 IsNew: category != "CrewShipWeapons" && category != "CrewShipSalvagedWeapons" ? true : undefined
1087 1087 },
1088 1088 defaultOverwrites
1089 1089 );