public async Task Bot_Cannot_MoveForward_With_North_Orientation_On_1x1_Arena( )
        {
            // Arrange
            Arena arena = new Arena {
                Width = 1, Height = 1
            };
            Team team = new Team {
                Name = "Team!"
            };
            Bot bot = new Bot {
                LocationX = 0, LocationY = 0, Orientation = Orientation.North, MaximumStamina = 1, CurrentStamina = 1, StaminaDrain = 0
            };
            Deployment deployment = new Deployment {
                Arena = arena, Team = team, Bot = bot
            };

            bot.Deployments = (new[] { deployment }).ToList( );

            Script botScript = await BotScript.PrepareScript("MoveForward();".Base64Encode( ));

            botScript.Compile( );
            ScriptGlobals globals = new ScriptGlobals(arena, bot, new List <Bot>( ));

            // Act
            await botScript.RunAsync(globals);

            // Assert
            Assert.AreEqual(0, globals.LocationX);
            Assert.AreEqual(0, globals.LocationY);
            Assert.AreEqual(1, globals.Stamina);
            Assert.AreEqual(0, globals.StaminaDrain);
        }
Beispiel #2
0
        private async Task <Script> GetCompiledBotScript(Bot bot)
        {
            if (!_cache.ScriptStored(bot))
            {
                var botScript = await BotScript.PrepareScript(bot.Script);

                botScript.Compile();
                _cache.StoreScript(bot, botScript);
            }

            return(_cache.LoadScript(bot));
        }