Improve item location code, including some error detection
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
module Dodge.Inventory.Location
|
||||
(updateRootItemID
|
||||
, crUpdateItemLocations
|
||||
, setInvPosFromSS
|
||||
, tryGetRootItemInvID
|
||||
)
|
||||
where
|
||||
import Dodge.Base.You
|
||||
import Dodge.Data.SelectionList
|
||||
@@ -12,7 +17,9 @@ import Control.Applicative
|
||||
|
||||
tryGetRootItemInvID :: Int -> Creature -> Maybe Int
|
||||
tryGetRootItemInvID i cr = do
|
||||
let adj = invAdj (_crInv cr)
|
||||
let adj = case invAdj' (_crInv cr) of
|
||||
Left str -> error $ "tryToGetRootItemInvID: "++ str
|
||||
Right x -> x
|
||||
thetree <- adj ^? ix i -- to check that the index does point to SOME item in the inventory
|
||||
thetree ^? _1 . _Just . _1 <|> Just i
|
||||
|
||||
|
||||
Reference in New Issue
Block a user