Commit before attempting to split ItemUse into prism + lenses
This commit is contained in:
@@ -4,9 +4,9 @@ module Dodge.Creature.Impulse.UseItem (
|
|||||||
itemEffect,
|
itemEffect,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Control.Lens
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
import Control.Lens
|
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Cuse
|
import Dodge.Cuse
|
||||||
@@ -25,7 +25,8 @@ useItem cr' w = fromMaybe (f w) $ do
|
|||||||
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
||||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
it <- cr ^? crInv . ix itRef
|
it <- cr ^? crInv . ix itRef
|
||||||
return $ itemEffect cr it w
|
return $
|
||||||
|
itemEffect cr it w
|
||||||
& worldEventFlags . at InventoryChange ?~ ()
|
& worldEventFlags . at InventoryChange ?~ ()
|
||||||
where
|
where
|
||||||
f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||||
@@ -137,5 +138,4 @@ useLeftItem cid w = fromMaybe w $ do
|
|||||||
. useL f itm cr
|
. useL f itm cr
|
||||||
$ w
|
$ w
|
||||||
|
|
||||||
|
|
||||||
-- TODO determine itmShouldBeUsed with reference to config options
|
-- TODO determine itmShouldBeUsed with reference to config options
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ yourControl cr w
|
|||||||
w
|
w
|
||||||
& cWorld . lWorld . creatures . ix (_crID cr)
|
& cWorld . lWorld . creatures . ix (_crID cr)
|
||||||
%~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons (_input w)))
|
%~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons (_input w)))
|
||||||
& pressedMBEffectsNoInventory pkeys
|
& pressedMBEffectsTopInventory pkeys
|
||||||
where
|
where
|
||||||
pkeys = w ^. input . mouseButtons
|
pkeys = w ^. input . mouseButtons
|
||||||
intopinv = fromMaybe False $ do
|
intopinv = fromMaybe False $ do
|
||||||
@@ -115,8 +115,8 @@ mouseActionsCr pkeys cr
|
|||||||
theaction <- cr ^? crManipulation . manObject . inInventory . iselAction
|
theaction <- cr ^? crManipulation . manObject . inInventory . iselAction
|
||||||
return $ theaction == NoInvSelAction
|
return $ theaction == NoInvSelAction
|
||||||
|
|
||||||
pressedMBEffectsNoInventory :: M.Map SDL.MouseButton Bool -> World -> World
|
pressedMBEffectsTopInventory :: M.Map SDL.MouseButton Bool -> World -> World
|
||||||
pressedMBEffectsNoInventory pkeys w
|
pressedMBEffectsTopInventory pkeys w
|
||||||
| isDown SDL.ButtonLeft && isDown SDL.ButtonRight && inTopInv = useItem (you w) w
|
| isDown SDL.ButtonLeft && isDown SDL.ButtonRight && inTopInv = useItem (you w) w
|
||||||
| isDown SDL.ButtonLeft && inTopInv = useLeftItem 0 w
|
| isDown SDL.ButtonLeft && inTopInv = useLeftItem 0 w
|
||||||
| isDown SDL.ButtonMiddle =
|
| isDown SDL.ButtonMiddle =
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ mouseOverSelectionList ::
|
|||||||
mouseOverSelectionList ldps screen u
|
mouseOverSelectionList ldps screen u
|
||||||
| x > xl && x < xr
|
| x > xl && x < xr
|
||||||
&& ylower == yupper
|
&& ylower == yupper
|
||||||
&& (mmoving || (_scDisplayTime screen == 0))
|
&& (mmoving || (_scDisplayTime screen <= 1)) -- slight hack
|
||||||
&& ylower >= 0
|
&& ylower >= 0
|
||||||
&& ylower < ymax
|
&& ylower < ymax
|
||||||
&& isselectable =
|
&& isselectable =
|
||||||
|
|||||||
Reference in New Issue
Block a user