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

fix: purchase response doesn't include exalted weapons when applicable (#647)

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

代码差异

1 个文件 +23 -14
Modified src/services/inventoryService.ts +23 -14
@@ -219,16 +219,16 @@ export const addItem = async (
219 219 case "Powersuits":
220 220 switch (typeName.substr(1).split("/")[2]) {
221 221 default: {
222 const suit = await addPowerSuit(typeName, accountId);
222 const inventoryChanges = await addPowerSuit(typeName, accountId);
223 223 await updateSlots(accountId, InventorySlot.SUITS, 0, 1);
224 224 return {
225 225 InventoryChanges: {
226 ...inventoryChanges,
226 227 SuitBin: {
227 228 count: 1,
228 229 platinum: 0,
229 230 Slots: -1
230 },
231 Suits: [suit]
231 }
232 232 }
233 233 };
234 234 }
@@ -247,16 +247,16 @@ export const addItem = async (
247 247 };
248 248 }
249 249 case "EntratiMech": {
250 const mechSuit = await addMechSuit(typeName, accountId);
250 const inventoryChanges = await addMechSuit(typeName, accountId);
251 251 await updateSlots(accountId, InventorySlot.MECHSUITS, 0, 1);
252 252 return {
253 253 InventoryChanges: {
254 ...inventoryChanges,
254 255 MechBin: {
255 256 count: 1,
256 257 platinum: 0,
257 258 Slots: -1
258 },
259 MechSuits: [mechSuit]
259 }
260 260 }
261 261 };
262 262 }
@@ -405,33 +405,41 @@ export const addSentinelWeapon = async (typeName: string, accountId: string) =>
405 405 return changedInventory.SentinelWeapons[sentinelIndex - 1].toJSON();
406 406 };
407 407
408 export const addPowerSuit = async (powersuitName: string, accountId: string): Promise<IEquipmentClient> => {
408 export const addPowerSuit = async (powersuitName: string, accountId: string): Promise<IInventoryChanges> => {
409 const inventoryChanges: IInventoryChanges = {};
409 410 const specialItems = getExalted(powersuitName);
410 411 if (specialItems) {
411 412 for await (const specialItem of specialItems) {
412 await addSpecialItem(specialItem, accountId);
413 await addSpecialItem(specialItem, accountId, inventoryChanges);
413 414 }
414 415 }
415 416 const inventory = await getInventory(accountId);
416 417 const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 });
417 418 const changedInventory = await inventory.save();
418 return changedInventory.Suits[suitIndex - 1].toJSON() as object as IEquipmentClient;
419 inventoryChanges.Suits = [changedInventory.Suits[suitIndex - 1].toJSON()];
420 return inventoryChanges;
419 421 };
420 422
421 export const addMechSuit = async (mechsuitName: string, accountId: string) => {
423 export const addMechSuit = async (mechsuitName: string, accountId: string): Promise<IInventoryChanges> => {
424 const inventoryChanges: IInventoryChanges = {};
422 425 const specialItems = getExalted(mechsuitName);
423 426 if (specialItems) {
424 427 for await (const specialItem of specialItems) {
425 await addSpecialItem(specialItem, accountId);
428 await addSpecialItem(specialItem, accountId, inventoryChanges);
426 429 }
427 430 }
428 431 const inventory = await getInventory(accountId);
429 432 const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 });
430 433 const changedInventory = await inventory.save();
431 return changedInventory.MechSuits[suitIndex - 1].toJSON();
434 inventoryChanges.MechSuits = [changedInventory.MechSuits[suitIndex - 1].toJSON()];
435 return inventoryChanges;
432 436 };
433 437
434 export const addSpecialItem = async (itemName: string, accountId: string): Promise<IEquipmentClient | undefined> => {
438 export const addSpecialItem = async (
439 itemName: string,
440 accountId: string,
441 inventoryChanges: IInventoryChanges
442 ): Promise<void> => {
435 443 const inventory = await getInventory(accountId);
436 444 if (inventory.SpecialItems.find(x => x.ItemType == itemName)) {
437 445 return;
@@ -444,7 +452,8 @@ export const addSpecialItem = async (itemName: string, accountId: string): Promi
444 452 XP: 0
445 453 });
446 454 const changedInventory = await inventory.save();
447 return changedInventory.SpecialItems[specialItemIndex - 1].toJSON<IEquipmentClient>();
455 inventoryChanges.SpecialItems ??= [];
456 (inventoryChanges.SpecialItems as object[]).push(changedInventory.SpecialItems[specialItemIndex - 1].toJSON());
448 457 };
449 458
450 459 export const addSpaceSuit = async (spacesuitName: string, accountId: string) => {