Beispiel #1
0
        public FireShotResponse TryPlayerAttack(Player currentPlayer, Player enemyPlayer)
        {
            UserIO.WriteLine($"{currentPlayer.Name}, your turn!");
            UserIO.DrawBoard(enemyPlayer);
            UserIO.WriteLine("Where would you like to fire?");
            Coordinate aimingAt = UserIO.GetCoord();

            return(enemyPlayer.Board.FireShot(aimingAt));
        }
Beispiel #2
0
        public void ShipSetup()
        {
            ResetBoard();
            UserIO.WriteLine($"Alright {Name}, let's setup your ships.");
            ShipType currentShip;

            for (int i = 0; i < 5; i++)
            {
                currentShip = (ShipType)i;
                UserIO.WriteLine($"Place your {currentShip.ToString()}.");

                PlaceShipRequest request = new PlaceShipRequest()
                {
                    Coordinate = UserIO.GetCoord(),
                    Direction  = UserIO.GetDirection(),
                    ShipType   = currentShip
                };

                ShipPlacement spotValidity = board.PlaceShip(request);
                switch (spotValidity)
                {
                case ShipPlacement.NotEnoughSpace:
                    i--;
                    UserIO.WriteLine("Not enough space to place a ship there!");
                    continue;

                case ShipPlacement.Overlap:
                    i--;
                    UserIO.WriteLine("This spot overlaps with another ship!");
                    break;

                case ShipPlacement.Ok:
                    UserIO.WriteLine("Ship placement works!");
                    break;

                default:
                    break;
                }
            }
            UserIO.Continue();
        }