2024-02-04 17:47:36 +01:00
|
|
|
|
namespace CShocker.Ranges;
|
|
|
|
|
|
|
|
|
|
public readonly struct IntegerRange
|
|
|
|
|
{
|
2024-02-12 02:01:31 +01:00
|
|
|
|
// ReSharper disable twice MemberCanBePrivate.Global -> Exposed
|
2024-02-04 17:47:36 +01:00
|
|
|
|
public readonly int Min, Max;
|
|
|
|
|
|
|
|
|
|
public IntegerRange(int min, int max)
|
|
|
|
|
{
|
|
|
|
|
this.Min = min;
|
|
|
|
|
this.Max = max;
|
|
|
|
|
}
|
2024-02-11 22:24:53 +01:00
|
|
|
|
|
2024-02-12 02:02:30 +01:00
|
|
|
|
public bool IsValueWithinLimits(int value)
|
2024-02-11 22:24:53 +01:00
|
|
|
|
{
|
|
|
|
|
return value >= this.Min && value <= this.Max;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 02:04:58 +01:00
|
|
|
|
public int RandomValueWithinLimits()
|
|
|
|
|
{
|
|
|
|
|
return Random.Shared.Next(this.Min, this.Max);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-11 22:24:53 +01:00
|
|
|
|
internal string RangeString()
|
|
|
|
|
{
|
|
|
|
|
return $"{this.Min}-{this.Max}";
|
|
|
|
|
}
|
2024-02-04 17:47:36 +01:00
|
|
|
|
}
|