private static IEnumerable <Location> MovesInOneDirection(Location from, Board board, Location dir, bool infinit) { CellContent fromCellContent = board.Get(from); for (int i = 1; i < (infinit ? 8 : 2); i++) { var to = new Location(from.X + dir.X * i, from.Y + dir.Y * i); if (!to.InBoard) { break; } CellContent toCellContent = board.Get(to); if (toCellContent.Piece == null) { yield return(to); } else { if (toCellContent.Color != fromCellContent.Color) { yield return(to); } yield break; } } }
public Move(Board board, Location from, Location to, CellContent oldDestinationCell) { this.board = board; this.from = from; this.to = to; this.oldDestinationCell = oldDestinationCell; }
public Move PerformMove(Location from, Location to) { CellContent old = Get(to); Set(to, Get(from)); Set(from, CellContent.Empty); return(new Move(this, from, to, old)); }
public void Set(Location location, CellContent cell) { cells[location.X, location.Y] = cell; }