feat: remove incarnon #688
@ -9,9 +9,9 @@ export const evolveWeaponController: RequestHandler = async (req, res) => {
|
|||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
const payload = getJSONfromString(String(req.body)) as IEvolveWeaponRequest;
|
const payload = getJSONfromString(String(req.body)) as IEvolveWeaponRequest;
|
||||||
console.assert(payload.Action == "EWA_INSTALL");
|
|
||||||
|
|
||||||
const recipe = getRecipe(payload.Recipe)!;
|
const recipe = getRecipe(payload.Recipe)!;
|
||||||
|
if (payload.Action == "EWA_INSTALL") {
|
||||||
addMiscItems(
|
addMiscItems(
|
||||||
inventory,
|
inventory,
|
||||||
recipe.ingredients.map(x => ({ ItemType: x.ItemType, ItemCount: x.ItemCount * -1 }))
|
recipe.ingredients.map(x => ({ ItemType: x.ItemType, ItemCount: x.ItemCount * -1 }))
|
||||||
@ -31,13 +31,26 @@ export const evolveWeaponController: RequestHandler = async (req, res) => {
|
|||||||
ItemType: payload.EvoType
|
ItemType: payload.EvoType
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else if (payload.Action == "EWA_UNINSTALL") {
|
||||||
|
addMiscItems(inventory, [
|
||||||
|
{
|
||||||
|
ItemType: recipe.resultType,
|
||||||
|
ItemCount: 1
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
|||||||
|
const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
|
||||||
|
item.Features! &= ~EquipmentFeatures.INCARNON_GENESIS;
|
||||||
|
} else {
|
||||||
|
throw new Error(`unexpected evolve weapon action: ${payload.Action}`);
|
||||||
|
}
|
||||||
|
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
res.end();
|
res.end();
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IEvolveWeaponRequest {
|
interface IEvolveWeaponRequest {
|
||||||
Action: "EWA_INSTALL";
|
Action: string;
|
||||||
Category: WeaponTypeInternal;
|
Category: WeaponTypeInternal;
|
||||||
Recipe: string; // e.g. "/Lotus/Types/Items/MiscItems/IncarnonAdapters/UnlockerBlueprints/DespairIncarnonBlueprint"
|
Recipe: string; // e.g. "/Lotus/Types/Items/MiscItems/IncarnonAdapters/UnlockerBlueprints/DespairIncarnonBlueprint"
|
||||||
UninstallRecipe: "";
|
UninstallRecipe: "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user
💡 Codebase verification
Based on the analysis of the codebase, I can now provide the final response:
The non-null assertion is risky and should be handled properly
Looking at the error handling patterns in the codebase, particularly in
gildWeaponController.ts
, there's a consistent pattern of checking for item existence and throwing descriptive errors. The current use of non-null assertion (!
) inevolveWeaponController.ts
could lead to runtime errors if the item is not found.The suggested changes are:
gildWeaponController.ts
that properly validate item existence🔗 Analysis chain
Verify item existence before using the non-null assertion operator.
Using
!
onfind(...)
can cause a runtime error iffind
returnsundefined
. Consider throwing a descriptive error or gracefully handling the missing item.Let me gather more information about the codebase to verify the concern.
🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
Length of output: 12272