Use NewIntMap InvInt for crInv
This commit is contained in:
@@ -4,6 +4,7 @@ module Dodge.Inventory.CheckSlots (
|
||||
maxInvSlots,
|
||||
) where
|
||||
|
||||
import NewInt
|
||||
import Control.Monad
|
||||
import Dodge.Item.InvSize
|
||||
import Control.Lens
|
||||
@@ -14,11 +15,11 @@ import qualified IntMapHelp as IM
|
||||
{- | checks whether or not an item will fit in your inventory
|
||||
if so return Just the next slot to be used
|
||||
-}
|
||||
checkInvSlotsYou :: Item -> World -> Maybe Int
|
||||
checkInvSlotsYou :: Item -> World -> Maybe (NewInt InvInt)
|
||||
checkInvSlotsYou it w = do
|
||||
ycr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
guard $ crNumFreeSlots (w ^. cWorld . lWorld . items) ycr >= itInvHeight it
|
||||
Just . IM.newKey $ _crInv ycr
|
||||
Just . NInt . IM.newKey . _unNIntMap $ _crInv ycr
|
||||
|
||||
crNumFreeSlots :: IM.IntMap Item -> Creature -> Int
|
||||
--crNumFreeSlots cr = _crInvCapacity cr - invSize (_crInv cr)
|
||||
@@ -29,5 +30,5 @@ crNumFreeSlots m cr = maxInvSlots - invSize (fmap f (_crInv cr))
|
||||
maxInvSlots :: Int
|
||||
maxInvSlots = 25
|
||||
|
||||
invSize :: IM.IntMap Item -> Int
|
||||
invSize :: NewIntMap InvInt Item -> Int
|
||||
invSize = alaf Sum foldMap itInvHeight
|
||||
|
||||
Reference in New Issue
Block a user