Commit before changes to creature inventory update
This commit is contained in:
@@ -51,7 +51,7 @@ foldCr xs cr w = foldr f w xs
|
||||
-- This should be made more sensible: should the movement side effects apply to
|
||||
-- the creature before or after it has moved?
|
||||
-- at what point invSideEffects is applied wrt to when the creature moves
|
||||
-- may effect whether the shield moves correctly
|
||||
-- may affect whether the shield moves correctly
|
||||
stateUpdate :: (Creature -> World -> World) -> Creature -> World -> World
|
||||
stateUpdate f = foldCr
|
||||
[ doDamage
|
||||
@@ -138,10 +138,10 @@ movementSideEff cr w
|
||||
(randAng,_) = randomR (0,2*pi) $ _randGen w
|
||||
|
||||
heldItemUpdate :: Int -> Item -> Item
|
||||
heldItemUpdate invid = (itUse %~ useUpdate) . (itIsHeld .~ True) . (itInvPos ?~ invid)
|
||||
heldItemUpdate invid = (itUse %~ useUpdate) . (itInvPos ?~ invid) . (itIsHeld .~ True)
|
||||
|
||||
invItemUpdate :: Int -> Item -> Item
|
||||
invItemUpdate invid = (itUse %~ useUpdate) . (itIsHeld .~ False) . (itInvPos ?~ invid)
|
||||
invItemUpdate invid = (itUse %~ useUpdate) . (itInvPos ?~ invid) . (itIsHeld .~ False)
|
||||
|
||||
useUpdate :: ItemUse -> ItemUse
|
||||
useUpdate = (useHammer . hammerPosition %~ moveHammerUp)
|
||||
@@ -156,15 +156,21 @@ invSideEff cr w = weaponReloadSounds cr
|
||||
. flip (foldr $ useEquipment cr) (IM.keys $ _crInvEquipped cr)
|
||||
$ IM.foldrWithKey f w (_crInv cr)
|
||||
where
|
||||
f i it w' = doitemupdate w' & case it ^? itEffect . itInvEffect of
|
||||
--upitemsw = w & creatures . ix (_crID cr) . crInv %~ IM.mapWithKey (itemUpdate cr)
|
||||
f i it w' = (doItemTargeting i cr . doitemupdate) w' & case it ^? itEffect . itInvEffect of
|
||||
Nothing -> id
|
||||
Just g -> g (heldItemUpdate i it) cr -- this is done twice!
|
||||
where
|
||||
doitemupdate
|
||||
| i == _crInvSel cr = doItemTargeting i cr . (itpointer %~ heldItemUpdate i)
|
||||
| otherwise = doItemTargeting i cr . (itpointer %~ invItemUpdate i)
|
||||
| i == _crInvSel cr = (itpointer %~ heldItemUpdate i)
|
||||
| otherwise = (itpointer %~ invItemUpdate i)
|
||||
itpointer = creatures . ix (_crID cr) . crInv . ix i
|
||||
|
||||
itemUpdate :: Creature -> Int -> Item -> Item
|
||||
itemUpdate cr i
|
||||
| i == _crInvSel cr = heldItemUpdate i
|
||||
| otherwise = invItemUpdate i
|
||||
|
||||
doItemTargeting :: Int -> Creature -> World -> World
|
||||
doItemTargeting invid cr w = case cr ^? crInv . ix invid . itTargeting of
|
||||
Nothing -> w
|
||||
|
||||
Reference in New Issue
Block a user