mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Match assets with descriptions by instance IDs as well (#1622)
* Match assets with descriptions by instance IDs as well * Change order of properties
This commit is contained in:
@@ -183,7 +183,7 @@ namespace ArchiSteamFarm {
|
||||
return null;
|
||||
}
|
||||
|
||||
Dictionary<ulong, (bool Marketable, bool Tradable, uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)> descriptions = new Dictionary<ulong, (bool Marketable, bool Tradable, uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)>();
|
||||
Dictionary<(ulong ClassID, ulong InstanceID), (bool Marketable, bool Tradable, uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)> descriptions = new Dictionary<(ulong ClassID, ulong InstanceID), (bool Marketable, bool Tradable, uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)>();
|
||||
|
||||
foreach (Steam.InventoryResponse.Description description in response.Descriptions.Where(description => description != null)) {
|
||||
if (description.ClassID == 0) {
|
||||
@@ -192,15 +192,11 @@ namespace ArchiSteamFarm {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (descriptions.ContainsKey(description.ClassID)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
descriptions[description.ClassID] = (description.Marketable, description.Tradable, description.RealAppID, description.Type, description.Rarity);
|
||||
descriptions[(description.ClassID, description.InstanceID)] = (description.Marketable, description.Tradable, description.RealAppID, description.Type, description.Rarity);
|
||||
}
|
||||
|
||||
foreach (Steam.Asset asset in response.Assets.Where(asset => asset != null)) {
|
||||
if (descriptions.TryGetValue(asset.ClassID, out (bool Marketable, bool Tradable, uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity) description)) {
|
||||
if (descriptions.TryGetValue((asset.ClassID, asset.InstanceID), out (bool Marketable, bool Tradable, uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity) description)) {
|
||||
if ((marketable.HasValue && (description.Marketable != marketable.Value)) || (tradable.HasValue && (description.Tradable != tradable.Value)) || (wantedRealAppIDs?.Contains(description.RealAppID) == false) || (unwantedRealAppIDs?.Contains(description.RealAppID) == true) || (wantedTypes?.Contains(description.Type) == false) || (wantedSets?.Contains((description.RealAppID, description.Type, description.Rarity)) == false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,9 @@ namespace ArchiSteamFarm.Json {
|
||||
[PublicAPI]
|
||||
public ulong ContextID { get; private set; }
|
||||
|
||||
[PublicAPI]
|
||||
public ulong InstanceID { get; private set; }
|
||||
|
||||
[PublicAPI]
|
||||
public bool Marketable { get; internal set; }
|
||||
|
||||
@@ -171,6 +174,25 @@ namespace ArchiSteamFarm.Json {
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "instanceid", Required = Required.DisallowNull)]
|
||||
private string InstanceIDText {
|
||||
set {
|
||||
if (string.IsNullOrEmpty(value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ulong.TryParse(value, out ulong instanceID)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(instanceID));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
InstanceID = instanceID;
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
// Constructed from trades being received or plugins
|
||||
public Asset(uint appID, ulong contextID, ulong classID, uint amount, bool marketable = true, uint realAppID = 0, EType type = EType.Unknown, ERarity rarity = ERarity.Unknown) {
|
||||
if ((appID == 0) || (contextID == 0) || (classID == 0) || (amount == 0)) {
|
||||
@@ -456,6 +478,7 @@ namespace ArchiSteamFarm.Json {
|
||||
internal readonly uint AppID;
|
||||
|
||||
internal ulong ClassID { get; private set; }
|
||||
internal ulong InstanceID { get; private set; }
|
||||
internal bool Marketable { get; private set; }
|
||||
internal Asset.ERarity Rarity { get; private set; }
|
||||
internal uint RealAppID { get; private set; }
|
||||
@@ -483,6 +506,25 @@ namespace ArchiSteamFarm.Json {
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "instanceid", Required = Required.DisallowNull)]
|
||||
private string InstanceIDText {
|
||||
set {
|
||||
if (string.IsNullOrEmpty(value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ulong.TryParse(value, out ulong instanceID)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(instanceID));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
InstanceID = instanceID;
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "marketable", Required = Required.Always)]
|
||||
private byte MarketableNumber {
|
||||
|
||||
Reference in New Issue
Block a user