Example #1
0
        public void Game_Draw_6Rows_6Columns()
        {
            ConnectFour connectFour =
                DataGenerator.Get_CF_Game_Draw_6Rows_6Columns();

            var resultY   = connectFour.CheckWin('y');
            var resultR   = connectFour.CheckWin('r');
            var boardfull = connectFour.IsBoardFull();

            Assert.True(!resultY && !resultR && boardfull);
        }
Example #2
0
        public void Diagonal_Yellow_Wins(int rows, int columns)
        {
            ConnectFour connectFour =
                DataGenerator.Get_CF_TopLeftToBottomRight_Diagonal_Yellow_Win_Check(rows, columns);

            var result = connectFour.CheckWin('y');

            Assert.True(result);
        }
        private void handleMove(int z)
        {
            for (int i = 5; i > -1; i--)
            {
                if (board.OpenCells[i, z] == board.Open)
                {
                    Chip chip = new Chip(i, z);
                    player.TakeTurn(board, chip);
                    printBoard();
                    break;
                }
            }

            if (game.CheckWin(1, board) == 1)
            {
                game.EndGame(1);
                disableButtons();
                lblResult.CssClass = "msg";
                lblResult.Text     = "Player Win";
            }
            else
            {
                bot.TakeTurn(board);
                printBoard();

                if (game.CheckWin(2, board) == 1)
                {
                    game.EndGame(2);
                    disableButtons();
                    lblResult.CssClass = "msg";
                    lblResult.Text     = "Bot Win";
                }
                else if (game.CheckWin(2, board) == 2)
                {
                    game.EndGame(3);
                    disableButtons();
                    lblResult.CssClass = "msg";
                    lblResult.Text     = "Tie";
                }
                checkButtons();
            }
        }
Example #4
0
        public void Vertical_Red_windCheck(int rows, int columns)
        {
            ConnectFour connectFour = new ConnectFour(rows, columns);

            for (int i = 0; i < 4; i++)
            {
                connectFour.Drop('r', 0);
            }

            var result = connectFour.CheckWin('r');

            Assert.True(result);
        }
Example #5
0
        public void Horizontal_Yellow_WinCheck(int rows, int columns)
        {
            ConnectFour connectFour = new ConnectFour(rows, columns);

            for (int i = 0; i < 4; i++)
            {
                connectFour.Drop('y', i);
            }

            var result = connectFour.CheckWin('y');

            Assert.True(result);
        }