示例#1
0
        private void CheckDian(GoLayout layout, int row, int col, GoPointType type)
        {
            GoPoint dian = layout.GetPoint(row, col);

            if (dian == null)
            {
                throw new Exception("Dian get error");
            }
            Assert.AreEqual(dian.Type, type);
        }
示例#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
        public GoBlock(int size, GoPoint dian)
        {
            size_ = size;
            type_ = dian.Type;
            ID    = ++mainid;
            if (dian.Block != null)
            {
                GoException.Throw("Attempt add a Dian to double Block");
            }
            int index = dian.Coord.GetIndex(size_);

            dianMap_.Add(index, dian);
            dian.Block = this;
            CleanQi();
            DetectNeighborBlock(dian, dian.UP);
            DetectNeighborBlock(dian, dian.DOWN);
            DetectNeighborBlock(dian, dian.LEFT);
            DetectNeighborBlock(dian, dian.RIGHT);
        }
示例#4
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);
        }
示例#5
0
文件: GoLayout.cs 项目: macomfan/goGo
        public bool PopStep()
        {
            GoStep  step  = steps_.Pop();
            GoPoint point = GetPoint(step.Coord);

            OnRemoveChess(point);
            if (step.Removed.Count != 0)
            {
                GoPointType removedType = GoPointType.EMPTY;
                if (step.Type == GoPointType.BLACK)
                {
                    removedType = GoPointType.WHITE;
                }
                else if (step.Type == GoPointType.WHITE)
                {
                    removedType = GoPointType.BLACK;
                }
                foreach (GoCoord item in step.Removed)
                {
                    SetupPoint(item, removedType);
                }
            }
            return(false);
        }
示例#6
0
文件: GoPoint.cs 项目: macomfan/goGo
 public GoPoint(GoCoord coord, GoPointVisitor vistior)
 {
     coord_   = coord;
     vistior_ = vistior;
     type_    = GoPointType.EMPTY;
 }
示例#7
0
 public void GoStep(GoLayout layout, int row, int col, GoPointType type)
 {
     layout.PushStep(new GoStep(new GoCoord(row, col), type));
 }
示例#8
0
 public void SetDianAndCheckQi(GoLayout layout, int row, int col, GoPointType type, int qi)
 {
     layout.SetupPoint(new GoCoord(row, col), type);
     Assert.AreEqual(qi, layout.GetQi(row, col));
 }
示例#9
0
 public void SetDian(GoLayout layout, int row, int col, GoPointType type)
 {
     layout.SetupPoint(new GoCoord(row, col), type);
 }
示例#10
0
 public void GoStepAndCheckQi(GoLayout layout, int row, int col, GoPointType type, int qi)
 {
     layout.PushStep(new GoStep(new GoCoord(row, col), type));
     Assert.AreEqual(qi, layout.GetQi(row, col));
 }
示例#11
0
 public Pieces(int row, int col, GoPointType type)
 {
     coord_ = new GoCoord(row, col);
     type_  = type;
 }
示例#12
0
 public GoStep(GoCoord coord, GoPointType type)
 {
     coord_ = coord;
     type_  = type;
 }