Major item refactor, still broken
This commit is contained in:
@@ -26,26 +26,18 @@ import Dodge.Data.World
|
||||
pointerYourSelectedItem :: Applicative a => (Item -> a Item) -> World -> a World
|
||||
pointerYourSelectedItem f w = fromMaybe (pure w) $ do
|
||||
itinvid <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
|
||||
Just $ (cWorld . lWorld . creatures . ix 0 . crInv . ix itinvid) f w
|
||||
itid <- w ^? cWorld . lWorld . creatures . ix 0 . crInv . ix itinvid
|
||||
Just $ (cWorld . lWorld . items . ix itid) f w
|
||||
-- note the ilIsRoot/Selected/Attached booleans are irrelevant
|
||||
|
||||
pointerYourRootItem :: Applicative a => (Item -> a Item) -> World -> a World
|
||||
pointerYourRootItem f w = fromMaybe (pure w) $ do
|
||||
itinvid <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imRootSelectedItem
|
||||
Just $ (cWorld . lWorld . creatures . ix 0 . crInv . ix itinvid) f w
|
||||
itid <- w ^? cWorld . lWorld . creatures . ix 0 . crInv . ix itinvid
|
||||
Just $ (cWorld . lWorld . items . ix itid) f w
|
||||
|
||||
pointerToItem :: Applicative f => Item -> (Item -> f Item) -> World -> f World
|
||||
pointerToItem x = case x ^. itLocation of
|
||||
OnFloor -> cWorld . lWorld . items . ix (x ^. itID . unNInt)
|
||||
OnTurret _ -> cWorld . lWorld . items . ix (x ^. itID . unNInt)
|
||||
InInv cid invid _ _ _ _ -> cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
||||
InVoid -> const pure
|
||||
pointerToItem x = cWorld . lWorld . items . ix (x ^. itID . unNInt)
|
||||
|
||||
pointerToItemID :: Applicative f => NewInt ItmInt -> (Item -> f Item) -> World -> f World
|
||||
pointerToItemID itid f w = fromMaybe (pure w) $ do
|
||||
itloc <- w ^? cWorld . lWorld . itemLocations . ix (_unNInt itid)
|
||||
return $ (\x -> x f w) $ case itloc of
|
||||
OnFloor -> cWorld . lWorld . items . ix (itid ^. unNInt)
|
||||
OnTurret _ -> cWorld . lWorld . items . ix (itid ^. unNInt)
|
||||
InInv cid invid _ _ _ _ -> cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
||||
InVoid -> const pure
|
||||
pointerToItemID itid = cWorld . lWorld . items . ix (itid ^. unNInt)
|
||||
|
||||
Reference in New Issue
Block a user