Sum attached held items to determine strength effect
This commit is contained in:
@@ -12,7 +12,9 @@ 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
|
||||
@@ -65,9 +67,9 @@ crCurrentEquipment lw = fmap f . _crEquipment
|
||||
strFromHeldItem :: LWorld -> Creature -> Int
|
||||
strFromHeldItem lw cr = fromMaybe 0 $ do
|
||||
Aiming {} <- cr ^? crStance . posture
|
||||
i <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
j <- cr ^? crInv . ix i
|
||||
fmap (negate . itemWeight) $ lw ^? items . ix j
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user