Refactor damages to materials
This commit is contained in:
@@ -9,22 +9,25 @@ import Dodge.Spark
|
||||
import Geometry
|
||||
import LensHelp
|
||||
|
||||
applyCreatureDamage :: [Damage] -> Creature -> World -> World
|
||||
applyCreatureDamage dms cr = case crMaterial (cr ^. crType) of
|
||||
Flesh -> defaultApplyDamage dms cr
|
||||
Crystal -> id
|
||||
_ -> defaultApplyDamage dms cr
|
||||
--applyCreatureDamage :: [Damage] -> Creature -> World -> World
|
||||
--applyCreatureDamage dms cr =
|
||||
-- case crMaterial (cr ^. crType) of
|
||||
-- Flesh -> defaultApplyDamage dms cr
|
||||
-- Crystal -> id
|
||||
-- _ -> defaultApplyDamage dms cr
|
||||
|
||||
defaultApplyDamage :: [Damage] -> Creature -> World -> World
|
||||
defaultApplyDamage ds cr w =
|
||||
foldl' (applyIndividualDamage cr) w ds'
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) %~ doPoisonDam
|
||||
where
|
||||
(ps, ds') = partition isPoison ds
|
||||
isPoison Poison{} = True
|
||||
isPoison _ = False
|
||||
poisonDam = quot (max 0 (sum (map _dmAmount ps))) 10
|
||||
doPoisonDam = crHP -~ poisonDam
|
||||
--defaultApplyDamage :: [Damage] -> Creature -> World -> World
|
||||
--defaultApplyDamage ds cr w =
|
||||
applyCreatureDamage :: [Damage] -> Creature -> World -> World
|
||||
applyCreatureDamage dms cr w = foldl' (applyIndividualDamage cr) w dms
|
||||
-- foldl' (applyIndividualDamage cr) w ds'
|
||||
-- & cWorld . lWorld . creatures . ix (_crID cr) %~ doPoisonDam
|
||||
-- where
|
||||
-- (ps, ds') = partition isPoison ds
|
||||
-- isPoison Poison{} = True
|
||||
-- isPoison _ = False
|
||||
-- poisonDam = quot (max 0 (sum (map _dmAmount ps))) 10
|
||||
-- doPoisonDam = crHP -~ poisonDam
|
||||
|
||||
--applyDamageEffect :: Damage -> DamageEffect -> Creature -> World -> World
|
||||
--applyDamageEffect dm de cr = case de of
|
||||
@@ -64,5 +67,5 @@ damageHP :: Creature -> Int -> World -> World
|
||||
damageHP cr x =
|
||||
cWorld . lWorld . creatures . ix (_crID cr)
|
||||
%~ ( (crHP -~ x)
|
||||
. (crPastDamage +~ x)
|
||||
. (crPain +~ x)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user