diff --git a/Libraries/Core/Generators/RagfairOfferGenerator.cs b/Libraries/Core/Generators/RagfairOfferGenerator.cs index acf48788..41edcec1 100644 --- a/Libraries/Core/Generators/RagfairOfferGenerator.cs +++ b/Libraries/Core/Generators/RagfairOfferGenerator.cs @@ -126,7 +126,7 @@ public class RagfairOfferGenerator( itemHelper.AddCartridgesToAmmoBox(itemsClone, itemHelper.GetItem(rootItem.Template).Value); } - var roubleListingPrice = Math.Round((double) ConvertOfferRequirementsIntoRoubles(offerRequirements)); + var roubleListingPrice = Math.Round(ConvertOfferRequirementsIntoRoubles(offerRequirements)); var singleItemListingPrice = isPackOffer ? roubleListingPrice / itemStackCount : roubleListingPrice; var offer = new RagfairOffer @@ -209,14 +209,14 @@ public class RagfairOfferGenerator( * @param offerRequirements barter requirements for offer * @returns rouble cost of offer */ - protected int ConvertOfferRequirementsIntoRoubles(List offerRequirements) + protected double ConvertOfferRequirementsIntoRoubles(IEnumerable offerRequirements) { - var roublePrice = 0; + var roublePrice = 0d; foreach (var requirement in offerRequirements) { - roublePrice += (int) (paymentHelper.IsMoneyTpl(requirement.Template) - ? Math.Round((double) CalculateRoublePrice((int) requirement.Count, requirement.Template)) - : ragfairPriceService.GetFleaPriceForItem(requirement.Template) * requirement.Count); // get flea price for barter offer items + roublePrice += (paymentHelper.IsMoneyTpl(requirement.Template) + ? Math.Round(CalculateRoublePrice(requirement.Count.Value, requirement.Template)) + : ragfairPriceService.GetFleaPriceForItem(requirement.Template) * requirement.Count.Value); // Get flea price for barter offer items } return roublePrice; @@ -244,7 +244,7 @@ public class RagfairOfferGenerator( * @param currencyType Type of currency (euro/dollar/rouble) * @returns count of roubles */ - protected int CalculateRoublePrice(int currencyCount, string currencyType) + protected double CalculateRoublePrice(double currencyCount, string currencyType) { if (currencyType == Money.ROUBLES) { diff --git a/Libraries/Core/Helpers/HandbookHelper.cs b/Libraries/Core/Helpers/HandbookHelper.cs index 118b2de4..672e2092 100644 --- a/Libraries/Core/Helpers/HandbookHelper.cs +++ b/Libraries/Core/Helpers/HandbookHelper.cs @@ -166,11 +166,11 @@ public class HandbookHelper( /// Currency count to convert /// What current currency is /// Count in roubles - public int InRUB(double nonRoubleCurrencyCount, string currencyTypeFrom) + public double InRUB(double nonRoubleCurrencyCount, string currencyTypeFrom) { - return (int) (currencyTypeFrom == Money.ROUBLES + return currencyTypeFrom == Money.ROUBLES ? nonRoubleCurrencyCount - : Math.Round(nonRoubleCurrencyCount * GetTemplatePrice(currencyTypeFrom))); + : Math.Round(nonRoubleCurrencyCount * GetTemplatePrice(currencyTypeFrom)); } /// @@ -179,7 +179,7 @@ public class HandbookHelper( /// roubles to convert /// Currency to convert roubles into /// currency count in desired type - public int FromRUB(double roubleCurrencyCount, string currencyTypeTo) + public double FromRUB(double roubleCurrencyCount, string currencyTypeTo) { if (currencyTypeTo == Money.ROUBLES) { @@ -188,7 +188,9 @@ public class HandbookHelper( // Get price of currency from handbook var price = GetTemplatePrice(currencyTypeTo); - return (int) (price > 0 ? Math.Max(1, Math.Round(roubleCurrencyCount / price)) : 0); + return price > 0 + ? Math.Max(1, Math.Round(roubleCurrencyCount / price)) + : 0; } public HandbookCategory GetCategoryById(string handbookId) diff --git a/Libraries/Core/Models/Eft/Common/Tables/Trader.cs b/Libraries/Core/Models/Eft/Common/Tables/Trader.cs index 00a84b69..35cffade 100644 --- a/Libraries/Core/Models/Eft/Common/Tables/Trader.cs +++ b/Libraries/Core/Models/Eft/Common/Tables/Trader.cs @@ -479,6 +479,7 @@ public record TraderAssort public record BarterScheme { + // Confirmed in client [JsonPropertyName("count")] public double? Count { diff --git a/Libraries/Core/Services/FenceService.cs b/Libraries/Core/Services/FenceService.cs index 0c05cc17..41c1b389 100644 --- a/Libraries/Core/Services/FenceService.cs +++ b/Libraries/Core/Services/FenceService.cs @@ -998,7 +998,7 @@ public class FenceService( // Multiply item cost by desired multiplier var basePrice = barterSchemes[itemRoot.Id][0][0].Count; - barterSchemes[itemRoot.Id][0][0].Count = Math.Round((double) (basePrice * multipler)); + barterSchemes[itemRoot.Id][0][0].Count = Math.Round(basePrice.Value * multiplier.Value); return; } diff --git a/Libraries/Core/Services/RagfairPriceService.cs b/Libraries/Core/Services/RagfairPriceService.cs index 4f6677fa..96745d23 100644 --- a/Libraries/Core/Services/RagfairPriceService.cs +++ b/Libraries/Core/Services/RagfairPriceService.cs @@ -300,15 +300,14 @@ public class RagfairPriceService( price = RandomiseOfferPrice(price, range); // Convert to different currency if required. - var roublesId = Money.ROUBLES; - if (desiredCurrency != roublesId) + if (desiredCurrency != Money.ROUBLES) { price = _handbookHelper.FromRUB(price, desiredCurrency); } - if (price < 1) + if (price <= 0) { - return 1; + return 0.1d; } return price;