mirror of
https://github.com/kwsch/pk3DS.git
synced 2026-03-22 01:44:33 -05:00
27 lines
655 B
C#
27 lines
655 B
C#
namespace pk3DS.Core.Randomizers;
|
|
|
|
/// <summary> Cyclical Shuffled Randomizer </summary>
|
|
/// <remarks>
|
|
/// The shuffled list is iterated over, and reshuffled when exhausted.
|
|
/// The list does not repeat values until the list is exhausted.
|
|
/// </remarks>
|
|
public class GenericRandomizer(int[] randomValues)
|
|
{
|
|
private int ctr;
|
|
|
|
public void Reset()
|
|
{
|
|
ctr = 0;
|
|
Util.Shuffle(randomValues);
|
|
}
|
|
|
|
public int Next()
|
|
{
|
|
if (ctr == 0)
|
|
Util.Shuffle(randomValues);
|
|
|
|
int value = randomValues[ctr++];
|
|
ctr %= randomValues.Length;
|
|
return value;
|
|
}
|
|
} |