Continue tree based inventory update
This commit is contained in:
@@ -71,3 +71,8 @@ battery =
|
||||
, _iaLoaded = 100
|
||||
}
|
||||
}
|
||||
|
||||
bulletSynthesizer :: Item
|
||||
bulletSynthesizer = defaultHeldItem
|
||||
& itType . iyBase .~ ATTACH BULLETSYNTHESIZER
|
||||
& itUse .~ AttachUse NoAttachParams
|
||||
|
||||
@@ -88,6 +88,7 @@ showAttachItem :: AttachType -> String
|
||||
showAttachItem t = case t of
|
||||
SCROLLATTACH x -> show x
|
||||
TARGETATTACH x -> show x
|
||||
BULLETSYNTHESIZER -> "BSYNTH"
|
||||
|
||||
showEquipItem :: EquipItemType -> String
|
||||
showEquipItem eit = case eit of
|
||||
|
||||
@@ -14,15 +14,15 @@ import LensHelp
|
||||
import Picture
|
||||
import Shape
|
||||
import ShapePicture
|
||||
import Data.Maybe
|
||||
--import Data.Maybe
|
||||
|
||||
itemHeldAmmoPic :: Item -> Item -> SPic
|
||||
itemHeldAmmoPic itm amit = itemSPic itm <> addAmmoClip itm amit
|
||||
--itemHeldAmmoPic :: Item -> Item -> SPic
|
||||
--itemHeldAmmoPic itm amit = itemSPic itm <> addAmmoClip itm amit
|
||||
|
||||
addAmmoClip :: Item -> Item -> SPic
|
||||
addAmmoClip itm amit = fromMaybe mempty $ do
|
||||
hit <- itm ^? itType . iyBase . ibtHeld
|
||||
return mempty
|
||||
--addAmmoClip :: Item -> Item -> SPic
|
||||
--addAmmoClip itm amit = fromMaybe mempty $ do
|
||||
-- hit <- itm ^? itType . iyBase . ibtHeld
|
||||
-- return mempty
|
||||
|
||||
itemSPic :: Item -> SPic
|
||||
itemSPic it =
|
||||
|
||||
@@ -19,7 +19,9 @@ singleDT x = DT x [] []
|
||||
baseComposedItem :: ItemBaseType -> PCI
|
||||
baseComposedItem ibt = case ibt of
|
||||
HELD BURSTRIFLE -> (WeaponCI, [BulletAmmoCI])
|
||||
AMMOMAG TINMAG -> (BulletAmmoCI, [])
|
||||
AMMOMAG TINMAG -> (BulletAmmoCI, [AmmoModifierCI])
|
||||
AMMOMAG DRUMMAG -> (BulletAmmoCI, [AmmoModifierCI])
|
||||
ATTACH BULLETSYNTHESIZER -> (AmmoModifierCI, [])
|
||||
_ -> (UncomposableCI, [])
|
||||
|
||||
baseCI :: Item -> PCI'
|
||||
@@ -34,7 +36,7 @@ joinItems t@(DT (itm,px,cx) ls' rs') s@(DT (_,py,_) _ _)
|
||||
checkdepth a a'@(DT b ls rs) = fromMaybe (checktop a a') $ do
|
||||
c <- safeHead ls
|
||||
d <- checkdepth a c
|
||||
return $ Just $ DT b (d:ls) rs
|
||||
return $ Just $ DT b (d:tail ls) rs
|
||||
checktop a@(DT (_,pa,_) _ _) (DT (itm2,pb,cb) ls rs)
|
||||
| pa `elem` cb = Just (DT (itm2,pb, delete pa cb) (a:ls) rs)
|
||||
| otherwise = Nothing
|
||||
@@ -107,9 +109,17 @@ iDTboth fspace fline flink (DT x l r) = DT (flink x)
|
||||
flattenDT :: DoubleTree a -> [a]
|
||||
flattenDT (DT x l r) = concatMap flattenDT l ++ (x : concatMap flattenDT r)
|
||||
|
||||
indentInv :: IM.IntMap Item -> [String]
|
||||
indentInv =
|
||||
concatMap (flattenDT .indentDoubleTreeWith (' ':) ('|':) ('+':) . fmap (const "")) .
|
||||
prettyDT :: (a -> String) -> DoubleTree a -> [String]
|
||||
prettyDT f (DT x l r) = concatMap (map ('/':) . prettyDT f) r
|
||||
++ (f x : concatMap (map ('\\':) . prettyDT f) l)
|
||||
|
||||
invTree :: IM.IntMap Item -> [String]
|
||||
invTree = concatMap (prettyDT (\(itm,_,_) -> show (_itType itm))) .
|
||||
joinItemsInList joinItems . IM.elems . fmap (singleDT . baseCI)
|
||||
|
||||
indentInv :: IM.IntMap Item -> IM.IntMap String
|
||||
indentInv = IM.fromList . zip [0..] .
|
||||
reverse . concatMap (flattenDT .indentDoubleTreeWith (' ':) ('|':) ('+':) . fmap (const "")) .
|
||||
joinItemsInList joinItems . IM.elems . fmap (singleDT . baseCI)
|
||||
|
||||
--indentInv :: IM.IntMap Item -> [String]
|
||||
|
||||
Reference in New Issue
Block a user