Remove Either construct over invAdj
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
All good (594 modules, at 14:50:27)
|
||||
All good (594 modules, at 15:02:57)
|
||||
|
||||
@@ -27,9 +27,7 @@ tryGetRootAttachedFromInvID invid im = do
|
||||
-- location ids
|
||||
tryGetRootItemInvID :: Int -> Creature -> Maybe Int
|
||||
tryGetRootItemInvID i cr = do
|
||||
let adj = case invAdj (_crInv cr) of
|
||||
Left str -> error $ "tryToGetRootItemInvID: " ++ str
|
||||
Right x -> x
|
||||
let adj = invAdj (_crInv cr)
|
||||
theroot <- adj ^? ix i
|
||||
theroot ^? _1 . _Just . _1 <|> Just i
|
||||
|
||||
|
||||
@@ -179,16 +179,13 @@ invRootMap = foldMap (dtToIntMapWithRoot (^?! itLocation . ilInvID) . fmap (^. _
|
||||
-- location ids
|
||||
-- consider explicitly reseting the inventory ids (but this probably really
|
||||
-- should be done upstream anyway in the actually creature inventory)
|
||||
invAdj :: IM.IntMap Item -> Either String (IM.IntMap (Maybe (Int, Int), [Int], [Int]))
|
||||
invAdj im = do
|
||||
l <- mapM g $ invLDT im
|
||||
return $ IM.unions l
|
||||
invAdj :: IM.IntMap Item -> IM.IntMap (Maybe (Int, Int), [Int], [Int])
|
||||
invAdj im = IM.unions . map g $ invLDT im
|
||||
where
|
||||
g = dtToLRAdjEither getid . ldtToDT
|
||||
g = dtToLRAdj getid . ldtToDT
|
||||
getid (itm, _, _) =
|
||||
maybe
|
||||
(Left ("invAdj item " ++ show (_itID itm) ++ " location: " ++ show (itm ^? itLocation)))
|
||||
Right
|
||||
fromMaybe
|
||||
(error ("invAdj item " ++ show (_itID itm) ++ " location: " ++ show (itm ^? itLocation)))
|
||||
$ itm ^? itLocation . ilInvID
|
||||
|
||||
-- returns an intmap with trees for all items
|
||||
|
||||
@@ -72,9 +72,7 @@ drawInventory sss w cfig =
|
||||
curs = invCursorParams w
|
||||
iextra = fromMaybe mempty $ do
|
||||
inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv
|
||||
let x = case invAdj inv of
|
||||
Left str -> error $ "drawInventory: " ++ str
|
||||
Right y -> y
|
||||
let x = invAdj inv
|
||||
return $ inventoryExtra sss cfig w x
|
||||
|
||||
drawDIMouseOver :: World -> Picture
|
||||
|
||||
Reference in New Issue
Block a user