public bool IsValidDiagonalMove(Square from, Square to) { int x, y; if (from.Row <= to.Row) { x = 1; } else { x = -1; } if (from.Col <= to.Col) { y = 1; } else { y = -1; } for (Square current = Square.At(from.Row + x, from.Col + y); current != to; current = Square.At(current.Row + x, current.Col + y)) { if (!current.IsInBounds() || GetPiece(current) != null) { return(false); } } return(IsValidDestination(from, to)); }
public bool IsValidDestination(Square from, Square to) { if (!to.IsInBounds() || GetPiece(to) != null && GetPiece(to).Player == GetPiece(from).Player) { return(false); } return(true); }