返回提交历史
Modified
src/services/inventoryService.ts
+0
-17
Modified
src/services/purchaseService.ts
+33
-2
Modified
src/types/purchaseTypes.ts
+1
-0
XFEstudio/XFESpaceNinjaServer
fix: booster packs not showing what items were gained after purchase (#635)
4d1bbff9
代码差异
3 个文件
+34
-19
@@ -28,12 +28,10 @@ import {
28
28
} from "../types/requestTypes";
29
29
import { logger } from "@/src/utils/logger";
30
30
import { getWeaponType, getExalted } from "@/src/services/itemDataService";
31
import { getRandomWeightedReward } from "@/src/services/rngService";
32
31
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
33
32
import { IEquipmentClient, IItemConfig } from "../types/inventoryTypes/commonInventoryTypes";
34
33
import {
35
34
ExportArcanes,
36
ExportBoosterPacks,
37
35
ExportCustoms,
38
36
ExportFlavour,
39
37
ExportGear,
@@ -183,21 +181,6 @@ export const addItem = async (
183
181
}
184
182
};
185
183
}
186
if (typeName in ExportBoosterPacks) {
187
const pack = ExportBoosterPacks[typeName];
188
const InventoryChanges = {};
189
for (const weights of pack.rarityWeightsPerRoll) {
190
const result = getRandomWeightedReward(pack.components, weights);
191
if (result) {
192
logger.debug(`booster pack rolled`, result);
193
combineInventoryChanges(
194
InventoryChanges,
195
(await addItem(accountId, result.type, result.itemCount)).InventoryChanges
196
);
197
}
198
}
199
return { InventoryChanges };
200
}
201
184
if (typeName in ExportUpgrades || typeName in ExportArcanes) {
202
185
const inventory = await getInventory(accountId);
203
186
const changes = [
@@ -9,12 +9,14 @@ import {
9
9
updateCurrency,
10
10
updateSlots
11
11
} from "@/src/services/inventoryService";
12
import { getRandomWeightedReward } from "@/src/services/rngService";
12
13
import { getVendorManifestByOid } from "@/src/services/serversideVendorsService";
13
14
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
14
15
import { IPurchaseRequest, IPurchaseResponse, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes";
15
16
import { logger } from "@/src/utils/logger";
16
17
import worldState from "@/static/fixed_responses/worldState.json";
17
18
import {
19
ExportBoosterPacks,
18
20
ExportBundles,
19
21
ExportGear,
20
22
ExportResources,
@@ -38,7 +40,10 @@ export const getStoreItemTypesCategory = (typesItem: string) => {
38
40
return typeElements[1];
39
41
};
40
42
41
export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountId: string) => {
43
export const handlePurchase = async (
44
purchaseRequest: IPurchaseRequest,
45
accountId: string
46
): Promise<IPurchaseResponse> => {
42
47
logger.debug("purchase request", purchaseRequest);
43
48
44
49
if (purchaseRequest.PurchaseParams.Source == 7) {
@@ -259,17 +264,43 @@ const handleSlotPurchase = async (
259
264
};
260
265
};
261
266
267
const handleBoosterPackPurchase = async (typeName: string, accountId: string): Promise<IPurchaseResponse> => {
268
const pack = ExportBoosterPacks[typeName];
269
if (!pack) {
270
throw new Error(`unknown booster pack: ${typeName}`);
271
}
272
const purchaseResponse: IPurchaseResponse = {
273
BoosterPackItems: "",
274
InventoryChanges: {}
275
};
276
for (const weights of pack.rarityWeightsPerRoll) {
277
const result = getRandomWeightedReward(pack.components, weights);
278
if (result) {
279
logger.debug(`booster pack rolled`, result);
280
purchaseResponse.BoosterPackItems +=
281
result.type.split("/Lotus/").join("/Lotus/StoreItems/") + ',{"lvl":0};';
282
combineInventoryChanges(
283
purchaseResponse.InventoryChanges,
284
(await addItem(accountId, result.type, result.itemCount)).InventoryChanges
285
);
286
}
287
}
288
return purchaseResponse;
289
};
290
262
291
//TODO: change to getInventory, apply changes then save at the end
263
292
const handleTypesPurchase = async (
264
293
typesName: string,
265
294
accountId: string,
266
295
quantity: number
267
): Promise<{ InventoryChanges: IInventoryChanges }> => {
296
): Promise<IPurchaseResponse> => {
268
297
const typeCategory = getStoreItemTypesCategory(typesName);
269
298
logger.debug(`type category ${typeCategory}`);
270
299
switch (typeCategory) {
271
300
default:
272
301
return await addItem(accountId, typesName, quantity);
302
case "BoosterPacks":
303
return await handleBoosterPackPurchase(typesName, accountId);
273
304
case "SlotItems":
274
305
return await handleSlotPurchase(typesName, accountId);
275
306
}
@@ -25,6 +25,7 @@ export interface IPurchaseResponse {
25
25
Tag: string;
26
26
Standing: number;
27
27
}[];
28
BoosterPackItems?: string;
28
29
}
29
30
30
31
export type IBinChanges = {