change to prim Ctors

This commit is contained in:
CWX
2025-01-18 19:17:35 +00:00
parent 41d2bfa1d9
commit 5c5a42b535
25 changed files with 551 additions and 973 deletions
+15 -24
View File
@@ -10,28 +10,15 @@ using Core.Services;
namespace Core.Controllers;
[Injectable]
public class InsuranceController
public class InsuranceController(
ISptLogger<InsuranceController> _logger,
ProfileHelper _profileHelper,
InsuranceService _insuranceService,
ConfigServer _configServer
)
{
private readonly ISptLogger<InsuranceController> _logger;
private readonly ProfileHelper _profileHelper;
private readonly InsuranceService _insuranceService;
private readonly ConfigServer _configServer;
private readonly InsuranceConfig _insuranceConfig;
protected InsuranceConfig _insuranceConfig = _configServer.GetConfig<InsuranceConfig>();
public InsuranceController(
ISptLogger<InsuranceController> logger,
ProfileHelper profileHelper,
InsuranceService insuranceService,
ConfigServer configServer
)
{
_logger = logger;
_profileHelper = profileHelper;
_insuranceService = insuranceService;
_configServer = configServer;
_insuranceConfig = _configServer.GetConfig<InsuranceConfig>();
}
/**
* Handle client/insurance/items/list/cost
@@ -47,23 +34,27 @@ public class InsuranceController
var pmcData = _profileHelper.GetPmcProfile(sessionId);
var inventoryItemsHash = new Dictionary<string, Item>();
foreach (var item in pmcData.Inventory.Items) {
foreach (var item in pmcData.Inventory.Items)
{
inventoryItemsHash[item.Id] = item;
}
// Loop over each trader in request
foreach(var trader in request.Traders)
foreach (var trader in request.Traders)
{
var items = new Dictionary<string, double>();
foreach (var itemId in request.Items) {
foreach (var itemId in request.Items)
{
// Ensure hash has item in it
if (!inventoryItemsHash.ContainsKey(itemId))
{
_logger.Debug("Item with id: ${ itemId} missing from player inventory, skipping");
continue;
}
items[inventoryItemsHash[itemId].Template] = _insuranceService.GetRoublePriceToInsureItemWithTrader(pmcData, inventoryItemsHash[itemId], trader);
items[inventoryItemsHash[itemId].Template] =
_insuranceService.GetRoublePriceToInsureItemWithTrader(pmcData, inventoryItemsHash[itemId], trader);
}
response[trader] = items;