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

feat: implement CreditBundle purchases (#989)

This fixes purchasing one of the few bundles that include these credit bundles. Ex: Essential Damage mod bundles Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/989 Co-authored-by: nrbdev <itzneonrb@gmail.com> Co-committed-by: nrbdev <itzneonrb@gmail.com>

e1af6bd5
nrbdev <itzneonrb@gmail.com>
提交于

代码差异

2 个文件 +22 -1
Modified src/services/missionInventoryUpdateService.ts +3 -1
@@ -62,7 +62,9 @@ export const creditBundles: Record<string, number> = {
62 62 "/Lotus/Types/PickUps/Credits/CorpusArenaCreditRewards/CorpusArenaRewardTwoHard": 175000,
63 63 "/Lotus/Types/PickUps/Credits/CorpusArenaCreditRewards/CorpusArenaRewardThreeHard": 250000,
64 64 "/Lotus/Types/StoreItems/CreditBundles/Zariman/TableACreditsCommon": 15000,
65 "/Lotus/Types/StoreItems/CreditBundles/Zariman/TableACreditsUncommon": 30000
65 "/Lotus/Types/StoreItems/CreditBundles/Zariman/TableACreditsUncommon": 30000,
66 "/Lotus/Types/StoreItems/CreditBundles/CreditBundleA": 50000,
67 "/Lotus/Types/StoreItems/CreditBundles/CreditBundleC": 175000
66 68 };
67 69
68 70 export const fusionBundles: Record<string, number> = {
Modified src/services/purchaseService.ts +19 -0
@@ -25,6 +25,7 @@ import {
25 25 } from "warframe-public-export-plus";
26 26 import { config } from "./configService";
27 27 import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel";
28 import { creditBundles } from "./missionInventoryUpdateService";
28 29
29 30 export const getStoreItemCategory = (storeItem: string): string => {
30 31 const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
@@ -330,6 +331,22 @@ const handleBoosterPackPurchase = async (
330 331 return purchaseResponse;
331 332 };
332 333
334 const handleCreditBundlePurchase = async (
335 typeName: string,
336 inventory: TInventoryDatabaseDocument
337 ): Promise<IPurchaseResponse> => {
338 if (typeName && typeName in creditBundles) {
339 const creditsAmount = creditBundles[typeName];
340
341 inventory.RegularCredits += creditsAmount;
342 await inventory.save();
343
344 return { InventoryChanges: { RegularCredits: creditsAmount } };
345 } else {
346 throw new Error(`unknown credit bundle: ${typeName}`);
347 }
348 };
349
333 350 //TODO: change to getInventory, apply changes then save at the end
334 351 const handleTypesPurchase = async (
335 352 typesName: string,
@@ -345,6 +362,8 @@ const handleTypesPurchase = async (
345 362 return handleBoosterPackPurchase(typesName, inventory, quantity);
346 363 case "SlotItems":
347 364 return handleSlotPurchase(typesName, inventory, quantity);
365 case "CreditBundles":
366 return handleCreditBundlePurchase(typesName, inventory);
348 367 }
349 368 };
350 369