Esempio n. 1
0
        private GameResult ExecuteActionSequence(string sequence)
        {
            var actions = SequenceParser.Parse(this, sequence);

            foreach (var turtleAction in actions)
            {
                try
                {
                    turtleAction();
                }
                catch (TurtleOutOfBoundsException)
                {
                    return(new GameResult(GameMessages.OutOfBounds, false));
                }

                if (_turtle.LandedOnMine())
                {
                    return(new GameResult(GameMessages.MineHit, false));
                }
            }

            if (_turtle.CanExit())
            {
                return(new GameResult(GameMessages.Success, true));
            }

            return(new GameResult(GameMessages.ExitNotReached, false));
        }