Fix bugs in equipment allocation using hotkeys
The behaviour is still not perfect, should be able to cycle through all options by pressing one key. There is unnecessary memory of past state going on here
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
module Dodge.Inventory.CheckSlots (
|
||||
checkInvSlotsYou,
|
||||
crNumFreeSlots,
|
||||
crInvSize,
|
||||
) where
|
||||
|
||||
import Control.Monad
|
||||
import Dodge.Item.InvSize
|
||||
import Control.Lens
|
||||
import Data.Monoid
|
||||
import Dodge.Base.You
|
||||
import Dodge.Data.World
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
@@ -15,19 +14,13 @@ import qualified IntMapHelp as IM
|
||||
if so return Just the next slot to be used
|
||||
-}
|
||||
checkInvSlotsYou :: Item -> World -> Maybe Int
|
||||
checkInvSlotsYou it w
|
||||
| crNumFreeSlots ycr >= itInvHeight it =
|
||||
Just . IM.newKey $ _crInv ycr
|
||||
| otherwise = Nothing
|
||||
where
|
||||
ycr = you w
|
||||
checkInvSlotsYou it w = do
|
||||
ycr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
guard $ crNumFreeSlots ycr >= itInvHeight it
|
||||
Just . IM.newKey $ _crInv ycr
|
||||
|
||||
crNumFreeSlots :: Creature -> Int
|
||||
crNumFreeSlots cr = _crInvCapacity cr - invSize (_crInv cr)
|
||||
|
||||
crInvSize :: Creature -> Int
|
||||
crInvSize = invSize . _crInv
|
||||
|
||||
invSize :: IM.IntMap Item -> Int
|
||||
invSize = alaf Sum foldMap itInvHeight
|
||||
--invSize = sum . fmap _itInvSize
|
||||
|
||||
Reference in New Issue
Block a user