feat: identify & repair railjack armaments (#1686)
Closes #1676 Reviewed-on: #1686 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
9940024a01
commit
66e34b7be9
@ -1,33 +1,64 @@
|
|||||||
import { addCrewShipSalvagedWeaponSkin, addCrewShipRawSalvage, getInventory } from "@/src/services/inventoryService";
|
import {
|
||||||
|
addCrewShipSalvagedWeaponSkin,
|
||||||
|
addCrewShipRawSalvage,
|
||||||
|
getInventory,
|
||||||
|
addEquipment
|
||||||
|
} from "@/src/services/inventoryService";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { ICrewShipComponentFingerprint } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { ICrewShipComponentFingerprint, IInnateDamageFingerprint } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { ExportCustoms } from "warframe-public-export-plus";
|
import { ExportCustoms, ExportRailjackWeapons, ExportUpgrades } from "warframe-public-export-plus";
|
||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||||
import { getRandomInt } from "@/src/services/rngService";
|
import { getRandomInt } from "@/src/services/rngService";
|
||||||
|
import { IFingerprintStat } from "@/src/helpers/rivenHelper";
|
||||||
|
|
||||||
export const crewShipIdentifySalvageController: RequestHandler = async (req, res) => {
|
export const crewShipIdentifySalvageController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const inventory = await getInventory(accountId, "CrewShipSalvagedWeaponSkins CrewShipRawSalvage");
|
const inventory = await getInventory(
|
||||||
|
accountId,
|
||||||
|
"CrewShipSalvagedWeaponSkins CrewShipSalvagedWeapons CrewShipRawSalvage"
|
||||||
|
);
|
||||||
const payload = getJSONfromString<ICrewShipIdentifySalvageRequest>(String(req.body));
|
const payload = getJSONfromString<ICrewShipIdentifySalvageRequest>(String(req.body));
|
||||||
|
|
||||||
const meta = ExportCustoms[payload.ItemType];
|
const inventoryChanges: IInventoryChanges = {};
|
||||||
let upgradeFingerprint: ICrewShipComponentFingerprint = { compat: payload.ItemType, buffs: [] };
|
if (payload.ItemType in ExportCustoms) {
|
||||||
if (meta.subroutines) {
|
const meta = ExportCustoms[payload.ItemType];
|
||||||
upgradeFingerprint = {
|
let upgradeFingerprint: ICrewShipComponentFingerprint = { compat: payload.ItemType, buffs: [] };
|
||||||
SubroutineIndex: getRandomInt(0, meta.subroutines.length - 1),
|
if (meta.subroutines) {
|
||||||
...upgradeFingerprint
|
upgradeFingerprint = {
|
||||||
};
|
SubroutineIndex: getRandomInt(0, meta.subroutines.length - 1),
|
||||||
|
...upgradeFingerprint
|
||||||
|
};
|
||||||
|
}
|
||||||
|
for (const upgrade of meta.randomisedUpgrades!) {
|
||||||
|
upgradeFingerprint.buffs.push({ Tag: upgrade.tag, Value: Math.trunc(Math.random() * 0x40000000) });
|
||||||
|
}
|
||||||
|
addCrewShipSalvagedWeaponSkin(
|
||||||
|
inventory,
|
||||||
|
payload.ItemType,
|
||||||
|
JSON.stringify(upgradeFingerprint),
|
||||||
|
inventoryChanges
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const meta = ExportRailjackWeapons[payload.ItemType];
|
||||||
|
const upgradeType = meta.defaultUpgrades![0].ItemType;
|
||||||
|
const upgradeMeta = ExportUpgrades[upgradeType];
|
||||||
|
const buffs: IFingerprintStat[] = [];
|
||||||
|
for (const buff of upgradeMeta.upgradeEntries!) {
|
||||||
|
buffs.push({
|
||||||
|
Tag: buff.tag,
|
||||||
|
Value: Math.trunc(Math.random() * 0x40000000)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
addEquipment(inventory, "CrewShipSalvagedWeapons", payload.ItemType, undefined, inventoryChanges, {
|
||||||
|
UpgradeType: upgradeType,
|
||||||
|
UpgradeFingerprint: JSON.stringify({
|
||||||
|
compat: payload.ItemType,
|
||||||
|
buffs
|
||||||
|
} satisfies IInnateDamageFingerprint)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
for (const upgrade of meta.randomisedUpgrades!) {
|
|
||||||
upgradeFingerprint.buffs.push({ Tag: upgrade.tag, Value: Math.trunc(Math.random() * 0x40000000) });
|
|
||||||
}
|
|
||||||
const inventoryChanges: IInventoryChanges = addCrewShipSalvagedWeaponSkin(
|
|
||||||
inventory,
|
|
||||||
payload.ItemType,
|
|
||||||
JSON.stringify(upgradeFingerprint)
|
|
||||||
);
|
|
||||||
|
|
||||||
inventoryChanges.CrewShipRawSalvage = [
|
inventoryChanges.CrewShipRawSalvage = [
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ import { ExportDojoRecipes } from "warframe-public-export-plus";
|
|||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import {
|
import {
|
||||||
addCrewShipWeaponSkin,
|
addCrewShipWeaponSkin,
|
||||||
|
addEquipment,
|
||||||
addItem,
|
addItem,
|
||||||
addMiscItems,
|
addMiscItems,
|
||||||
addRecipes,
|
addRecipes,
|
||||||
@ -382,18 +383,31 @@ interface IGuildTechContributeRequest {
|
|||||||
const claimSalvagedComponent = (inventory: TInventoryDatabaseDocument, itemId: string): IInventoryChanges => {
|
const claimSalvagedComponent = (inventory: TInventoryDatabaseDocument, itemId: string): IInventoryChanges => {
|
||||||
// delete personal tech project
|
// delete personal tech project
|
||||||
const personalTechProjectIndex = inventory.PersonalTechProjects.findIndex(x => x.CategoryItemId?.equals(itemId));
|
const personalTechProjectIndex = inventory.PersonalTechProjects.findIndex(x => x.CategoryItemId?.equals(itemId));
|
||||||
if (personalTechProjectIndex != -1) {
|
const personalTechProject = inventory.PersonalTechProjects[personalTechProjectIndex];
|
||||||
inventory.PersonalTechProjects.splice(personalTechProjectIndex, 1);
|
inventory.PersonalTechProjects.splice(personalTechProjectIndex, 1);
|
||||||
}
|
|
||||||
|
const category = personalTechProject.ProductCategory! as "CrewShipWeapons" | "CrewShipWeaponSkins";
|
||||||
|
const salvageCategory = category == "CrewShipWeapons" ? "CrewShipSalvagedWeapons" : "CrewShipSalvagedWeaponSkins";
|
||||||
|
|
||||||
// find salved part & delete it
|
// find salved part & delete it
|
||||||
const crewShipSalvagedWeaponSkinsIndex = inventory.CrewShipSalvagedWeaponSkins.findIndex(x => x._id.equals(itemId));
|
const salvageIndex = inventory[salvageCategory].findIndex(x => x._id.equals(itemId));
|
||||||
const crewShipWeaponSkin = inventory.CrewShipSalvagedWeaponSkins[crewShipSalvagedWeaponSkinsIndex];
|
const salvageItem = inventory[category][salvageIndex];
|
||||||
inventory.CrewShipSalvagedWeaponSkins.splice(crewShipSalvagedWeaponSkinsIndex, 1);
|
inventory[salvageCategory].splice(salvageIndex, 1);
|
||||||
|
|
||||||
// add final item
|
// add final item
|
||||||
const inventoryChanges = {
|
const inventoryChanges = {
|
||||||
...addCrewShipWeaponSkin(inventory, crewShipWeaponSkin.ItemType, crewShipWeaponSkin.UpgradeFingerprint),
|
...(category == "CrewShipWeaponSkins"
|
||||||
|
? addCrewShipWeaponSkin(inventory, salvageItem.ItemType, salvageItem.UpgradeFingerprint)
|
||||||
|
: addEquipment(
|
||||||
|
inventory,
|
||||||
|
category,
|
||||||
|
salvageItem.ItemType,
|
||||||
|
undefined,
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
UpgradeFingerprint: salvageItem.UpgradeFingerprint
|
||||||
|
}
|
||||||
|
)),
|
||||||
...occupySlot(inventory, InventorySlot.RJ_COMPONENT_AND_ARMAMENTS, false)
|
...occupySlot(inventory, InventorySlot.RJ_COMPONENT_AND_ARMAMENTS, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1083,7 +1083,7 @@ export const addEquipment = (
|
|||||||
Configs: [],
|
Configs: [],
|
||||||
XP: 0,
|
XP: 0,
|
||||||
ModularParts: modularParts,
|
ModularParts: modularParts,
|
||||||
IsNew: category != "CrewShipWeapons" ? true : undefined
|
IsNew: category != "CrewShipWeapons" && category != "CrewShipSalvagedWeapons" ? true : undefined
|
||||||
},
|
},
|
||||||
defaultOverwrites
|
defaultOverwrites
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user