Continue tree based inventory update

This commit is contained in:
2024-09-10 16:35:44 +01:00
parent 854fc96ac7
commit 26f3610f82
14 changed files with 259 additions and 271 deletions
+3 -5
View File
@@ -4,8 +4,6 @@ module Dodge.Inventory.CheckSlots (
crInvSize,
) where
import Control.Lens
import Data.Maybe
import Dodge.Base.You
import Dodge.Data.World
import Dodge.Item.SlotsTaken
@@ -17,15 +15,15 @@ import qualified IntMapHelp as IM
checkInvSlotsYou :: Item -> World -> Maybe Int
checkInvSlotsYou it w
| crNumFreeSlots ycr >= ceiling (_itInvSize it) =
Just $ findItemSlot it (_crInv ycr)
Just $ findItemSlot (_crInv ycr)
| otherwise = Nothing
where
ycr = you w
-- Assumes that the item is singular.
-- Do not want to stack floor items for now
findItemSlot :: Item -> IM.IntMap Item -> Int
findItemSlot it inv = maybe 0 ((+ 1) . fst) $ IM.lookupMax inv
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