public static bool IsGameOver(GameBoard i_Board) { return(!(i_Board.Score != 0 && GameLogic.isEmpty(i_Board))); }
private static bool vaildMove(Color i_Color, int i_DirectionRow, int i_DirectionCol, int i_Row, int i_Col, GameBoard i_Borad) { bool vaildIndex = false; Color other = Color.Black; if (i_Color == Color.Black) { other = Color.White; } if (i_DirectionRow + i_Row < 0 || i_DirectionRow + i_Row >= i_Borad.Size || i_DirectionCol + i_Col < 0 || i_DirectionCol + i_Col >= i_Borad.Size) { vaildIndex = false; } else if (i_Borad.MatrixButton[i_Row + i_DirectionRow, i_Col + i_DirectionCol].BackColor != other) { vaildIndex = false; } else { if (i_Color != i_Borad.MatrixButton[i_Row + i_DirectionRow, i_DirectionCol + i_Col].BackColor && i_Borad.MatrixButton[i_Row + i_DirectionRow, i_DirectionCol + i_Col].Text != string.Empty) { vaildIndex = checkLineIsGood(i_Color, i_DirectionRow, i_DirectionCol, i_DirectionRow + i_Row, i_DirectionCol + i_Col, i_Borad); } } return(vaildIndex); }
private static bool flipLine(Color i_Color, int i_DirectionRow, int i_DirectionCol, int i_Row, int i_Col, GameBoard i_Borad) { bool vaildIndex = false; if (i_DirectionRow + i_Row < 0 || i_DirectionRow + i_Row >= i_Borad.Size || i_DirectionCol + i_Col < 0 || i_DirectionCol + i_Col >= i_Borad.Size) { vaildIndex = false; } else { if (i_Borad.MatrixButton[i_DirectionRow + i_Row, i_DirectionCol + i_Col].Text == string.Empty) { vaildIndex = false; } else { if (i_Borad.MatrixButton[i_DirectionRow + i_Row, i_DirectionCol + i_Col].BackColor == i_Color) { vaildIndex = true; } else { if (flipLine(i_Color, i_DirectionRow, i_DirectionCol, i_DirectionRow + i_Row, i_DirectionCol + i_Col, i_Borad) == true) { i_Borad.MatrixButton[i_DirectionRow + i_Row, i_DirectionCol + i_Col].BackColor = i_Color; i_Borad.MatrixButton[i_DirectionRow + i_Row, i_DirectionCol + i_Col].Text = "O"; vaildIndex = true; } else { vaildIndex = false; } } } } return(vaildIndex); }