Fix scope rotation after torque

This commit is contained in:
2023-05-28 16:22:54 +01:00
parent 24939094c6
commit 9283ae187f
7 changed files with 39 additions and 41 deletions
+7
View File
@@ -2,9 +2,11 @@ module Dodge.Item.Location (
pointerToItemLocation,
getItem,
pointerToItem,
pointerYourItem,
) where
import Control.Lens
import Data.Maybe
import Dodge.Data.World
getItem :: Int -> World -> Maybe Item
@@ -26,6 +28,11 @@ 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
Just $ pointerToItemLocation (InInv 0 itinvid) f w
pointerToItem ::
Applicative f =>
Item ->