public void TradingSingleGameNeutralAccept() { Steam.Item item1 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 1, 1, 570, Steam.Item.EType.TradingCard); Steam.Item item2 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 2, 1, 570, Steam.Item.EType.TradingCard); HashSet <Steam.Item> inventory = new HashSet <Steam.Item> { item1 }; HashSet <Steam.Item> itemsToGive = new HashSet <Steam.Item> { item1 }; HashSet <Steam.Item> itemsToReceive = new HashSet <Steam.Item> { item2 }; Assert.IsTrue(AcceptsTrade(inventory, itemsToGive, itemsToReceive)); }
public void TradingMultiGameMultiTypeNeutralAccept() { Steam.Item item1Type1Game1 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 1, 1, 570, Steam.Item.EType.TradingCard); Steam.Item item1Type1Game1X9 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 1, 9, 570, Steam.Item.EType.TradingCard); Steam.Item item2Type1Game1 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 2, 1, 570, Steam.Item.EType.TradingCard); Steam.Item item3Type2Game2 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 3, 1, 730, Steam.Item.EType.Emoticon); Steam.Item item4Type2Game2 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 4, 1, 730, Steam.Item.EType.Emoticon); HashSet <Steam.Item> inventory = new HashSet <Steam.Item> { item1Type1Game1X9, item3Type2Game2 }; HashSet <Steam.Item> itemsToGive = new HashSet <Steam.Item> { item1Type1Game1, item3Type2Game2 }; HashSet <Steam.Item> itemsToReceive = new HashSet <Steam.Item> { item2Type1Game1, item4Type2Game2 }; Assert.IsTrue(AcceptsTrade(inventory, itemsToGive, itemsToReceive)); }
public void TradingMultiGameBadReject() { Steam.Item item1Game1 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 1, 1, 570, Steam.Item.EType.TradingCard); Steam.Item item1Game1X9 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 1, 9, 570, Steam.Item.EType.TradingCard); Steam.Item item2Game1 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 2, 1, 570, Steam.Item.EType.TradingCard); Steam.Item item1Game2 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 3, 1, 730, Steam.Item.EType.TradingCard); Steam.Item item2Game2 = new Steam.Item(Steam.Item.SteamAppID, Steam.Item.SteamCommunityContextID, 4, 1, 730, Steam.Item.EType.TradingCard); HashSet <Steam.Item> inventory = new HashSet <Steam.Item> { item1Game1X9, item1Game2, item2Game2 }; HashSet <Steam.Item> itemsToGive = new HashSet <Steam.Item> { item1Game1, item1Game2 }; HashSet <Steam.Item> itemsToReceive = new HashSet <Steam.Item> { item2Game1, item2Game2 }; Assert.IsFalse(AcceptsTrade(inventory, itemsToGive, itemsToReceive)); }
private static bool ParseItems(Dictionary<ulong, Tuple<uint, Steam.Item.EType>> descriptions, List<KeyValue> input, HashSet<Steam.Item> output) { if ((descriptions == null) || (input == null) || (input.Count == 0) || (output == null)) { ASF.ArchiLogger.LogNullError(nameof(descriptions) + " || " + nameof(input) + " || " + nameof(output)); return false; } foreach (KeyValue item in input) { uint appID = item["appid"].AsUnsignedInteger(); if (appID == 0) { ASF.ArchiLogger.LogNullError(nameof(appID)); return false; } ulong contextID = item["contextid"].AsUnsignedLong(); if (contextID == 0) { ASF.ArchiLogger.LogNullError(nameof(contextID)); return false; } ulong classID = item["classid"].AsUnsignedLong(); if (classID == 0) { ASF.ArchiLogger.LogNullError(nameof(classID)); return false; } uint amount = item["amount"].AsUnsignedInteger(); if (amount == 0) { ASF.ArchiLogger.LogNullError(nameof(amount)); return false; } uint realAppID = appID; Steam.Item.EType type = Steam.Item.EType.Unknown; Tuple<uint, Steam.Item.EType> description; if (descriptions.TryGetValue(classID, out description)) { realAppID = description.Item1; type = description.Item2; } Steam.Item steamItem = new Steam.Item(appID, contextID, classID, amount, realAppID, type); output.Add(steamItem); } return true; }