Updated node comments to c# format

This commit is contained in:
Chomp
2025-07-21 21:09:17 +01:00
parent 41756041d4
commit 8f4f72dcdd
12 changed files with 191 additions and 171 deletions
@@ -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
*/
/// <summary>
/// Create a new notification that displays the "Your offer was sold!" prompt and removes sold offer from "My Offers" on clientside
/// </summary>
/// <param name="dialogueMessage">Message from dialog that was sent</param>
/// <param name="ragfairData">Ragfair data to attach to notification</param>
/// <returns></returns>
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
*/
/// <summary>
/// Create a new notification with the specified dialogueMessage object
/// </summary>
/// <param name="dialogueMessage"></param>
/// <returns>WsChatMessageReceived</returns>
public WsChatMessageReceived CreateNewMessageNotification(Message dialogueMessage)
{
return new WsChatMessageReceived
@@ -52,6 +52,12 @@ public class NotifierHelper(HttpServerHelper httpServerHelper)
};
}
/// <summary>
/// Create a new rating ragfair notification
/// </summary>
/// <param name="rating">new rating</param>
/// <param name="isGrowing">Rating is going up</param>
/// <returns>WsRagfairNewRating</returns>
public WsRagfairNewRating CreateRagfairNewRatingNotification(double rating, bool isGrowing)
{
return new WsRagfairNewRating
@@ -63,6 +69,11 @@ public class NotifierHelper(HttpServerHelper httpServerHelper)
};
}
/// <summary>
/// Get the web socket server URI
/// </summary>
/// <param name="sessionId">Player/Session id</param>
/// <returns>URI as string</returns>
public string GetWebSocketServer(MongoId sessionId)
{
return $"{httpServerHelper.GetWebsocketUrl()}/notifierServer/getwebsocket/{sessionId.ToString()}";
@@ -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
*/
/// <summary>
/// Checks to see if the preset is of the given base class
/// </summary>
/// <param name="id">id of the preset</param>
/// <param name="baseClass">BaseClasses enum to check against</param>
/// <returns>True if the preset is of the given base class, false otherwise</returns>
public bool IsPresetBaseClass(MongoId id, MongoId baseClass)
{
return IsPreset(id)
@@ -290,13 +290,6 @@ public class QuestHelper(
}
}
/**
*
* @param pmcData
* @param newState
* @param acceptedQuest
*/
/// <summary>
/// Look up quest in db by accepted quest id and construct a profile-ready object ready to store in profile
/// </summary>
@@ -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
*/
/// <summary>
/// Fail the provided quests - Update quest in profile, otherwise add fresh quest object with failed status
/// </summary>
/// <param name="sessionID">session id</param>
/// <param name="pmcData">player profile</param>
/// <param name="questsToFail">quests to fail</param>
/// <param name="output">Client output</param>
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
*/
/// <summary>
/// Send a popup to player on successful completion of a quest
/// </summary>
/// <param name="sessionID">session id</param>
/// <param name="pmcData">Player profile</param>
/// <param name="completedQuestId">Completed quest id</param>
/// <param name="questRewards">Rewards given to player</param>
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
*/
/// <summary>
/// Remove a quest entirely from a profile
/// </summary>
/// <param name="sessionId">Player id</param>
/// <param name="questIdToRemove">Qid of quest to remove</param>
protected void RemoveQuestFromScavProfile(MongoId sessionId, MongoId questIdToRemove)
{
var fullProfile = profileHelper.GetFullProfile(sessionId);
@@ -151,10 +151,12 @@ public class RagfairHelper(
return result;
}
/**
* Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks.
*/
/// <summary>
/// Iterate over array of identical items and merge stack count
/// Ragfair allows abnormally large stacks
/// </summary>
/// <param name="items">Items to merge</param>
/// <returns></returns>
public List<Item> MergeStackable(List<Item> items)
{
var list = new List<Item>();
@@ -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
*/
/// <summary>
/// Return the symbol for a currency
/// e.g. 5449016a4bdc2d6f028b456f return ₽
/// </summary>
/// <param name="currencyTpl">currency to get symbol for</param>
/// <returns>symbol of currency</returns>
public string GetCurrencySymbol(string currencyTpl)
{
return currencyTpl == Money.EUROS ? "€"
@@ -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
*/
/// <summary>
/// Process all player-listed flea offers for a desired profile
/// </summary>
/// <param name="sessionId">Session id to process offers for</param>
/// <returns>true = complete</returns>
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
*/
/// <summary>
/// Delete an offer from a desired profile and from ragfair offers
/// </summary>
/// <param name="sessionId">Session id of profile to delete offer from</param>
/// <param name="offerId">Id of offer to delete</param>
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
*/
/// <summary>
/// Get a localised message for when players offer has sold on flea
/// </summary>
/// <param name="itemTpl">Item sold</param>
/// <param name="boughtAmount"></param>
/// <returns>Localised string</returns>
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
*/
/// <summary>
/// Check an offer passes the various search criteria the player requested
/// </summary>
/// <param name="searchRequest">Client search request</param>
/// <param name="offer">Offer to check</param>
/// <param name="pmcData">Player profile</param>
/// <returns>True if offer passes criteria</returns>
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
*/
/// <summary>
/// Check that the passed in offer item is functional
/// </summary>
/// <param name="offerRootItem">The root item of the offer</param>
/// <param name="offer">Flea offer to check</param>
/// <returns>True if the given item is functional</returns>
public bool IsItemFunctional(Item offerRootItem, RagfairOffer offer)
{
// Non-preset weapons/armor are always functional
@@ -29,11 +29,11 @@ public class RagfairServerHelper(
protected const string goodsReturnedTemplate = "5bdabfe486f7743e1665df6e 0"; // Your item was not sold
protected readonly RagfairConfig ragfairConfig = configServer.GetConfig<RagfairConfig>();
/**
* Is item valid / on blacklist / quest item
* @param itemDetails
* @returns boolean
*/
/// <summary>
/// Is item valid / not on blacklist / not a quest item
/// </summary>
/// <param name="itemDetails">Item to check</param>
/// <returns></returns>
public bool IsItemValidRagfairItem(KeyValuePair<bool, TemplateItem?> 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
*/
/// <summary>
/// Is supplied item tpl on the ragfair custom blacklist from configs/ragfair.json/dynamic
/// </summary>
/// <param name="itemTemplateId">Item tpl to check is blacklisted</param>
/// <returns>True if its blacklisted</returns>
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
*/
/// <summary>
/// Is supplied parent id on the ragfair custom item category blacklist
/// </summary>
/// <param name="itemParentId">Parent Id to check is blacklisted</param>
/// <returns>true if blacklisted</returns>
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
*/
/// <summary>
/// Is supplied id a trader
/// </summary>
/// <param name="traderId">id to check</param>
/// <returns>True if id was a trader</returns>
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
*/
/// <summary>
/// Send items back to player
/// </summary>
/// <param name="sessionID">Player to send items to</param>
/// <param name="returnedItems">Items to send to player</param>
public void ReturnItems(MongoId sessionID, List<Item> 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()
/// <summary>
/// Choose a currency at random with bias
/// </summary>
/// <returns>Currency TPL</returns>
public MongoId GetDynamicOfferCurrency()
{
return weightedRandomHelper.GetWeightedValue(ragfairConfig.Dynamic.Currencies);
}
@@ -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
*/
/// <summary>
/// Sort a list of ragfair offers by something (id/rating/offer name/price/expiry time)
/// </summary>
/// <param name="offers">Offers to sort</param>
/// <param name="type">How to sort it</param>
/// <param name="direction">Ascending/descending</param>
/// <returns>Sorted offers</returns>
public List<RagfairOffer> SortOffers(
List<RagfairOffer> 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
*/
/// <summary>
/// Order two offers by rouble price value
/// </summary>
/// <param name="a">Offer a</param>
/// <param name="b">Offer b</param>
/// <returns>-1, 0, 1</returns>
protected int SortOffersByPrice(RagfairOffer a, RagfairOffer b)
{
return (int)(a.RequirementsCost.Value - b.RequirementsCost.Value);
}
/// <summary>
/// Order two offers by rouble price value
/// </summary>
/// <param name="a">Offer a</param>
/// <param name="b">Offer b</param>
/// <returns>-1, 0, 1</returns>
protected int SortOffersByExpiry(RagfairOffer a, RagfairOffer b)
{
return (int)(a.EndTime - b.EndTime);
return (int)((a.EndTime ?? 0) - (b.EndTime ?? 0));
}
}
@@ -30,7 +30,7 @@ public class WeightedRandomHelper(
var itemKeys = values.Keys.ToList();
var weights = values.Values.ToList();
var chosenItem = WeightedRandom<T>(itemKeys, weights);
var chosenItem = WeightedRandom(itemKeys, weights);
return chosenItem.Item;
}
@@ -109,7 +109,7 @@ public class WeightedRandomHelper(
}
/// <summary>
/// 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
/// </summary>
/// <param name="weightedDict">Values to reduce</param>
public void ReduceWeightValues(IDictionary<MongoId, double> weightedDict)
@@ -144,9 +144,11 @@ public class WeightedRandomHelper(
}
}
/**
* Get the common divisor between all values in the passed in list and returns it
*/
/// <summary>
/// Get the common divisor between all values from provided list and return it
/// </summary>
/// <param name="numbers">Numbers to get common divisor of</param>
/// <returns>Common divisor</returns>
protected double CommonDivisor(List<double> numbers)
{
var result = numbers[0];
@@ -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; }
@@ -117,15 +117,13 @@ public class ProbabilityObjectArray<K, V> : List<ProbabilityObject<K, V>>
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
*/
/// <summary>
/// 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
/// </summary>
/// <returns>the maximum value of all relative probabilities in this ProbabilityObjectArray</returns>
public double MaxProbability()
{
return this.Max(x => x.RelativeProbability).Value;
@@ -217,12 +215,12 @@ public class ProbabilityObject<K, V>
{
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
*/
/// <summary>
/// constructor for the ProbabilityObject
/// </summary>
/// <param name="key">The key of the element</param>
/// <param name="relativeProbability">The relative probability of this element</param>
/// <param name="data">Optional data attached to the element</param>
public ProbabilityObject(K key, double? relativeProbability, V? data)
{
Key = key;
@@ -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
*/
/// <summary>
/// Read all json files in database folder and map into a json object
/// </summary>
/// <param name="filePath">path to database folder</param>
/// <returns></returns>
protected async Task HydrateDatabase(string filePath)
{
logger.Info(_serverLocalisationService.GetText("importing_database"));
@@ -34,23 +34,26 @@ public class HttpResponseUtil(
return value;
}
/**
* Return passed in data as JSON string
* @param data
* @returns
*/
/// <summary>
/// Return passed in data as JSON string
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="data">Object to serialise into string</param>
/// <returns>response as string</returns>
public string NoBody<T>(T data)
{
return ClearString(jsonUtil.Serialize(data));
}
/**
* Game client needs server responses in a particular format
* @param data
* @param err
* @param errmsg
* @returns
*/
/// <summary>
/// Game client needs server responses in a particular format
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="data"></param>
/// <param name="err"></param>
/// <param name="errmsg"></param>
/// <param name="sanitize"></param>
/// <returns>response as string</returns>
public string GetBody<T>(
T data,
BackendErrorCodes err = BackendErrorCodes.None,
@@ -79,6 +82,10 @@ public class HttpResponseUtil(
);
}
/// <summary>
/// Get empty string as a response
/// </summary>
/// <returns>Client response</returns>
public string EmptyResponse()
{
return GetBody("", BackendErrorCodes.None, "");
@@ -94,13 +101,13 @@ public class HttpResponseUtil(
return GetBody(new List<object>());
}
/**
* 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
*/
/// <summary>
/// Add an error into the 'warnings' array of the client response message
/// </summary>
/// <param name="output">IItemEventRouterResponse</param>
/// <param name="message">Error message</param>
/// <param name="errorCode">Error code</param>
/// <returns>IItemEventRouterResponse</returns>
public ItemEventRouterResponse AppendErrorToOutput(
ItemEventRouterResponse output,
string? message = null,