Add file
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
module Dodge.Inventory.FindRoot where
|
||||
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Data.Creature
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
|
||||
getRootItemID :: Int -> Creature -> Int
|
||||
getRootItemID i cr = fromMaybe i $ do
|
||||
let adj = invAdj (_crInv cr)
|
||||
adj ^? ix i . _1 . _Just . _1
|
||||
|
||||
updateRootItemID :: Creature -> Creature
|
||||
updateRootItemID cr = fromMaybe cr $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
|
||||
return $ cr & crManipulation . manObject . inInventory . imRootItem .~
|
||||
getRootItemID i cr
|
||||
Reference in New Issue
Block a user