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); }
// 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); }
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); }
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); }
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); }
public GoPoint(GoCoord coord, GoPointVisitor vistior) { coord_ = coord; vistior_ = vistior; type_ = GoPointType.EMPTY; }
public void GoStep(GoLayout layout, int row, int col, GoPointType type) { layout.PushStep(new GoStep(new GoCoord(row, col), type)); }
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)); }
public void SetDian(GoLayout layout, int row, int col, GoPointType type) { layout.SetupPoint(new GoCoord(row, col), type); }
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)); }
public Pieces(int row, int col, GoPointType type) { coord_ = new GoCoord(row, col); type_ = type; }
public GoStep(GoCoord coord, GoPointType type) { coord_ = coord; type_ = type; }