From e34688e295964500e1d0215e55fa57fe3628e9bc Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 12 Aug 2016 17:29:41 +0200 Subject: better equipment accessor --- src/Sequence/Contact/Types.hs | 4 ++-- src/Sequence/Contact/Types/Internal.hs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Sequence/Contact/Types.hs b/src/Sequence/Contact/Types.hs index df33506..5f8808d 100644 --- a/src/Sequence/Contact/Types.hs +++ b/src/Sequence/Contact/Types.hs @@ -183,8 +183,8 @@ sDamage' zone = sDamage . ix zone sCripple' :: Hitzone -> Traversal' Stats ShockEffect sCripple' zone = sCripple . ix zone -sEquipment' :: Typeable a => String -> Traversal' Stats a -sEquipment' (CI.mk -> k) = sEquipment . ix k . traverse . _Dynamic +sEquipment' :: Typeable a => String -> Lens' Stats (Maybe a) +sEquipment' (CI.mk -> k) = lens (preview _Dynamic <=< view (sEquipment . at k)) (flip $ set (sEquipment . at k) . (preview (re _Dynamic) =<<)) sTotalDamage :: Lens' Stats Int sTotalDamage = lens retrieve $ flip spread diff --git a/src/Sequence/Contact/Types/Internal.hs b/src/Sequence/Contact/Types/Internal.hs index 9df3527..7938a06 100644 --- a/src/Sequence/Contact/Types/Internal.hs +++ b/src/Sequence/Contact/Types/Internal.hs @@ -111,7 +111,7 @@ data Stats = Prop , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) , _sModifiers :: Set Modifier - , _sEquipment :: Map (CI String) [Dynamic] + , _sEquipment :: Map (CI String) Dynamic } | Humanoid { _sAStrength @@ -178,7 +178,7 @@ data Stats = Prop , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) , _sModifiers :: Set Modifier - , _sEquipment :: Map (CI String) [Dynamic] + , _sEquipment :: Map (CI String) Dynamic } | Quadruped { _sAStrength @@ -220,7 +220,7 @@ data Stats = Prop , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) , _sModifiers :: Set Modifier - , _sEquipment :: Map (CI String) [Dynamic] + , _sEquipment :: Map (CI String) Dynamic } | Dolphin { _sAStrength @@ -262,5 +262,5 @@ data Stats = Prop , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) , _sModifiers :: Set Modifier - , _sEquipment :: Map (CI String) [Dynamic] + , _sEquipment :: Map (CI String) Dynamic } -- cgit v1.2.3