chore: handle addMiscItems leaving account with 0 or less of an item
This commit is contained in:
		
							parent
							
								
									ae832d0125
								
							
						
					
					
						commit
						740590dcba
					
				@ -661,7 +661,13 @@ export const addMiscItems = (inventory: TInventoryDatabaseDocument, itemsArray:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (itemIndex !== -1) {
 | 
					        if (itemIndex !== -1) {
 | 
				
			||||||
            MiscItems[itemIndex].ItemCount += ItemCount;
 | 
					            MiscItems[itemIndex].ItemCount += ItemCount;
 | 
				
			||||||
            inventory.markModified(`MiscItems.${itemIndex}.ItemCount`);
 | 
					            if (MiscItems[itemIndex].ItemCount <= 0) {
 | 
				
			||||||
 | 
					                if (MiscItems[itemIndex].ItemCount == 0) {
 | 
				
			||||||
 | 
					                    MiscItems.splice(itemIndex, 1);
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    logger.warn(`account now owns a negative amount of ${ItemType}`);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            MiscItems.push({ ItemCount, ItemType });
 | 
					            MiscItems.push({ ItemCount, ItemType });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user