InfamousVague/LootBox

Buff system

Opened this issue · 0 comments

Hi,

First of all, thanks for this little, simple and very cool project :-)

I just encountered an issue with the buff system. Indeed, the rarity with a buff may exceed 1 which causes an error if you haven't set a box with a chance higher than the rarity + buff.
To correct that, I set the default buff to 1 instead of 0 and use this.buff with the box.chance instead of the rarity like below :
chooseBox () { const rarity = Math.random() const box = this.boxes.filter(box => (box.chance * this.buff) >= rarity) return box.reverse()[0] }
This way it allows me to increase probability by a percentage instead of a flat value.

👍