Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo n.º 2
0
		public Move(Board board, Location from, Location to, CellContent oldDestinationCell)
		{
			this.board = board;
			this.from = from;
			this.to = to;
			this.oldDestinationCell = oldDestinationCell;
		}
Exemplo n.º 3
0
 public Move(Board board, Location from, Location to, CellContent oldDestinationCell)
 {
     this.board = board;
     this.from  = from;
     this.to    = to;
     this.oldDestinationCell = oldDestinationCell;
 }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
		public void Set(Location location, CellContent cell)
		{
			cells[location.X, location.Y] = cell;
		}
Exemplo n.º 6
0
 public void Set(Location location, CellContent cell)
 {
     cells[location.X, location.Y] = cell;
 }