Example #1
0
        public IfBlockExecuter(WaitForTokenHandler waitForTokenHandler, WaitForReTokenHandler waitForReTokenHandler, MatchWaitTokenHandler matchWaitTokenHandler)
        {
            _tokenizer = new Tokenizer(TokenDefinitionRegistry.Default().Definitions());
            _tokenHandlers = new SimpleDictionary<string, ITokenHandler>();

            _tokenHandlers["exit"] = new ExitTokenHandler();
            _tokenHandlers["comment"] = new ContinueTokenHandler();
            _tokenHandlers["debuglevel"] = new DebugLevelTokenHandler();
            _tokenHandlers["var"] = new VarTokenHandler();
            _tokenHandlers["unvar"] = new UnVarTokenHandler();
            _tokenHandlers["hasvar"] = new HasVarTokenHandler();
            _tokenHandlers["goto"] = new GotoTokenHandler();
            _tokenHandlers["waitfor"] = waitForTokenHandler;
            _tokenHandlers["waitforre"] = waitForReTokenHandler;
            _tokenHandlers["pause"] = new PauseTokenHandler();
            _tokenHandlers["put"] = new SendCommandTokenHandler();
            _tokenHandlers["echo"] = new EchoTokenHandler();
            _tokenHandlers["match"] = new MatchTokenHandler();
            _tokenHandlers["matchre"] = new MatchTokenHandler();
            _tokenHandlers["matchwait"] = matchWaitTokenHandler;
            _tokenHandlers["save"] = new SaveTokenHandler();
            _tokenHandlers["move"] = new MoveTokenHandler();
            _tokenHandlers["nextroom"] = new NextroomTokenHandler();
            _tokenHandlers["send"] = new SendTokenHandler();
            _tokenHandlers["parse"] = new ParseTokenHandler();
            _tokenHandlers["containsre"] = new ContainsReTokenHandler();
            _tokenHandlers["gosub"] = new GoSubTokenHandler();
            _tokenHandlers["return"] = new ReturnTokenHandler();
        }
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);
            theLogger = new InMemoryScriptLog();
            theGameStream = new GameStream(theGameState);

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IGameState>(theGameState);
            theServices.Add<IScriptLog>(theLogger);
            theServices.Add<IVariableReplacer>(new VariableReplacer());
            theServices.Add<ICommandProcessor>(new CommandProcessor(theServices, theServices.Get<IVariableReplacer>(), theLogger));
            theServices.Add<IGameStream>(theGameStream);

            theScriptContext = new ScriptContext("1", "sendcommand", CancellationToken.None,  theServices, null);
            theScriptContext.DebugLevel = 5;

            theHandler = new SendCommandTokenHandler();
        }