36 lines
1.1 KiB
Haskell
36 lines
1.1 KiB
Haskell
module Dodge.Creature.Statistics (
|
|
getCrMoveSpeed,
|
|
getCrDexterity,
|
|
) where
|
|
|
|
import Data.Maybe
|
|
import Dodge.Data.Creature
|
|
import qualified IntMapHelp as IM
|
|
import LensHelp
|
|
|
|
getCrDexterity :: Creature -> Int
|
|
getCrDexterity cr = _dexterity (_crStatistics cr)
|
|
|
|
getCrMoveSpeed :: Creature -> Int
|
|
getCrMoveSpeed cr = strFromHeldItem cr + strFromEquipment cr + _strength (_crStatistics cr)
|
|
|
|
strFromEquipment :: Creature -> Int
|
|
strFromEquipment = sum . fmap equipmentStrValue . crCurrentEquipment
|
|
|
|
equipmentStrValue :: Item -> Int
|
|
equipmentStrValue itm = case _itType itm of
|
|
EQUIP FRONTARMOUR -> negate 3
|
|
EQUIP POWERLEGS -> 3
|
|
_ -> 0
|
|
|
|
crCurrentEquipment :: Creature -> IM.IntMap Item
|
|
crCurrentEquipment = IM.filter (isJust . (^? itLocation . ilEquipSite . _Just)) . _crInv
|
|
|
|
strFromHeldItem :: Creature -> Int
|
|
strFromHeldItem cr
|
|
--x--- | _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do
|
|
| _posture (_crStance cr) == Aiming = negate $ fromMaybe 0 $ do
|
|
i <- cr ^? crManipulation . manObject . imRootSelectedItem
|
|
cr ^? crInv . ix i . itUse . heldAim . aimWeight
|
|
| otherwise = 0
|