Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: graninas/The-Amoeba-World
base: 69df24ce14
...
head fork: graninas/The-Amoeba-World
compare: 78baf848d9
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
17 Amoeba/GameLogic/Language/Translating/Actions.hs
@@ -6,15 +6,17 @@ import GameLogic.Language.Translating.Runtime
import Prelude hiding (log)
import Control.Monad.Trans.Either (left)
+-- Binds trigger to an action
(/>) :: Show a => (a -> Bool) -> (a -> Trans ()) -> a -> Trans ()
(/>) trigger act token = if trigger token
then act token
else logExt $ "Token not triggered: " ++ show token
-
+-- Action that do nothing, only logs info.
skip :: Show a => a -> Trans ()
skip t = log $ "Skip for: " ++ show t
+-- Action inserts item as object template.
addItem (Item name props) = do
log $ "Adding object template for: " ++ show name
insertObjectTemplate name props
@@ -37,8 +39,11 @@ getWorldCells props = do
-}
--setupWorld :: a -> PropertyToken -> Trans ()
-setupWorld propsScheme t = undefined
-
-setWidth = undefined
-setHeight = undefined
-setCells = undefined
+setupWorld rules (World name props) = do
+ log $ "Setting World: " ++ name ++ "."
+ translate rules props
+setupWorld _ t = left $ "setupWorld: World expected but got " ++ show t
+
+setWidth _ = log $ "setWidth"
+setHeight _ = log $ "setHeight"
+setCells _ = log $ "setCells"
View
19 Amoeba/GameLogic/Language/Translating/Runtime.hs
@@ -56,3 +56,22 @@ insertObjectTemplate name props = do
Just _ -> left $ "Object template for item " ++ name ++ " is duplicated."
log $ "Object template for item " ++ name ++ " added."
+-- Makes from rules list the list of context modificators.
+-- Folds the new list with applying to current context.
+apply rules t = mapM_ ($ t) rules
+
+{- Same function:
+apply rules t = sequence_ (map ($ t) rules)
+-}
+
+{- Same function:
+apply rules t = do
+ ctx <- get
+ let ctxModifier t ctx mod = do
+ put ctx
+ mod t
+ get
+ foldM_ (ctxModifier t) ctx rules
+-}
+
+translate rules = mapM_ (apply rules)
View
23 Amoeba/GameLogic/Language/Translating/Translator.hs
@@ -27,29 +27,6 @@ nextId prevId = do
indexingRt = initialRt (nextId 1)
--- Makes from scheme's list the list of context modificators.
--- Folds the new list with applying to current context.
-apply sc t = mapM_ ($ t) sc
-
-{- Same function:
-apply sc t = sequence_ (map ($ t) sc)
--}
-
-{- Same function:
-apply sc t = do
- ctx <- get
- let ctxModifier t ctx mod = do
- put ctx
- mod t
- get
- foldM_ (ctxModifier t) ctx sc
--}
-
-translate _ [] = return ()
-translate sc (t:ts) = do
- apply sc t
- translate sc ts
-
translateToWorld [] = Left "There are no tokens."
translateToWorld tokens = return $ evalState (runEitherT (translate scheme tokens)) indexingRt

No commit comments for this range

Something went wrong with that request. Please try again.