Skip to content

Commit

Permalink
Implement InventorySpaceValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Mar 28, 2022
1 parent 622ce06 commit b47c2db
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions EndlessClient/HUD/Inventory/InventorySpaceValidator.cs
@@ -1,18 +1,26 @@
using AutomaticTypeMapper;
using EOLib.Domain.Map;
using EOLib.IO;
using EOLib.IO.Map;
using EOLib.IO.Repositories;
using Optional;

namespace EndlessClient.HUD.Inventory
{
[AutoMappedType]
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)
Expand All @@ -22,8 +30,9 @@ public bool ItemFits(IItem item)

public bool ItemFits(ItemSize itemSize)
{
// todo: inventory grid management
return true;
return _inventoryService
.GetNextOpenSlot((Matrix<bool>)_inventorySlotProvider.FilledSlots, itemSize, Option.None<int>())
.HasValue;
}
}

Expand Down

0 comments on commit b47c2db

Please sign in to comment.