23 lines
808 B
Haskell
23 lines
808 B
Haskell
module Dodge.SelectedClose (getSelectedCloseObj, interactWithCloseObj) where
|
|
|
|
import Control.Lens
|
|
import Dodge.Button.Event
|
|
import Dodge.Data.World
|
|
import Dodge.Inventory.Add
|
|
import NewInt
|
|
|
|
interactWithCloseObj :: Either (NewInt ItmInt) Button -> World -> World
|
|
interactWithCloseObj e w = worldEventFlags . at InventoryChange ?~ () $ case e of
|
|
(Left flit) -> pickUpItem 0 (_unNInt flit) w
|
|
(Right but) -> doButtonEvent (but ^. btEvent) but w
|
|
|
|
getSelectedCloseObj :: World -> Maybe (Either (NewInt ItmInt) Button)
|
|
getSelectedCloseObj w = do
|
|
Sel i j _ <- w ^? hud . diSelection . _Just
|
|
case i of
|
|
3 -> Left <$> w ^? hud . closeItems . ix j
|
|
5 -> do
|
|
k <- w ^? hud . closeButtons . ix j
|
|
fmap Right $ w ^? cWorld . lWorld . buttons . ix k
|
|
_ -> Nothing
|