Rework how unit effects work, enabling push/pull
This commit is contained in:
parent
2461dcfb07
commit
3d43f317d1
|
@ -6,7 +6,6 @@ This is a work in progress engine for Maleghast, whose main goal currently inclu
|
|||
|
||||
Currently missing core mechanics include:
|
||||
- Hazards
|
||||
- Pushing/Pulling
|
||||
- LoS blocking
|
||||
- Tyrants
|
||||
- Thralls
|
||||
|
|
|
@ -19,7 +19,7 @@ import GameModel
|
|||
import Units.Components
|
||||
( AttackT(..)
|
||||
, anyTarget
|
||||
, buildAttack
|
||||
, buildAttack, inflictTokens
|
||||
)
|
||||
|
||||
gunwight :: BaseStats
|
||||
|
@ -49,7 +49,7 @@ gunwightActions =
|
|||
, tMelee = False
|
||||
, tDamageType = Unblockable
|
||||
, tDamageAmount = 2
|
||||
, tHeadshotEffects = [InflictTokens VitalVulnr (-1)]
|
||||
, tHeadshotEffects = [inflictTokens VitalVulnr (-1)]
|
||||
, tStandardEffects = []
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
module Units.Components
|
||||
( AttackT(..)
|
||||
, ProtoEffect
|
||||
, anyTarget
|
||||
, buildAttack
|
||||
, SelfAbilityT(..)
|
||||
, mkSelfAbility
|
||||
, inflictTokens
|
||||
, push
|
||||
, pull
|
||||
)
|
||||
where
|
||||
|
||||
|
@ -14,12 +18,15 @@ import GameModel
|
|||
, Choice
|
||||
, DamageType
|
||||
, Effect(..)
|
||||
, mkChoice
|
||||
, mkChoice, Token, forcedMove, ForcedMoveType (..), owner
|
||||
)
|
||||
import Util ((??))
|
||||
|
||||
import Numeric.Natural (Natural)
|
||||
|
||||
-------------------------
|
||||
-- Attacks & Abilities --
|
||||
-------------------------
|
||||
|
||||
data AttackT = AttackT
|
||||
{ tName :: String
|
||||
, tRange :: (Natural, Natural)
|
||||
|
@ -27,8 +34,8 @@ data AttackT = AttackT
|
|||
, tMelee :: Bool
|
||||
, tDamageType :: DamageType
|
||||
, tDamageAmount :: Natural
|
||||
, tHeadshotEffects :: [CharacterIdentifier -> Effect]
|
||||
, tStandardEffects :: [CharacterIdentifier -> Effect]
|
||||
, tHeadshotEffects :: [ProtoEffect]
|
||||
, tStandardEffects :: [ProtoEffect]
|
||||
}
|
||||
|
||||
anyTarget :: BoardState -> CharacterIdentifier -> Bool
|
||||
|
@ -37,15 +44,37 @@ anyTarget = const $ const True
|
|||
buildAttack :: AttackT -> CharacterIdentifier -> Choice
|
||||
buildAttack (AttackT {..}) attacker = mkChoice tName [targetEffect]
|
||||
where
|
||||
attackDetails =
|
||||
Attack <$> sequence tHeadshotEffects ?? tMelee <*> sequence tStandardEffects ?? tDamageType ?? tDamageAmount
|
||||
attackDetails target = Attack
|
||||
((sequence $ sequence tHeadshotEffects attacker) target)
|
||||
tMelee
|
||||
((sequence $ sequence tStandardEffects attacker) target)
|
||||
tDamageType
|
||||
tDamageAmount
|
||||
attackEffect target = [ResolveAttack attacker (attackDetails target) target]
|
||||
targetEffect = Target attacker tRange tValidTargets attackEffect
|
||||
|
||||
data SelfAbilityT = SelfAbilityT
|
||||
{ tName :: String
|
||||
, tEffects :: [CharacterIdentifier -> Effect]
|
||||
, tEffects :: [ProtoEffect]
|
||||
}
|
||||
|
||||
mkSelfAbility :: SelfAbilityT -> CharacterIdentifier -> Choice
|
||||
mkSelfAbility (SelfAbilityT {..}) = mkChoice tName <$> sequence tEffects
|
||||
mkSelfAbility (SelfAbilityT {..}) cid = mkChoice tName (sequence (sequence tEffects cid) cid)
|
||||
|
||||
-----------------------------
|
||||
--------- Effects -----------
|
||||
-----------------------------
|
||||
|
||||
type ProtoEffect = CharacterIdentifier -> CharacterIdentifier -> Effect
|
||||
|
||||
inflictTokens :: Num n => Token n -> n -> ProtoEffect
|
||||
inflictTokens tokenType tokenCount _ = InflictTokens tokenType tokenCount
|
||||
|
||||
genericShift :: ForcedMoveType -> Natural -> ProtoEffect
|
||||
genericShift fmType amount puller = forcedMove fmType amount (owner puller) (Left puller)
|
||||
|
||||
push :: Natural -> ProtoEffect
|
||||
push = genericShift Push
|
||||
|
||||
pull :: Natural -> ProtoEffect
|
||||
pull = genericShift Pull
|
|
@ -21,7 +21,7 @@ import Units.Components
|
|||
, anyTarget
|
||||
, buildAttack
|
||||
, SelfAbilityT(..)
|
||||
, mkSelfAbility
|
||||
, mkSelfAbility, inflictTokens, pull, push
|
||||
)
|
||||
import Lens.Micro
|
||||
|
||||
|
@ -63,7 +63,7 @@ basicActions =
|
|||
, tDamageType = BasicDamage
|
||||
, tDamageAmount = 0
|
||||
, tHeadshotEffects = []
|
||||
, tStandardEffects = [InflictTokens VitalVulnr (-1)]
|
||||
, tStandardEffects = [inflictTokens VitalVulnr (-1)]
|
||||
}
|
||||
, buildAttack $ AttackT
|
||||
{ tName = "Slime"
|
||||
|
@ -73,7 +73,7 @@ basicActions =
|
|||
, tDamageType = BasicDamage
|
||||
, tDamageAmount = 0
|
||||
, tHeadshotEffects = []
|
||||
, tStandardEffects = [InflictTokens SpeedSlow (-1)]
|
||||
, tStandardEffects = [inflictTokens SpeedSlow (-1)]
|
||||
}
|
||||
, buildAttack $ AttackT
|
||||
{ tName = "Nerf"
|
||||
|
@ -83,7 +83,7 @@ basicActions =
|
|||
, tDamageType = BasicDamage
|
||||
, tDamageAmount = 0
|
||||
, tHeadshotEffects = []
|
||||
, tStandardEffects = [InflictTokens StrWeak (-1)]
|
||||
, tStandardEffects = [inflictTokens StrWeak (-1)]
|
||||
}
|
||||
, buildAttack $ AttackT
|
||||
{ tName = "Yoink"
|
||||
|
@ -93,19 +93,29 @@ basicActions =
|
|||
, tDamageType = BasicDamage
|
||||
, tDamageAmount = 0
|
||||
, tHeadshotEffects = []
|
||||
, tStandardEffects = [forcedMove Pull 3 Min (Left (Max, 1))]
|
||||
, 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]
|
||||
, tEffects = [inflictTokens VitalVulnr 1]
|
||||
}
|
||||
, mkSelfAbility $ SelfAbilityT
|
||||
{ tName = "Zoomify"
|
||||
, tEffects = [InflictTokens SpeedSlow 1]
|
||||
, tEffects = [inflictTokens SpeedSlow 1]
|
||||
}
|
||||
, mkSelfAbility $ SelfAbilityT
|
||||
{ tName = "Get String"
|
||||
, tEffects = [InflictTokens StrWeak 1]
|
||||
, tEffects = [inflictTokens StrWeak 1]
|
||||
}
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue