But a big problem with this approach is the *granularity*.
Just to pick the example you used, if we wanted "rare" to be 1%, and still assuming the same 3 weapons (4 occurrences), we would need 20 values in the rarity array.
And *still* combined.rare.sword would be 2% instead of 1%.
And so on.
I think I would opt for a much simpler yet more flexible system:
Code:
var weapons = {
"sword" : [ 70, 28, 2 ],
"bow" : [ 60, 30, 10 ],
"staff" : [ 80, 19, 1 ]
};
where the 3 numbers are the percentage chances that a given weapon will be common, uncommon, or rare.
Completely flexible: You can decide what "rare" means on a per-weapon basis *and* you can easily see the distribution *and* you can easily change it.
Changing the distribution with RndMe's dual array system might turn into a real challenge to get the numbers you actually want.