Reason for existance.
I needed a simple way to generate lists that I can roll a dice against, and get a result. Typical example is a table top rpg, loot table.
Example of Usage:
const RangedList = ;const RangedListEntry = ;let rangedList = ;//Add Entry, object / relevancerangedList;rangedList;rangedList;rangedList;rangedList;//You can set the range any time during your script,rangedListRandomRelevance;rangedListRandomRelevance;});
Example of generated list printed to log:
1 - 6: {"name":"glove of strength","strength":2}
7 - 38: {"name":"rusty dagger","atk":-2}
39 - 57: {"name":"healing potion","life":2}
58 - 59: {"name":"unicorn feather","tempSkill":"Flight"}
60 - 97: {"name":"bag of gold","money":15}
98 - 100: "Re-Roll"
The call will log a warn if the range is smaller then the number of entries, or if your relevance for one object is extremly high Example:
obj1 = relevance 1000 obj2 = relevance 1 obj3 = relevace 1
1 - 99: obj1,
99-100: obj2
100-101: obj3
This is due to the fact that we floor values, but allow no value below zero.