Ejemplo n.º 1
0
        public void TradeCountInventory()
        {
            Bot.main.Invoke((Action)(() =>
            {
                ShowTrade = new ShowTrade(Bot, Bot.SteamFriends.GetFriendPersonaName(OtherSID));
                ShowTrade.Show();
                ShowTrade.Activate();
            }));
            BackpackTF.CurrentSchema = BackpackTF.FetchSchema();
            // Let's count our inventory
            Thread loadInventory = new Thread(() =>
            {
                Console.WriteLine("Trade window opened.");
                Console.WriteLine("Loading all inventory items.");
                if (Bot.CurrentTrade == null)
                {
                    return;
                }
                Inventory.Item[] inventory = Trade.MyInventory.Items;
                foreach (Inventory.Item item in inventory)
                {
                    if (!item.IsNotTradeable)
                    {
                        var currentItem  = Trade.CurrentSchema.GetItem(item.Defindex);
                        string name      = "";
                        string itemValue = "";
                        var type         = Convert.ToInt32(item.Quality.ToString());
                        if (QualityToName(type) != "Unique")
                        {
                            name += QualityToName(type) + " ";
                        }
                        name += currentItem.ItemName;
                        if (QualityToName(type) == "Unusual")
                        {
                            try
                            {
                                for (int count = 0; count < item.Attributes.Length; count++)
                                {
                                    if (item.Attributes[count].Defindex == 134)
                                    {
                                        name += " (Effect: " + EffectToName(item.Attributes[count].FloatValue) + ")";
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                        if (currentItem.CraftMaterialType == "supply_crate")
                        {
                            for (int count = 0; count < item.Attributes.Length; count++)
                            {
                                name += " #" + (item.Attributes[count].FloatValue);
                                if (item.Attributes[count].Defindex == 186)
                                {
                                    name += " (Gifted)";
                                }
                            }
                        }
                        name += " (Level " + item.Level + ")";
                        try
                        {
                            int size = item.Attributes.Length;
                            for (int count = 0; count < size; count++)
                            {
                                if (item.Attributes[count].Defindex == 261)
                                {
                                    string paint = ShowBackpack.PaintToName(item.Attributes[count].FloatValue);
                                    name        += " (Painted: " + paint + ")";
                                }
                                if (item.Attributes[count].Defindex == 186)
                                {
                                    name += " (Gifted)";
                                }
                            }
                        }
                        catch
                        {
                            // Item has no attributes... or something.
                        }
                        if (item.IsNotCraftable)
                        {
                            name += " (Uncraftable)";
                        }
                        if (currentItem.Name == "Wrapped Gift")
                        {
                            // Untested!
                            try
                            {
                                var containedItem = Trade.CurrentSchema.GetItem(item.ContainedItem.Defindex);
                                var containedName = GetItemName(containedItem, item.ContainedItem, out itemValue);
                                name += " (Contains: " + containedName + ")";
                            }
                            catch (Exception ex)
                            {
                                Bot.Print(ex);
                                // Guess this doesn't work :P.
                            }
                        }
                        string price = Util.GetPrice(item.Defindex, currentItem.ItemQuality, item);
                        ListInventory.Add(name, item.Id, currentItem.ImageURL, price);
                    }
                }
                try
                {
                    ShowTrade.loading = false;
                    Bot.main.Invoke((Action)(() => ShowTrade.list_inventory.SetObjects(ListInventory.Get())));
                }
                catch
                {
                }
            });

            loadInventory.Start();
        }
Ejemplo n.º 2
0
        string GetItemName(Schema.Item schemaItem, Inventory.Item inventoryItem, out string price, bool id = false)
        {
            price = "Unknown";
            bool   isGifted    = false;
            bool   isUnusual   = false;
            var    currentItem = Trade.CurrentSchema.GetItem(schemaItem.Defindex);
            string name        = "";
            var    type        = Convert.ToInt32(inventoryItem.Quality.ToString());

            if (Util.QualityToName(type) != "Unique")
            {
                name += Util.QualityToName(type) + " ";
            }
            name += currentItem.ItemName;
            name += " (" + SteamTrade.Trade.CurrentItemsGame.GetItemRarity(schemaItem.Defindex.ToString()) + ")";
            if (Util.QualityToName(type) == "Unusual")
            {
                isUnusual = true;
                try
                {
                    for (int count = 0; count < inventoryItem.Attributes.Length; count++)
                    {
                        if (inventoryItem.Attributes[count].Defindex == 134)
                        {
                            name += " (Effect: " + Trade.CurrentSchema.GetEffectName(inventoryItem.Attributes[count].FloatValue) + ")";
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            if (currentItem.CraftMaterialType == "supply_crate")
            {
                for (int count = 0; count < inventoryItem.Attributes.Length; count++)
                {
                    name += " #" + (inventoryItem.Attributes[count].FloatValue);
                }
            }
            try
            {
                int size = inventoryItem.Attributes.Length;
                for (int count = 0; count < size; count++)
                {
                    if (inventoryItem.Attributes[count].Defindex == 261)
                    {
                        string paint = ShowBackpack.PaintToName(inventoryItem.Attributes[count].FloatValue);
                        name += " (Painted: " + paint + ")";
                    }
                    if (inventoryItem.Attributes[count].Defindex == 186)
                    {
                        isGifted = true;
                        name    += " (Gifted)";
                    }
                }
            }
            catch
            {
                // Item has no attributes... or something.
            }
            if (inventoryItem.IsNotCraftable)
            {
                name += " (Uncraftable)";
            }
            if (!string.IsNullOrWhiteSpace(inventoryItem.CustomName))
            {
                name += " (Custom Name: " + inventoryItem.CustomName + ")";
            }
            if (!string.IsNullOrWhiteSpace(inventoryItem.CustomDescription))
            {
                name += " (Custom Desc.: " + inventoryItem.CustomDescription + ")";
            }
            if (id)
            {
                name += " :" + inventoryItem.Id;
            }
            if (!isGifted && !isUnusual)
            {
                ListBackpack.Add(name, inventoryItem.Defindex, currentItem.ImageURL, price);
            }
            else
            {
                ListBackpack.Add(name, inventoryItem.Defindex, currentItem.ImageURL, price);
            }
            return(name);
        }
Ejemplo n.º 3
0
        string GetItemName(Schema.Item schemaItem, Inventory.Item inventoryItem, out string price, bool id = false)
        {
            price = "Unknown";
            bool   isGifted    = false;
            bool   isUnusual   = false;
            var    currentItem = Trade.CurrentSchema.GetItem(schemaItem.Defindex);
            string name        = "";
            var    type        = Convert.ToInt32(inventoryItem.Quality.ToString());

            if (QualityToName(type) != "Unique")
            {
                name += QualityToName(type) + " ";
            }
            name += currentItem.ItemName;
            if (QualityToName(type) == "Unusual")
            {
                isUnusual = true;
                try
                {
                    for (int count = 0; count < inventoryItem.Attributes.Length; count++)
                    {
                        if (inventoryItem.Attributes[count].Defindex == 134)
                        {
                            name += " (Effect: " + EffectToName(inventoryItem.Attributes[count].FloatValue) + ")";
                            price = Util.GetPrice(schemaItem.Defindex, type, inventoryItem, false, (int)inventoryItem.Attributes[count].FloatValue);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            if (currentItem.CraftMaterialType == "supply_crate")
            {
                for (int count = 0; count < inventoryItem.Attributes.Length; count++)
                {
                    name += " #" + (inventoryItem.Attributes[count].FloatValue);
                }
            }
            name += " (Level " + inventoryItem.Level + ")";
            try
            {
                int size = inventoryItem.Attributes.Length;
                for (int count = 0; count < size; count++)
                {
                    if (inventoryItem.Attributes[count].Defindex == 261)
                    {
                        string paint = ShowBackpack.PaintToName(inventoryItem.Attributes[count].FloatValue);
                        name += " (Painted: " + paint + ")";
                    }
                    if (inventoryItem.Attributes[count].Defindex == 186)
                    {
                        isGifted = true;
                        name    += " (Gifted)";
                    }
                }
            }
            catch
            {
                // Item has no attributes... or something.
            }
            if (inventoryItem.IsNotCraftable)
            {
                name += " (Uncraftable)";
            }
            if (currentItem.Name == "Wrapped Gift")
            {
                isGifted = true;
                // Untested!
                try
                {
                    int size = inventoryItem.Attributes.Length;
                    for (int count = 0; count < size; count++)
                    {
                        var containedItem = Trade.CurrentSchema.GetItem(inventoryItem.ContainedItem.Defindex);
                        var containedName = GetItemName(containedItem, inventoryItem.ContainedItem, out price, false);
                        price = Util.GetPrice(inventoryItem.ContainedItem.Defindex, Convert.ToInt32(inventoryItem.ContainedItem.Quality.ToString()), inventoryItem, true);
                        name += " (Contains: " + containedName + ")";
                    }
                }
                catch
                {
                    // Item has no attributes... or something.
                }
            }
            if (id)
            {
                name += " :" + inventoryItem.Id;
            }
            if (!isGifted && !isUnusual)
            {
                price = Util.GetPrice(currentItem.Defindex, type, inventoryItem);
                ListBackpack.Add(name, inventoryItem.Defindex, currentItem.ImageURL, price);
            }
            else
            {
                ListBackpack.Add(name, inventoryItem.Defindex, currentItem.ImageURL, price);
            }
            return(name);
        }
Ejemplo n.º 4
0
        public void TradeCountInventory()
        {
            Bot.main.Invoke((Action)(() =>
            {
                ShowTrade = new ShowTrade(Bot, Bot.SteamFriends.GetFriendPersonaName(OtherSID));
                ShowTrade.Show();
                ShowTrade.Activate();
            }));
            // Let's count our inventory
            Thread loadInventory = new Thread(() =>
            {
                Console.WriteLine("Trade window opened.");
                Console.WriteLine("Loading all inventory items.");
                try
                {
                    if (Bot.CurrentTrade == null)
                    {
                        return;
                    }
                    if (Trade.MyInventory == null)
                    {
                        Bot.log.Error("Trade inventory is null!");
                        return;
                    }
                    if (Trade.MyInventory.Items == null)
                    {
                        Bot.log.Error("Trade inventory item list is null!");
                        return;
                    }
                    Inventory.Item[] inventory = Trade.MyInventory.Items;
                    Bot.log.Debug("Adding items to trade inventory list.");
                    if (Trade.CurrentItemsGame == null)
                    {
                        Bot.log.Error("ItemsGame is null!");
                        return;
                    }
                    if (Trade.CurrentSchema == null)
                    {
                        Bot.log.Error("Schema is null!");
                        return;
                    }
                    foreach (Inventory.Item item in inventory)
                    {
                        if (!item.IsNotTradeable)
                        {
                            var currentItem  = Trade.CurrentSchema.GetItem(item.Defindex);
                            string name      = "";
                            string itemValue = "";
                            var type         = Convert.ToInt32(item.Quality.ToString());
                            if (Util.QualityToName(type) != "Unique")
                            {
                                name += Util.QualityToName(type) + " ";
                            }
                            name += currentItem.ItemName;
                            name += " (" + SteamTrade.Trade.CurrentItemsGame.GetItemRarity(item.Defindex.ToString()) +
                                    ")";
                            if (Util.QualityToName(type) == "Unusual")
                            {
                                try
                                {
                                    for (int count = 0; count < item.Attributes.Length; count++)
                                    {
                                        if (item.Attributes[count].Defindex == 134)
                                        {
                                            name += " (Effect: " +
                                                    Trade.CurrentSchema.GetEffectName(item.Attributes[count].FloatValue) +
                                                    ")";
                                        }
                                    }
                                }
                                catch (Exception)
                                {
                                }
                            }
                            try
                            {
                                int size = item.Attributes.Length;
                                for (int count = 0; count < size; count++)
                                {
                                    if (item.Attributes[count].Defindex == 261)
                                    {
                                        string paint = ShowBackpack.PaintToName(item.Attributes[count].FloatValue);
                                        name        += " (Painted: " + paint + ")";
                                    }
                                    if (item.Attributes[count].Defindex == 186)
                                    {
                                        name += " (Gifted)";
                                    }
                                }
                            }
                            catch
                            {
                                // Item has no attributes... or something.
                            }
                            ListInventory.Add(name, item.Id, currentItem.ImageURL);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Bot.log.Error(ex.ToString());
                    return;
                }
                try
                {
                    ShowTrade.loading = false;
                    Bot.main.Invoke((Action)(() => ShowTrade.list_inventory.SetObjects(ListInventory.Get())));
                }
                catch (Exception ex)
                {
                    Bot.log.Error(ex.ToString());
                }
            });

            loadInventory.Start();
        }