Ejemplo n.º 1
0
 static bool hasEnoughGold(BuildItem item)
 {
     return(ObjectManager.Player.Gold >= ItemController.GetItemCost(item.Id));
 }
Ejemplo n.º 2
0
        private static void buyOrSellItems()
        {
            try
            {
                if (CurrentBuild == null)
                {
                    return;
                }
                if (CurrentBuild.Items.Count != 0)
                {
                    var buildItem = CurrentBuild.Items[0];
                    if (buildItem != null)
                    {
                        if (buildItem.Sell)
                        {
                            ItemController.SellItemId(buildItem.Id);
                            Chat.Print("Sold item: " + buildItem.Name);
                            CurrentBuild.Items.Remove(buildItem);
                        }
                        else
                        {
                            if (Item.HasItem(buildItem.Id, ObjectManager.Player))
                            {
                                Chat.Print("Already had item: " + buildItem.Name);
                                Chat.Print("Removing item:" + CurrentBuild.Items[0].Name);
                                CurrentBuild.Items.RemoveAt(0);
                                Chat.Print("Items to buy count: " + CurrentBuild.Items.Count);
                            }
                            else
                            {
                                if (hasEnoughGold(buildItem))
                                {
                                    ItemController.BuyItemId(buildItem.Id);
                                    Chat.Print("Bought item: " + buildItem.Name);
                                    Chat.Print("Removing item:" + CurrentBuild.Items[0].Name);
                                    CurrentBuild.Items.RemoveAt(0);
                                    Chat.Print("Items to buy count: " + CurrentBuild.Items.Count);
                                }
                                else
                                {
                                    if (buildItem.BuildFrom.Count != 0)
                                    {
                                        var itemToBuy = buildItem.BuildFrom[0];
                                        if (itemToBuy.BuildFrom.Count != 0)
                                        {
                                            var tmp = itemToBuy.BuildFrom[0];
                                            if (hasEnoughGold(tmp))
                                            {
                                                Chat.Print("Removed sub sub item:: " + tmp.Name);
                                                itemToBuy.BuildFrom.RemoveAt(0);
                                                //Buy tmp
                                                ItemController.BuyItemId(tmp.Id);
                                                Chat.Print("Bought sub sub item: " + tmp.Name);
                                            }
                                        }
                                        else
                                        {
                                            if (hasEnoughGold(itemToBuy))
                                            {
                                                Chat.Print("Removed sub item: " + itemToBuy.Name);
                                                buildItem.BuildFrom.RemoveAt(0);

                                                ItemController.BuyItemId(itemToBuy.Id);
                                                Chat.Print("Bought sub item: " + itemToBuy.Name);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                PotionController.BuyOrSellPotions();
            }
            catch (Exception)
            {
            }
            isShopping = false;
        }