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

chore: handle addMiscItems & addMods resulting in account having 0 or less of a type (#821)

45c32b08
Sainan <sainan@calamity.inc>
提交于

代码差异

1 个文件 +14 -2
Modified src/services/inventoryService.ts +14 -2
@@ -661,7 +661,13 @@ export const addMiscItems = (inventory: TInventoryDatabaseDocument, itemsArray:
661 661
662 662 if (itemIndex !== -1) {
663 663 MiscItems[itemIndex].ItemCount += ItemCount;
664 inventory.markModified(`MiscItems.${itemIndex}.ItemCount`);
664 if (MiscItems[itemIndex].ItemCount <= 0) {
665 if (MiscItems[itemIndex].ItemCount == 0) {
666 MiscItems.splice(itemIndex, 1);
667 } else {
668 logger.warn(`account now owns a negative amount of ${ItemType}`);
669 }
670 }
665 671 } else {
666 672 MiscItems.push({ ItemCount, ItemType });
667 673 }
@@ -723,7 +729,13 @@ export const addMods = (inventory: TInventoryDatabaseDocument, itemsArray: IRawU
723 729
724 730 if (itemIndex !== -1) {
725 731 RawUpgrades[itemIndex].ItemCount += ItemCount;
726 inventory.markModified(`RawUpgrades.${itemIndex}.ItemCount`);
732 if (RawUpgrades[itemIndex].ItemCount <= 0) {
733 if (RawUpgrades[itemIndex].ItemCount == 0) {
734 RawUpgrades.splice(itemIndex, 1);
735 } else {
736 logger.warn(`account now owns a negative amount of ${ItemType}`);
737 }
738 }
727 739 } else {
728 740 RawUpgrades.push({ ItemCount, ItemType });
729 741 }