summaryrefslogtreecommitdiff
path: root/src/Sequence/Utils.hs
diff options
context:
space:
mode:
authorGregor Kleen <pngwjpgh@users.noreply.github.com>2016-06-25 17:50:52 +0200
committerGregor Kleen <pngwjpgh@users.noreply.github.com>2016-06-25 17:50:52 +0200
commiteea3a546370ed95321dcc21b4db739ad0d893dfb (patch)
tree6e7686fcd84dccf83d85b4245022ec61e1a5f8d2 /src/Sequence/Utils.hs
parent7a80cf63d55c62a2e5fbf4c937fae4e33f5629c2 (diff)
download2017-01-16_17:13:37-eea3a546370ed95321dcc21b4db739ad0d893dfb.tar
2017-01-16_17:13:37-eea3a546370ed95321dcc21b4db739ad0d893dfb.tar.gz
2017-01-16_17:13:37-eea3a546370ed95321dcc21b4db739ad0d893dfb.tar.bz2
2017-01-16_17:13:37-eea3a546370ed95321dcc21b4db739ad0d893dfb.tar.xz
2017-01-16_17:13:37-eea3a546370ed95321dcc21b4db739ad0d893dfb.zip
Inspect entities
Diffstat (limited to 'src/Sequence/Utils.hs')
-rw-r--r--src/Sequence/Utils.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Sequence/Utils.hs b/src/Sequence/Utils.hs
index 929189e..ba6ce95 100644
--- a/src/Sequence/Utils.hs
+++ b/src/Sequence/Utils.hs
@@ -1,4 +1,4 @@
1{-# LANGUAGE ViewPatterns, FlexibleContexts, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, OverloadedStrings, RankNTypes #-} 1{-# LANGUAGE ViewPatterns, FlexibleContexts, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, OverloadedStrings, OverloadedLists, RankNTypes #-}
2 2
3module Sequence.Utils 3module Sequence.Utils
4 ( withArg, withFocus, withFocus' 4 ( withArg, withFocus, withFocus'
@@ -140,3 +140,16 @@ instance Argument DamageType GameState where
140 arg (CI.mk -> word) = return $ Map.lookup word types 140 arg (CI.mk -> word) = return $ Map.lookup word types
141 where 141 where
142 types = Map.fromList [(CI.mk $ show dType, dType) | dType <- [minBound .. maxBound]] 142 types = Map.fromList [(CI.mk $ show dType, dType) | dType <- [minBound .. maxBound]]
143
144instance Completion (Formula Stats) GameState where
145 completableLabel _ = "<value>"
146 complete _ st (CI.foldCase -> prefix) = return . map CI.original . filter ((prefix `isPrefixOf`) . CI.foldedCase) . Map.keys $ Map.filter (isJust . (\a -> preview (gFocus' . eStats . folding a) st)) statAccessors
147
148instance Argument (Formula Stats) GameState where
149 arg (CI.mk -> name) = runMaybeT $ do
150 accessor <- MaybeT . return $ Map.lookup name statAccessors
151 MaybeT . preuse $ gFocus' . eStats . folding accessor
152
153statAccessors :: Map (CI String) (Stats -> Maybe (Formula Stats))
154statAccessors = [
155 ]