44 lines
1.3 KiB
Haskell
44 lines
1.3 KiB
Haskell
module Dodge.Creature.Statistics (
|
|
getCrMoveSpeed,
|
|
getCrDexterity,
|
|
) where
|
|
|
|
import Data.IntMap.Merge.Strict
|
|
import Data.Maybe
|
|
--import Dodge.Creature.Test
|
|
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 cr =
|
|
merge
|
|
dropMissing
|
|
dropMissing
|
|
(zipWithMatched (\_ _ itm -> itm))
|
|
(_crInvEquipped cr)
|
|
(_crInv cr)
|
|
|
|
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
|