From 21896f81fd30c314d1826af19c25c386bd28e1be Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 12 Aug 2016 17:04:44 +0200 Subject: dynamically typed equipment --- sequence.cabal | 2 +- sequence.nix | 2 +- src/Sequence/Contact/Archetypes.hs | 8 ++++++++ src/Sequence/Contact/Types.hs | 7 +++++++ src/Sequence/Contact/Types/Internal.hs | 10 ++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/sequence.cabal b/sequence.cabal index 3550262..2fd3724 100644 --- a/sequence.cabal +++ b/sequence.cabal @@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: sequence -version: 0.1.0 +version: 0.2.0 -- synopsis: -- description: license: MIT diff --git a/sequence.nix b/sequence.nix index 35347cc..3120275 100644 --- a/sequence.nix +++ b/sequence.nix @@ -6,7 +6,7 @@ }: mkDerivation { pname = "sequence"; - version = "0.1.0"; + version = "0.2.0"; src = ./.; isLibrary = false; isExecutable = true; diff --git a/src/Sequence/Contact/Archetypes.hs b/src/Sequence/Contact/Archetypes.hs index c93210d..1973b97 100644 --- a/src/Sequence/Contact/Archetypes.hs +++ b/src/Sequence/Contact/Archetypes.hs @@ -122,6 +122,8 @@ prop = Prop , _sExtraSkills = [] , _sModifiers = [] + + , _sEquipment = [] } player = prop { _sSeqEpsilon = True } @@ -247,6 +249,8 @@ human = Humanoid , _sExtraSkills = [] , _sModifiers = damageMods + + , _sEquipment = [] } where arm zone = def @@ -353,6 +357,8 @@ dog = Quadruped , _sExtraSkills = [] , _sModifiers = damageMods + + , _sEquipment = [] } where lauf zone = def @@ -440,6 +446,8 @@ dolphin = Dolphin , _sExtraSkills = [] , _sModifiers = damageMods + + , _sEquipment = [] } childOfMu = human diff --git a/src/Sequence/Contact/Types.hs b/src/Sequence/Contact/Types.hs index 12283b9..df33506 100644 --- a/src/Sequence/Contact/Types.hs +++ b/src/Sequence/Contact/Types.hs @@ -26,6 +26,8 @@ import Data.List import Data.Ord import Data.ExtendedReal import Data.Monoid (Monoid(..), (<>)) +import Data.Dynamic +import Data.Dynamic.Lens import Control.Monad.Reader (ask, local) import Control.Monad.State @@ -152,6 +154,8 @@ instance Default Stats where , _sExtraSkills = [] , _sModifiers = [] + + , _sEquipment = [] } applyModifier :: String -> (Test -> FormulaM Stats Test) -> Effect @@ -179,6 +183,9 @@ 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 + sTotalDamage :: Lens' Stats Int sTotalDamage = lens retrieve $ flip spread where diff --git a/src/Sequence/Contact/Types/Internal.hs b/src/Sequence/Contact/Types/Internal.hs index ca4d022..9df3527 100644 --- a/src/Sequence/Contact/Types/Internal.hs +++ b/src/Sequence/Contact/Types/Internal.hs @@ -10,6 +10,8 @@ import Data.Ratio import Data.Ord import Data.Monoid +import Data.Dynamic + import Control.Lens import Data.CaseInsensitive (CI) @@ -108,6 +110,8 @@ data Stats = Prop , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) , _sModifiers :: Set Modifier + + , _sEquipment :: Map (CI String) [Dynamic] } | Humanoid { _sAStrength @@ -173,6 +177,8 @@ data Stats = Prop , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) , _sModifiers :: Set Modifier + + , _sEquipment :: Map (CI String) [Dynamic] } | Quadruped { _sAStrength @@ -213,6 +219,8 @@ data Stats = Prop , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) , _sModifiers :: Set Modifier + + , _sEquipment :: Map (CI String) [Dynamic] } | Dolphin { _sAStrength @@ -253,4 +261,6 @@ data Stats = Prop , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) , _sModifiers :: Set Modifier + + , _sEquipment :: Map (CI String) [Dynamic] } -- cgit v1.2.3