Continue LDT -> DT

This commit is contained in:
2025-07-12 14:08:17 +01:00
parent f47f99eac4
commit 3dc70c483a
+9 -9
View File
@@ -1,7 +1,7 @@
{-# LANGUAGE TupleSections #-}
module Dodge.Item.Grammar (
invDT,
invLDT,
-- invLDT,
invDT',
invAdj,
invRootMap,
@@ -246,10 +246,10 @@ joinItemsInList f = fst . h . ([],)
Just w -> h ( zs,w : ys)
-- this puts the first elements in the intmap at the end of the list
invLDT :: IM.IntMap Item -> [LDTree ItemLink CItem]
invLDT =
joinItemsInList tryAttachItems . IM.elems
. fmap (singleLDT . baseCI)
--invLDT :: IM.IntMap Item -> [LDTree ItemLink CItem]
--invLDT =
-- joinItemsInList tryAttachItems . IM.elems
-- . fmap (singleLDT . baseCI)
invDT :: IM.IntMap Item -> [DTree CItem]
invDT = fmap ldtToDT .
@@ -269,8 +269,8 @@ invDT' = fmap propagateOrientation' . invDT
invRootMap :: IM.IntMap Item -> IM.IntMap (Maybe Int, DTree Item)
invRootMap =
foldMap
(dtToIntMapWithRoot (^?! itLocation . ilInvID) . fmap (^. _1) . ldtToDT)
. invLDT
(dtToIntMapWithRoot (^?! itLocation . ilInvID) . fmap (^. _1) )
. invDT
-- this assumes the creature inventory is well formed, specifically the
-- location ids
@@ -278,9 +278,9 @@ invRootMap =
-- should be done upstream anyway in the actually creature inventory)
-- The first Int in the maybe is the root, the second the parent
invAdj :: IM.IntMap Item -> IM.IntMap (Maybe (Int, Int), [Int], [Int])
invAdj = IM.unions . map g . invLDT
invAdj = IM.unions . map g . invDT
where
g = dtToLRAdj getid . ldtToDT
g = dtToLRAdj getid
getid (itm, _) =
fromMaybe
(error ("invAdj item " ++ show (_itID itm) ++ " location: " ++ show (itm ^? itLocation)))