Exemplo n.º 1
0
 public bool PieceMove(int Sx, int Sy, int x, int y, ref selected sel)
 {
     if (MoveJudge(Sx, Sy, x, y, ref sel))
     {
         Handle = Handle ? false : true;//移动后更换执手方
         Move(Sx, Sy, x, y);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 2
0
 public void Select(int x, int y, ref selected sel)
 {
     if (Piece[x, y] != -1)
     {
         if (Handle == false && Piece[x, y] < 8)
         {
             sel.select = true;
             sel.x      = x;
             sel.y      = y;
         }
         else if (Handle == true && Piece[x, y] >= 8)
         {
             sel.select = true;
             sel.x      = x;
             sel.y      = y;
         }
     }
 }
Exemplo n.º 3
0
        }//判断行动是否是棋子的行动范围

        private bool MoveJudge(int Sx, int Sy, int x, int y, ref selected sel)
        {
            if (ActionScope(Sx, Sy, x, y))
            {
                if (Checkerboard[x, y] == 5 && (Piece[Sx, Sy] != 0 && Piece[Sx, Sy] != 8) && Piece[x, y] == -1)
                {
                    return(false);
                }
                else if (Piece[x, y] != -1 && Piece[Sx, Sy] / 8 == Piece[x, y] / 8)
                {
                    sel.x = x;
                    sel.y = y;
                    return(false);
                }//下一步是己方棋子
                else if (Piece[x, y] != -1 && Piece[Sx, Sy] / 8 != Piece[x, y] / 8)
                {
                    if (Piece[Sx, Sy] % 8 != 7 || Piece[x, y] % 8 != 0)
                    {
                        if ((Checkerboard[Sx, Sy] == 5 && Checkerboard[x, y] == 5) || (Checkerboard[Sx, Sy] != 5 && Checkerboard[x, y] != 5))
                        {
                            if (Piece[Sx, Sy] % 8 == 0 && Piece[x, y] % 8 == 7)
                            {
                                return(true);
                            }
                            else if ((Checkerboard[x, y] == 2 && Piece[Sx, Sy] / 8 == 0) || (Checkerboard[x, y] == 4 && Piece[Sx, Sy] / 8 == 1))
                            {
                                return(true);                                                                                                                //在陷阱中的棋子随便吃
                            }
                            else if (Piece[Sx, Sy] % 8 >= Piece[x, y] % 8)
                            {
                                return(true);
                            }
                            else if (Math.Abs(Sx - x) > 1 || Math.Abs(Sy - y) > 1)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }//判断是否同为水或陆
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }//下一步是敌方棋子
                else if ((Checkerboard[x, y] == 1 && Piece[Sx, Sy] / 8 == 0) || (Checkerboard[x, y] == 3 && Piece[Sx, Sy] / 8 == 1))
                {
                    return(false);
                }//不能进己方兽穴
                else
                {
                    return(true);
                }
            }
            else if (Piece[x, y] != -1 && Piece[Sx, Sy] / 8 == Piece[x, y] / 8)
            {
                sel.x = x;
                sel.y = y;
                return(false);
            }
            else
            {
                return(false);
            }
        }