diff options
author | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-08-12 17:04:44 +0200 |
---|---|---|
committer | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-08-12 17:04:44 +0200 |
commit | 21896f81fd30c314d1826af19c25c386bd28e1be (patch) | |
tree | 879c70faeaee57e81afa3549735fc67fa153085c /src | |
parent | e65e3f11fe911a6ca1009cf35f4b3e7ca907c459 (diff) | |
download | 2017-01-16_17:13:37-21896f81fd30c314d1826af19c25c386bd28e1be.tar 2017-01-16_17:13:37-21896f81fd30c314d1826af19c25c386bd28e1be.tar.gz 2017-01-16_17:13:37-21896f81fd30c314d1826af19c25c386bd28e1be.tar.bz2 2017-01-16_17:13:37-21896f81fd30c314d1826af19c25c386bd28e1be.tar.xz 2017-01-16_17:13:37-21896f81fd30c314d1826af19c25c386bd28e1be.zip |
dynamically typed equipment
Diffstat (limited to 'src')
-rw-r--r-- | src/Sequence/Contact/Archetypes.hs | 8 | ||||
-rw-r--r-- | src/Sequence/Contact/Types.hs | 7 | ||||
-rw-r--r-- | src/Sequence/Contact/Types/Internal.hs | 10 |
3 files changed, 25 insertions, 0 deletions
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 | |||
122 | 122 | ||
123 | , _sExtraSkills = [] | 123 | , _sExtraSkills = [] |
124 | , _sModifiers = [] | 124 | , _sModifiers = [] |
125 | |||
126 | , _sEquipment = [] | ||
125 | } | 127 | } |
126 | 128 | ||
127 | player = prop { _sSeqEpsilon = True } | 129 | player = prop { _sSeqEpsilon = True } |
@@ -247,6 +249,8 @@ human = Humanoid | |||
247 | 249 | ||
248 | , _sExtraSkills = [] | 250 | , _sExtraSkills = [] |
249 | , _sModifiers = damageMods | 251 | , _sModifiers = damageMods |
252 | |||
253 | , _sEquipment = [] | ||
250 | } | 254 | } |
251 | where | 255 | where |
252 | arm zone = def | 256 | arm zone = def |
@@ -353,6 +357,8 @@ dog = Quadruped | |||
353 | 357 | ||
354 | , _sExtraSkills = [] | 358 | , _sExtraSkills = [] |
355 | , _sModifiers = damageMods | 359 | , _sModifiers = damageMods |
360 | |||
361 | , _sEquipment = [] | ||
356 | } | 362 | } |
357 | where | 363 | where |
358 | lauf zone = def | 364 | lauf zone = def |
@@ -440,6 +446,8 @@ dolphin = Dolphin | |||
440 | 446 | ||
441 | , _sExtraSkills = [] | 447 | , _sExtraSkills = [] |
442 | , _sModifiers = damageMods | 448 | , _sModifiers = damageMods |
449 | |||
450 | , _sEquipment = [] | ||
443 | } | 451 | } |
444 | 452 | ||
445 | childOfMu = human | 453 | 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 | |||
26 | import Data.Ord | 26 | import Data.Ord |
27 | import Data.ExtendedReal | 27 | import Data.ExtendedReal |
28 | import Data.Monoid (Monoid(..), (<>)) | 28 | import Data.Monoid (Monoid(..), (<>)) |
29 | import Data.Dynamic | ||
30 | import Data.Dynamic.Lens | ||
29 | 31 | ||
30 | import Control.Monad.Reader (ask, local) | 32 | import Control.Monad.Reader (ask, local) |
31 | import Control.Monad.State | 33 | import Control.Monad.State |
@@ -152,6 +154,8 @@ instance Default Stats where | |||
152 | 154 | ||
153 | , _sExtraSkills = [] | 155 | , _sExtraSkills = [] |
154 | , _sModifiers = [] | 156 | , _sModifiers = [] |
157 | |||
158 | , _sEquipment = [] | ||
155 | } | 159 | } |
156 | 160 | ||
157 | applyModifier :: String -> (Test -> FormulaM Stats Test) -> Effect | 161 | applyModifier :: String -> (Test -> FormulaM Stats Test) -> Effect |
@@ -179,6 +183,9 @@ sDamage' zone = sDamage . ix zone | |||
179 | sCripple' :: Hitzone -> Traversal' Stats ShockEffect | 183 | sCripple' :: Hitzone -> Traversal' Stats ShockEffect |
180 | sCripple' zone = sCripple . ix zone | 184 | sCripple' zone = sCripple . ix zone |
181 | 185 | ||
186 | sEquipment' :: Typeable a => String -> Traversal' Stats a | ||
187 | sEquipment' (CI.mk -> k) = sEquipment . ix k . traverse . _Dynamic | ||
188 | |||
182 | sTotalDamage :: Lens' Stats Int | 189 | sTotalDamage :: Lens' Stats Int |
183 | sTotalDamage = lens retrieve $ flip spread | 190 | sTotalDamage = lens retrieve $ flip spread |
184 | where | 191 | 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 | |||
10 | import Data.Ord | 10 | import Data.Ord |
11 | import Data.Monoid | 11 | import Data.Monoid |
12 | 12 | ||
13 | import Data.Dynamic | ||
14 | |||
13 | import Control.Lens | 15 | import Control.Lens |
14 | 16 | ||
15 | import Data.CaseInsensitive (CI) | 17 | import Data.CaseInsensitive (CI) |
@@ -108,6 +110,8 @@ data Stats = Prop | |||
108 | 110 | ||
109 | , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) | 111 | , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) |
110 | , _sModifiers :: Set Modifier | 112 | , _sModifiers :: Set Modifier |
113 | |||
114 | , _sEquipment :: Map (CI String) [Dynamic] | ||
111 | } | 115 | } |
112 | | Humanoid | 116 | | Humanoid |
113 | { _sAStrength | 117 | { _sAStrength |
@@ -173,6 +177,8 @@ data Stats = Prop | |||
173 | 177 | ||
174 | , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) | 178 | , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) |
175 | , _sModifiers :: Set Modifier | 179 | , _sModifiers :: Set Modifier |
180 | |||
181 | , _sEquipment :: Map (CI String) [Dynamic] | ||
176 | } | 182 | } |
177 | | Quadruped | 183 | | Quadruped |
178 | { _sAStrength | 184 | { _sAStrength |
@@ -213,6 +219,8 @@ data Stats = Prop | |||
213 | 219 | ||
214 | , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) | 220 | , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) |
215 | , _sModifiers :: Set Modifier | 221 | , _sModifiers :: Set Modifier |
222 | |||
223 | , _sEquipment :: Map (CI String) [Dynamic] | ||
216 | } | 224 | } |
217 | | Dolphin | 225 | | Dolphin |
218 | { _sAStrength | 226 | { _sAStrength |
@@ -253,4 +261,6 @@ data Stats = Prop | |||
253 | 261 | ||
254 | , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) | 262 | , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) |
255 | , _sModifiers :: Set Modifier | 263 | , _sModifiers :: Set Modifier |
264 | |||
265 | , _sEquipment :: Map (CI String) [Dynamic] | ||
256 | } | 266 | } |