Remove left click/hotkey item data types
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
module Dodge.Creature.Impulse.UseItem (
|
||||
useRootItem,
|
||||
useItemLeftClick,
|
||||
useItemHotkey,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Maybe
|
||||
import Dodge.Cuse
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.World
|
||||
@@ -17,8 +14,6 @@ import Dodge.Hotkey
|
||||
import Dodge.Inventory
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Item.Location
|
||||
import Dodge.Luse
|
||||
import Dodge.SelectUse
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
useRootItem :: Int -> World -> World
|
||||
@@ -97,41 +92,3 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||
itRef = cr ^?! crManipulation . manObject . imSelectedItem -- unsafe!! TODO change?
|
||||
onequip itm' = doItmCrWdWd ((_eeOnEquip . _uequipEffect . _itUse) itm') itm'
|
||||
onremove itm' = doItmCrWdWd ((_eeOnRemove . _uequipEffect . _itUse) itm') itm'
|
||||
|
||||
-- need to make sure that the root item is not erroneously selected in the
|
||||
-- following
|
||||
useItemLeftClick :: Creature -> World -> World
|
||||
useItemLeftClick cr w = fromMaybe w $ do
|
||||
guard . not $ _crInvLock cr
|
||||
invid <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
itm <- cr ^? crInv . ix invid
|
||||
ituse <- cr ^? crInv . ix invid . itUse
|
||||
case ituse of
|
||||
UseHeld{} -> return w
|
||||
UseConsume eff -> return $ useC eff itm cr w
|
||||
UseEquip{} -> return $ doequipmentchange invid
|
||||
UseHotkey{} -> return $ doequipmentchange invid
|
||||
UseNothing{} -> return w
|
||||
UseAttach{} -> do
|
||||
return $ selectUse itm cr w
|
||||
_ -> Nothing
|
||||
where
|
||||
doequipmentchange invid = fromMaybe w $ do
|
||||
guard (_crHammerPosition cr == HammerUp)
|
||||
return $ toggleEquipmentAt invid cr w
|
||||
|
||||
-- & f
|
||||
-- where
|
||||
-- f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
|
||||
useItemHotkey :: Int -> Int -> World -> World
|
||||
useItemHotkey crid invid w = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix crid
|
||||
itm <- cr ^? crInv . ix invid
|
||||
luse <- itm ^? itUse . leftUse
|
||||
return $
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix crid . crInv . ix invid . itUse . leftHammer .~ HammerDown
|
||||
& useL luse itm cr
|
||||
|
||||
-- TODO determine itmShouldBeUsed with reference to config options
|
||||
|
||||
Reference in New Issue
Block a user