121 lines
2.9 KiB
Haskell
121 lines
2.9 KiB
Haskell
{-# LANGUAGE LambdaCase #-}
|
|
module Dodge.Creature.Statistics (
|
|
getCrMoveSpeed,
|
|
crStrength,
|
|
crDexterity,
|
|
crIntelligence,
|
|
) where
|
|
|
|
import Dodge.Data.Equipment.Misc
|
|
import qualified Data.Map.Strict as M
|
|
import NewInt
|
|
import Dodge.Data.LWorld
|
|
import Data.Maybe
|
|
--import qualified IntMapHelp as IM
|
|
import qualified Data.IntMap.Strict as IM
|
|
import LensHelp
|
|
import qualified Data.IntSet as IS
|
|
|
|
crDexterity :: Creature -> Int
|
|
crDexterity cr = case cr ^. crType of
|
|
Avatar { _avDexterity = x } -> x
|
|
AvatarDead -> 0
|
|
ChaseCrit {} -> 46
|
|
SwarmCrit -> 46
|
|
AutoCrit -> 46
|
|
BarrelCrit {} -> 0
|
|
LampCrit {} -> 0
|
|
|
|
crStrength :: Creature -> Int
|
|
crStrength cr = case cr ^. crType of
|
|
Avatar { _avStrength = x } -> x
|
|
AvatarDead -> 0
|
|
ChaseCrit {} -> 46
|
|
SwarmCrit -> 40
|
|
AutoCrit -> 46
|
|
BarrelCrit {} -> 0
|
|
LampCrit {} -> 0
|
|
|
|
crIntelligence :: Creature -> Int
|
|
crIntelligence cr = case cr ^. crType of
|
|
Avatar { _avIntelligence = x } -> x
|
|
AvatarDead -> 0
|
|
ChaseCrit {} -> 20
|
|
SwarmCrit -> 20
|
|
AutoCrit -> 20
|
|
BarrelCrit {} -> 0
|
|
LampCrit {} -> 0
|
|
|
|
|
|
getCrMoveSpeed :: LWorld -> Creature -> Int
|
|
getCrMoveSpeed lw cr = strFromHeldItem lw cr + strFromEquipment lw cr + crStrength cr
|
|
|
|
strFromEquipment :: LWorld -> Creature -> Int
|
|
strFromEquipment lw = sum . fmap equipmentStrValue . crCurrentEquipment lw
|
|
|
|
equipmentStrValue :: Item -> Int
|
|
equipmentStrValue itm = case _itType itm of
|
|
EQUIP FRONTARMOUR -> negate 3
|
|
EQUIP POWERLEGS -> 3
|
|
_ -> 0
|
|
|
|
crCurrentEquipment :: LWorld -> Creature -> M.Map EquipSite Item
|
|
crCurrentEquipment lw = fmap f . _crEquipment
|
|
where
|
|
f i = lw ^?! items . ix (_unNInt i)
|
|
|
|
strFromHeldItem :: LWorld -> Creature -> Int
|
|
strFromHeldItem lw cr = fromMaybe 0 $ do
|
|
Aiming {} <- cr ^? crStance . posture
|
|
is <- cr ^? crManipulation . manObject . imAttachedItems
|
|
let js = IM.elems $ IM.restrictKeys (cr ^. crInv . unNIntMap) is
|
|
return . negate . sum . fmap itemWeight $ IM.restrictKeys (lw ^. items) $ IS.fromList js
|
|
|
|
itemWeight :: Item -> Int
|
|
itemWeight it = case it ^. itType of
|
|
HELD hit -> heldItemWeight hit
|
|
LASER -> 15
|
|
_ -> 1
|
|
|
|
heldItemWeight :: HeldItemType -> Int
|
|
heldItemWeight = \case
|
|
BANGSTICK{} -> 5
|
|
REWINDER -> 5
|
|
TIMESTOPPER -> 5
|
|
TIMESCROLLER -> 5
|
|
PISTOL -> 5
|
|
MACHINEPISTOL -> 5
|
|
AUTOPISTOL -> 5
|
|
SMG -> 10
|
|
BANGCONE -> 5
|
|
BLUNDERBUSS -> 10
|
|
GRAPECANNON{} -> 10
|
|
MINIGUNX{} -> 20
|
|
VOLLEYGUN{} -> 15
|
|
RIFLE -> 10
|
|
ALTERIFLE -> 10
|
|
AUTORIFLE -> 10
|
|
BURSTRIFLE -> 10
|
|
BANGROD -> 10
|
|
ELEPHANTGUN -> 10
|
|
AMR -> 10
|
|
AUTOAMR -> 10
|
|
SNIPERRIFLE -> 10
|
|
FLAMESPITTER -> 5
|
|
FLAMETHROWER -> 10
|
|
FLAMETORRENT -> 10
|
|
FLAMEWALL -> 10
|
|
BLOWTORCH -> 10
|
|
TESLACOIL -> 15
|
|
TRACTORGUN -> 10
|
|
RLAUNCHER -> 20
|
|
RLAUNCHERX{} -> 20
|
|
GLAUNCHER -> 10
|
|
POISONSPRAYER -> 10
|
|
SHATTERGUN -> 10
|
|
LED -> 5
|
|
FLATSHIELD -> 15
|
|
KEYCARD {} -> 5
|
|
BLINKER -> 5
|
|
BLINKERUNSAFE -> 5
|