Randomize all the items in a collection is a function in the backend.
Before I go down the wrong rabbit hole - I’d like to understand the best practise approach to using this function.
I have two use cases I’d like to use this (or other to solve).
Determine a specific ‘value’ from a list of values. E.g.
Rank one, would have values 0 to 100.
Rank two would have values 101 to 200.
So first we determine is this user rank one, or two and then we determine what value they get from each range.
Theory - we query values 0 to 100, randomize and set value on array item [0].
We want to randomly award a prize.
First we want to determine if this action (API Call receive blockchain data) should win a ‘box’ that may contain a prize.
Ideally we can randomly pick a number from a range, and then have a condition that if that number == X then it’s a winner. If there are any better ideas here…
Second we want to determine if once opened, this box delivers a prize. There would be 6 items in the box, 2 would be no win, the other 4 would be ‘win’. So we want to randomize and return one value to confirm if / what the user has won.
Theory here - we could query the box prizes, and randomize and again just always pick entry [0]. But if there are better ways…
Thank you in advance for any help!
Last updated: