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