This commit is contained in:
Chomp
2025-01-16 20:37:06 +00:00
12 changed files with 179 additions and 61 deletions
+6 -6
View File
@@ -34,20 +34,20 @@ public class ClientLogController
switch (logRequest.Level)
{
case LogLevel.ERROR:
case LogLevel.Error:
this._logger.Error(message);
break;
case LogLevel.WARN:
case LogLevel.Warn:
this._logger.Warning(message);
break;
case LogLevel.SUCCESS:
case LogLevel.INFO:
case LogLevel.Success:
case LogLevel.Info:
this._logger.Info(message);
break;
case LogLevel.CUSTOM:
case LogLevel.Custom:
this._logger.Info(message /* TODO: , color.ToString(), backgroundColor.ToString()*/);
break;
case LogLevel.DEBUG:
case LogLevel.Debug:
this._logger.Debug(message);
break;
default:
+3
View File
@@ -94,6 +94,7 @@ public class DialogueController
var activeBots = new List<UserDialogInfo>();
var chatBotConfig = _coreConfig.Features.ChatbotFeatures;
/*
foreach (var bot in _dialogueChatBots)
{
var botData = bot.GetChatBot();
@@ -101,6 +102,8 @@ public class DialogueController
activeBots.Add(botData);
}
}
TODO: FUCK THESE BOTS STOPPING US GETTING TO THE FUCKING MENU
*/
return activeBots;
}
+1 -1
View File
@@ -55,7 +55,7 @@ public class HttpServerHelper
/** Get websocket url + port */
public string GetWebsocketUrl()
{
return $"ws://${BuildUrl()}";
return $"ws://{BuildUrl()}";
}
public void SendTextJson(HttpResponse resp, object output)
+4 -4
View File
@@ -222,7 +222,7 @@ public class ItemHelper
/// </summary>
/// <param name="tpl">Item to look price up of</param>
/// <returns>Price in roubles</returns>
public decimal GetItemPrice(string tpl)
public double GetItemPrice(string tpl)
{
throw new NotImplementedException();
}
@@ -233,7 +233,7 @@ public class ItemHelper
/// </summary>
/// <param name="tpl">Item to look price up of</param>
/// <returns>Price in roubles</returns>
public decimal GetItemMaxPrice(string tpl)
public double GetItemMaxPrice(string tpl)
{
throw new NotImplementedException();
}
@@ -243,7 +243,7 @@ public class ItemHelper
/// </summary>
/// <param name="tpl">Items tpl id to look up price</param>
/// <returns>Price in roubles (0 if not found)</returns>
public decimal GetStaticItemPrice(string tpl)
public double GetStaticItemPrice(string tpl)
{
throw new NotImplementedException();
}
@@ -253,7 +253,7 @@ public class ItemHelper
/// </summary>
/// <param name="tpl">Items tpl id to look up price</param>
/// <returns>Price in roubles (undefined if not found)</returns>
public decimal GetDynamicItemPrice(string tpl)
public double GetDynamicItemPrice(string tpl)
{
throw new NotImplementedException();
}
+5 -6
View File
@@ -4,20 +4,19 @@ using Core.Models.Eft.Ws;
namespace Core.Helpers;
[Injectable]
[Injectable(InjectionType.Singleton)]
public class NotifierHelper
{
private readonly HttpServerHelper _httpServerHelper;
protected WsPing ping = new WsPing();
public NotifierHelper(
HttpServerHelper httpServerHelper)
{
_httpServerHelper = httpServerHelper;
}
public WsNotificationEvent GetDefaultNotification()
{
throw new NotImplementedException();
}
public WsNotificationEvent GetDefaultNotification() => ping;
/**
* Create a new notification that displays the "Your offer was sold!" prompt and removes sold offer from "My Offers" on clientside
@@ -55,6 +54,6 @@ public class NotifierHelper
public string GetWebSocketServer(string sessionID)
{
return $"{ _httpServerHelper.GetWebsocketUrl()}/ notifierServer / getwebsocket /{sessionID}";
return $"{_httpServerHelper.GetWebsocketUrl()}/notifierServer/getwebsocket/{sessionID}";
}
}
+2 -1
View File
@@ -210,7 +210,8 @@ public class QuestHelper
*/
public bool ShowEventQuestToPlayer(string questId)
{
throw new NotImplementedException();
_logger.Error($"NOT IMPLEMENTED");
return false;
}
/**
+1 -9
View File
@@ -135,6 +135,7 @@ public class EquipmentBuild : UserBuild
public List<Item>? Items { get; set; } // Same as PMC inventory items
[JsonPropertyName("BuildType")]
[JsonConverter(typeof(JsonStringEnumConverter))]
public EquipmentBuildType? BuildType { get; set; }
}
@@ -165,15 +166,6 @@ public class MagazineTemplateAmmoItem
/** Used by defaultEquipmentPresets.json */
public class DefaultEquipmentPreset : EquipmentBuild
{
[JsonPropertyName("Items")]
public List<Item>? Items { get; set; }
[JsonPropertyName("Root")]
public string? Root { get; set; }
[JsonPropertyName("BuildType")]
public string? BuildType { get; set; }
[JsonPropertyName("type")]
public string? Type { get; set; }
}
+4 -3
View File
@@ -2,6 +2,7 @@
public enum EquipmentBuildType
{
CUSTOM = 0,
STANDARD = 1
}
Custom,
Standard,
Storage
}
+3 -2
View File
@@ -10,14 +10,15 @@ public class ClientLogRequest : IRequestData
public string? Source { get; set; }
[JsonPropertyName("Level")]
[JsonConverter(typeof(JsonStringEnumConverter))] // TODO: Fix in modules to send enumValue instead of string
public LogLevel? Level { get; set; }
[JsonPropertyName("Message")]
public string? Message { get; set; }
[JsonPropertyName("Color")]
public LogTextColor? Color { get; set; }
public string? Color { get; set; } // TODO: FIX THIS SHIT FOR COLOURS
[JsonPropertyName("BackgroundColor")]
public LogBackgroundColor? BackgroundColor { get; set; }
public string? BackgroundColor { get; set; }
}
+7 -7
View File
@@ -2,12 +2,12 @@
public enum LogLevel
{
ERROR = 0,
WARN = 1,
SUCCESS = 2,
INFO = 3,
CUSTOM = 4,
DEBUG = 5
Error,
Warn,
Success,
Info,
Custom,
Debug
}
// TODO: needs to be moved to enums namespace
// TODO: needs to be moved to enums namespace
+2 -2
View File
@@ -19,7 +19,7 @@ public class QuestStaticRouter : StaticRouter
jsonUtil,
[
new RouteAction(
"",
"/client/quest/list",
(
url,
info,
@@ -28,7 +28,7 @@ public class QuestStaticRouter : StaticRouter
) => _questCallbacks.ListQuests(url, info as ListQuestsRequestData, sessionID),
typeof(ListQuestsRequestData)),
new RouteAction(
"",
"/client/repeatalbeQuests/activityPeriods",
(
url,
info,
+141 -20
View File
@@ -17,6 +17,7 @@ public class BotLootCacheService
protected ISptLogger<BotLootCacheService> _logger;
protected ItemHelper _itemHelper;
protected PMCLootGenerator _pmcLootGenerator;
protected LocalisationService _localisationService;
protected RagfairPriceService _ragfairPriceService;
protected ICloner _cloner;
@@ -26,13 +27,15 @@ public class BotLootCacheService
ISptLogger<BotLootCacheService> logger,
ItemHelper itemHelper,
PMCLootGenerator pmcLootGenerator,
LocalisationService localisationService,
RagfairPriceService ragfairPriceService,
ICloner cloner
)
)
{
_logger = logger;
_itemHelper = itemHelper;
_pmcLootGenerator = pmcLootGenerator;
_localisationService = localisationService;
_ragfairPriceService = ragfairPriceService;
_cloner = cloner;
}
@@ -60,7 +63,98 @@ public class BotLootCacheService
BotType botJsonTemplate,
MinMax? itemPriceMinMax = null)
{
throw new NotImplementedException();
if (!BotRoleExistsInCache(botRole))
{
InitCacheForBotRole(botRole);
AddLootToCache(botRole, isPmc, botJsonTemplate);
}
Dictionary<string, double> result = null;
switch (lootType)
{
case LootCacheType.Special:
result = _lootCache[botRole].SpecialItems;
break;
case LootCacheType.Backpack:
result = _lootCache[botRole].BackpackLoot;
break;
case LootCacheType.Pocket:
result = _lootCache[botRole].PocketLoot;
break;
case LootCacheType.Vest:
result = _lootCache[botRole].VestLoot;
break;
case LootCacheType.Secure:
result = _lootCache[botRole].SecureLoot;
break;
case LootCacheType.Combined:
result = _lootCache[botRole].CombinedPoolLoot;
break;
case LootCacheType.HealingItems:
result = _lootCache[botRole].HealingItems;
break;
case LootCacheType.GrenadeItems:
result = _lootCache[botRole].GrenadeItems;
break;
case LootCacheType.DrugItems:
result = _lootCache[botRole].DrugItems;
break;
case LootCacheType.FoodItems:
result = _lootCache[botRole].FoodItems;
break;
case LootCacheType.DrinkItems:
result = _lootCache[botRole].DrinkItems;
break;
case LootCacheType.CurrencyItems:
result = _lootCache[botRole].CurrencyItems;
break;
case LootCacheType.StimItems:
result = _lootCache[botRole].StimItems;
break;
default:
_logger.Error(
_localisationService.GetText(
"bot-loot_type_not_found",
new
{
lootType = lootType,
botRole = botRole,
isPmc = isPmc
}
)
);
break;
}
if (itemPriceMinMax is not null)
{
var filteredResult = result.Where(
i =>
{
var itemPrice = _itemHelper.GetItemPrice(i.Key);
if (itemPriceMinMax?.Min is not null && itemPriceMinMax?.Max is not null)
{
return itemPrice >= itemPriceMinMax?.Min && itemPrice <= itemPriceMinMax?.Max;
}
if (itemPriceMinMax?.Min is not null && itemPriceMinMax?.Max is null)
{
return itemPrice >= itemPriceMinMax?.Min;
}
if (itemPriceMinMax?.Min is null && itemPriceMinMax?.Max is not null)
{
return itemPrice <= itemPriceMinMax?.Max;
}
return false;
}
);
return _cloner.Clone(filteredResult.ToDictionary(pair => pair.Key, pair => pair.Value));
}
return _cloner.Clone(result);
}
/// <summary>
@@ -76,7 +170,7 @@ public class BotLootCacheService
// Flatten all individual slot loot pools into one big pool, while filtering out potentially missing templates
Dictionary<string, double> specialLootPool = new();
Dictionary<string, double> backpackLootPool= new();
Dictionary<string, double> backpackLootPool = new();
Dictionary<string, double> pocketLootPool = new();
Dictionary<string, double> vestLootPool = new();
Dictionary<string, double> secureLootTPool = new();
@@ -100,7 +194,7 @@ public class BotLootCacheService
{ "SpecialLoot", lootPool.SpecialLoot },
{ "TacticalVest", lootPool.TacticalVest }
};
foreach (var kvp in poolsToProcess)
{
@@ -150,7 +244,8 @@ public class BotLootCacheService
if (!specialLootItems.Any())
{
// key = tpl, value = weight
foreach (var itemKvP in specialLootPool) {
foreach (var itemKvP in specialLootPool)
{
var itemTemplate = _itemHelper.GetItem(itemKvP.Key).Value;
if (!(IsBulletOrGrenade(itemTemplate.Properties) || IsMagazine(itemTemplate.Properties)))
{
@@ -169,7 +264,8 @@ public class BotLootCacheService
if (!healingItems.Any())
{
// key = tpl, value = weight
foreach (var itemKvP in combinedLootPool) {
foreach (var itemKvP in combinedLootPool)
{
var itemTemplate = _itemHelper.GetItem(itemKvP.Key).Value;
if (
IsMedicalItem(itemTemplate.Properties) &&
@@ -187,7 +283,8 @@ public class BotLootCacheService
// no drugs whitelist, find and assign from combined item pool
if (!drugItems.Any())
{
foreach (var itemKvP in (combinedLootPool)) {
foreach (var itemKvP in (combinedLootPool))
{
var itemTemplate = _itemHelper.GetItem(itemKvP.Key).Value;
if (IsMedicalItem(itemTemplate.Properties) && itemTemplate.Parent == BaseClasses.DRUGS)
{
@@ -201,7 +298,8 @@ public class BotLootCacheService
// No food whitelist, find and assign from combined item pool
if (!foodItems.Any())
{
foreach (var itemKvP in (combinedLootPool)) {
foreach (var itemKvP in (combinedLootPool))
{
var itemTemplate = _itemHelper.GetItem(itemKvP.Key).Value;
if (_itemHelper.IsOfBaseclass(itemTemplate.Id, BaseClasses.FOOD))
{
@@ -215,7 +313,8 @@ public class BotLootCacheService
// No drink whitelist, find and assign from combined item pool
if (!drinkItems.Any())
{
foreach (var itemKvP in combinedLootPool) {
foreach (var itemKvP in combinedLootPool)
{
var itemTemplate = _itemHelper.GetItem(itemKvP.Key).Value;
if (_itemHelper.IsOfBaseclass(itemTemplate.Id, BaseClasses.DRINK))
{
@@ -229,7 +328,8 @@ public class BotLootCacheService
// No currency whitelist, find and assign from combined item pool
if (!currencyItems.Any())
{
foreach (var itemKvP in combinedLootPool) {
foreach (var itemKvP in combinedLootPool)
{
var itemTemplate = _itemHelper.GetItem(itemKvP.Key).Value;
if (_itemHelper.IsOfBaseclass(itemTemplate.Id, BaseClasses.MONEY))
{
@@ -243,7 +343,8 @@ public class BotLootCacheService
// No whitelist, find and assign from combined item pool
if (!stimItems.Any())
{
foreach (var itemKvP in combinedLootPool) {
foreach (var itemKvP in combinedLootPool)
{
var itemTemplate = _itemHelper.GetItem(itemKvP.Key).Value;
if (IsMedicalItem(itemTemplate.Properties) && itemTemplate.Parent == BaseClasses.STIMULATOR)
{
@@ -257,7 +358,8 @@ public class BotLootCacheService
// no whitelist, find and assign from combined item pool
if (!grenadeItems.Any())
{
foreach (var itemKvP in combinedLootPool) {
foreach (var itemKvP in combinedLootPool)
{
var itemTemplate = _itemHelper.GetItem(itemKvP.Key).Value;
if (IsGrenade(itemTemplate.Properties))
{
@@ -268,12 +370,14 @@ public class BotLootCacheService
// Get backpack loot (excluding magazines, bullets, grenades, drink, food and healing/stim items)
var filteredBackpackItems = new Dictionary<string, double>();
foreach (var itemKvP in backpackLootPool) {
foreach (var itemKvP in backpackLootPool)
{
var itemResult = _itemHelper.GetItem(itemKvP.Key);
if (itemResult.Value is null)
{
continue;
}
var itemTemplate = itemResult.Value;
if (
IsBulletOrGrenade(itemTemplate.Properties) ||
@@ -294,12 +398,14 @@ public class BotLootCacheService
// Get pocket loot (excluding magazines, bullets, grenades, drink, food medical and healing/stim items)
var filteredPocketItems = new Dictionary<string, double>();
foreach (var itemKvP in pocketLootPool) {
foreach (var itemKvP in pocketLootPool)
{
var itemResult = _itemHelper.GetItem(itemKvP.Key);
if (itemResult.Value is null)
{
continue;
}
var itemTemplate = itemResult.Value;
if (
IsBulletOrGrenade(itemTemplate.Properties) ||
@@ -308,10 +414,11 @@ public class BotLootCacheService
IsGrenade(itemTemplate.Properties) ||
IsFood(itemTemplate.Id) ||
IsDrink(itemTemplate.Id) ||
IsCurrency(itemTemplate.Id) ||
IsCurrency(itemTemplate.Id) ||
itemTemplate.Properties.Height is null || // lacks height
itemTemplate.Properties.Width is null // lacks width
) {
)
{
continue;
}
@@ -320,7 +427,8 @@ public class BotLootCacheService
// Get vest loot (excluding magazines, bullets, grenades, medical and healing/stim items)
var filteredVestItems = new Dictionary<string, double>();
foreach (var itemKvP in vestLootPool) {
foreach (var itemKvP in vestLootPool)
{
var itemResult = _itemHelper.GetItem(itemKvP.Key);
if (itemResult.Value is null)
{
@@ -368,12 +476,25 @@ public class BotLootCacheService
/// <param name="itemsToAdd">items to add to combined pool if unique</param>
protected void AddUniqueItemsToPool(List<TemplateItem> poolToAddTo, List<TemplateItem> itemsToAdd)
{
throw new NotImplementedException();
if (poolToAddTo.Count() == 0) {
poolToAddTo.AddRange(itemsToAdd);
return;
}
poolToAddTo.Concat(itemsToAdd);
poolToAddTo = poolToAddTo.Distinct().ToList();
}
protected void AddItemsToPool(Dictionary<string, double> poolToAddTo, Dictionary<string, double> poolOfItemsToAdd)
{
throw new NotImplementedException();
foreach (var tpl in poolOfItemsToAdd) {
// Skip adding items that already exist
if (poolToAddTo.ContainsKey(tpl.Key)) {
continue;
}
poolToAddTo[tpl.Key] = poolOfItemsToAdd[tpl.Key];
}
}
/// <summary>
@@ -383,7 +504,7 @@ public class BotLootCacheService
/// <returns></returns>
protected bool IsBulletOrGrenade(Props props)
{
throw new NotImplementedException();
return props.AmmoType is not null;
}
/// <summary>