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: trade fish for standing (#681)

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

代码差异

3 个文件 +33 -15
Modified package-lock.json +4 -4
@@ -12,7 +12,7 @@
12 12 "copyfiles": "^2.4.1",
13 13 "express": "^5",
14 14 "mongoose": "^8.9.2",
15 "warframe-public-export-plus": "^0.5.17",
15 "warframe-public-export-plus": "^0.5.18",
16 16 "warframe-riven-info": "^0.1.2",
17 17 "winston": "^3.17.0",
18 18 "winston-daily-rotate-file": "^5.0.0"
@@ -3778,9 +3778,9 @@
3778 3778 }
3779 3779 },
3780 3780 "node_modules/warframe-public-export-plus": {
3781 "version": "0.5.17",
3782 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.17.tgz",
3783 "integrity": "sha512-AWOfUxDHz+UmpbA9ZUGLIrP+3eQOiVq9tw1FXgx7ySkJLEnZUsoi3wn0IFiavSy2iE6JQIyCiSIZCJQTaCV6kA=="
3781 "version": "0.5.18",
3782 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.18.tgz",
3783 "integrity": "sha512-wUaW5Ua5tXHOYkKJxbealdCcTnRLUN7UCkvYOJEwlB/H14EBzDaqxg4engGqzbq4H8fmttyp3EUo4vazSaxZWg=="
3784 3784 },
3785 3785 "node_modules/warframe-riven-info": {
3786 3786 "version": "0.1.2",
Modified package.json +1 -1
@@ -16,7 +16,7 @@
16 16 "copyfiles": "^2.4.1",
17 17 "express": "^5",
18 18 "mongoose": "^8.9.2",
19 "warframe-public-export-plus": "^0.5.17",
19 "warframe-public-export-plus": "^0.5.18",
20 20 "warframe-riven-info": "^0.1.2",
21 21 "winston": "^3.17.0",
22 22 "winston-daily-rotate-file": "^5.0.0"
Modified src/controllers/api/fishmongerController.ts +28 -10
@@ -6,30 +6,48 @@ import { RequestHandler } from "express";
6 6 import { ExportResources } from "warframe-public-export-plus";
7 7
8 8 export const fishmongerController: RequestHandler = async (req, res) => {
9 if (!req.query.dissect) {
10 throw new Error("expected fishmonger request to be for dissection");
11 }
12 9 const accountId = await getAccountIdForRequest(req);
13 10 const inventory = await getInventory(accountId);
14 11 const body = getJSONfromString(String(req.body)) as IFishmongerRequest;
15 12 const miscItemChanges: IMiscItem[] = [];
13 let syndicateTag: string | undefined;
14 let standingChange = 0;
16 15 for (const fish of body.Fish) {
17 for (const part of ExportResources[fish.ItemType].dissectionParts!) {
18 const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType);
19 if (partItem) {
20 partItem.ItemCount += part.ItemCount;
21 } else {
22 miscItemChanges.push(part);
16 const fishData = ExportResources[fish.ItemType];
17 if (req.query.dissect == "1") {
18 for (const part of fishData.dissectionParts!) {
19 const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType);
20 if (partItem) {
21 partItem.ItemCount += part.ItemCount * fish.ItemCount;
22 } else {
23 miscItemChanges.push({ ItemType: part.ItemType, ItemCount: part.ItemCount * fish.ItemCount });
24 }
23 25 }
26 } else {
27 syndicateTag = fishData.syndicateTag!;
28 standingChange += fishData.standingBonus! * fish.ItemCount;
24 29 }
25 30 miscItemChanges.push({ ItemType: fish.ItemType, ItemCount: fish.ItemCount * -1 });
26 31 }
27 32 addMiscItems(inventory, miscItemChanges);
33 if (standingChange && syndicateTag) {
34 const syndicate = inventory.Affiliations.find(x => x.Tag == syndicateTag);
35 if (syndicate !== undefined) {
36 syndicate.Standing += standingChange;
37 } else {
38 inventory.Affiliations.push({
39 Tag: syndicateTag,
40 Standing: standingChange
41 });
42 }
43 }
28 44 await inventory.save();
29 45 res.json({
30 46 InventoryChanges: {
31 47 MiscItems: miscItemChanges
32 }
48 },
49 SyndicateTag: syndicateTag,
50 StandingChange: standingChange
33 51 });
34 52 };
35 53