Add tutorial and QoL improvements
This commit is contained in:
@@ -22,10 +22,22 @@ namespace KernelPanic.Combat
|
||||
public static class RandomRoll
|
||||
{
|
||||
private static Random _random = new(0);
|
||||
public static int CurrentSeed { get; private set; }
|
||||
public static int DrawCount { get; private set; }
|
||||
|
||||
public static void Seed(int seed)
|
||||
{
|
||||
_random = new Random(seed);
|
||||
CurrentSeed = seed;
|
||||
DrawCount = 0;
|
||||
}
|
||||
|
||||
public static void Restore(int seed, int draws)
|
||||
{
|
||||
if (draws < 0 || draws > 10000000) throw new ArgumentOutOfRangeException(nameof(draws));
|
||||
Seed(seed);
|
||||
for (int i = 0; i < draws; i++) _random.Next();
|
||||
DrawCount = draws;
|
||||
}
|
||||
|
||||
public static int RollRange(int min, int max, RollContext context)
|
||||
@@ -41,7 +53,9 @@ namespace KernelPanic.Combat
|
||||
return max;
|
||||
}
|
||||
|
||||
return _random.Next(min, max + 1);
|
||||
int value = _random.Next(min, max + 1);
|
||||
DrawCount += (long)max + 1 - min > int.MaxValue ? 2 : 1;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user