Too much coding.
What CG can is, is follow what some Japanese games are doing:
Each pack starts with a box of character pulls i.e. 20 4*, 50 3*, 100 2*, 500 1*.
You keep drawing from the box until all the characters are pulled. This means that you can get lucky and pull 11 4* right from the start (I am sure that is not possible even for Japanese games), or keep pulling until the box is empty to get all your 4*.
This way, the developers right from the start have an X amount they want to earn from characters, and focus on developing gameplay content, or more characters for the new box of pulls.
This is probably the most ethical way of doing gachas (as they are called in Japanese games). It is not an industry standard outside of Japan, but the most fair to all sides.