maleghast-engine/src/Units/Debug.hs

144 lines
3.8 KiB
Haskell

module Units.Debug
( basic
)
where
import GameModel
( Armor(..), ActingUnit
, BaseStats(..)
, CharacterIdentifier
, Choice
, DamageType(..)
, Token(..), StatusEffect (..)
, Hook(..), Effect(..)
, Trigger(..), BoardState
, TargettedUnit(..)
, targettedUnit
)
import Units.Components
( AttackT(..)
, anyTarget
, buildAttack
, SelfAbilityT(..)
, mkSelfAbility, inflictTokens, pull, push
, inflictStatusEffect
)
import Lens.Micro
basic :: BaseStats
basic = BaseStats
{ name = "Basic Debug Unit"
, hp = 4
, mov = 4
, df = 4
, arm = NoArmor
, actions = basicActions
, traits = []
}
basicActions :: [ActingUnit -> Choice]
basicActions =
[ buildAttack $ AttackT
{ tName = "Peashooter"
, tRange = (1, 3)
, tValidTargets = anyTarget
, tMelee = False
, tDamageType = BasicDamage
, tDamageAmount = 1
, tHeadshotEffects = []
, tStandardEffects = []
}
, buildAttack $ AttackT
{ tName = "Jarate"
, tRange = (1, 3)
, tValidTargets = anyTarget
, tMelee = False
, tDamageType = BasicDamage
, tDamageAmount = 0
, tHeadshotEffects = []
, tStandardEffects = [inflictTokens VitalVulnr (-1)]
}
, buildAttack $ AttackT
{ tName = "Slime"
, tRange = (1, 3)
, tValidTargets = anyTarget
, tMelee = False
, tDamageType = BasicDamage
, tDamageAmount = 0
, tHeadshotEffects = []
, tStandardEffects = [inflictTokens SpeedSlow (-1)]
}
, buildAttack $ AttackT
{ tName = "Nerf"
, tRange = (1, 3)
, tValidTargets = anyTarget
, tMelee = False
, tDamageType = BasicDamage
, tDamageAmount = 0
, tHeadshotEffects = []
, tStandardEffects = [inflictTokens StrWeak (-1)]
}
, buildAttack $ AttackT
{ tName = "Yoink"
, tRange = (1, 4)
, tValidTargets = anyTarget
, tMelee = False
, tDamageType = BasicDamage
, tDamageAmount = 0
, tHeadshotEffects = []
, tStandardEffects = [pull 3]
}
, buildAttack $ AttackT
{ tName = "Yeet"
, tRange = (1, 4)
, tValidTargets = anyTarget
, tMelee = False
, tDamageType = BasicDamage
, tDamageAmount = 0
, tHeadshotEffects = []
, tStandardEffects = [push 3]
}
, mkSelfAbility $ SelfAbilityT
{ tName = "Calcify"
, tEffects = [inflictTokens VitalVulnr 1]
}
, mkSelfAbility $ SelfAbilityT
{ tName = "Zoomify"
, tEffects = [inflictTokens SpeedSlow 1]
}
, mkSelfAbility $ SelfAbilityT
{ tName = "Blood Shield"
, tEffects = [inflictStatusEffect bloodShield]
}
]
bloodShield :: StatusEffect
bloodShield = StatusEffect
{ seName = "Blood Shield"
, seHooks =
[ Hook
{ hookTrigger = TookDamage
, hookEffect = damageHookEffect
}
]
, seModifiers = []
, seUpdate =
[ Hook
{ hookTrigger = TookDamage
, hookEffect = damageHookDecrement
}
]
, seState = 1
, seShowState = \n -> '(' : replicate n '*' ++ ")"
}
where
damageHookEffect :: TargettedUnit -> BoardState -> Int -> CharacterIdentifier -> [Effect]
damageHookEffect (TargettedUnit injuredUnit) _ _ us =
[InflictTokens VitalVulnr 1 (TargettedUnit us) | injuredUnit == us ]
damageHookDecrement :: TargettedUnit -> BoardState -> Int -> CharacterIdentifier -> Maybe Int
damageHookDecrement damagedUnit _ n us
| damagedUnit ^. targettedUnit == us && n > 1 = Just $ pred n
| damagedUnit ^. targettedUnit == us = Nothing
| otherwise = Just n