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

SpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/SpaceNinjaServer

feat: remove incarnon (#688)

c80dd1bb
Sainan <sainan@calamity.inc>
提交于

代码差异

1 个文件 +33 -20
Modified src/controllers/api/evolveWeaponController.ts +33 -20
@@ -9,27 +9,40 @@ export const evolveWeaponController: RequestHandler = async (req, res) => {
9 9 const accountId = await getAccountIdForRequest(req);
10 10 const inventory = await getInventory(accountId);
11 11 const payload = getJSONfromString(String(req.body)) as IEvolveWeaponRequest;
12 console.assert(payload.Action == "EWA_INSTALL");
13 12
14 13 const recipe = getRecipe(payload.Recipe)!;
15 addMiscItems(
16 inventory,
17 recipe.ingredients.map(x => ({ ItemType: x.ItemType, ItemCount: x.ItemCount * -1 }))
18 );
19
20 const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
21 item.Features ??= 0;
22 item.Features |= EquipmentFeatures.INCARNON_GENESIS;
23
24 item.SkillTree = "0";
25
26 inventory.EvolutionProgress ??= [];
27 if (!inventory.EvolutionProgress.find(entry => entry.ItemType == payload.EvoType)) {
28 inventory.EvolutionProgress.push({
29 Progress: 0,
30 Rank: 1,
31 ItemType: payload.EvoType
32 });
14 if (payload.Action == "EWA_INSTALL") {
15 addMiscItems(
16 inventory,
17 recipe.ingredients.map(x => ({ ItemType: x.ItemType, ItemCount: x.ItemCount * -1 }))
18 );
19
20 const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
21 item.Features ??= 0;
22 item.Features |= EquipmentFeatures.INCARNON_GENESIS;
23
24 item.SkillTree = "0";
25
26 inventory.EvolutionProgress ??= [];
27 if (!inventory.EvolutionProgress.find(entry => entry.ItemType == payload.EvoType)) {
28 inventory.EvolutionProgress.push({
29 Progress: 0,
30 Rank: 1,
31 ItemType: payload.EvoType
32 });
33 }
34 } else if (payload.Action == "EWA_UNINSTALL") {
35 addMiscItems(inventory, [
36 {
37 ItemType: recipe.resultType,
38 ItemCount: 1
39 }
40 ]);
41
42 const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
43 item.Features! &= ~EquipmentFeatures.INCARNON_GENESIS;
44 } else {
45 throw new Error(`unexpected evolve weapon action: ${payload.Action}`);
33 46 }
34 47
35 48 await inventory.save();
@@ -37,7 +50,7 @@ export const evolveWeaponController: RequestHandler = async (req, res) => {
37 50 };
38 51
39 52 interface IEvolveWeaponRequest {
40 Action: "EWA_INSTALL";
53 Action: string;
41 54 Category: WeaponTypeInternal;
42 55 Recipe: string; // e.g. "/Lotus/Types/Items/MiscItems/IncarnonAdapters/UnlockerBlueprints/DespairIncarnonBlueprint"
43 56 UninstallRecipe: "";