示例#1
0
        private void MakeATurn(Warrior player, IConsoleWrapper consoleWrapper)
        {
            (int x, int y)oldPosition;
            int  currentSpeedPoints;
            int  moves        = 0;
            bool isInputValid = true;

            currentSpeedPoints = player.SpeedPoints;

            while (moves < currentSpeedPoints && _game.Status == GameStatusType.Running)
            {
                oldPosition = (player.Position.X, player.Position.Y);
                if (isInputValid)
                {
                    Console.WriteLine($"Player{player.Symbol}, make a move please!");
                }

                DirectionType directionType = _playersManager.GetPlayerDirection(consoleWrapper);

                if (player.Move(directionType))
                {
                    isInputValid = true;
                    _playersManager.EatFruits(player, _figures);

                    _gridManager.DisplayOnGrid(oldPosition);
                    _gridManager.DisplayOnGrid(player);

                    moves++;

                    if (CheckHasPlayerWon(player))
                    {
                        break;
                    }

                    _gridManager.PrintGrid();
                    _playersManager.PrintPlayersStatistics();
                }
                else
                {
                    Console.WriteLine("Wrong input! Please choose a correct direction.");
                    isInputValid = false;
                }
            }
        }