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:
|
Currently missing core mechanics include:
|
||||||
- Hazards
|
- Hazards
|
||||||
- Pushing/Pulling
|
|
||||||
- LoS blocking
|
- LoS blocking
|
||||||
- Tyrants
|
- Tyrants
|
||||||
- Thralls
|
- Thralls
|
||||||
|
|
|
@ -19,7 +19,7 @@ import GameModel
|
||||||
import Units.Components
|
import Units.Components
|
||||||
( AttackT(..)
|
( AttackT(..)
|
||||||
, anyTarget
|
, anyTarget
|
||||||
, buildAttack
|
, buildAttack, inflictTokens
|
||||||
)
|
)
|
||||||
|
|
||||||
gunwight :: BaseStats
|
gunwight :: BaseStats
|
||||||
|
@ -49,7 +49,7 @@ gunwightActions =
|
||||||
, tMelee = False
|
, tMelee = False
|
||||||
, tDamageType = Unblockable
|
, tDamageType = Unblockable
|
||||||
, tDamageAmount = 2
|
, tDamageAmount = 2
|
||||||
, tHeadshotEffects = [InflictTokens VitalVulnr (-1)]
|
, tHeadshotEffects = [inflictTokens VitalVulnr (-1)]
|
||||||
, tStandardEffects = []
|
, tStandardEffects = []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
module Units.Components
|
module Units.Components
|
||||||
( AttackT(..)
|
( AttackT(..)
|
||||||
|
, ProtoEffect
|
||||||
, anyTarget
|
, anyTarget
|
||||||
, buildAttack
|
, buildAttack
|
||||||
, SelfAbilityT(..)
|
, SelfAbilityT(..)
|
||||||
, mkSelfAbility
|
, mkSelfAbility
|
||||||
|
, inflictTokens
|
||||||
|
, push
|
||||||
|
, pull
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
@ -14,12 +18,15 @@ import GameModel
|
||||||
, Choice
|
, Choice
|
||||||
, DamageType
|
, DamageType
|
||||||
, Effect(..)
|
, Effect(..)
|
||||||
, mkChoice
|
, mkChoice, Token, forcedMove, ForcedMoveType (..), owner
|
||||||
)
|
)
|
||||||
import Util ((??))
|
|
||||||
|
|
||||||
import Numeric.Natural (Natural)
|
import Numeric.Natural (Natural)
|
||||||
|
|
||||||
|
-------------------------
|
||||||
|
-- Attacks & Abilities --
|
||||||
|
-------------------------
|
||||||
|
|
||||||
data AttackT = AttackT
|
data AttackT = AttackT
|
||||||
{ tName :: String
|
{ tName :: String
|
||||||
, tRange :: (Natural, Natural)
|
, tRange :: (Natural, Natural)
|
||||||
|
@ -27,8 +34,8 @@ data AttackT = AttackT
|
||||||
, tMelee :: Bool
|
, tMelee :: Bool
|
||||||
, tDamageType :: DamageType
|
, tDamageType :: DamageType
|
||||||
, tDamageAmount :: Natural
|
, tDamageAmount :: Natural
|
||||||
, tHeadshotEffects :: [CharacterIdentifier -> Effect]
|
, tHeadshotEffects :: [ProtoEffect]
|
||||||
, tStandardEffects :: [CharacterIdentifier -> Effect]
|
, tStandardEffects :: [ProtoEffect]
|
||||||
}
|
}
|
||||||
|
|
||||||
anyTarget :: BoardState -> CharacterIdentifier -> Bool
|
anyTarget :: BoardState -> CharacterIdentifier -> Bool
|
||||||
|
@ -37,15 +44,37 @@ anyTarget = const $ const True
|
||||||
buildAttack :: AttackT -> CharacterIdentifier -> Choice
|
buildAttack :: AttackT -> CharacterIdentifier -> Choice
|
||||||
buildAttack (AttackT {..}) attacker = mkChoice tName [targetEffect]
|
buildAttack (AttackT {..}) attacker = mkChoice tName [targetEffect]
|
||||||
where
|
where
|
||||||
attackDetails =
|
attackDetails target = Attack
|
||||||
Attack <$> sequence tHeadshotEffects ?? tMelee <*> sequence tStandardEffects ?? tDamageType ?? tDamageAmount
|
((sequence $ sequence tHeadshotEffects attacker) target)
|
||||||
|
tMelee
|
||||||
|
((sequence $ sequence tStandardEffects attacker) target)
|
||||||
|
tDamageType
|
||||||
|
tDamageAmount
|
||||||
attackEffect target = [ResolveAttack attacker (attackDetails target) target]
|
attackEffect target = [ResolveAttack attacker (attackDetails target) target]
|
||||||
targetEffect = Target attacker tRange tValidTargets attackEffect
|
targetEffect = Target attacker tRange tValidTargets attackEffect
|
||||||
|
|
||||||
data SelfAbilityT = SelfAbilityT
|
data SelfAbilityT = SelfAbilityT
|
||||||
{ tName :: String
|
{ tName :: String
|
||||||
, tEffects :: [CharacterIdentifier -> Effect]
|
, tEffects :: [ProtoEffect]
|
||||||
}
|
}
|
||||||
|
|
||||||
mkSelfAbility :: SelfAbilityT -> CharacterIdentifier -> Choice
|
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
|
, anyTarget
|
||||||
, buildAttack
|
, buildAttack
|
||||||
, SelfAbilityT(..)
|
, SelfAbilityT(..)
|
||||||
, mkSelfAbility
|
, mkSelfAbility, inflictTokens, pull, push
|
||||||
)
|
)
|
||||||
import Lens.Micro
|
import Lens.Micro
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ basicActions =
|
||||||
, tDamageType = BasicDamage
|
, tDamageType = BasicDamage
|
||||||
, tDamageAmount = 0
|
, tDamageAmount = 0
|
||||||
, tHeadshotEffects = []
|
, tHeadshotEffects = []
|
||||||
, tStandardEffects = [InflictTokens VitalVulnr (-1)]
|
, tStandardEffects = [inflictTokens VitalVulnr (-1)]
|
||||||
}
|
}
|
||||||
, buildAttack $ AttackT
|
, buildAttack $ AttackT
|
||||||
{ tName = "Slime"
|
{ tName = "Slime"
|
||||||
|
@ -73,7 +73,7 @@ basicActions =
|
||||||
, tDamageType = BasicDamage
|
, tDamageType = BasicDamage
|
||||||
, tDamageAmount = 0
|
, tDamageAmount = 0
|
||||||
, tHeadshotEffects = []
|
, tHeadshotEffects = []
|
||||||
, tStandardEffects = [InflictTokens SpeedSlow (-1)]
|
, tStandardEffects = [inflictTokens SpeedSlow (-1)]
|
||||||
}
|
}
|
||||||
, buildAttack $ AttackT
|
, buildAttack $ AttackT
|
||||||
{ tName = "Nerf"
|
{ tName = "Nerf"
|
||||||
|
@ -83,7 +83,7 @@ basicActions =
|
||||||
, tDamageType = BasicDamage
|
, tDamageType = BasicDamage
|
||||||
, tDamageAmount = 0
|
, tDamageAmount = 0
|
||||||
, tHeadshotEffects = []
|
, tHeadshotEffects = []
|
||||||
, tStandardEffects = [InflictTokens StrWeak (-1)]
|
, tStandardEffects = [inflictTokens StrWeak (-1)]
|
||||||
}
|
}
|
||||||
, buildAttack $ AttackT
|
, buildAttack $ AttackT
|
||||||
{ tName = "Yoink"
|
{ tName = "Yoink"
|
||||||
|
@ -93,19 +93,29 @@ basicActions =
|
||||||
, tDamageType = BasicDamage
|
, tDamageType = BasicDamage
|
||||||
, tDamageAmount = 0
|
, tDamageAmount = 0
|
||||||
, tHeadshotEffects = []
|
, 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
|
, mkSelfAbility $ SelfAbilityT
|
||||||
{ tName = "Calcify"
|
{ tName = "Calcify"
|
||||||
, tEffects = [InflictTokens VitalVulnr 1]
|
, tEffects = [inflictTokens VitalVulnr 1]
|
||||||
}
|
}
|
||||||
, mkSelfAbility $ SelfAbilityT
|
, mkSelfAbility $ SelfAbilityT
|
||||||
{ tName = "Zoomify"
|
{ tName = "Zoomify"
|
||||||
, tEffects = [InflictTokens SpeedSlow 1]
|
, tEffects = [inflictTokens SpeedSlow 1]
|
||||||
}
|
}
|
||||||
, mkSelfAbility $ SelfAbilityT
|
, mkSelfAbility $ SelfAbilityT
|
||||||
{ tName = "Get String"
|
{ tName = "Get String"
|
||||||
, tEffects = [InflictTokens StrWeak 1]
|
, tEffects = [inflictTokens StrWeak 1]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue