Ejemplo n.º 1
0
        public void Run()
        {
            do
            {
                UserIO.SplashScreen();
                UserIO.WelcomeUser();

                ////Players and Boards

                Player User1 = new Player();
                Player User2 = new Player();
                User1.EnemyPlayer = User2;
                User2.EnemyPlayer = User1;

                UserIO.User1(User1);
                UserIO.DisplayBoard(User1.Board);
                UserIO.PlaceShips(User1.Board);
                UserIO.ClearConsole("Press key and end turn.");

                UserIO.User2(User2);
                UserIO.DisplayBoard(User2.Board);
                UserIO.PlaceShips(User2.Board);
                UserIO.ClearConsole("Press key and end turn");

                UserIO.Randomize(User1, User2);
                UserIO.ClearConsole("Press any key");

                UserIO.TakingTurns(User1, User2);
            }while (UserIO.VictoryAndGlory() == true);
        }
Ejemplo n.º 2
0
        // method for turn, use player as input
        public static ShotStatus PlayerTurn(Player player, Board board)
        {
            Console.WriteLine($"Press any key to begin {player.Name}'s turn");
            Console.ReadKey(true);

            //display opponent's board
            UserIO.DisplayBoard(board);
            FireShotResponse response;

            do
            {
                //get coord for shot
                Coordinate coord = UserIO.GetCoordinates();

                //check result
                response = board.FireShot(coord);
                DisplayShotStatus(player, response);
            } while (response.ShotStatus == ShotStatus.Invalid || response.ShotStatus == ShotStatus.Duplicate);

            return(response.ShotStatus);
        }