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: subtract standing for syndicate purchases (#608)

412de026
Sainan <sainan@calamity.inc>
提交于

代码差异

4 个文件 +41 -8
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.9",
15 "warframe-public-export-plus": "^0.5.10",
16 16 "warframe-riven-info": "^0.1.2",
17 17 "winston": "^3.17.0",
18 18 "winston-daily-rotate-file": "^5.0.0"
@@ -3877,9 +3877,9 @@
3877 3877 }
3878 3878 },
3879 3879 "node_modules/warframe-public-export-plus": {
3880 "version": "0.5.9",
3881 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.9.tgz",
3882 "integrity": "sha512-qwQVtYI7wghatg7UrJ3CFstXba5Hsks398L6ngv16auqoTVAfw/cLBqFv9DzsEpqvcVWL22IZIH+cNWiq1JXOQ=="
3880 "version": "0.5.10",
3881 "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.10.tgz",
3882 "integrity": "sha512-6RtWkQDMouMXoUePohkAsYYG/wGW9b/WjSIcrxCb80pWpwrMWr5lr7kzDKPMRkq1Ju8uh9sJirp/5oyeiJbyyQ=="
3883 3883 },
3884 3884 "node_modules/warframe-riven-info": {
3885 3885 "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.9",
19 "warframe-public-export-plus": "^0.5.10",
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/services/purchaseService.ts +26 -3
@@ -11,10 +11,10 @@ import {
11 11 } from "@/src/services/inventoryService";
12 12 import { getVendorManifestByOid } from "@/src/services/serversideVendorsService";
13 13 import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
14 import { IPurchaseRequest, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes";
14 import { IPurchaseRequest, IPurchaseResponse, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes";
15 15 import { logger } from "@/src/utils/logger";
16 16 import worldState from "@/static/fixed_responses/worldState.json";
17 import { ExportBundles, ExportGear, ExportVendors, TRarity } from "warframe-public-export-plus";
17 import { ExportBundles, ExportGear, ExportSyndicates, ExportVendors, TRarity } from "warframe-public-export-plus";
18 18
19 19 export const getStoreItemCategory = (storeItem: string) => {
20 20 const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
@@ -66,6 +66,29 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
66 66 };
67 67
68 68 switch (purchaseRequest.PurchaseParams.Source) {
69 case 2:
70 if (!purchaseRequest.PurchaseParams.UseFreeFavor!) {
71 const syndicateTag = purchaseRequest.PurchaseParams.SyndicateTag!;
72 const syndicate = ExportSyndicates[syndicateTag];
73 if (syndicate) {
74 const favour = syndicate.favours.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
75 if (favour) {
76 const inventory = await getInventory(accountId);
77 const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag);
78 if (affiliation) {
79 purchaseResponse.Standing = [
80 {
81 Tag: syndicateTag,
82 Standing: favour.standingCost
83 }
84 ];
85 affiliation.Standing -= favour.standingCost;
86 await inventory.save();
87 }
88 }
89 }
90 }
91 break;
69 92 case 7:
70 93 if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) {
71 94 const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId!];
@@ -136,7 +159,7 @@ const handleStoreItemAcquisition = async (
136 159 quantity: number,
137 160 durability: TRarity,
138 161 ignorePurchaseQuantity: boolean = false
139 ): Promise<{ InventoryChanges: IInventoryChanges }> => {
162 ): Promise<IPurchaseResponse> => {
140 163 let purchaseResponse = {
141 164 InventoryChanges: {}
142 165 };
Modified src/types/purchaseTypes.ts +10 -0
@@ -13,10 +13,20 @@ export interface IPurchaseParams {
13 13 Quantity: number;
14 14 UsePremium: boolean;
15 15 ExpectedPrice: number;
16 SyndicateTag?: string; // for Source 2
17 UseFreeFavor?: boolean; // for Source 2
16 18 }
17 19
18 20 export type IInventoryChanges = Record<string, IBinChanges | object[]>;
19 21
22 export interface IPurchaseResponse {
23 InventoryChanges: IInventoryChanges;
24 Standing?: {
25 Tag: string;
26 Standing: number;
27 }[];
28 }
29
20 30 export type IBinChanges = {
21 31 count: number;
22 32 platinum: number;