Work on cleaning up item effects/attachments etc
This commit is contained in:
+14
-17
@@ -1,6 +1,7 @@
|
||||
module Dodge.ItEffect where
|
||||
|
||||
import Dodge.Euse
|
||||
import Dodge.Data
|
||||
import Dodge.Item.Equipment
|
||||
import Dodge.LightSource.Torch
|
||||
import Control.Lens
|
||||
|
||||
@@ -8,25 +9,21 @@ doInvEffect :: ItInvEffect -> Item -> Creature -> World -> World
|
||||
doInvEffect iie = case iie of
|
||||
NoInvEffect -> const $ const id
|
||||
RewindEffect -> rewindEffect
|
||||
ResetAttachmentEffect -> resetAttachmentEffect
|
||||
OnOffHeldEffect f g -> onOffEff f g
|
||||
-- ResetAttachmentEffect -> resetAttachmentEffect
|
||||
EffectIfHeld f g -> onOffEff f g
|
||||
CreateHeldLight -> createHeldLight
|
||||
CreateShieldWall -> createShieldWall
|
||||
RemoveShieldWall -> removeShieldWall
|
||||
EffectWhileHeld f -> onOffEff f NoInvEffect
|
||||
|
||||
doFloorEffect :: ItFloorEffect -> Int -> World -> World
|
||||
doFloorEffect NoFloorEffect = const id
|
||||
|
||||
doDropEffect :: ItDropEffect -> Item -> Creature -> World -> World
|
||||
doDropEffect iie = case iie of
|
||||
NoDropEffect -> const $ const id
|
||||
|
||||
onOffEff :: ItInvEffect -> ItInvEffect -> Item -> Creature -> World -> World
|
||||
onOffEff f g it
|
||||
| _itIsHeld it = doInvEffect f it
|
||||
| otherwise = doInvEffect g it
|
||||
|
||||
|
||||
rewindEffect :: Item -> Creature -> World -> World
|
||||
rewindEffect itm cr w
|
||||
| Just invid == _crLeftInvSel cr = w & cWorld . rewindWorlds %~ (take maxcharge . (cw : ))
|
||||
@@ -34,20 +31,20 @@ rewindEffect itm cr w
|
||||
| otherwise = w & cWorld . rewindWorlds .~ []
|
||||
& ptrWpCharge .~ 0
|
||||
where
|
||||
invid = _ipInvID $ _itPos itm
|
||||
invid = _ipInvID $ _itLocation itm
|
||||
ptrWpCharge = cWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
|
||||
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
|
||||
cw = _cWorld w
|
||||
& rewindWorlds .~ []
|
||||
|
||||
resetAttachmentEffect :: Item -> Creature -> World -> World
|
||||
resetAttachmentEffect itm cr w
|
||||
| _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment
|
||||
| otherwise = w & pointToIt . itEffect . ieCounter -~ 1
|
||||
where
|
||||
iteff = _itEffect itm
|
||||
invid = _ipInvID $ _itPos itm
|
||||
pointToIt = cWorld . creatures . ix (_crID cr) . crInv . ix invid
|
||||
--resetAttachmentEffect :: Item -> Creature -> World -> World
|
||||
--resetAttachmentEffect itm cr w
|
||||
-- | _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment
|
||||
-- | otherwise = w & pointToIt . itEffect . ieCounter -~ 1
|
||||
-- where
|
||||
-- iteff = _itEffect itm
|
||||
-- invid = _ipInvID $ _itLocation itm
|
||||
-- pointToIt = cWorld . creatures . ix (_crID cr) . crInv . ix invid
|
||||
|
||||
createHeldLight :: Item -> Creature -> World -> World
|
||||
createHeldLight itm cr = createTorchLightOffset cr itm 0
|
||||
|
||||
Reference in New Issue
Block a user