Refactor, try to limit dependencies
This commit is contained in:
+15
-14
@@ -1,15 +1,14 @@
|
||||
module Dodge.ItEffect where
|
||||
|
||||
import Dodge.Euse
|
||||
import Dodge.Data
|
||||
import Dodge.LightSource.Torch
|
||||
import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import Dodge.Euse
|
||||
import Dodge.LightSource.Torch
|
||||
|
||||
doInvEffect :: ItInvEffect -> Item -> Creature -> World -> World
|
||||
doInvEffect iie = case iie of
|
||||
NoInvEffect -> const $ const id
|
||||
RewindEffect -> rewindEffect
|
||||
-- ResetAttachmentEffect -> resetAttachmentEffect
|
||||
EffectIfHeld f g -> onOffEff f g
|
||||
CreateHeldLight -> createHeldLight
|
||||
CreateShieldWall -> createShieldWall
|
||||
@@ -22,23 +21,26 @@ doFloorEffect NoFloorEffect = const id
|
||||
onOffEff :: ItInvEffect -> ItInvEffect -> Item -> Creature -> World -> World
|
||||
onOffEff f g it
|
||||
| _itIsHeld it = doInvEffect f it
|
||||
| otherwise = doInvEffect g it
|
||||
| otherwise = doInvEffect g it
|
||||
|
||||
rewindEffect :: Item -> Creature -> World -> World
|
||||
rewindEffect itm cr w
|
||||
| Just invid == _crLeftInvSel cr = w & cWorld . rewindWorlds %~ (take maxcharge . (cw : ))
|
||||
& ptrWpCharge .~ length (_rewindWorlds (_cWorld w))
|
||||
| otherwise = w & cWorld . rewindWorlds .~ []
|
||||
& ptrWpCharge .~ 0
|
||||
rewindEffect itm cr w
|
||||
| Just invid == _crLeftInvSel cr =
|
||||
w & cWorld . rewindWorlds %~ (take maxcharge . (cw :))
|
||||
& ptrWpCharge .~ length (_rewindWorlds (_cWorld w))
|
||||
| otherwise =
|
||||
w & cWorld . rewindWorlds .~ []
|
||||
& ptrWpCharge .~ 0
|
||||
where
|
||||
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 .~ []
|
||||
cw =
|
||||
_cWorld w
|
||||
& rewindWorlds .~ []
|
||||
|
||||
--resetAttachmentEffect :: Item -> Creature -> World -> World
|
||||
--resetAttachmentEffect itm cr w
|
||||
--resetAttachmentEffect itm cr w
|
||||
-- | _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment
|
||||
-- | otherwise = w & pointToIt . itEffect . ieCounter -~ 1
|
||||
-- where
|
||||
@@ -48,4 +50,3 @@ rewindEffect itm cr w
|
||||
|
||||
createHeldLight :: Item -> Creature -> World -> World
|
||||
createHeldLight itm cr = createTorchLightOffset cr itm 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user