Move generators to primary ctor

This commit is contained in:
CWX
2025-01-18 19:54:33 +00:00
parent 5c5a42b535
commit 7e7c1d1aaa
22 changed files with 816 additions and 1088 deletions
+10 -20
View File
@@ -11,25 +11,13 @@ using Core.Utils;
namespace Core.Generators;
[Injectable]
public class BotLevelGenerator
public class BotLevelGenerator(
ISptLogger<BotLevelGenerator> _logger,
RandomUtil _randomUtil,
MathUtil _mathUtil,
DatabaseService _databaseService
)
{
protected ISptLogger<BotLevelGenerator> _logger;
protected RandomUtil _randomUtil;
protected MathUtil _mathUtil;
protected DatabaseService _databaseService;
public BotLevelGenerator(
ISptLogger<BotLevelGenerator> logger,
RandomUtil randomUtil,
MathUtil mathUtil,
DatabaseService databaseService)
{
_logger = logger;
_randomUtil = randomUtil;
_mathUtil = mathUtil;
_databaseService = databaseService;
}
/// <summary>
/// Return a randomised bot level and exp value
/// </summary>
@@ -44,8 +32,10 @@ public class BotLevelGenerator
// Get random level based on the exp table.
int exp = 0;
var level = int.Parse(ChooseBotLevel(botLevelRange.Min.Value, botLevelRange.Max.Value, 1, 1.15)
.ToString()); // TODO - nasty double to string to int conversion
var level = int.Parse(
ChooseBotLevel(botLevelRange.Min.Value, botLevelRange.Max.Value, 1, 1.15)
.ToString()
); // TODO - nasty double to string to int conversion
for (var i = 0; i < level; i++)
{
exp += expTable[i].Experience.Value;