mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 07:04:27 +00:00
Add Marketable property into inventory Assets (#1031)
* Add files via upload Add Marketable * Add files via upload Add Marketable * Fix
This commit is contained in:
parent
e1e9a9f457
commit
b3f11e0188
2 changed files with 25 additions and 10 deletions
|
@ -1066,7 +1066,7 @@ namespace ArchiSteamFarm {
|
|||
return null;
|
||||
}
|
||||
|
||||
Dictionary<(uint AppID, ulong ClassID), (uint RealAppID, Steam.Asset.EType Type)> descriptions = new Dictionary<(uint AppID, ulong ClassID), (uint RealAppID, Steam.Asset.EType Type)>();
|
||||
Dictionary<(uint AppID, ulong ClassID), (uint RealAppID, Steam.Asset.EType Type, bool Marketable)> descriptions = new Dictionary<(uint AppID, ulong ClassID), (uint RealAppID, Steam.Asset.EType Type, bool Marketable)>();
|
||||
|
||||
foreach (KeyValue description in response["descriptions"].Children) {
|
||||
uint appID = description["appid"].AsUnsignedInteger();
|
||||
|
@ -1104,9 +1104,11 @@ namespace ArchiSteamFarm {
|
|||
if (!string.IsNullOrEmpty(descriptionType)) {
|
||||
type = GetItemType(descriptionType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool marketable = description["marketable"].AsBoolean();
|
||||
|
||||
descriptions[(appID, classID)] = (realAppID, type);
|
||||
descriptions[(appID, classID)] = (realAppID, type, marketable);
|
||||
}
|
||||
|
||||
HashSet<Steam.TradeOffer> result = new HashSet<Steam.TradeOffer>();
|
||||
|
@ -1437,7 +1439,7 @@ namespace ArchiSteamFarm {
|
|||
return null;
|
||||
}
|
||||
|
||||
Dictionary<ulong, (bool Tradable, uint RealAppID, Steam.Asset.EType Type)> descriptions = new Dictionary<ulong, (bool Tradable, uint RealAppID, Steam.Asset.EType Type)>();
|
||||
Dictionary<ulong, (bool Tradable, bool Marketable, uint RealAppID, Steam.Asset.EType Type)> descriptions = new Dictionary<ulong, (bool Tradable, bool Marketable, uint RealAppID, Steam.Asset.EType Type)>();
|
||||
|
||||
foreach (Steam.InventoryResponse.Description description in response.Descriptions.Where(description => description != null)) {
|
||||
if (description.ClassID == 0) {
|
||||
|
@ -1463,16 +1465,17 @@ namespace ArchiSteamFarm {
|
|||
}
|
||||
}
|
||||
|
||||
descriptions[description.ClassID] = (description.Tradable, realAppID, type);
|
||||
descriptions[description.ClassID] = (description.Tradable, description.Marketable, realAppID, type);
|
||||
}
|
||||
|
||||
foreach (Steam.Asset asset in response.Assets.Where(asset => asset != null)) {
|
||||
if (descriptions.TryGetValue(asset.ClassID, out (bool Tradable, uint RealAppID, Steam.Asset.EType Type) description)) {
|
||||
if (descriptions.TryGetValue(asset.ClassID, out (bool Tradable, bool Marketable, uint RealAppID, Steam.Asset.EType Type) description)) {
|
||||
if ((tradable.HasValue && (description.Tradable != tradable.Value)) || (wantedRealAppIDs?.Contains(description.RealAppID) == false) || (wantedSets?.Contains((description.RealAppID, description.Type)) == false) || (wantedTypes?.Contains(description.Type) == false) || (skippedSets?.Contains((description.RealAppID, description.Type)) == true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
asset.Tradable = description.Tradable;
|
||||
asset.Marketable = description.Marketable;
|
||||
asset.RealAppID = description.RealAppID;
|
||||
asset.Type = description.Type;
|
||||
} else if (tradable.HasValue || (wantedRealAppIDs != null) || (wantedSets != null) || (wantedTypes != null) || (skippedSets != null)) {
|
||||
|
@ -2379,7 +2382,7 @@ namespace ArchiSteamFarm {
|
|||
return uri.AbsolutePath.StartsWith("/login", StringComparison.Ordinal) || uri.Host.Equals("lostauth");
|
||||
}
|
||||
|
||||
private static bool ParseItems(IReadOnlyDictionary<(uint AppID, ulong ClassID), (uint RealAppID, Steam.Asset.EType Type)> descriptions, IReadOnlyCollection<KeyValue> input, ICollection<Steam.Asset> output) {
|
||||
private static bool ParseItems(IReadOnlyDictionary<(uint AppID, ulong ClassID), (uint RealAppID, Steam.Asset.EType Type, bool Marketable)> descriptions, IReadOnlyCollection<KeyValue> input, ICollection<Steam.Asset> output) {
|
||||
if ((descriptions == null) || (input == null) || (input.Count == 0) || (output == null)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(descriptions) + " || " + nameof(input) + " || " + nameof(output));
|
||||
|
||||
|
@ -2421,13 +2424,15 @@ namespace ArchiSteamFarm {
|
|||
|
||||
uint realAppID = 0;
|
||||
Steam.Asset.EType type = Steam.Asset.EType.Unknown;
|
||||
bool marketable = true;
|
||||
|
||||
if (descriptions.TryGetValue((appID, classID), out (uint RealAppID, Steam.Asset.EType Type) description)) {
|
||||
if (descriptions.TryGetValue((appID, classID), out (uint RealAppID, Steam.Asset.EType Type, bool Marketable) description)) {
|
||||
realAppID = description.RealAppID;
|
||||
type = description.Type;
|
||||
marketable = description.Marketable;
|
||||
}
|
||||
|
||||
Steam.Asset steamAsset = new Steam.Asset(appID, contextID, classID, amount, realAppID, type);
|
||||
Steam.Asset steamAsset = new Steam.Asset(appID, contextID, classID, amount, realAppID, type, marketable);
|
||||
output.Add(steamAsset);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,9 @@ namespace ArchiSteamFarm.Json {
|
|||
[PublicAPI]
|
||||
public bool Tradable { get; internal set; }
|
||||
|
||||
[PublicAPI]
|
||||
public bool Marketable { get; internal set; }
|
||||
|
||||
[PublicAPI]
|
||||
public EType Type { get; internal set; }
|
||||
|
||||
|
@ -157,7 +160,7 @@ namespace ArchiSteamFarm.Json {
|
|||
}
|
||||
|
||||
// Constructed from trades being received or plugins
|
||||
public Asset(uint appID, uint contextID, ulong classID, uint amount, uint realAppID = 0, EType type = EType.Unknown) {
|
||||
public Asset(uint appID, uint contextID, ulong classID, uint amount, uint realAppID = 0, EType type = EType.Unknown, bool marketable = true) {
|
||||
if ((appID == 0) || (contextID == 0) || (classID == 0) || (amount == 0)) {
|
||||
throw new ArgumentNullException(nameof(appID) + " || " + nameof(contextID) + " || " + nameof(classID) + " || " + nameof(amount));
|
||||
}
|
||||
|
@ -168,6 +171,7 @@ namespace ArchiSteamFarm.Json {
|
|||
Amount = amount;
|
||||
RealAppID = realAppID;
|
||||
Type = type;
|
||||
Marketable = marketable;
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
|
@ -439,6 +443,7 @@ namespace ArchiSteamFarm.Json {
|
|||
|
||||
internal ulong ClassID { get; private set; }
|
||||
internal bool Tradable { get; private set; }
|
||||
internal bool Marketable { get; private set; }
|
||||
|
||||
[JsonProperty(PropertyName = "classid", Required = Required.Always)]
|
||||
private string ClassIDText {
|
||||
|
@ -464,6 +469,11 @@ namespace ArchiSteamFarm.Json {
|
|||
set => Tradable = value > 0;
|
||||
}
|
||||
|
||||
[JsonProperty(PropertyName = "marketable", Required = Required.Always)]
|
||||
private byte MarketableNumber {
|
||||
set => Marketable = value > 0;
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
private Description() { }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue