Pawtang / roguelike

8 stars 2 forks source link

Enhanced probability function for events #41

Closed mcn8 closed 5 years ago

mcn8 commented 5 years ago

https://github.com/Pawtang/roguelike/blob/39b77561dae4467db0abcf91627533ced7f19f59/js/events.js#L1-L6

I would recommend switching to weighted probabilities here. It'll make it either to balance so you don't have to repeatedly paste in event types just to get the probability you want. Instead, you could adjust a number.

This looks like a good library option (and there's a lot of ways you could use this for other things): https://chancejs.com/miscellaneous/weighted.html

Otherwise, you could use a hashtable: const events = { "battle": 0.5, "treasureRoom": 0.25, "eventlessRoom": 0.25}; or a 2D array.

rtsai0104 commented 5 years ago

We have implemented something like your suggestion in #43 .