コード例 #1
0
ファイル: Board.cs プロジェクト: FreddeFrallan/Albot.Online
        public static PlayingPiece[,] cloneField(PlayingPiece[,] board)
        {
            PlayingPiece[,] postField = new PlayingPiece[8, 8];
            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    if (board [x, y] != null)
                    {
                        postField [x, y] = board [x, y].clone();
                    }
                }
            }

            return(postField);
        }
コード例 #2
0
ファイル: Board.cs プロジェクト: FreddeFrallan/Albot.Online
        public Board playMove(Move move)
        {
            PlayingPiece[,] postField = cloneField(board);
            PlayingPiece movePiece = postField [move.start [0], move.start [1]];

            postField [move.start [0], move.start [1]]   = null;
            postField [move.target [0], move.target [1]] = movePiece;
            movePiece.setPos(move.target);
            movePiece.onPlayingMove();

            if (move.type == PieceType.pawn)
            {
                postField = handlePawnSpecialls(postField, move, movePiece);
            }


            return(new Board(postField));
        }
コード例 #3
0
ファイル: Pawn.cs プロジェクト: FreddeFrallan/Albot.Online
        public void giveAnPeasant(PlayingPiece[,] board)
        {
            for (int i = -1; i <= 1; i += 2)
            {
                int[] sidePos = new int[2] {
                    pos [0] + i, pos [1]
                };
                SquareStatus temp = getSquareState(board, sidePos);
                if (temp != SquareStatus.occupied)
                {
                    continue;
                }

                PlayingPiece p = board[sidePos[0], sidePos[1]];
                if (p.type != PieceType.pawn || p.getColor() == playerColor)
                {
                    continue;
                }

                (p as Pawn).enableEnPeasant(this);
            }
        }
コード例 #4
0
ファイル: Board.cs プロジェクト: FreddeFrallan/Albot.Online
        private void initPlayerLists()
        {
            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    PlayingPiece p = board [x, y];
                    if (p == null)
                    {
                        continue;
                    }

                    if (p.getColor() == Color.white)
                    {
                        whites.Add(p);
                    }
                    else
                    {
                        blacks.Add(p);
                    }
                }
            }
        }
コード例 #5
0
ファイル: Pawn.cs プロジェクト: FreddeFrallan/Albot.Online
 public void enableEnPeasant(PlayingPiece target)
 {
     canEnPeasant      = true;
     enPeasantPos      = target.getPos();
     enPeasantPos [1] += playerColor == Color.white ? 1 : -1;
 }
コード例 #6
0
ファイル: Board.cs プロジェクト: FreddeFrallan/Albot.Online
        private PlayingPiece[,] handlePawnSpecialls(PlayingPiece[,] postField, Move move, PlayingPiece movePiece)
        {
            if (Math.Abs(move.start [1] - move.target [1]) == 2)               //Played double step, give enpeasant!
            {
                (movePiece as Pawn).giveAnPeasant(postField);
            }

            if (move.start [0] != move.target [0])            //Played enpeasant! remove targetEnpeasant
            {
                postField = (movePiece as Pawn).onPlayedOnPeasant(postField);
            }

            return(postField);
        }