From b47c2db0bd9f07d109426c04fa9c16892e0a63aa Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Sun, 27 Mar 2022 19:12:30 -0700 Subject: [PATCH] Implement InventorySpaceValidator --- .../HUD/Inventory/InventorySpaceValidator.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs b/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs index d0f16b279..3d9f3e88c 100644 --- a/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs +++ b/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs @@ -1,7 +1,9 @@ using AutomaticTypeMapper; using EOLib.Domain.Map; using EOLib.IO; +using EOLib.IO.Map; using EOLib.IO.Repositories; +using Optional; namespace EndlessClient.HUD.Inventory { @@ -9,10 +11,16 @@ namespace EndlessClient.HUD.Inventory public class InventorySpaceValidator : IInventorySpaceValidator { private readonly IEIFFileProvider _eifFileProvider; + private readonly IInventorySlotProvider _inventorySlotProvider; + private readonly IInventoryService _inventoryService; - public InventorySpaceValidator(IEIFFileProvider eifFileProvider) + public InventorySpaceValidator(IEIFFileProvider eifFileProvider, + IInventorySlotProvider inventorySlotProvider, + IInventoryService inventoryService) { _eifFileProvider = eifFileProvider; + _inventorySlotProvider = inventorySlotProvider; + _inventoryService = inventoryService; } public bool ItemFits(IItem item) @@ -22,8 +30,9 @@ public bool ItemFits(IItem item) public bool ItemFits(ItemSize itemSize) { - // todo: inventory grid management - return true; + return _inventoryService + .GetNextOpenSlot((Matrix)_inventorySlotProvider.FilledSlots, itemSize, Option.None()) + .HasValue; } }