From aa1ee5588a53d2990d68a6729b87733168c7a77b Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 24 May 2024 17:50:34 +0100 Subject: [PATCH] Fix inventory showing quantities set to 0 (#239) # Description Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. - Fix a bug where the inventory would show a "x0" quantity when there were entities in the database with a current quantity of 0. - This occurs when you sacrifice cards, that command can't delete the row as it has claims connected to it in another table, so we need to maintain that key. #227 ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) # How Has This Been Tested? Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration. # Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that provde my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Co-authored-by: VylpesTester Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/239 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- src/helpers/InventoryHelper.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/helpers/InventoryHelper.ts b/src/helpers/InventoryHelper.ts index 3b0c40a..8792ea6 100644 --- a/src/helpers/InventoryHelper.ts +++ b/src/helpers/InventoryHelper.ts @@ -35,7 +35,8 @@ export default class InventoryHelper { .filter(x => { x.cards = x.cards .sort((a, b) => b.type - a.type) - .filter(y => inventory.find(z => z.CardNumber == y.id)); + .filter(y => inventory.find(z => z.CardNumber == y.id)) + .filter(y => inventory.find(z => z.CardNumber == y.id)!.Quantity > 0); return x; });