forked from OpenWF/SpaceNinjaServer
feat: infusing abilities (#676)
This commit is contained in:
parent
48aa145a20
commit
0c6f6e556f
@ -3,11 +3,13 @@ import { IUpgradesRequest } from "@/src/types/requestTypes";
|
||||
import {
|
||||
ArtifactPolarity,
|
||||
IEquipmentDatabase,
|
||||
EquipmentFeatures
|
||||
EquipmentFeatures,
|
||||
IAbilityOverride
|
||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
|
||||
import { getRecipeByResult } from "@/src/services/itemDataService";
|
||||
|
||||
export const upgradesController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
@ -28,97 +30,120 @@ export const upgradesController: RequestHandler = async (req, res) => {
|
||||
]);
|
||||
}
|
||||
|
||||
switch (operation.UpgradeRequirement) {
|
||||
case "/Lotus/Types/Items/MiscItems/OrokinReactor":
|
||||
case "/Lotus/Types/Items/MiscItems/OrokinCatalyst":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.Features ??= 0;
|
||||
item.Features |= EquipmentFeatures.DOUBLE_CAPACITY;
|
||||
break;
|
||||
}
|
||||
if (operation.OperationType == "UOT_ABILITY_OVERRIDE") {
|
||||
console.assert(payload.ItemCategory == "Suits");
|
||||
const suit = inventory.Suits.find(x => x._id.toString() == payload.ItemId.$oid)!;
|
||||
|
||||
let newAbilityOverride: IAbilityOverride | undefined;
|
||||
if (operation.UpgradeRequirement != "") {
|
||||
newAbilityOverride = {
|
||||
Ability: operation.UpgradeRequirement,
|
||||
Index: operation.PolarizeSlot
|
||||
};
|
||||
|
||||
const recipe = getRecipeByResult(operation.UpgradeRequirement)!;
|
||||
for (const ingredient of recipe.ingredients) {
|
||||
inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType)!.Count -=
|
||||
ingredient.ItemCount;
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/UtilityUnlocker":
|
||||
case "/Lotus/Types/Items/MiscItems/WeaponUtilityUnlocker":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.Features ??= 0;
|
||||
item.Features |= EquipmentFeatures.UTILITY_SLOT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/HeavyWeaponCatalyst":
|
||||
console.assert(payload.ItemCategory == "SpaceGuns");
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.Features ??= 0;
|
||||
item.Features |= EquipmentFeatures.GRAVIMAG_INSTALLED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/WeaponPrimaryArcaneUnlocker":
|
||||
case "/Lotus/Types/Items/MiscItems/WeaponSecondaryArcaneUnlocker":
|
||||
case "/Lotus/Types/Items/MiscItems/WeaponMeleeArcaneUnlocker":
|
||||
case "/Lotus/Types/Items/MiscItems/WeaponAmpArcaneUnlocker":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.Features ??= 0;
|
||||
item.Features |= EquipmentFeatures.ARCANE_SLOT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/Forma":
|
||||
case "/Lotus/Types/Items/MiscItems/FormaUmbra":
|
||||
case "/Lotus/Types/Items/MiscItems/FormaAura":
|
||||
case "/Lotus/Types/Items/MiscItems/FormaStance":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.XP = 0;
|
||||
setSlotPolarity(item, operation.PolarizeSlot, operation.PolarizeValue);
|
||||
item.Polarized ??= 0;
|
||||
item.Polarized += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/ModSlotUnlocker":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.ModSlotPurchases ??= 0;
|
||||
item.ModSlotPurchases += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/CustomizationSlotUnlocker":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.CustomizationSlotPurchases ??= 0;
|
||||
item.CustomizationSlotPurchases += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "":
|
||||
console.assert(operation.OperationType == "UOT_SWAP_POLARITY");
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
for (let i = 0; i != operation.PolarityRemap.length; ++i) {
|
||||
if (operation.PolarityRemap[i].Slot != i) {
|
||||
setSlotPolarity(item, i, operation.PolarityRemap[i].Value);
|
||||
}
|
||||
}
|
||||
|
||||
for (const entry of operation.PolarityRemap) {
|
||||
suit.Configs[entry.Slot] ??= {};
|
||||
suit.Configs[entry.Slot].AbilityOverride = newAbilityOverride;
|
||||
}
|
||||
} else
|
||||
switch (operation.UpgradeRequirement) {
|
||||
case "/Lotus/Types/Items/MiscItems/OrokinReactor":
|
||||
case "/Lotus/Types/Items/MiscItems/OrokinCatalyst":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.Features ??= 0;
|
||||
item.Features |= EquipmentFeatures.DOUBLE_CAPACITY;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unsupported upgrade: " + operation.UpgradeRequirement);
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/UtilityUnlocker":
|
||||
case "/Lotus/Types/Items/MiscItems/WeaponUtilityUnlocker":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.Features ??= 0;
|
||||
item.Features |= EquipmentFeatures.UTILITY_SLOT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/HeavyWeaponCatalyst":
|
||||
console.assert(payload.ItemCategory == "SpaceGuns");
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.Features ??= 0;
|
||||
item.Features |= EquipmentFeatures.GRAVIMAG_INSTALLED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/WeaponPrimaryArcaneUnlocker":
|
||||
case "/Lotus/Types/Items/MiscItems/WeaponSecondaryArcaneUnlocker":
|
||||
case "/Lotus/Types/Items/MiscItems/WeaponMeleeArcaneUnlocker":
|
||||
case "/Lotus/Types/Items/MiscItems/WeaponAmpArcaneUnlocker":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.Features ??= 0;
|
||||
item.Features |= EquipmentFeatures.ARCANE_SLOT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/Forma":
|
||||
case "/Lotus/Types/Items/MiscItems/FormaUmbra":
|
||||
case "/Lotus/Types/Items/MiscItems/FormaAura":
|
||||
case "/Lotus/Types/Items/MiscItems/FormaStance":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.XP = 0;
|
||||
setSlotPolarity(item, operation.PolarizeSlot, operation.PolarizeValue);
|
||||
item.Polarized ??= 0;
|
||||
item.Polarized += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/ModSlotUnlocker":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.ModSlotPurchases ??= 0;
|
||||
item.ModSlotPurchases += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/Lotus/Types/Items/MiscItems/CustomizationSlotUnlocker":
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
item.CustomizationSlotPurchases ??= 0;
|
||||
item.CustomizationSlotPurchases += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "":
|
||||
console.assert(operation.OperationType == "UOT_SWAP_POLARITY");
|
||||
for (const item of inventory[payload.ItemCategory]) {
|
||||
if (item._id.toString() == payload.ItemId.$oid) {
|
||||
for (let i = 0; i != operation.PolarityRemap.length; ++i) {
|
||||
if (operation.PolarityRemap[i].Slot != i) {
|
||||
setSlotPolarity(item, i, operation.PolarityRemap[i].Value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unsupported upgrade: " + operation.UpgradeRequirement);
|
||||
}
|
||||
}
|
||||
await inventory.save();
|
||||
res.json({ InventoryChanges: {} });
|
||||
|
@ -65,6 +65,10 @@ export const getRecipe = (uniqueName: string): IRecipe | undefined => {
|
||||
return ExportRecipes[uniqueName];
|
||||
};
|
||||
|
||||
export const getRecipeByResult = (resultType: string): IRecipe | undefined => {
|
||||
return Object.values(ExportRecipes).find(x => x.resultType == resultType);
|
||||
};
|
||||
|
||||
export const getExalted = (uniqueName: string): string[] | undefined => {
|
||||
return getSuitByUniqueName(uniqueName)?.exalted;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user