.NET Format Style Fixes

This commit is contained in:
clodanSPT
2025-07-20 19:04:02 +00:00
committed by Format Bot
parent 9584d171f0
commit 2af0891c66
3 changed files with 34 additions and 8 deletions
@@ -175,7 +175,11 @@ public class RandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner)
/// If the generated number is less than 0, it will recursively attempt to generate a valid number up to 100 times.
/// If it fails to generate a valid number after 100 attempts, it will return a random float between 0.01 and twice the mean.
/// </remarks>
public virtual double GetNormallyDistributedRandomNumber(double mean, double sigma, int attempt = 0)
public virtual double GetNormallyDistributedRandomNumber(
double mean,
double sigma,
int attempt = 0
)
{
double u,
v;
@@ -233,7 +237,11 @@ public class RandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner)
/// and MaxSignificantDigits(15), inclusive. If not provided, precision is determined by the input values.
/// </param>
/// <returns></returns>
public virtual double RandNum(double val1, double val2 = 0, int precision = DecimalPointRandomPrecision)
public virtual double RandNum(
double val1,
double val2 = 0,
int precision = DecimalPointRandomPrecision
)
{
if (!double.IsFinite(val1) || !double.IsFinite(val2))
{
+5 -1
View File
@@ -28,7 +28,11 @@ public class DI
var diHandler = new DependencyInjectionHandler(services);
diHandler.AddInjectableTypesFromTypeAssembly(typeof(App));
diHandler.AddInjectableTypesFromTypeList([typeof(MockLogger<>)/* TODO: this needs to be enabled but the randomizer needs to NOT be random, typeof(MockRandomUtil)*/]);
diHandler.AddInjectableTypesFromTypeList(
[
typeof(MockLogger<>), /* TODO: this needs to be enabled but the randomizer needs to NOT be random, typeof(MockRandomUtil)*/
]
);
diHandler.InjectAll();
+19 -5
View File
@@ -6,7 +6,8 @@ using SPTarkov.Server.Core.Utils.Cloners;
namespace UnitTests.Mock;
[Injectable(TypeOverride = typeof(RandomUtil))]
public class MockRandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner) : RandomUtil(_logger, _cloner)
public class MockRandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner)
: RandomUtil(_logger, _cloner)
{
public override int GetInt(int min, int max = Int32.MaxValue, bool exclusive = false)
{
@@ -66,7 +67,11 @@ public class MockRandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner) : R
return GetCollectionValue(dictionary.Values);
}
public override double GetNormallyDistributedRandomNumber(double mean, double sigma, int attempt = 0)
public override double GetNormallyDistributedRandomNumber(
double mean,
double sigma,
int attempt = 0
)
{
// TODO: No idea what to do with this
return base.GetNormallyDistributedRandomNumber(mean, sigma, attempt);
@@ -82,12 +87,20 @@ public class MockRandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner) : R
return val1;
}
public override List<T> DrawRandomFromList<T>(List<T> originalList, int count = 1, bool replacement = true)
public override List<T> DrawRandomFromList<T>(
List<T> originalList,
int count = 1,
bool replacement = true
)
{
return originalList.Slice(0, count);
}
public override List<TKey> DrawRandomFromDict<TKey, TVal>(Dictionary<TKey, TVal> dict, int count = 1, bool replacement = true)
public override List<TKey> DrawRandomFromDict<TKey, TVal>(
Dictionary<TKey, TVal> dict,
int count = 1,
bool replacement = true
)
{
// TODO: derandomize
return base.DrawRandomFromDict(dict, count, replacement);
@@ -109,7 +122,8 @@ public class MockRandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner) : R
return base.GetNumberPrecision(num);
}
public override T? GetArrayValue<T>(IEnumerable<T> list) where T : default
public override T? GetArrayValue<T>(IEnumerable<T> list)
where T : default
{
return GetCollectionValue(list);
}