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

XFESpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/XFESpaceNinjaServer

fix: removing an archon shard doesn't refund it (#729)

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

代码差异

1 个文件 +19 -0
Modified src/controllers/api/infestedFoundryController.ts +19 -0
@@ -52,14 +52,33 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
52 52 const request = getJSONfromString(String(req.body)) as IShardUninstallRequest;
53 53 const inventory = await getInventory(accountId);
54 54 const suit = inventory.Suits.find(suit => suit._id.toString() == request.SuitId.$oid)!;
55
56 // refund shard
57 const shard = Object.entries(colorToShard).find(
58 ([color]) => color == suit.ArchonCrystalUpgrades![request.Slot].Color
59 )![1];
60 const miscItemChanges = [
61 {
62 ItemType: shard,
63 ItemCount: 1
64 }
65 ];
66 addMiscItems(inventory, miscItemChanges);
67
68 // remove from suit
55 69 suit.ArchonCrystalUpgrades![request.Slot] = {};
70
71 // remove bile
56 72 const bile = inventory.InfestedFoundry!.Resources!.find(
57 73 x => x.ItemType == "/Lotus/Types/Items/InfestedFoundry/HelminthBile"
58 74 )!;
59 75 bile.Count -= 300;
76
60 77 await inventory.save();
78
61 79 res.json({
62 80 InventoryChanges: {
81 MiscItems: miscItemChanges,
63 82 InfestedFoundry: inventory.toJSON().InfestedFoundry
64 83 }
65 84 });