Sum attached held items to determine strength effect

This commit is contained in:
2025-09-01 10:26:43 +01:00
parent 291a35f538
commit 6c3c023ed9
2 changed files with 110 additions and 108 deletions
+5 -3
View File
@@ -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