Commit before attempting to split ItemUse into prism + lenses
This commit is contained in:
@@ -4,9 +4,9 @@ module Dodge.Creature.Impulse.UseItem (
|
||||
itemEffect,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Foldable
|
||||
import Control.Lens
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import Dodge.Cuse
|
||||
@@ -25,8 +25,9 @@ useItem cr' w = fromMaybe (f w) $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
it <- cr ^? crInv . ix itRef
|
||||
return $ itemEffect cr it w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
return $
|
||||
itemEffect cr it w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
where
|
||||
f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
|
||||
@@ -129,13 +130,12 @@ useLeftItem cid w = fromMaybe w $ do
|
||||
if itmIsConsumable || itmIsEquipable
|
||||
then return $ useItem cr w -- I believe this ONLY sets equipment options
|
||||
else do
|
||||
invid <- cr ^. crLeftInvSel . lisMPos
|
||||
invid <- cr ^. crLeftInvSel . lisMPos
|
||||
itm <- cr ^? crInv . ix invid
|
||||
f <- cr ^? crInv . ix invid . itUse . leftUse
|
||||
return
|
||||
. (runIdentity . pointerToItemLocation (_itLocation itm) (return . (itUse . leftHammer .~ HammerDown)))
|
||||
. useL f itm cr
|
||||
$ w
|
||||
|
||||
|
||||
-- TODO determine itmShouldBeUsed with reference to config options
|
||||
|
||||
Reference in New Issue
Block a user