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 --- sequence.cabal | 2 +- sequence.nix | 2 +- src/Sequence/Contact/Types.hs | 4 ++-- src/Sequence/Contact/Types/Internal.hs | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sequence.cabal b/sequence.cabal index 2fd3724..2236e74 100644 --- a/sequence.cabal +++ b/sequence.cabal @@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: sequence -version: 0.2.0 +version: 1.0.0 -- synopsis: -- description: license: MIT diff --git a/sequence.nix b/sequence.nix index 3120275..ac589aa 100644 --- a/sequence.nix +++ b/sequence.nix @@ -6,7 +6,7 @@ }: mkDerivation { pname = "sequence"; - version = "0.2.0"; + version = "1.0.0"; src = ./.; isLibrary = false; isExecutable = true; 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