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 in modular weapons for standing (#1172)

Closes #1055 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1172

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

代码差异

3 个文件 +47 -13
Modified package-lock.json +4 -4
@@ -17,7 +17,7 @@
17 17 "mongoose": "^8.11.0",
18 18 "morgan": "^1.10.0",
19 19 "typescript": ">=4.7.4 <5.6.0",
20 "warframe-public-export-plus": "^0.5.43",
20 "warframe-public-export-plus": "^0.5.44",
21 21 "warframe-riven-info": "^0.1.2",
22 22 "winston": "^3.17.0",
23 23 "winston-daily-rotate-file": "^5.0.0"
@@ -4006,9 +4006,9 @@
4006 4006 }
4007 4007 },
4008 4008 "node_modules/warframe-public-export-plus": {
4009 "version": "0.5.43",
4010 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.43.tgz",
4011 "integrity": "sha512-LeF7HmsjOPsJDtgr66x3iMEIAQgcxKNM54VG895FTemgHLLo34UGDyeS1yIfY67WxxbTUgW3MkHQLlCEJXD14w=="
4009 "version": "0.5.44",
4010 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.44.tgz",
4011 "integrity": "sha512-0EH3CQBCuuELiLBL1brc/o6Qx8CK723TJF5o68VXc60ha93Juo6LQ+dV+QgzFvVQ5RZTjBLtKB4MP8qw3YHCUQ=="
4012 4012 },
4013 4013 "node_modules/warframe-riven-info": {
4014 4014 "version": "0.1.2",
Modified package.json +1 -1
@@ -22,7 +22,7 @@
22 22 "mongoose": "^8.11.0",
23 23 "morgan": "^1.10.0",
24 24 "typescript": ">=4.7.4 <5.6.0",
25 "warframe-public-export-plus": "^0.5.43",
25 "warframe-public-export-plus": "^0.5.44",
26 26 "warframe-riven-info": "^0.1.2",
27 27 "winston": "^3.17.0",
28 28 "winston-daily-rotate-file": "^5.0.0"
Modified src/controllers/api/syndicateStandingBonusController.ts +42 -8
@@ -1,10 +1,19 @@
1 1 import { RequestHandler } from "express";
2 2 import { getAccountIdForRequest } from "@/src/services/loginService";
3 import { addMiscItems, getInventory, getStandingLimit, updateStandingLimit } from "@/src/services/inventoryService";
4 import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
3 import {
4 addMiscItems,
5 freeUpSlot,
6 getInventory,
7 getStandingLimit,
8 updateStandingLimit
9 } from "@/src/services/inventoryService";
10 import { IMiscItem, InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
5 11 import { IOid } from "@/src/types/commonTypes";
6 import { ExportSyndicates } from "warframe-public-export-plus";
12 import { ExportSyndicates, ExportWeapons } from "warframe-public-export-plus";
7 13 import { getMaxStanding } from "@/src/helpers/syndicateStandingHelper";
14 import { logger } from "@/src/utils/logger";
15 import { IInventoryChanges } from "@/src/types/purchaseTypes";
16 import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
8 17
9 18 export const syndicateStandingBonusController: RequestHandler = async (req, res) => {
10 19 const accountId = await getAccountIdForRequest(req);
@@ -12,6 +21,7 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
12 21
13 22 const syndicateMeta = ExportSyndicates[request.Operation.AffiliationTag];
14 23
24 // Process items
15 25 let gainedStanding = 0;
16 26 request.Operation.Items.forEach(item => {
17 27 const medallion = (syndicateMeta.medallions ?? []).find(medallion => medallion.itemType == item.ItemType);
@@ -21,9 +31,35 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
21 31
22 32 item.ItemCount *= -1;
23 33 });
24
25 34 const inventory = await getInventory(accountId);
26 35 addMiscItems(inventory, request.Operation.Items);
36 const inventoryChanges: IInventoryChanges = {};
37 inventoryChanges.MiscItems = request.Operation.Items;
38
39 // Process modular weapon
40 if (request.Operation.ModularWeaponId.$oid != "000000000000000000000000") {
41 const category = req.query.Category as "LongGuns" | "Pistols" | "Melee" | "OperatorAmps";
42 const weapon = inventory[category].id(request.Operation.ModularWeaponId.$oid)!;
43 if (gainedStanding !== 0) {
44 throw new Error(`modular weapon standing bonus should be mutually exclusive`);
45 }
46 weapon.ModularParts!.forEach(part => {
47 const partStandingBonus = ExportWeapons[part].donationStandingBonus;
48 if (partStandingBonus === undefined) {
49 throw new Error(`no standing bonus for ${part}`);
50 }
51 logger.debug(`modular weapon part ${part} gives ${partStandingBonus} standing`);
52 gainedStanding += partStandingBonus;
53 });
54 if (weapon.Features && (weapon.Features & EquipmentFeatures.GILDED) != 0) {
55 gainedStanding *= 2;
56 }
57 inventoryChanges.RemovedIdItems = [{ ItemId: request.Operation.ModularWeaponId }];
58 inventory[category].pull({ _id: request.Operation.ModularWeaponId.$oid });
59 const slotBin = category == "OperatorAmps" ? InventorySlot.AMPS : InventorySlot.WEAPONS;
60 freeUpSlot(inventory, slotBin);
61 inventoryChanges[slotBin] = { count: -1, platinum: 0, Slots: 1 };
62 }
27 63
28 64 let syndicate = inventory.Affiliations.find(x => x.Tag == request.Operation.AffiliationTag);
29 65 if (!syndicate) {
@@ -50,9 +86,7 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
50 86 await inventory.save();
51 87
52 88 res.json({
53 InventoryChanges: {
54 MiscItems: request.Operation.Items
55 },
89 InventoryChanges: inventoryChanges,
56 90 AffiliationMods: [
57 91 {
58 92 Tag: request.Operation.AffiliationTag,
@@ -67,6 +101,6 @@ interface ISyndicateStandingBonusRequest {
67 101 AffiliationTag: string;
68 102 AlternateBonusReward: ""; // ???
69 103 Items: IMiscItem[];
104 ModularWeaponId: IOid;
70 105 };
71 ModularWeaponId: IOid; // Seems to just be "000000000000000000000000", also note there's a "Category" query field
72 106 }