How are Rules applied to shopping card and other modules?

I want to know how whether it is possible to create a rule that users will get a discount based on number of items in cart * the quantity of each item.