Beispiel #1
0
        private List <Point> refreshPossibleMoves()
        {
            List <Point> possiblePos = new List <Point>();

            switch (this.type)
            {
            case ChessPieceType.Keima:
                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (this.playerindex == 1 && j < 3)
                        {
                            continue;
                        }
                        if (this.playerindex == 2 && j > 7)
                        {
                            break;
                        }
                        if (Board.getChessPiece(new Point(i, j)) == null)
                        {
                            possiblePos.Add(new Point(i, j));
                        }
                    }
                }
                break;

            case ChessPieceType.Kyosha:
                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (this.playerindex == 1 && j == 1)
                        {
                            continue;
                        }
                        if (this.playerindex == 2 && j == 9)
                        {
                            break;
                        }
                        if (Board.getChessPiece(new Point(i, j)) == null)
                        {
                            possiblePos.Add(new Point(i, j));
                        }
                    }
                }
                break;

            case ChessPieceType.Fuhyo:
                for (int i = 1; i <= 9; i++)
                {
                    bool secondFu = false;
                    for (int j = 1; j <= 9; j++)
                    {
                        ChessPiece target = Board.getChessPiece(new Point(i, j));
                        if (target != null && target.defaultType == ChessPieceType.Fuhyo)
                        {
                            if ((target.player.role == "first" && this.playerindex == 1) || (target.player.role == "second" && this.playerindex == 2))
                            {
                                secondFu = true;
                                break;
                            }
                        }
                    }
                    if (!secondFu)
                    {
                        for (int j = 1; j <= 9; j++)
                        {
                            if (this.playerindex == 1 && j == 1)
                            {
                                continue;
                            }
                            if (this.playerindex == 2 && j == 9)
                            {
                                break;
                            }
                            if (Board.getChessPiece(new Point(i, j)) == null)
                            {
                                possiblePos.Add(new Point(i, j));                                                  //檢查打步詰
                            }
                        }
                    }
                }
                break;

            default:
                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (Board.getChessPiece(new Point(i, j)) == null)
                        {
                            possiblePos.Add(new Point(i, j));
                        }
                    }
                }
                break;
            }
            return(possiblePos);
        }
Beispiel #2
0
        public static void setChessPiece(ChessPiece target)
        {
            Point point = target.board_point;

            board[point.X, point.Y] = target;
        }
Beispiel #3
0
 public static bool CheckMate(Point point, ChessPiece target, Player player)
 {
     //Input:The chessPiece and point to move at next step
     //TODO: Check if checkmate
     return(false);
 }
Beispiel #4
0
 public static void DeployCP(ChessPiece cp, Point to)
 {
     MessageBox.Show(cp.player + "deploy to " + to.X + "," + to.Y);
 }