diff --git a/Libraries/Core/Callbacks/PrestigeCallbacks.cs b/Libraries/Core/Callbacks/PrestigeCallbacks.cs
index 51310fa8..b6000b6b 100644
--- a/Libraries/Core/Callbacks/PrestigeCallbacks.cs
+++ b/Libraries/Core/Callbacks/PrestigeCallbacks.cs
@@ -31,7 +31,7 @@ public class PrestigeCallbacks(
///
///
///
- public string ObtainPrestige(string url, List info, string sessionID)
+ public string ObtainPrestige(string url, ObtainPrestigeRequestList info, string sessionID)
{
_prestigeController.ObtainPrestige(sessionID, info);
diff --git a/Libraries/Core/Controllers/PrestigeController.cs b/Libraries/Core/Controllers/PrestigeController.cs
index b58d6c55..3854ef8a 100644
--- a/Libraries/Core/Controllers/PrestigeController.cs
+++ b/Libraries/Core/Controllers/PrestigeController.cs
@@ -52,7 +52,7 @@ public class PrestigeController(
///
public void ObtainPrestige(
string sessionId,
- List request)
+ ObtainPrestigeRequestList request)
{
var prePrestigeProfileClone = _cloner.Clone(_profileHelper.GetFullProfile(sessionId));
var prePrestigePmc = prePrestigeProfileClone.CharacterData.PmcData;
@@ -123,7 +123,7 @@ public class PrestigeController(
// Flag profile as having achieved this prestige level
newProfile.CharacterData.PmcData.Prestige[currentPrestigeData.Id] = _timeUtil.GetTimeStamp();
- newProfile.CharacterData.PmcData.Info.PrestigeLevel++;
+ newProfile.CharacterData.PmcData.Info.PrestigeLevel = indexOfPrestigeObtained;
if (request is not null)
{
diff --git a/Libraries/Core/Generators/RagfairOfferGenerator.cs b/Libraries/Core/Generators/RagfairOfferGenerator.cs
index 3dc27ec7..985472d7 100644
--- a/Libraries/Core/Generators/RagfairOfferGenerator.cs
+++ b/Libraries/Core/Generators/RagfairOfferGenerator.cs
@@ -703,7 +703,7 @@ public class RagfairOfferGenerator(
if (rootItem.Upd?.Key != null && itemDetails.Properties.MaximumNumberOfUsage > 1) {
// Randomize key uses
- rootItem.Upd.Key.NumberOfUsages = Math.Round((double) itemDetails.Properties.MaximumNumberOfUsage * (1 - maxMultiplier));
+ rootItem.Upd.Key.NumberOfUsages = (int?)Math.Round(itemDetails.Properties.MaximumNumberOfUsage.Value * (1 - maxMultiplier));
return;
}
diff --git a/Libraries/Core/Helpers/ItemHelper.cs b/Libraries/Core/Helpers/ItemHelper.cs
index 48242ccf..72b74de3 100644
--- a/Libraries/Core/Helpers/ItemHelper.cs
+++ b/Libraries/Core/Helpers/ItemHelper.cs
@@ -98,7 +98,7 @@ public class ItemHelper(
* @param compareUpdProperties Upd properties to compare between the items
* @returns true if they are the same, false if they aren't
*/
- public bool isSameItems(List- item1, List
- item2, HashSet compareUpdProperties = null)
+ public bool IsSameItems(List
- item1, List
- item2, HashSet compareUpdProperties = null)
{
if (item1.Count() != item2.Count)
{
@@ -113,7 +113,7 @@ public class ItemHelper(
return false;
}
- if (!this.isSameItem(itemOf1, itemOf2, compareUpdProperties))
+ if (!IsSameItem(itemOf1, itemOf2, compareUpdProperties))
{
return false;
}
@@ -130,29 +130,65 @@ public class ItemHelper(
* @param compareUpdProperties Upd properties to compare between the items
* @returns true if they are the same, false if they aren't
*/
- public bool isSameItem(Item item1, Item item2, HashSet compareUpdProperties = null)
+ public bool IsSameItem(Item item1, Item item2, HashSet? compareUpdProperties = null)
{
+ // Different tpl == different item
if (item1.Template != item2.Template)
{
return false;
}
- var props = typeof(Upd).GetProperties();
- if (compareUpdProperties is not null)
+ // Both lack upd object + same tpl = same
+ if (item1.Upd is null && item2.Upd is null)
{
- return compareUpdProperties.ToArray()
- .All(
- (p) =>
- {
- var item1p = props.FirstOrDefault(prop => prop.Name.ToLower() == p.ToLower()).GetValue(item1.Upd);
- var item2p = props.FirstOrDefault(prop => prop.Name.ToLower() == p.ToLower()).GetValue(item2.Upd);
- ;
- return _compareUtil.RecursiveCompare(item1p, item2p);
- }
- ); // TODO: please refactor this is you know how
+ return true;
}
- return _compareUtil.RecursiveCompare(item1.Upd, item2.Upd);
+ // item1 lacks upd, item2 has one
+ if (item1.Upd is null && item2.Upd is not null)
+ {
+ return false;
+ }
+
+ // item1 has upd, item2 lacks one
+ if (item1.Upd is not null && item2.Upd is null)
+ {
+ return false;
+ }
+
+ // key = Upd property Type as string, value = comparison function that returns bool
+ var comparers = new Dictionary>
+ {
+ { "Key", (upd1, upd2) => upd1.Key?.NumberOfUsages == upd2.Key?.NumberOfUsages },
+ { "Buff", (upd1, upd2) => upd1.Buff?.Value == upd2.Buff?.Value && upd1.Buff?.BuffType == upd2.Buff?.BuffType },
+ { "CultistAmulet", (upd1, upd2) => upd1.CultistAmulet?.NumberOfUsages == upd2.CultistAmulet?.NumberOfUsages },
+ { "Dogtag", (upd1, upd2) => upd1.Dogtag?.ProfileId == upd2.Dogtag?.ProfileId },
+ { "FaceShield", (upd1, upd2) => upd1.FaceShield?.Hits == upd2.FaceShield?.Hits },
+ { "Foldable", (upd1, upd2) => upd1.Foldable?.Folded.GetValueOrDefault(false) == upd2.Foldable?.Folded.GetValueOrDefault(false) },
+ { "FoodDrink", (upd1, upd2) => upd1.FoodDrink?.HpPercent == upd2.FoodDrink?.HpPercent },
+ { "MedKit", (upd1, upd2) => upd1.MedKit?.HpResource == upd2.MedKit?.HpResource },
+ { "RecodableComponent", (upd1, upd2) => upd1.RecodableComponent?.IsEncoded == upd2.RecodableComponent?.IsEncoded },
+ { "RepairKit", (upd1, upd2) => upd1.RepairKit?.Resource == upd2.RepairKit?.Resource },
+ { "Resource", (upd1, upd2) => upd1.Resource?.UnitsConsumed == upd2.Resource?.UnitsConsumed }
+ };
+
+ // Choose above keys or passed in keys to compare items with
+ var valuesToCompare = compareUpdProperties?.Count > 0 ? compareUpdProperties : comparers.Keys.ToHashSet();
+ foreach (var propertyName in valuesToCompare)
+ {
+ if (!comparers.TryGetValue(propertyName, out var comparer))
+ {
+ // Key not found, skip
+ continue;
+ }
+
+ if (!comparer(item1.Upd, item2.Upd))
+ {
+ return false;
+ }
+ }
+
+ return true;
}
/**
diff --git a/Libraries/Core/Models/Eft/Common/Tables/Item.cs b/Libraries/Core/Models/Eft/Common/Tables/Item.cs
index fc6e344a..c3225246 100644
--- a/Libraries/Core/Models/Eft/Common/Tables/Item.cs
+++ b/Libraries/Core/Models/Eft/Common/Tables/Item.cs
@@ -244,8 +244,9 @@ public record UpdFoodDrink
public record UpdKey
{
+ // Checked in client
[JsonPropertyName("NumberOfUsages")]
- public double? NumberOfUsages { get; set; }
+ public int? NumberOfUsages { get; set; }
}
public record UpdResource
diff --git a/Libraries/Core/Models/Eft/Prestige/ObtainPrestigeRequest.cs b/Libraries/Core/Models/Eft/Prestige/ObtainPrestigeRequest.cs
index 44ae3ab1..1af2ab6a 100644
--- a/Libraries/Core/Models/Eft/Prestige/ObtainPrestigeRequest.cs
+++ b/Libraries/Core/Models/Eft/Prestige/ObtainPrestigeRequest.cs
@@ -1,8 +1,14 @@
using System.Text.Json.Serialization;
+using Core.Models.Utils;
namespace Core.Models.Eft.Prestige
{
- public record ObtainPrestigeRequest
+ public class ObtainPrestigeRequestList : List, IRequestData
+ {
+
+ }
+
+ public record ObtainPrestigeRequest : IRequestData
{
[JsonPropertyName("id")]
public string Id { get; set; }
@@ -21,5 +27,8 @@ namespace Core.Models.Eft.Prestige
[JsonPropertyName("z")]
public int Z { get; set; }
+
+ [JsonPropertyName("r")]
+ public string R { get; set; }
}
}
diff --git a/Libraries/Core/Routers/Static/PrestigeStaticRouter.cs b/Libraries/Core/Routers/Static/PrestigeStaticRouter.cs
index 3e13f09c..aebdba68 100644
--- a/Libraries/Core/Routers/Static/PrestigeStaticRouter.cs
+++ b/Libraries/Core/Routers/Static/PrestigeStaticRouter.cs
@@ -33,7 +33,8 @@ public class PrestigeStaticRouter : StaticRouter
info,
sessionID,
output
- ) => _presetCallbacks.ObtainPrestige(url, info as List, sessionID))
+ ) => _presetCallbacks.ObtainPrestige(url, info as ObtainPrestigeRequestList, sessionID)
+ , typeof(ObtainPrestigeRequestList))
]
)
{
diff --git a/Libraries/Core/Services/FenceService.cs b/Libraries/Core/Services/FenceService.cs
index 42093548..35efb603 100644
--- a/Libraries/Core/Services/FenceService.cs
+++ b/Libraries/Core/Services/FenceService.cs
@@ -405,7 +405,7 @@ public class FenceService(
existingFenceAssorts.Items,
existingRootItem.Id
);
- if (itemHelper.isSameItems(itemWithChildren, existingFullItemTree, fenceItemUpdCompareProperties))
+ if (itemHelper.IsSameItems(itemWithChildren, existingFullItemTree, fenceItemUpdCompareProperties))
{
// Guard against a missing stack count
if (existingRootItem.Upd?.StackObjectsCount == null)