Moved GetScavKarmaLevel to extension method
This commit is contained in:
@@ -12,7 +12,6 @@ using SPTarkov.Server.Core.Models.Utils;
|
||||
using SPTarkov.Server.Core.Servers;
|
||||
using SPTarkov.Server.Core.Services;
|
||||
using SPTarkov.Server.Core.Utils;
|
||||
using SPTarkov.Server.Core.Utils.Cloners;
|
||||
using SPTarkov.Server.Core.Utils.Json;
|
||||
using LogLevel = SPTarkov.Server.Core.Models.Spt.Logging.LogLevel;
|
||||
|
||||
@@ -26,22 +25,15 @@ public class GameController(
|
||||
DatabaseService _databaseService,
|
||||
TimeUtil _timeUtil,
|
||||
HttpServerHelper _httpServerHelper,
|
||||
InventoryHelper _inventoryHelper,
|
||||
RandomUtil _randomUtil,
|
||||
HideoutHelper _hideoutHelper,
|
||||
ProfileHelper _profileHelper,
|
||||
ProfileFixerService _profileFixerService,
|
||||
LocalisationService _localisationService,
|
||||
PostDbLoadService _postDbLoadService,
|
||||
CustomLocationWaveService _customLocationWaveService,
|
||||
OpenZoneService _openZoneService,
|
||||
SeasonalEventService _seasonalEventService,
|
||||
ItemBaseClassService _itemBaseClassService,
|
||||
GiftService _giftService,
|
||||
RaidTimeAdjustmentService _raidTimeAdjustmentService,
|
||||
ProfileActivityService _profileActivityService,
|
||||
CreateProfileService _createProfileService,
|
||||
ICloner _cloner
|
||||
ProfileActivityService _profileActivityService
|
||||
)
|
||||
{
|
||||
protected BotConfig _botConfig = _configServer.GetConfig<BotConfig>();
|
||||
@@ -49,7 +41,6 @@ public class GameController(
|
||||
protected double _deviation = 0.0001;
|
||||
protected HideoutConfig _hideoutConfig = _configServer.GetConfig<HideoutConfig>();
|
||||
protected HttpConfig _httpConfig = _configServer.GetConfig<HttpConfig>();
|
||||
protected RagfairConfig _ragfairConfig = _configServer.GetConfig<RagfairConfig>();
|
||||
|
||||
/// <summary>
|
||||
/// Handle client/game/start
|
||||
|
||||
@@ -73,5 +73,27 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
{
|
||||
return profile?.Skills?.Common?.FirstOrDefault(s => s.Id == skill);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the scav karma level for a profile
|
||||
/// Is also the fence trader rep level
|
||||
/// </summary>
|
||||
/// <param name="pmcData">pmc profile</param>
|
||||
/// <returns>karma level</returns>
|
||||
public static double GetScavKarmaLevel(this PmcData pmcData)
|
||||
{
|
||||
// can be empty during profile creation
|
||||
if (!pmcData.TradersInfo.TryGetValue(Traders.FENCE, out var fenceInfo))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fenceInfo.Standing > 6)
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
return Math.Floor(fenceInfo.Standing ?? 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ public class FenceBaseAssortGenerator(
|
||||
/// Get the penetration power value of an ammo, works with ammo boxes and raw ammos
|
||||
/// </summary>
|
||||
/// <param name="rootItemDb"> Ammo box or ammo item from items.db </param>
|
||||
/// <returns> Penetration power of passed in item, undefined if it doesnt have a power </returns>
|
||||
/// <returns> Penetration power of passed in item, undefined if it doesn't have a power </returns>
|
||||
protected double? GetAmmoPenetrationPower(TemplateItem rootItemDb)
|
||||
{
|
||||
if (itemHelper.IsOfBaseclass(rootItemDb.Id, BaseClasses.AMMO_BOX))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Globalization;
|
||||
using SPTarkov.DI.Annotations;
|
||||
using SPTarkov.Server.Core.Extensions;
|
||||
using SPTarkov.Server.Core.Helpers;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
@@ -51,7 +52,7 @@ public class PlayerScavGenerator(
|
||||
var pmcDataClone = _cloner.Clone(profileCharactersClone.PmcData);
|
||||
var existingScavDataClone = _cloner.Clone(profileCharactersClone.ScavData);
|
||||
|
||||
var scavKarmaLevel = GetScavKarmaLevel(pmcDataClone);
|
||||
var scavKarmaLevel = pmcDataClone.GetScavKarmaLevel();
|
||||
|
||||
// use karma level to get correct karmaSettings
|
||||
if (
|
||||
@@ -195,31 +196,6 @@ public class PlayerScavGenerator(
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the scav karama level for a profile
|
||||
/// Is also the fence trader rep level
|
||||
/// </summary>
|
||||
/// <param name="pmcData">pmc profile</param>
|
||||
/// <returns>karma level</returns>
|
||||
protected double GetScavKarmaLevel(PmcData pmcData)
|
||||
{
|
||||
// can be empty during profile creation
|
||||
if (!pmcData.TradersInfo.TryGetValue(Traders.FENCE, out var fenceInfo))
|
||||
{
|
||||
_logger.Warning(
|
||||
_localisationService.GetText("scav-missing_karma_level_getting_default")
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fenceInfo.Standing > 6)
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
return Math.Floor(fenceInfo.Standing ?? 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a baseBot template
|
||||
/// If the parameter doesnt match "assault", take parts from the loot type and apply to the return bot template
|
||||
|
||||
@@ -73,12 +73,7 @@ public class TraderStore(
|
||||
/// <returns></returns>
|
||||
public ITrader? GetTraderById(string traderId)
|
||||
{
|
||||
if (_traders.TryGetValue(traderId, out var trader))
|
||||
{
|
||||
return trader;
|
||||
}
|
||||
|
||||
return null;
|
||||
return _traders.GetValueOrDefault(traderId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user