This commit is contained in:
Tibo De Peuter 2022-12-23 12:06:46 +01:00
parent f284413836
commit 11eb00ea0b
6 changed files with 59 additions and 21 deletions

View file

@ -91,4 +91,10 @@ isInventoryFull p = inventorySize <= length (inventory p)
-- Check if the inventory of the player contains an item.
inventoryContains :: ItemId -> Player -> Bool
inventoryContains id p = any ((== id) . itemId) $ inventory p
inventoryContains id p = any ((== id) . itemId) $ inventory p
-- Retrieve an item from inventory
itemFromInventory :: ItemId -> [Item] -> (Maybe Item, [Item])
itemFromInventory iid list = (match, filteredList)
where match = find ((== iid) . itemId) list
filteredList = filter ((/= iid) . itemId) list