From eea3a546370ed95321dcc21b4db739ad0d893dfb Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 25 Jun 2016 17:50:52 +0200 Subject: Inspect entities --- src/Sequence/Utils.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/Sequence/Utils.hs') 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 @@ -{-# LANGUAGE ViewPatterns, FlexibleContexts, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, OverloadedStrings, RankNTypes #-} +{-# LANGUAGE ViewPatterns, FlexibleContexts, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, OverloadedStrings, OverloadedLists, RankNTypes #-} module Sequence.Utils ( withArg, withFocus, withFocus' @@ -140,3 +140,16 @@ instance Argument DamageType GameState where arg (CI.mk -> word) = return $ Map.lookup word types where types = Map.fromList [(CI.mk $ show dType, dType) | dType <- [minBound .. maxBound]] + +instance Completion (Formula Stats) GameState where + completableLabel _ = "" + 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 + +instance Argument (Formula Stats) GameState where + arg (CI.mk -> name) = runMaybeT $ do + accessor <- MaybeT . return $ Map.lookup name statAccessors + MaybeT . preuse $ gFocus' . eStats . folding accessor + +statAccessors :: Map (CI String) (Stats -> Maybe (Formula Stats)) +statAccessors = [ + ] -- cgit v1.2.3