private void UpdateBoard(Point source, Point destination) { var newValue = this.currentPlayer; int sweep = 0, startPoint = 0, endPoint = 0; var isXFixed = source.X == destination.X; var fixedValue = (source.X == destination.X) ? source.X : source.Y; AdjustLoopOperator loopOp; CheckLoopOperator checkOp; NextPieceOperator nextPieceOp; if (source.Y > destination.Y || source.X > destination.X) { loopOp = new AdjustLoopOperator(this.Decrement); checkOp = new CheckLoopOperator(this.IsGreaterThan); nextPieceOp = new NextPieceOperator(this.NextPieceBack); } else { loopOp = new AdjustLoopOperator(this.Increment); checkOp = new CheckLoopOperator(this.IsLessThan); nextPieceOp = new NextPieceOperator(this.NextPieceForward); } startPoint = isXFixed ? source.Y : source.X; endPoint = isXFixed ? destination.Y : destination.X; for (sweep = startPoint; checkOp(sweep, endPoint); loopOp(ref sweep)) { if (isXFixed == true) { this.SetPiece(fixedValue, sweep, this.GetPiece(fixedValue, nextPieceOp(sweep))); } else { this.SetPiece(sweep, fixedValue, this.GetPiece(nextPieceOp(sweep), fixedValue)); } } this.SetPiece(destination.X, destination.Y, newValue); }