diff --git a/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs index 2e57720e..a74523a3 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs @@ -15,12 +15,12 @@ public class NotifierHelper(HttpServerHelper httpServerHelper) return ping; } - /** - * Create a new notification that displays the "Your offer was sold!" prompt and removes sold offer from "My Offers" on clientside - * @param dialogueMessage Message from dialog that was sent - * @param ragfairData Ragfair data to attach to notification - * @returns - */ + /// + /// Create a new notification that displays the "Your offer was sold!" prompt and removes sold offer from "My Offers" on clientside + /// + /// Message from dialog that was sent + /// Ragfair data to attach to notification + /// public WsRagfairOfferSold CreateRagfairOfferSoldNotification( Message dialogueMessage, MessageContentRagfair ragfairData @@ -36,11 +36,11 @@ public class NotifierHelper(HttpServerHelper httpServerHelper) }; } - /** - * Create a new notification with the specified dialogueMessage object - * @param dialogueMessage - * @returns - */ + /// + /// Create a new notification with the specified dialogueMessage object + /// + /// + /// WsChatMessageReceived public WsChatMessageReceived CreateNewMessageNotification(Message dialogueMessage) { return new WsChatMessageReceived @@ -52,6 +52,12 @@ public class NotifierHelper(HttpServerHelper httpServerHelper) }; } + /// + /// Create a new rating ragfair notification + /// + /// new rating + /// Rating is going up + /// WsRagfairNewRating public WsRagfairNewRating CreateRagfairNewRatingNotification(double rating, bool isGrowing) { return new WsRagfairNewRating @@ -63,6 +69,11 @@ public class NotifierHelper(HttpServerHelper httpServerHelper) }; } + /// + /// Get the web socket server URI + /// + /// Player/Session id + /// URI as string public string GetWebSocketServer(MongoId sessionId) { return $"{httpServerHelper.GetWebsocketUrl()}/notifierServer/getwebsocket/{sessionId.ToString()}"; diff --git a/Libraries/SPTarkov.Server.Core/Helpers/PresetHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/PresetHelper.cs index dacf7923..f0e1f1a8 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/PresetHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/PresetHelper.cs @@ -109,12 +109,12 @@ public class PresetHelper(DatabaseService databaseService, ItemHelper itemHelper return databaseService.GetGlobals().ItemPresets.ContainsKey(id); } - /** - * Checks to see if the preset is of the given base class. - * @param id The id of the preset - * @param baseClass The BaseClasses enum to check against - * @returns True if the preset is of the given base class, false otherwise - */ + /// + /// Checks to see if the preset is of the given base class + /// + /// id of the preset + /// BaseClasses enum to check against + /// True if the preset is of the given base class, false otherwise public bool IsPresetBaseClass(MongoId id, MongoId baseClass) { return IsPreset(id) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/QuestHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/QuestHelper.cs index 04f39102..a5e411f9 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/QuestHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/QuestHelper.cs @@ -290,13 +290,6 @@ public class QuestHelper( } } - /** - * - * @param pmcData - * @param newState - * @param acceptedQuest - */ - /// /// Look up quest in db by accepted quest id and construct a profile-ready object ready to store in profile /// @@ -1494,14 +1487,13 @@ public class QuestHelper( .ToList(); } - /** - * Fail the provided quests - * Update quest in profile, otherwise add fresh quest object with failed status - * @param sessionID session id - * @param pmcData player profile - * @param questsToFail quests to fail - * @param output Client output - */ + /// + /// Fail the provided quests - Update quest in profile, otherwise add fresh quest object with failed status + /// + /// session id + /// player profile + /// quests to fail + /// Client output protected void FailQuests( MongoId sessionID, PmcData pmcData, @@ -1560,13 +1552,13 @@ public class QuestHelper( } } - /** - * Send a popup to player on successful completion of a quest - * @param sessionID session id - * @param pmcData Player profile - * @param completedQuestId Completed quest id - * @param questRewards Rewards given to player - */ + /// + /// Send a popup to player on successful completion of a quest + /// + /// session id + /// Player profile + /// Completed quest id + /// Rewards given to player protected void SendSuccessDialogMessageOnQuestComplete( MongoId sessionID, PmcData pmcData, @@ -1645,11 +1637,11 @@ public class QuestHelper( } } - /** - * Remove a quest entirely from a profile - * @param sessionId Player id - * @param questIdToRemove Qid of quest to remove - */ + /// + /// Remove a quest entirely from a profile + /// + /// Player id + /// Qid of quest to remove protected void RemoveQuestFromScavProfile(MongoId sessionId, MongoId questIdToRemove) { var fullProfile = profileHelper.GetFullProfile(sessionId); diff --git a/Libraries/SPTarkov.Server.Core/Helpers/RagfairHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/RagfairHelper.cs index 13426838..1afe4188 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/RagfairHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/RagfairHelper.cs @@ -151,10 +151,12 @@ public class RagfairHelper( return result; } - /** - * Iterate over array of identical items and merge stack count - * Ragfair allows abnormally large stacks. - */ + /// + /// Iterate over array of identical items and merge stack count + /// Ragfair allows abnormally large stacks + /// + /// Items to merge + /// public List MergeStackable(List items) { var list = new List(); @@ -187,12 +189,12 @@ public class RagfairHelper( return [rootItem, .. list]; } - /** - * Return the symbol for a currency - * e.g. 5449016a4bdc2d6f028b456f return ₽ - * @param currencyTpl currency to get symbol for - * @returns symbol of currency - */ + /// + /// Return the symbol for a currency + /// e.g. 5449016a4bdc2d6f028b456f return ₽ + /// + /// currency to get symbol for + /// symbol of currency public string GetCurrencySymbol(string currencyTpl) { return currencyTpl == Money.EUROS ? "€" diff --git a/Libraries/SPTarkov.Server.Core/Helpers/RagfairOfferHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/RagfairOfferHelper.cs index 06cabbd8..e482763e 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/RagfairOfferHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/RagfairOfferHelper.cs @@ -629,11 +629,11 @@ public class RagfairOfferHelper( return loyaltyLockedOffers; } - /** - * Process all player-listed flea offers for a desired profile - * @param sessionId Session id to process offers for - * @returns true = complete - */ + /// + /// Process all player-listed flea offers for a desired profile + /// + /// Session id to process offers for + /// true = complete public bool ProcessOffersOnProfile(MongoId sessionId) { var currentTimestamp = timeUtil.GetTimeStamp(); @@ -754,11 +754,11 @@ public class RagfairOfferHelper( return profile.RagfairInfo.Offers; } - /** - * Delete an offer from a desired profile and from ragfair offers - * @param sessionId Session id of profile to delete offer from - * @param offerId Id of offer to delete - */ + /// + /// Delete an offer from a desired profile and from ragfair offers + /// + /// Session id of profile to delete offer from + /// Id of offer to delete protected void DeleteOfferById(MongoId sessionId, MongoId offerId) { var profileRagfairInfo = profileHelper.GetPmcProfile(sessionId).RagfairInfo; @@ -870,12 +870,12 @@ public class RagfairOfferHelper( return eventOutputHolder.GetOutput(offerOwnerSessionId); } - /** - * Get a localised message for when players offer has sold on flea - * @param itemTpl Item sold - * @param boughtAmount How many were purchased - * @returns Localised message text - */ + /// + /// Get a localised message for when players offer has sold on flea + /// + /// Item sold + /// + /// Localised string protected string GetLocalisedOfferSoldMessage(MongoId itemTpl, int boughtAmount) { // Generate a message to inform that item was sold @@ -919,13 +919,13 @@ public class RagfairOfferHelper( return soldMessageLocaleGuid; } - /** - * Check an offer passes the various search criteria the player requested - * @param searchRequest Client search request - * @param offer Offer to check - * @param pmcData Player profile - * @returns True if offer passes criteria - */ + /// + /// Check an offer passes the various search criteria the player requested + /// + /// Client search request + /// Offer to check + /// Player profile + /// True if offer passes criteria protected bool PassesSearchFilterCriteria( SearchRequestData searchRequest, RagfairOffer offer, @@ -1053,12 +1053,12 @@ public class RagfairOfferHelper( return true; } - /** - * Check that the passed in offer item is functional - * @param offerRootItem The root item of the offer - * @param offer Flea offer to check - * @returns True if the given item is functional - */ + /// + /// Check that the passed in offer item is functional + /// + /// The root item of the offer + /// Flea offer to check + /// True if the given item is functional public bool IsItemFunctional(Item offerRootItem, RagfairOffer offer) { // Non-preset weapons/armor are always functional diff --git a/Libraries/SPTarkov.Server.Core/Helpers/RagfairServerHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/RagfairServerHelper.cs index 22c8808e..a63f2c84 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/RagfairServerHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/RagfairServerHelper.cs @@ -29,11 +29,11 @@ public class RagfairServerHelper( protected const string goodsReturnedTemplate = "5bdabfe486f7743e1665df6e 0"; // Your item was not sold protected readonly RagfairConfig ragfairConfig = configServer.GetConfig(); - /** - * Is item valid / on blacklist / quest item - * @param itemDetails - * @returns boolean - */ + /// + /// Is item valid / not on blacklist / not a quest item + /// + /// Item to check + /// public bool IsItemValidRagfairItem(KeyValuePair itemDetails) { var blacklistConfig = ragfairConfig.Dynamic.Blacklist; @@ -94,41 +94,41 @@ public class RagfairServerHelper( return true; } - /** - * Is supplied item tpl on the ragfair custom blacklist from configs/ragfair.json/dynamic - * @param itemTemplateId Item tpl to check is blacklisted - * @returns True if its blacklisted - */ + /// + /// Is supplied item tpl on the ragfair custom blacklist from configs/ragfair.json/dynamic + /// + /// Item tpl to check is blacklisted + /// True if its blacklisted protected bool IsItemOnCustomFleaBlacklist(MongoId itemTemplateId) { return ragfairConfig.Dynamic.Blacklist.Custom.Contains(itemTemplateId); } - /** - * Is supplied parent id on the ragfair custom item category blacklist - * @param parentId Parent Id to check is blacklisted - * @returns true if blacklisted - */ + /// + /// Is supplied parent id on the ragfair custom item category blacklist + /// + /// Parent Id to check is blacklisted + /// true if blacklisted protected bool IsItemCategoryOnCustomFleaBlacklist(MongoId itemParentId) { return ragfairConfig.Dynamic.Blacklist.CustomItemCategoryList.Contains(itemParentId); } - /** - * is supplied id a trader - * @param traderId - * @returns True if id was a trader - */ + /// + /// Is supplied id a trader + /// + /// id to check + /// True if id was a trader public bool IsTrader(MongoId traderId) { return databaseService.GetTraders().ContainsKey(traderId); } - /** - * Send items back to player - * @param sessionID Player to send items to - * @param returnedItems Items to send to player - */ + /// + /// Send items back to player + /// + /// Player to send items to + /// Items to send to player public void ReturnItems(MongoId sessionID, List returnedItems) { mailSendService.SendLocalisedNpcMessageToPlayer( @@ -193,11 +193,11 @@ public class RagfairServerHelper( return Math.Max((int)randomUtil.GetPercentOfValue(stackPercent, maxStackSize, 0), 1); } - /** - * Choose a currency at random with bias - * @returns currency tpl - */ - public string GetDynamicOfferCurrency() + /// + /// Choose a currency at random with bias + /// + /// Currency TPL + public MongoId GetDynamicOfferCurrency() { return weightedRandomHelper.GetWeightedValue(ragfairConfig.Dynamic.Currencies); } diff --git a/Libraries/SPTarkov.Server.Core/Helpers/RagfairSortHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/RagfairSortHelper.cs index efc15908..ca13df2f 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/RagfairSortHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/RagfairSortHelper.cs @@ -8,13 +8,13 @@ namespace SPTarkov.Server.Core.Helpers; [Injectable] public class RagfairSortHelper(LocaleService localeService) { - /** - * Sort a list of ragfair offers by something (id/rating/offer name/price/expiry time) - * @param offers Offers to sort - * @param type How to sort it - * @param direction Ascending/descending - * @returns Sorted offers - */ + /// + /// Sort a list of ragfair offers by something (id/rating/offer name/price/expiry time) + /// + /// Offers to sort + /// How to sort it + /// Ascending/descending + /// Sorted offers public List SortOffers( List offers, RagfairSort type, @@ -97,19 +97,25 @@ public class RagfairSortHelper(LocaleService localeService) return string.CompareOrdinal(nameA, nameB); } - /** - * Order two offers by rouble price value - * @param a Offer a - * @param b Offer b - * @returns - */ + /// + /// Order two offers by rouble price value + /// + /// Offer a + /// Offer b + /// -1, 0, 1 protected int SortOffersByPrice(RagfairOffer a, RagfairOffer b) { return (int)(a.RequirementsCost.Value - b.RequirementsCost.Value); } + /// + /// Order two offers by rouble price value + /// + /// Offer a + /// Offer b + /// -1, 0, 1 protected int SortOffersByExpiry(RagfairOffer a, RagfairOffer b) { - return (int)(a.EndTime - b.EndTime); + return (int)((a.EndTime ?? 0) - (b.EndTime ?? 0)); } } diff --git a/Libraries/SPTarkov.Server.Core/Helpers/WeightedRandomHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/WeightedRandomHelper.cs index 5bb68061..64c2e907 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/WeightedRandomHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/WeightedRandomHelper.cs @@ -30,7 +30,7 @@ public class WeightedRandomHelper( var itemKeys = values.Keys.ToList(); var weights = values.Values.ToList(); - var chosenItem = WeightedRandom(itemKeys, weights); + var chosenItem = WeightedRandom(itemKeys, weights); return chosenItem.Item; } @@ -109,7 +109,7 @@ public class WeightedRandomHelper( } /// - /// Find the greated common divisor of all weights and use it on the passed in dictionary + /// Find the greatest common divisor of all weights and use it on the passed in dictionary /// /// Values to reduce public void ReduceWeightValues(IDictionary weightedDict) @@ -144,9 +144,11 @@ public class WeightedRandomHelper( } } - /** - * Get the common divisor between all values in the passed in list and returns it - */ + /// + /// Get the common divisor between all values from provided list and return it + /// + /// Numbers to get common divisor of + /// Common divisor protected double CommonDivisor(List numbers) { var result = numbers[0]; diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Ws/WsChatMessageReceived.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Ws/WsChatMessageReceived.cs index 798f1d6f..3850e054 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Ws/WsChatMessageReceived.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Ws/WsChatMessageReceived.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Eft.Match; using SPTarkov.Server.Core.Models.Eft.Profile; @@ -7,7 +8,7 @@ namespace SPTarkov.Server.Core.Models.Eft.Ws; public record WsChatMessageReceived : WsNotificationEvent { [JsonPropertyName("dialogId")] - public string? DialogId { get; set; } + public MongoId? DialogId { get; set; } [JsonPropertyName("message")] public Message? Message { get; set; } diff --git a/Libraries/SPTarkov.Server.Core/Utils/Collections/ProbabilityObjectArray.cs b/Libraries/SPTarkov.Server.Core/Utils/Collections/ProbabilityObjectArray.cs index 37c24e35..bdfa9852 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/Collections/ProbabilityObjectArray.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/Collections/ProbabilityObjectArray.cs @@ -117,15 +117,13 @@ public class ProbabilityObjectArray : List> return element?.RelativeProbability; } - /** - * Get the maximum relative probability out of a ProbabilityObjectArray - * - * Example: - * po = new ProbabilityObjectArray(new ProbabilityObject("a", 5), new ProbabilityObject("b", 1)) - * po.maxProbability() // returns 5 - * - * @return {number} the maximum value of all relative probabilities in this ProbabilityObjectArray - */ + /// + /// Get the maximum relative probability out of a ProbabilityObjectArray + /// Example: + /// po = new ProbabilityObjectArray(new ProbabilityObject("a", 5), new ProbabilityObject("b", 1)) + /// po.maxProbability() // returns 5 + /// + /// the maximum value of all relative probabilities in this ProbabilityObjectArray public double MaxProbability() { return this.Max(x => x.RelativeProbability).Value; @@ -217,12 +215,12 @@ public class ProbabilityObject { public ProbabilityObject() { } - /** - * constructor for the ProbabilityObject - * @param {string} key The key of the element - * @param {number} relativeProbability The relative probability of this element - * @param {any} data Optional data attached to the element - */ + /// + /// constructor for the ProbabilityObject + /// + /// The key of the element + /// The relative probability of this element + /// Optional data attached to the element public ProbabilityObject(K key, double? relativeProbability, V? data) { Key = key; diff --git a/Libraries/SPTarkov.Server.Core/Utils/DatabaseImporter.cs b/Libraries/SPTarkov.Server.Core/Utils/DatabaseImporter.cs index 0d84c1af..30da416a 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/DatabaseImporter.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/DatabaseImporter.cs @@ -111,10 +111,11 @@ public class DatabaseImporter( } } - /** - * Read all json files in database folder and map into a json object - * @param filepath path to database folder - */ + /// + /// Read all json files in database folder and map into a json object + /// + /// path to database folder + /// protected async Task HydrateDatabase(string filePath) { logger.Info(_serverLocalisationService.GetText("importing_database")); diff --git a/Libraries/SPTarkov.Server.Core/Utils/HttpResponseUtil.cs b/Libraries/SPTarkov.Server.Core/Utils/HttpResponseUtil.cs index a305b0c7..9ae8ae10 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/HttpResponseUtil.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/HttpResponseUtil.cs @@ -34,23 +34,26 @@ public class HttpResponseUtil( return value; } - /** - * Return passed in data as JSON string - * @param data - * @returns - */ + /// + /// Return passed in data as JSON string + /// + /// + /// Object to serialise into string + /// response as string public string NoBody(T data) { return ClearString(jsonUtil.Serialize(data)); } - /** - * Game client needs server responses in a particular format - * @param data - * @param err - * @param errmsg - * @returns - */ + /// + /// Game client needs server responses in a particular format + /// + /// + /// + /// + /// + /// + /// response as string public string GetBody( T data, BackendErrorCodes err = BackendErrorCodes.None, @@ -79,6 +82,10 @@ public class HttpResponseUtil( ); } + /// + /// Get empty string as a response + /// + /// Client response public string EmptyResponse() { return GetBody("", BackendErrorCodes.None, ""); @@ -94,13 +101,13 @@ public class HttpResponseUtil( return GetBody(new List()); } - /** - * Add an error into the 'warnings' array of the client response message - * @param output IItemEventRouterResponse - * @param message Error message - * @param errorCode Error code - * @returns IItemEventRouterResponse - */ + /// + /// Add an error into the 'warnings' array of the client response message + /// + /// IItemEventRouterResponse + /// Error message + /// Error code + /// IItemEventRouterResponse public ItemEventRouterResponse AppendErrorToOutput( ItemEventRouterResponse output, string? message = null,