I'm struggling with coming up with an elegant solution to generating random events in the game that I'm working on.
Say there are 4 classes of events that can happen, with varying events in those classes that may occur.
So something along the lines of
main_events = {"common event", "not so common event", "somewhat rare event", "rare event"}
sub_events[0] = {"common event 1", "common event 2",..}
...
I have a somewhat kludgey solution in place that first just has a random number generated between 0 and 100, and if the number falls within a given range then a main event will be triggered. Then I'll do another random roll to see which sub event occurs.
Is there a better solution than something along these lines? Like I mention, it doesn't feel very elegant, and I'd like to make it easily expandable for the addition of future events.