コード例 #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;
 }