CShock/CShocker/Ranges/RandomIntegerRange.cs

21 lines
777 B
C#
Raw Normal View History

2024-01-17 04:11:30 +01:00
namespace CShocker.Ranges;
public abstract class RandomIntegerRange
{
2024-01-17 20:56:35 +01:00
public Range _range { get; init; }
2024-01-17 04:11:30 +01:00
internal RandomIntegerRange(Range range, Range limits)
{
if (range.Max - range.Min < 0)
throw new ArgumentException("Min has to be less or equal Max");
if (range.Min < limits.Min || range.Min > limits.Max)
throw new ArgumentOutOfRangeException(nameof(limits.Min), "Min has to be withing Range 0-100");
if (range.Max < limits.Min || range.Max > limits.Max)
throw new ArgumentOutOfRangeException(nameof(range.Max), "Max has to be withing Range 0-100");
this._range = range;
}
2024-01-17 19:39:48 +01:00
public int GetRandomRangeValue()
2024-01-17 04:11:30 +01:00
{
return Random.Shared.Next(_range.Min, _range.Max);
}
}