Beispiel #1
0
        public static void Start()
        {
            PlayerBoard playerBoard = new PlayerBoard();
            EnemyBoard  enemyBoard  = new EnemyBoard();

            Console.WriteLine("Witaj w grze w statki!");
            playerBoard.CreateFleet();
            enemyBoard.CreateFleet();

            do
            {
                RedrawBoards(playerBoard, enemyBoard);
                Console.ReadLine();
                PlayersShoot(playerBoard, enemyBoard);
            } while (!IsGameOver(playerBoard, enemyBoard));

            if (playerBoard.LostAllFleet())
            {
                RedrawBoards(playerBoard, enemyBoard);
                Console.Write("Przegrałeś!");
            }
            else
            {
                RedrawBoards(playerBoard, enemyBoard);
                Console.Write("Wygrałeś!");
            }
            Console.ReadLine();
        }
Beispiel #2
0
 public static bool IsGameOver(PlayerBoard playerBoard, EnemyBoard enemyBoard)
 {
     return(playerBoard.LostAllFleet() || enemyBoard.LostAllFleet());
 }
Beispiel #3
0
 public static void PlayersShoot(PlayerBoard playerBoard, EnemyBoard enemyBoard)
 {
     playerBoard.EnemyShoots(playerBoard);
     enemyBoard.ShootEnemy(enemyBoard);
 }
Beispiel #4
0
 public static void RedrawBoards(PlayerBoard playerBoard, EnemyBoard enemyBoard)
 {
     Console.Clear();
     playerBoard.DrawBoard();
     enemyBoard.DrawBoard();
 }