Beispiel #1
0
        public void ProcessMoves()
        {
            while (_commandsQueue.Count() != 0)
            {
                var command = _commandsQueue.Dequeue();

                if (command.Direction == RelativeDirection.Forward)
                {
                    var newCoordinates = _position.ProcessMovement(command.Distance);

                    if (!_terrain.WithinPerimeter(newCoordinates))
                    {
                        _commandsQueue.Clear();
                    }
                    else
                    {
                        _position.ExecuteMovement(newCoordinates);
                    }
                }
                else
                {
                    _position.ExecuteTurn(command);
                }
            }
        }