mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 07:04:27 +00:00
Misc
This commit is contained in:
parent
b3f11e0188
commit
15c0f8ebbe
3 changed files with 27 additions and 27 deletions
|
@ -33,7 +33,7 @@ namespace ArchiSteamFarm.Tests {
|
|||
public void MultiGameMultiTypeBadReject() {
|
||||
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
|
||||
CreateItem(1, 9),
|
||||
CreateItem(3, 9, 730, Steam.Asset.EType.Emoticon),
|
||||
CreateItem(3, 9, realAppID: 730, type: Steam.Asset.EType.Emoticon),
|
||||
CreateItem(4, realAppID: 730, type: Steam.Asset.EType.Emoticon)
|
||||
};
|
||||
|
||||
|
@ -320,6 +320,6 @@ namespace ArchiSteamFarm.Tests {
|
|||
}
|
||||
|
||||
[NotNull]
|
||||
private static Steam.Asset CreateItem(ulong classID, uint amount = 1, uint realAppID = Steam.Asset.SteamAppID, Steam.Asset.EType type = Steam.Asset.EType.TradingCard) => new Steam.Asset(Steam.Asset.SteamAppID, Steam.Asset.SteamCommunityContextID, classID, amount, realAppID, type);
|
||||
private static Steam.Asset CreateItem(ulong classID, uint amount = 1, bool marketable = true, uint realAppID = Steam.Asset.SteamAppID, Steam.Asset.EType type = Steam.Asset.EType.TradingCard) => new Steam.Asset(Steam.Asset.SteamAppID, Steam.Asset.SteamCommunityContextID, classID, amount, marketable, realAppID, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1066,7 +1066,7 @@ namespace ArchiSteamFarm {
|
|||
return null;
|
||||
}
|
||||
|
||||
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)>();
|
||||
Dictionary<(uint AppID, ulong ClassID), (bool Marketable, uint RealAppID, Steam.Asset.EType Type)> descriptions = new Dictionary<(uint AppID, ulong ClassID), (bool Marketable, uint RealAppID, Steam.Asset.EType Type)>();
|
||||
|
||||
foreach (KeyValue description in response["descriptions"].Children) {
|
||||
uint appID = description["appid"].AsUnsignedInteger();
|
||||
|
@ -1089,6 +1089,8 @@ namespace ArchiSteamFarm {
|
|||
continue;
|
||||
}
|
||||
|
||||
bool marketable = description["marketable"].AsBoolean();
|
||||
|
||||
uint realAppID = 0;
|
||||
Steam.Asset.EType type = Steam.Asset.EType.Unknown;
|
||||
|
||||
|
@ -1104,11 +1106,9 @@ namespace ArchiSteamFarm {
|
|||
if (!string.IsNullOrEmpty(descriptionType)) {
|
||||
type = GetItemType(descriptionType);
|
||||
}
|
||||
}
|
||||
|
||||
bool marketable = description["marketable"].AsBoolean();
|
||||
}
|
||||
|
||||
descriptions[(appID, classID)] = (realAppID, type, marketable);
|
||||
descriptions[(appID, classID)] = (marketable, realAppID, type);
|
||||
}
|
||||
|
||||
HashSet<Steam.TradeOffer> result = new HashSet<Steam.TradeOffer>();
|
||||
|
@ -1439,7 +1439,7 @@ namespace ArchiSteamFarm {
|
|||
return null;
|
||||
}
|
||||
|
||||
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)>();
|
||||
Dictionary<ulong, (bool Marketable, bool Tradable, uint RealAppID, Steam.Asset.EType Type)> descriptions = new Dictionary<ulong, (bool Marketable, bool Tradable, uint RealAppID, Steam.Asset.EType Type)>();
|
||||
|
||||
foreach (Steam.InventoryResponse.Description description in response.Descriptions.Where(description => description != null)) {
|
||||
if (description.ClassID == 0) {
|
||||
|
@ -1465,17 +1465,17 @@ namespace ArchiSteamFarm {
|
|||
}
|
||||
}
|
||||
|
||||
descriptions[description.ClassID] = (description.Tradable, description.Marketable, realAppID, type);
|
||||
descriptions[description.ClassID] = (description.Marketable, description.Tradable, realAppID, type);
|
||||
}
|
||||
|
||||
foreach (Steam.Asset asset in response.Assets.Where(asset => asset != null)) {
|
||||
if (descriptions.TryGetValue(asset.ClassID, out (bool Tradable, bool Marketable, uint RealAppID, Steam.Asset.EType Type) description)) {
|
||||
if (descriptions.TryGetValue(asset.ClassID, out (bool Marketable, bool Tradable, 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.Tradable = description.Tradable;
|
||||
asset.RealAppID = description.RealAppID;
|
||||
asset.Type = description.Type;
|
||||
} else if (tradable.HasValue || (wantedRealAppIDs != null) || (wantedSets != null) || (wantedTypes != null) || (skippedSets != null)) {
|
||||
|
@ -2382,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, bool Marketable)> descriptions, IReadOnlyCollection<KeyValue> input, ICollection<Steam.Asset> output) {
|
||||
private static bool ParseItems(IReadOnlyDictionary<(uint AppID, ulong ClassID), (bool Marketable, uint RealAppID, Steam.Asset.EType Type)> 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));
|
||||
|
||||
|
@ -2422,17 +2422,17 @@ namespace ArchiSteamFarm {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool marketable = true;
|
||||
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, bool Marketable) description)) {
|
||||
if (descriptions.TryGetValue((appID, classID), out (bool Marketable, uint RealAppID, Steam.Asset.EType Type) description)) {
|
||||
marketable = description.Marketable;
|
||||
realAppID = description.RealAppID;
|
||||
type = description.Type;
|
||||
marketable = description.Marketable;
|
||||
}
|
||||
|
||||
Steam.Asset steamAsset = new Steam.Asset(appID, contextID, classID, amount, realAppID, type, marketable);
|
||||
Steam.Asset steamAsset = new Steam.Asset(appID, contextID, classID, amount, marketable, realAppID, type);
|
||||
output.Add(steamAsset);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,15 +54,15 @@ namespace ArchiSteamFarm.Json {
|
|||
[PublicAPI]
|
||||
public uint ContextID { get; private set; }
|
||||
|
||||
[PublicAPI]
|
||||
public bool Marketable { get; internal set; }
|
||||
|
||||
[PublicAPI]
|
||||
public uint RealAppID { get; internal set; }
|
||||
|
||||
[PublicAPI]
|
||||
public bool Tradable { get; internal set; }
|
||||
|
||||
[PublicAPI]
|
||||
public bool Marketable { get; internal set; }
|
||||
|
||||
[PublicAPI]
|
||||
public EType Type { get; internal set; }
|
||||
|
||||
|
@ -160,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, bool marketable = true) {
|
||||
public Asset(uint appID, uint contextID, ulong classID, uint amount, bool marketable = true, uint realAppID = 0, EType type = EType.Unknown) {
|
||||
if ((appID == 0) || (contextID == 0) || (classID == 0) || (amount == 0)) {
|
||||
throw new ArgumentNullException(nameof(appID) + " || " + nameof(contextID) + " || " + nameof(classID) + " || " + nameof(amount));
|
||||
}
|
||||
|
@ -169,9 +169,9 @@ namespace ArchiSteamFarm.Json {
|
|||
ContextID = contextID;
|
||||
ClassID = classID;
|
||||
Amount = amount;
|
||||
Marketable = marketable;
|
||||
RealAppID = realAppID;
|
||||
Type = type;
|
||||
Marketable = marketable;
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
|
@ -442,8 +442,8 @@ namespace ArchiSteamFarm.Json {
|
|||
internal readonly string Type;
|
||||
|
||||
internal ulong ClassID { get; private set; }
|
||||
internal bool Tradable { get; private set; }
|
||||
internal bool Marketable { get; private set; }
|
||||
internal bool Tradable { get; private set; }
|
||||
|
||||
[JsonProperty(PropertyName = "classid", Required = Required.Always)]
|
||||
private string ClassIDText {
|
||||
|
@ -464,16 +464,16 @@ namespace ArchiSteamFarm.Json {
|
|||
}
|
||||
}
|
||||
|
||||
[JsonProperty(PropertyName = "tradable", Required = Required.Always)]
|
||||
private byte TradableNumber {
|
||||
set => Tradable = value > 0;
|
||||
}
|
||||
|
||||
[JsonProperty(PropertyName = "marketable", Required = Required.Always)]
|
||||
private byte MarketableNumber {
|
||||
set => Marketable = value > 0;
|
||||
}
|
||||
|
||||
[JsonProperty(PropertyName = "tradable", Required = Required.Always)]
|
||||
private byte TradableNumber {
|
||||
set => Tradable = value > 0;
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
private Description() { }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue