예제 #1
0
파일: ui.cs 프로젝트: fannar82/Confusion
 public static void announceWinner(Player pl)
 {
     Console.Write("Yay, player ");
     Console.Write(pl.name);
     Console.Write(" just won the game !!!");
     Console.WriteLine();
 }
예제 #2
0
        static void aTurn(int turn, Board gb, Player playerOne, Player playerTwo)
        {
            bool again = true;
            do
            {
                askPlayerForInput(gb, playerOne);
                gb.play(ui.selectedColumn, ui.selectedRow, 1);
                if ((turn > 2) && (gb.checkForVictory()))
                {
                    ui.announceWinner(playerOne);
                    again = false;
                }
                else if ((turn > 4) && (!gb.checkForVictory()))
                {
                    ui.announceDraw(playerOne, playerTwo);
                    again = false;
                }
                askPlayerForInput(gb, playerTwo);
                gb.play(ui.selectedColumn, ui.selectedRow, 2);
                if ((turn > 2) && (gb.checkForVictory()))
                {
                    ui.announceWinner(playerTwo);
                    again = false;
                }
                turn++;

            }
            while (again);
        }
예제 #3
0
 static void askPlayerForInput(Board gb, Player pl)
 {
     ConsoleKeyInfo input;
     do
     {
         input = ui.askPlayerForInput(pl);
         if (input.Key == ConsoleKey.UpArrow)
         {
                 ui.selectedRow = ui.selectedRow-1;
         }
         if (input.Key == ConsoleKey.DownArrow)
         {
                 ui.selectedRow = ui.selectedRow+1;
         }
         if (input.Key == ConsoleKey.LeftArrow)
         {
                 ui.selectedColumn = ui.selectedColumn-1;
         }
         if (input.Key == ConsoleKey.RightArrow)
         {
                 ui.selectedColumn = ui.selectedColumn+1;
         }
         ui.selectedRow = correctOutOfBounds(ui.selectedRow, gb.boardSize);
         ui.selectedColumn = correctOutOfBounds(ui.selectedColumn, gb.boardSize);
         ui.clearScreen();
         ui.drawBoard(gb);
     }
     while (input.Key != ConsoleKey.Enter);
 }
예제 #4
0
파일: ui.cs 프로젝트: fannar82/Confusion
 public static ConsoleKeyInfo askPlayerForInput(Player pl)
 {
     ConsoleKeyInfo input;
     Console.Write(pl.name);
     Console.Write(" please move your cursor with the arrow keys");
     input = Console.ReadKey();
     return input;
 }
예제 #5
0
파일: ui.cs 프로젝트: fannar82/Confusion
 public static void announceDraw(Player pl1, Player pl2)
 {
     Console.Write("Ohh, what a pity, neither ");
     Console.Write(pl1.name);
     Console.Write(" nor ");
     Console.Write(pl2.name);
     Console.Write(" won the game.");
     Console.WriteLine();
 }
예제 #6
0
 static void Main(string[] args)
 {
     Player playerOne;
     Player playerTwo;
     Board gb;
     int turn = 0;
     bool anotherGame = true;
     do
     {
         ui.clearScreen();
         playerOne = new Player(ui.getPlayersName("Player one"), 1);
         playerTwo = new Player(ui.getPlayersName("Player two"), 2);
         gb = new Board(3);
         ui.clearScreen();
         ui.drawBoard(gb);
         turn++;
         aTurn(turn, gb, playerOne, playerTwo);
         anotherGame = ui.askForAnotherGame();
     }
     while (anotherGame);
 }