Implement combining of items
This commit is contained in:
+2
-19
@@ -19,6 +19,7 @@ module Dodge.Inventory
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Inventory.CloseObject
|
||||
import Dodge.Inventory.CheckSlots
|
||||
import Dodge.Base
|
||||
import Dodge.Base.Collide
|
||||
import Geometry
|
||||
@@ -32,25 +33,6 @@ import Data.Maybe
|
||||
--import System.Random
|
||||
import Control.Lens
|
||||
|
||||
-- | 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 it w
|
||||
| crNumFreeSlots ycr >= _itInvSize it
|
||||
= Just $ maybe 0 ((+1) . fst) $ IM.lookupMax inv
|
||||
| otherwise = Nothing
|
||||
where
|
||||
ycr = you w
|
||||
inv = _crInv ycr
|
||||
|
||||
crNumFreeSlots :: Creature -> Int
|
||||
crNumFreeSlots cr = _crInvCapacity cr - invSize (_crInv cr)
|
||||
|
||||
crInvSize :: Creature -> Int
|
||||
crInvSize = invSize . _crInv
|
||||
|
||||
invSize :: IM.IntMap Item -> Int
|
||||
invSize = sum . fmap _itInvSize
|
||||
|
||||
-- | after this the item at the inventory position will no longer exist
|
||||
rmInvItem :: Int -- ^ Creature id
|
||||
@@ -87,6 +69,7 @@ closeObjectSize e = case e of
|
||||
Left flit -> _itInvSize $ _flIt flit
|
||||
Right _ -> 1
|
||||
|
||||
|
||||
selNumPos :: Int -> World -> Int
|
||||
selNumPos i w = splitgap + (foldl' (+) 0 . fst $ IM.split i (augmentedInvSizes w))
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user