예제 #1
0
        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);
        }
예제 #2
0
        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++;
        }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
        }
예제 #6
0
 private Winner CheckDiagonal(ChessmanPoint coordinate)
 {
     return(CheckBoth(coordinate, nameof(CheckDiagonal)));
 }
예제 #7
0
 private Winner CheckHorizontal(ChessmanPoint coordinate)
 {
     return(CheckBoth(coordinate, nameof(CheckHorizontal)));
 }
예제 #8
0
        public Winner Check(ChessmanPoint coordinate)
        {
            var checker = new Judgment(_chessBoard);

            return(checker.Check(coordinate));
        }