30 lines
781 B
Haskell
30 lines
781 B
Haskell
module Units
|
|
( computeStat
|
|
)
|
|
where
|
|
|
|
import GameModel
|
|
( baseStats
|
|
, BoardState
|
|
, CharacterIdentifier
|
|
, isElevated
|
|
, Stat(..)
|
|
, statBonusL
|
|
, ixCharacter
|
|
)
|
|
|
|
import Data.Maybe (fromMaybe)
|
|
import Lens.Micro
|
|
|
|
computeStat :: BoardState -> CharacterIdentifier -> Stat a -> a
|
|
computeStat board cid stat = case stat of
|
|
AttackDice -> 1 + elevationBonus + fromMaybe 0 specialtyBonus
|
|
DefenseDice -> 0 + elevationBonus + fromMaybe 0 specialtyBonus
|
|
FreeMove -> fromMaybe False specialtyBonus
|
|
where
|
|
statBonuses = ixCharacter cid . baseStats . statBonusL
|
|
specialtyBonus = case board ^? statBonuses of
|
|
Just statB -> Just $ statB board cid stat
|
|
Nothing -> Nothing
|
|
elevationBonus :: Int
|
|
elevationBonus = if isElevated board cid then 1 else 0 |