mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Open RNG for plugins
This commit is contained in:
@@ -196,6 +196,43 @@ namespace ArchiSteamFarm {
|
||||
return (text.Length % 2 == 0) && text.All(Uri.IsHexDigit);
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static int RandomNext() {
|
||||
lock (Random) {
|
||||
return Random.Next();
|
||||
}
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static int RandomNext(int maxValue) {
|
||||
if (maxValue < 0) {
|
||||
throw new ArgumentOutOfRangeException(nameof(maxValue));
|
||||
}
|
||||
|
||||
if (maxValue <= 1) {
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
lock (Random) {
|
||||
return Random.Next(maxValue);
|
||||
}
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static int RandomNext(int minValue, int maxValue) {
|
||||
if (minValue > maxValue) {
|
||||
throw new ArgumentOutOfRangeException(nameof(minValue) + " && " + nameof(maxValue));
|
||||
}
|
||||
|
||||
if (minValue >= maxValue - 1) {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
lock (Random) {
|
||||
return Random.Next(minValue, maxValue);
|
||||
}
|
||||
}
|
||||
|
||||
[ItemNotNull]
|
||||
[NotNull]
|
||||
[PublicAPI]
|
||||
@@ -268,12 +305,6 @@ namespace ArchiSteamFarm {
|
||||
return cookies.Count > 0 ? (from Cookie cookie in cookies where cookie.Name.Equals(name) select cookie.Value).FirstOrDefault() : null;
|
||||
}
|
||||
|
||||
internal static int RandomNext() {
|
||||
lock (Random) {
|
||||
return Random.Next();
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool RelativeDirectoryStartsWith(string directory, params string[] prefixes) {
|
||||
if (string.IsNullOrEmpty(directory) || (prefixes == null) || (prefixes.Length == 0)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(directory) + " || " + nameof(prefixes));
|
||||
|
||||
Reference in New Issue
Block a user