Use NewIntMap InvInt for crInv

This commit is contained in:
2025-08-25 10:21:59 +01:00
parent 25e64d5378
commit 3f6f1b4019
38 changed files with 437 additions and 406 deletions
+5 -3
View File
@@ -6,6 +6,7 @@ module Dodge.Creature.Statistics (
crIntelligence,
) where
import NewInt
import Dodge.Data.LWorld
import Data.Maybe
import qualified IntMapHelp as IM
@@ -54,8 +55,8 @@ equipmentStrValue itm = case _itType itm of
EQUIP POWERLEGS -> 3
_ -> 0
crCurrentEquipment :: LWorld -> Creature -> IM.IntMap Item
crCurrentEquipment lw = IM.filter (isJust . (^? itLocation . ilEquipSite . _Just)) . fmap f . _crInv
crCurrentEquipment :: LWorld -> Creature -> NewIntMap InvInt Item
crCurrentEquipment lw = over unNIntMap (IM.filter (isJust . (^? itLocation . ilEquipSite . _Just))) . fmap f . _crInv
where
f i = lw ^?! items . ix i
@@ -63,7 +64,8 @@ strFromHeldItem :: LWorld -> Creature -> Int
strFromHeldItem lw cr = fromMaybe 0 $ do
Aiming <- cr ^? crStance . posture
i <- cr ^? crManipulation . manObject . imRootSelectedItem
fmap (negate . itemWeight) $ lw ^? items . ix i
j <- cr ^? crInv . ix i
fmap (negate . itemWeight) $ lw ^? items . ix j
itemWeight :: Item -> Int
itemWeight it = case it ^. itType of