Implementation
This commit is contained in:
9
CShocker/Ranges/DurationRange.cs
Normal file
9
CShocker/Ranges/DurationRange.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace CShocker.Ranges;
|
||||
|
||||
public class DurationRange : RandomIntegerRange
|
||||
{
|
||||
public DurationRange(Range range) : base(range, new Range(0, 30000))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
9
CShocker/Ranges/IntensityRange.cs
Normal file
9
CShocker/Ranges/IntensityRange.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace CShocker.Ranges;
|
||||
|
||||
public class IntensityRange : RandomIntegerRange
|
||||
{
|
||||
public IntensityRange(Range range) : base(range, new Range(0, 100))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
21
CShocker/Ranges/RandomIntegerRange.cs
Normal file
21
CShocker/Ranges/RandomIntegerRange.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace CShocker.Ranges;
|
||||
|
||||
public abstract class RandomIntegerRange
|
||||
{
|
||||
private readonly Range _range;
|
||||
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;
|
||||
}
|
||||
|
||||
internal int GetRandomRangeValue()
|
||||
{
|
||||
return Random.Shared.Next(_range.Min, _range.Max);
|
||||
}
|
||||
}
|
12
CShocker/Ranges/Range.cs
Normal file
12
CShocker/Ranges/Range.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace CShocker.Ranges;
|
||||
|
||||
public struct Range
|
||||
{
|
||||
public short Min, Max;
|
||||
|
||||
public Range(short min, short max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user