Distinguish between selected item and root-selected item
This commit is contained in:
@@ -2,7 +2,8 @@ module Dodge.Item.Location (
|
||||
pointerToItemLocation,
|
||||
getItem,
|
||||
pointerToItem,
|
||||
pointerYourItem,
|
||||
pointerYourSelectedItem,
|
||||
pointerYourRootItem,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
@@ -28,9 +29,14 @@ pointerToItemLocation (InInv cid invid) = cWorld . lWorld . creatures . ix cid .
|
||||
pointerToItemLocation (OnFloor flid) = cWorld . lWorld . floorItems . ix flid . flIt
|
||||
pointerToItemLocation _ = const pure
|
||||
|
||||
pointerYourItem :: Applicative a => (Item -> a Item) -> World -> a World
|
||||
pointerYourItem f w = fromMaybe (pure w) $ do
|
||||
itinvid <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . inInventory . ispItem
|
||||
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 . inInventory . imSelectedItem
|
||||
Just $ pointerToItemLocation (InInv 0 itinvid) f w
|
||||
|
||||
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 . inInventory . imRootItem
|
||||
Just $ pointerToItemLocation (InInv 0 itinvid) f w
|
||||
|
||||
pointerToItem ::
|
||||
|
||||
Reference in New Issue
Block a user