#4 Attack
This commit is contained in:
parent
f284413836
commit
11eb00ea0b
6 changed files with 59 additions and 21 deletions
|
@ -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
|
Reference in a new issue