示例#1
0
文件: GoLayout.cs 项目: macomfan/goGo
 public GoPoint GetPoint(GoCoord coord)
 {
     if (!coord.IsVaild(SIZE))
     {
         return(null);
     }
     return(layout_[coord.GetIndex(SIZE)]);
 }
示例#2
0
文件: GoLayout.cs 项目: macomfan/goGo
//         public bool SetDian(GoCoord coord, GoDianType type)
//         {
//
//             else if (dian.Type == type)
//             {
//                 // no change
//                 return true;
//             }
//             else if (type == GoDianType.EMPTY)
//             {
//                 // Remove Zi
//                 RemoveChess(dian);
//                 return true;
//             }
//             else if (dian.Type != GoDianType.EMPTY)
//             {
// //                 if (!allowChangeZi_)
// //                 {
// //                     //Error need refresh
// //                     GoException.Throw("Cannot change chess, should remove it firstly");
// //                 }
//                 RemoveChess(dian);
//             }
//             dian.Type = type;
//             dian.Block = new GoBlock(SIZE, dian);
// //             if (autoTake_)
// //             {
//                 if (dian.Qi == 0 && !CheckTiZi(dian))
//                 {
//                     RemoveChess(dian);
//                     return false;
//                 }
//                 else
//                 {
//                     CheckTiZi(dian);
//                 }
// /*            }*/
//
//             if (DianChanged != null)
//             {
//                 DianChanged();
//             }
//
//             return true;
//         }

        public bool SetupPoint(GoCoord coord, GoPointType type)
        {
            GoPoint point = GetPoint(coord);

            if (point != null && point.Type != type)
            {
                OnRemoveChess(point);
                OnAddChess(coord, type);
                OnChessChanged();
            }
            return(true);
        }
示例#3
0
文件: GoLayout.cs 项目: macomfan/goGo
        private GoPoint OnAddChess(GoCoord coord, GoPointType type)
        {
            GoPoint point = GetPoint(coord);

            if (point == null)
            {
                GoException.Throw("The Coord is out of bounds");
            }
            else if (point.Type == type)
            {
                // no change
                return(point);
            }
            if (point.Type != GoPointType.EMPTY)
            {
                GoException.Throw("Should remove the Chess first");
            }
            point.Type  = type;
            point.Block = new GoBlock(SIZE, point);
            return(point);
        }
示例#4
0
文件: GoPoint.cs 项目: macomfan/goGo
 public GoPoint(GoCoord coord, GoPointVisitor vistior)
 {
     coord_   = coord;
     vistior_ = vistior;
     type_    = GoPointType.EMPTY;
 }
示例#5
0
 public GoStep(GoCoord coord, GoPointType type)
 {
     coord_ = coord;
     type_  = type;
 }