using System; namespace Artemis.Core { /// /// Represents a range between two signed integers /// public class IntRange { private readonly Random _rand; /// /// Creates a new instance of the class /// /// The start value of the range /// The end value of the range public IntRange(int start, int end) { Start = start; End = end; _rand = new Random(); } /// /// Gets or sets the start value of the range /// public int Start { get; set; } /// /// Gets or sets the end value of the range /// public int End { get; set; } /// /// Determines whether the given value is in this range /// /// The value to check /// /// Whether the value may be equal to or /// Defaults to /// /// public bool IsInRange(int value, bool inclusive = true) { if (inclusive) return value >= Start && value <= End; return value > Start && value < End; } /// /// Returns a pseudo-random value between and /// /// Whether the value may be equal to /// The pseudo-random value public int GetRandomValue(bool inclusive = true) { if (inclusive) return _rand.Next(Start, End + 1); return _rand.Next(Start + 1, End); } } }