But it could be called up after all values of the item are decided, which means the whole item creation process being done before the re-roll triggers (which would be dumb, but who knows?)
Or it could be embedded in a for loop of other general decisions and outputs a value which designates it as ‘failed’ and hence to be re-done from scratch, with whatever else might be in there.
There’s a myriad of dumb situations that could be done and it functions nonetheless.
The code design itself for that tiny aspect though is objectively bad.
Factually wrong.
If it doesn’t remove the red-ring from the viable choices the theoretical upper limit is infinity.
You should know that. You shouldn’t get that wrong even in your sleep.
19 rings. Number 19 is the red ring. It lands on 19, now it creates a value between 1 and 100, it lands on anything but ‘1’ or ‘2’, it returns. It rolls ‘19’ again, it goes and rolls the value… as often as needed.
Infinite… times… theoretically.
So this is a scaling problem. The more rings you have which offer a re-roll chance and the higher this chance is the more loops it’ll do, which is a exponential usage of resources.
What?
That’s also nonsensical!
A weight table has a end-value, every item has a weight. You add all values for the items together. The value returned and in the range for that item causes it to drop, end of function.
It’s worst-case 2 vectors which have the minimum value and the maximum value inside. MinVector’s next entry is decided by the same position of MaxVector’s former value + 1, MacVector’s value is the weight-range. The follow-up function hence dynamically resolves that.
It’s basic stuff.
Mind-numbingly basic stuff. We’re not talking about a bubble-sorting method created from your memory… and heck… you should know a simple bubble-sorting method in your sleep as well, and that’s vastly below that level of expertise.
My provided example is scalable, yours is not as too many entries cause the loop-time to exponentially increase towards infinite, mine doesn’t.
The only limiter is value type size limit, and if you reach a long long value’s max size because of that then whoever designed the system needs to get fired anyway.