Separate selected item from extra selected items
This commit is contained in:
@@ -16,22 +16,11 @@ import qualified IntMapHelp as IM
|
||||
checkInvSlotsYou :: Item -> World -> Maybe Int
|
||||
checkInvSlotsYou it w
|
||||
| crNumFreeSlots ycr >= _itInvSize it =
|
||||
Just $ findItemSlot (_crInv ycr)
|
||||
Just . IM.newKey $ _crInv ycr
|
||||
| otherwise = Nothing
|
||||
where
|
||||
ycr = you w
|
||||
|
||||
-- Assumes that the item is singular.
|
||||
-- Do not want to stack floor items for now
|
||||
findItemSlot :: IM.IntMap Item -> Int
|
||||
findItemSlot = maybe 0 ((+ 1) . fst) . IM.lookupMax
|
||||
--findItemSlot it inv = case it ^? itUse . useAmount of
|
||||
-- Just _ ->
|
||||
-- fromMaybe newslot $ IM.findIndex (\it' -> _itType it == _itType it') inv
|
||||
-- _ -> newslot
|
||||
-- where
|
||||
-- newslot = maybe 0 ((+ 1) . fst) $ IM.lookupMax inv
|
||||
|
||||
crNumFreeSlots :: Creature -> Int
|
||||
crNumFreeSlots cr = _crInvCapacity cr - invSize (_crInv cr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user