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 {
|
import {
|
||||||
ArtifactPolarity,
|
ArtifactPolarity,
|
||||||
IEquipmentDatabase,
|
IEquipmentDatabase,
|
||||||
EquipmentFeatures
|
EquipmentFeatures,
|
||||||
|
IAbilityOverride
|
||||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
|
} from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
|
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
|
||||||
|
import { getRecipeByResult } from "@/src/services/itemDataService";
|
||||||
|
|
||||||
export const upgradesController: RequestHandler = async (req, res) => {
|
export const upgradesController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
@ -28,6 +30,29 @@ export const upgradesController: RequestHandler = async (req, res) => {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const entry of operation.PolarityRemap) {
|
||||||
|
suit.Configs[entry.Slot] ??= {};
|
||||||
|
suit.Configs[entry.Slot].AbilityOverride = newAbilityOverride;
|
||||||
|
}
|
||||||
|
} else
|
||||||
switch (operation.UpgradeRequirement) {
|
switch (operation.UpgradeRequirement) {
|
||||||
case "/Lotus/Types/Items/MiscItems/OrokinReactor":
|
case "/Lotus/Types/Items/MiscItems/OrokinReactor":
|
||||||
case "/Lotus/Types/Items/MiscItems/OrokinCatalyst":
|
case "/Lotus/Types/Items/MiscItems/OrokinCatalyst":
|
||||||
|
@ -65,6 +65,10 @@ export const getRecipe = (uniqueName: string): IRecipe | undefined => {
|
|||||||
return ExportRecipes[uniqueName];
|
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 => {
|
export const getExalted = (uniqueName: string): string[] | undefined => {
|
||||||
return getSuitByUniqueName(uniqueName)?.exalted;
|
return getSuitByUniqueName(uniqueName)?.exalted;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user