mardi 19 juillet 2022

Obtaining items based on chance percentage

I am working on a Laravel project. I will explain the problem and I would be grateful if you help me. I want to add a feature to the project. First I want to explain the entities of the project:

User,Car,CarClass, Box.

each Car has a CarClass. User can buy a Box and open it.

When the user opens the box he bought, he can win a car from a certain CarClass by chance. for example:

Red box: street 45%, sport 30%, muscle 30%, hyper 0%

Yellow box: street 20%, sport 50%, muscle 10%, hyper 20%

User who buys the Red box has a 45% chance to win a car with street class car, 30% chance to win a car with sport class and so on... .

And we have different boxes with different percentages.

Should there be one method for unboxing? Should a special design pattern be used?

Whether it is a complete answer or a clue that can help me, I would be grateful.

Aucun commentaire:

Enregistrer un commentaire