Remove Either construct over invAdj

This commit is contained in:
2024-10-26 15:03:45 +01:00
parent 6402ab11da
commit 53557965d0
4 changed files with 8 additions and 15 deletions
+5 -8
View File
@@ -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