private Winner CheckBoth(ChessmanPoint coordinate, string validateMethod) { var stepLong = ValidateStepLong(validateMethod); return(Check(coordinate, stepLong, Chessman.White) == Winner.White ? Winner.White : Check(coordinate, stepLong, Chessman.Black) == Winner.Black ? Winner.Black : Winner.None); }
private void BlackGo(int x, int y) { Role = Role.White; _chessBoard[x, y] = new ChessmanPoint(x, y, Chessman.Black); DrawChessBoard(new Point(x, y)); Steps++; }
public Winner Check(ChessmanPoint coordinate) { var verticalWinner = CheckVertical(coordinate); var horizontalWinner = CheckHorizontal(coordinate); var leadingDiagonalWinner = CheckLeadingDiagonal(coordinate); var diagonalWinner = CheckDiagonal(coordinate); return(verticalWinner != Winner.None ? verticalWinner : horizontalWinner != Winner.None ? horizontalWinner : leadingDiagonalWinner != Winner.None ? leadingDiagonalWinner : diagonalWinner != Winner.None ? diagonalWinner : Winner.None); }
public PlayGround(string gameId) { GameId = gameId; RandomizeFirst(); Directory.CreateDirectory($"data\\image\\{GameId}"); for (var i = 0; i < 15; i++) { for (var j = 0; j < 15; j++) { _chessBoard[i, j] = new ChessmanPoint(i, j, Chessman.Empty); } } DrawChessBoard(default(Point)); }
private Winner Check(ChessmanPoint coordinate, Step stepLong, Chessman chessman) { var count = 0; var up = coordinate; // check the right side from self's coordinate while (up.X <= 14 && up.Y <= 14 && up.Chessman == chessman) { if (count == 5) { return(chessman == Chessman.White ? Winner.White : Winner.Black); } count++; try { up = _chessBoard.GetPoint(up.X + stepLong.RightX, up.Y + stepLong.RightY); } catch (IndexOutOfRangeException) { break; } } up = coordinate; // check the left side from self's coordinate while (up.X >= 0 && up.Y >= 0 && up.Chessman == chessman) { if (count == 5) { return(chessman == Chessman.White ? Winner.White : Winner.Black); } count++; try { up = _chessBoard.GetPoint(up.X + stepLong.LeftX, up.Y + stepLong.LeftY); } catch (IndexOutOfRangeException) { break; } } return(Winner.None); }
private Winner CheckDiagonal(ChessmanPoint coordinate) { return(CheckBoth(coordinate, nameof(CheckDiagonal))); }
private Winner CheckHorizontal(ChessmanPoint coordinate) { return(CheckBoth(coordinate, nameof(CheckHorizontal))); }
public Winner Check(ChessmanPoint coordinate) { var checker = new Judgment(_chessBoard); return(checker.Check(coordinate)); }