Exemplo n.º 1
0
        private List <uint> BuildItemList()
        {
            var idList = new List <uint>();

            string[] entries = ItemID.Split(',');
            if (entries.Length > 0)
            {
                foreach (string entry in entries)
                {
                    uint itemID;
                    if (!uint.TryParse(entry.Trim(), out itemID))
                    {
                        PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim());
                        continue;
                    }
                    idList.Add(itemID);
                }
            }
            else
            {
                PBLog.Warn(Strings["Error_NoItemEntries"]);
                IsDone = true;
            }
            return(idList);
        }
Exemplo n.º 2
0
        List <WoWItem> BuildItemList()
        {
            IEnumerable <WoWItem> tmpItemlist = from item in me.BagItems
                                                where !item.IsConjured && !item.IsSoulbound && !item.IsDisabled
                                                select item;

            if (UseCategory)
            {
                return(tmpItemlist.Where(i => !Pb.ProtectedItems.Contains(i.Entry) &&
                                         i.ItemInfo.ItemClass == Category && subCategoryCheck(i)).Take(12).ToList());
            }
            else
            {
                List <uint> idList  = new List <uint>();
                string[]    entries = ItemID.Split(',');
                if (entries != null && entries.Length > 0)
                {
                    foreach (var entry in entries)
                    {
                        uint temp = 0;
                        uint.TryParse(entry.Trim(), out temp);
                        idList.Add(temp);
                    }
                }
                else
                {
                    Professionbuddy.Err("No ItemIDs are specified");
                    IsDone = true;
                }
                return(tmpItemlist.Where(i => idList.Contains(i.Entry)).Take(12).ToList());
            }
        }
Exemplo n.º 3
0
        private List <AuctionEntry> BuildScanItemList()
        {
            var tmpItemlist = new List <AuctionEntry>();

            if (UseCategory)
            {
                var itemList =
                    StyxWoW.Me.BagItems.Where(
                        i =>
                        !i.IsSoulbound && !i.IsConjured && !i.IsDisabled && !i.IsGiftWrapped && i.ItemInfo.ItemClass == Category &&
                        SubCategoryCheck(i)).ToList();
                foreach (var item in itemList)
                {
                    // skip tradeskill tools. If tools need to be mailed then they should be selected by ID
                    if (ProfessionbuddyBot.Instance.TradeskillTools.Contains(item.Entry))
                    {
                        continue;
                    }
                    // don't add same item id multiple times.
                    if (tmpItemlist.Any(ae => ae.Id == item.Entry))
                    {
                        continue;
                    }
                    // skip items with less than 'StackSize amount in bag if not posting partial stacks.
                    if (!PostPartialStacks && Helpers.InbagCount(item.Entry) < StackSize)
                    {
                        continue;
                    }
                    tmpItemlist.Add(new AuctionEntry(item.Name, item.Entry, 0, 0));
                }
            }
            else
            {
                string[] entries = ItemID.Split(',');
                if (entries.Length > 0)
                {
                    foreach (string entry in entries)
                    {
                        uint itemID;
                        if (!uint.TryParse(entry.Trim(), out itemID))
                        {
                            PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim());
                            continue;
                        }
                        List <WoWItem> itemList = StyxWoW.Me.BagItems.Where(i => !i.IsSoulbound && !i.IsConjured && i.Entry == itemID).ToList();
                        if (!itemList.Any() || !PostPartialStacks && itemList.Count < StackSize)
                        {
                            continue;
                        }
                        tmpItemlist.Add(new AuctionEntry(itemList[0].Name, itemList[0].Entry, 0, 0));
                    }
                }
                else
                {
                    PBLog.Warn(Strings["Error_NoItemEntries"]);
                    IsDone = true;
                }
            }
            return(tmpItemlist);
        }
Exemplo n.º 4
0
        private List <BuyItemEntry> BuildItemList()
        {
            var list   = new List <BuyItemEntry>();
            var idList = new List <uint>();

            string[] entries = ItemID.Split(',');
            if (entries.Length > 0)
            {
                foreach (string entry in entries)
                {
                    uint temp;
                    uint.TryParse(entry.Trim(), out temp);
                    idList.Add(temp);
                }
            }
            else
            {
                Professionbuddy.Err(Pb.Strings["Error_NoItemEntries"]);
                IsDone = true;
            }

            switch (ItemListType)
            {
            case ItemType.Item:
                list.AddRange(idList.Select(id => new BuyItemEntry
                {
                    Id        = id,
                    BuyAmount =
                        (uint)
                        (!BuyAdditively
                                                                       ? Amount - Util.GetCarriedItemCount(id)
                                                                       : Amount)
                }));
                break;

            case ItemType.MaterialList:
                list.AddRange(
                    Pb.MaterialList.Select(kv => new BuyItemEntry {
                    Id = kv.Key, BuyAmount = (uint)kv.Value
                }));
                break;

            case ItemType.RecipeMats:
                list.AddRange(from id in idList
                              select(from tradeskill in Pb.TradeSkillList
                                     where tradeskill.KnownRecipes.ContainsKey(id)
                                     select tradeskill.KnownRecipes[id]).FirstOrDefault()
                              into recipe
                              where recipe != null
                              from ingred in recipe.Ingredients
                              let toBuyAmount =
                                  (int)((ingred.Required * Amount) - Ingredient.GetInBagItemCount(ingred.ID))
                                  where toBuyAmount > 0
                                  select new BuyItemEntry {
                    Id = ingred.ID, BuyAmount = (uint)toBuyAmount
                });
                break;
            }
            return(list);
        }
        Dictionary <uint, int> BuildItemList()
        {
            Dictionary <uint, int> items = new Dictionary <uint, int>();

            switch (GetItemfromBankType)
            {
            case BankWithdrawlItemType.SpecificItem:
                //List<uint> idList = new List<uint>();
                string[] entries = ItemID.Split(',');
                if (entries != null && entries.Length > 0)
                {
                    foreach (var entry in entries)
                    {
                        uint temp = 0;
                        uint.TryParse(entry.Trim(), out temp);
                        items.Add(temp, !WithdrawAdditively?  Amount - (int)Util.GetCarriedItemCount(temp):Amount);
                    }
                }
                else
                {
                    Professionbuddy.Err("No ItemIDs are specified");
                    IsDone = true;
                }
                break;

            case BankWithdrawlItemType.Materials:
                foreach (var kv in Pb.MaterialList)
                {
                    items.Add(kv.Key, kv.Value);
                }
                break;
            }
            return(items);
        }
Exemplo n.º 6
0
        private List <AuctionEntry> BuildScanItemList()
        {
            var tmpItemlist = new List <AuctionEntry>();
            Dictionary <uint, string> myAucs = GetMyAuctions();

            if (UseCategory)
            {
                using (StyxWoW.Memory.AcquireFrame())
                {
                    foreach (var aucKV in myAucs)
                    {
                        ItemInfo info = ItemInfo.FromId(aucKV.Key);
                        if (info != null)
                        {
                            if (info.ItemClass == Category && SubCategoryCheck(info.SubClassId))
                            {
                                tmpItemlist.Add(new AuctionEntry(aucKV.Value, aucKV.Key, 0, 0));
                            }
                        }
                        else
                        {
                            PBLog.Warn("item cache of {0} is null", aucKV.Value);
                        }
                    }
                }
            }
            else
            {
                if (ItemID == "0" || ItemID == "")
                {
                    tmpItemlist.AddRange(myAucs.Select(kv => new AuctionEntry(kv.Value, kv.Key, 0, 0)));
                }
                else
                {
                    string[] entries = ItemID.Split(',');
                    if (entries.Length > 0)
                    {
                        foreach (string entry in entries)
                        {
                            uint itemID;
                            if (!uint.TryParse(entry.Trim(), out itemID))
                            {
                                PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim());
                                continue;
                            }
                            if (myAucs.ContainsKey(itemID))
                            {
                                tmpItemlist.Add(new AuctionEntry(myAucs[itemID], itemID, 0, 0));
                            }
                        }
                    }
                }
            }
            return(tmpItemlist);
        }
        List <AuctionEntry> BuildScanItemList()
        {
            var tmpItemlist = new List <AuctionEntry>();
            Dictionary <uint, string> myAucs = GetMyAuctions();

            if (UseCategory)
            {
                using (new FrameLock())
                {
                    foreach (var aucKV in myAucs)
                    {
                        ItemInfo info = ItemInfo.FromId(aucKV.Key);
                        if (info != null)
                        {
                            if (info.ItemClass == Category && subCategoryCheck(info.SubClassId))
                            {
                                tmpItemlist.Add(new AuctionEntry(aucKV.Value, aucKV.Key, 0, 0));
                            }
                        }
                        else
                        {
                            Professionbuddy.Err("item cache of {0} is null", aucKV.Value);
                        }
                    }
                }
            }
            else
            {
                if (ItemID == "0" || ItemID == "")
                {
                    foreach (var kv in myAucs)
                    {
                        tmpItemlist.Add(new AuctionEntry(kv.Value, kv.Key, 0, 0));
                    }
                }
                else
                {
                    string[] entries = ItemID.Split(',');
                    if (entries != null && entries.Length > 0)
                    {
                        foreach (var entry in entries)
                        {
                            uint id = 0;
                            uint.TryParse(entry.Trim(), out id);
                            if (myAucs.ContainsKey(id))
                            {
                                tmpItemlist.Add(new AuctionEntry(myAucs[id], id, 0, 0));
                            }
                        }
                    }
                }
            }
            return(tmpItemlist);
        }
Exemplo n.º 8
0
        private Dictionary <uint, int> BuildItemList()
        {
            var itemList = new Dictionary <uint, int>();
            IEnumerable <WoWItem> tmpItemlist = from item in Me.BagItems
                                                where !item.IsConjured && !item.IsSoulbound && !item.IsDisabled
                                                select item;

            if (UseCategory)
            {
                foreach (WoWItem item in tmpItemlist)
                {
                    if (item.ItemInfo.ItemClass == Category &&
                        SubCategoryCheck(item) && !itemList.ContainsKey(item.Entry))
                    {
                        itemList.Add(
                            item.Entry,
                            Deposit == DepositWithdrawAmount.Amount
                                                                ? Amount
                                                                : Util.GetCarriedItemCount(item.Entry));
                    }
                }
            }
            else
            {
                string[] entries = ItemID.Split(',');
                if (entries.Length > 0)
                {
                    foreach (string entry in entries)
                    {
                        uint itemID;
                        if (!uint.TryParse(entry.Trim(), out itemID))
                        {
                            PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim());
                            continue;
                        }
                        itemList.Add(
                            itemID,
                            Deposit == DepositWithdrawAmount.Amount
                                                                ? Amount
                                                                : Util.GetCarriedItemCount(itemID));
                    }
                }
                else
                {
                    PBLog.Warn(Strings["Error_NoItemEntries"]);
                    IsDone = true;
                }
            }
            return(itemList);
        }
Exemplo n.º 9
0
        private List <AuctionEntry> BuildScanItemList()
        {
            var            tmpItemlist = new List <AuctionEntry>();
            List <WoWItem> itemList;

            if (UseCategory)
            {
                itemList = ObjectManager.Me.BagItems.
                           Where(i => !i.IsSoulbound && !i.IsConjured && !i.IsDisabled &&
                                 !Pb.ProtectedItems.Contains(i.Entry) &&
                                 i.ItemInfo.ItemClass == Category && SubCategoryCheck(i)).ToList();
                foreach (WoWItem item in itemList)
                {
                    if (!_containsItem(item, tmpItemlist))
                    {
                        tmpItemlist.Add(new AuctionEntry(item.Name, item.Entry, 0, 0));
                    }
                }
            }
            else
            {
                string[] entries = ItemID.Split(',');
                if (entries.Length > 0)
                {
                    foreach (string entry in entries)
                    {
                        uint id;
                        uint.TryParse(entry.Trim(), out id);
                        itemList =
                            ObjectManager.Me.BagItems.Where(i => !i.IsSoulbound && !i.IsConjured && i.Entry == id).
                            ToList();
                        if (itemList.Count > 0)
                        {
                            tmpItemlist.Add(new AuctionEntry(itemList[0].Name, itemList[0].Entry, 0, 0));
                        }
                    }
                }
                else
                {
                    Professionbuddy.Err(Pb.Strings["Error_NoItemEntries"]);
                    IsDone = true;
                }
            }
            return(tmpItemlist);
        }
Exemplo n.º 10
0
        Dictionary <uint, int> BuildItemList()
        {
            Dictionary <uint, int> itemList    = new Dictionary <uint, int>();
            IEnumerable <WoWItem>  tmpItemlist = from item in me.BagItems
                                                 where !item.IsConjured && !item.IsSoulbound && !item.IsDisabled
                                                 select item;

            if (UseCategory)
            {
                foreach (WoWItem item in tmpItemlist)
                {
                    if (!Pb.ProtectedItems.Contains(item.Entry) && item.ItemInfo.ItemClass == Category &&
                        subCategoryCheck(item) && !itemList.ContainsKey(item.Entry))
                    {
                        itemList.Add(item.Entry, Amount);
                    }
                }
            }
            else
            {
                string[] entries = ItemID.Split(',');
                if (entries != null && entries.Length > 0)
                {
                    foreach (var entry in entries)
                    {
                        uint temp = 0;
                        uint.TryParse(entry.Trim(), out temp);
                        itemList.Add(temp, Amount);
                    }
                }
                else
                {
                    Professionbuddy.Err("No ItemIDs are specified");
                    IsDone = true;
                }
            }
            Professionbuddy.Debug("List of items to deposit to bank");
            foreach (var item in itemList)
            {
                Professionbuddy.Debug("Item:{0} Amount:{1}", item.Key, item.Value);
            }
            Professionbuddy.Debug("End of list");
            return(itemList);
        }
Exemplo n.º 11
0
        private Dictionary <uint, int> BuildItemList()
        {
            var itemList = new Dictionary <uint, int>();
            IEnumerable <WoWItem> tmpItemlist = from item in Me.BagItems
                                                where !item.IsConjured && !item.IsSoulbound && !item.IsDisabled
                                                select item;

            if (UseCategory)
            {
                foreach (WoWItem item in tmpItemlist)
                {
                    if (!Pb.ProtectedItems.Contains(item.Entry) && item.ItemInfo.ItemClass == Category &&
                        SubCategoryCheck(item) && !itemList.ContainsKey(item.Entry))
                    {
                        itemList.Add(item.Entry, Mail == DepositWithdrawAmount.Amount
                                                     ? Amount
                                                     : Util.GetCarriedItemCount(item.Entry));
                    }
                }
            }
            else
            {
                string[] entries = ItemID.Split(',');
                if (entries.Length > 0)
                {
                    foreach (string entry in entries)
                    {
                        uint itemID;
                        uint.TryParse(entry.Trim(), out itemID);
                        itemList.Add(itemID, Mail == DepositWithdrawAmount.Amount
                                                 ? Amount
                                                 : Util.GetCarriedItemCount(itemID));
                    }
                }
                else
                {
                    Professionbuddy.Err("No ItemIDs are specified");
                    IsDone = true;
                }
            }
            return(itemList);
        }
        List <uint> BuildItemList()
        {
            List <uint> list = new List <uint>();

            string[] entries = ItemID.Split(',');
            if (entries != null && entries.Length > 0)
            {
                foreach (var entry in entries)
                {
                    uint temp = 0;
                    uint.TryParse(entry.Trim(), out temp);
                    list.Add(temp);
                }
            }
            else
            {
                Professionbuddy.Err("No ItemIDs are specified");
                IsDone = true;
            }
            return(list);
        }
Exemplo n.º 13
0
        private List <uint> BuildItemList()
        {
            var list = new List <uint>();

            string[] entries = ItemID.Split(',');
            if (entries.Length > 0)
            {
                foreach (string entry in entries)
                {
                    uint temp;
                    uint.TryParse(entry.Trim(), out temp);
                    list.Add(temp);
                }
            }
            else
            {
                Professionbuddy.Err(Pb.Strings["Error_NoItemEntries"]);
                IsDone = true;
            }
            return(list);
        }
        private Dictionary <uint, int> BuildItemList()
        {
            var items = new Dictionary <uint, int>();

            switch (GetItemfromBankType)
            {
            case BankWithdrawlItemType.SpecificItem:
                //List<uint> idList = new List<uint>();
                string[] entries = ItemID.Split(',');
                if (entries.Length > 0)
                {
                    foreach (string entry in entries)
                    {
                        uint itemID;
                        if (!uint.TryParse(entry.Trim(), out itemID))
                        {
                            PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim());
                            continue;
                        }
                        if (WithdrawAdditively)
                        {
                            items.Add(itemID, Withdraw == DepositWithdrawAmount.All ? int.MaxValue : Amount);
                        }
                        else
                        {
                            items.Add(itemID, Amount - Util.GetCarriedItemCount(itemID));
                        }
                    }
                }
                break;

            case BankWithdrawlItemType.Materials:
                foreach (var kv in PB.MaterialList)
                {
                    items.Add(kv.Key, kv.Value);
                }
                break;
            }
            return(items);
        }
Exemplo n.º 15
0
 protected override RunStatus Run(object context)
 {
     if (!IsDone)
     {
         if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible)
         {
             WoWPoint movetoPoint = _loc;
             WoWUnit  unit        = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == NpcEntry).
                                    OrderBy(o => o.Distance).FirstOrDefault();
             if (unit != null)
             {
                 movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, unit.Location, 3);
             }
             else if (movetoPoint == WoWPoint.Zero)
             {
                 movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry);
             }
             if (movetoPoint != WoWPoint.Zero && ObjectManager.Me.Location.Distance(movetoPoint) > 4.5)
             {
                 Util.MoveTo(movetoPoint);
             }
             else if (unit != null)
             {
                 unit.Target();
                 unit.Interact();
             }
             if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible &&
                 GossipFrame.Instance.GossipOptionEntries != null)
             {
                 foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries)
                 {
                     if (ge.Type == GossipEntry.GossipEntryType.Vendor)
                     {
                         GossipFrame.Instance.SelectGossipOption(ge.Index);
                         break;
                     }
                 }
             }
         }
         else
         {
             // check if we have merchant frame open at correct NPC
             if (NpcEntry > 0 && Me.GotTarget && Me.CurrentTarget.Entry != NpcEntry)
             {
                 MerchantFrame.Instance.Close();
                 return(RunStatus.Success);
             }
             if (!_concludingSw.IsRunning)
             {
                 if (BuyItemType == BuyItemActionType.SpecificItem)
                 {
                     var      idList  = new List <uint>();
                     string[] entries = ItemID.Split(',');
                     if (entries.Length > 0)
                     {
                         foreach (string entry in entries)
                         {
                             uint temp;
                             uint.TryParse(entry.Trim(), out temp);
                             idList.Add(temp);
                         }
                     }
                     else
                     {
                         Professionbuddy.Err(Pb.Strings["Error_NoItemEntries"]);
                         IsDone = true;
                         return(RunStatus.Failure);
                     }
                     foreach (uint id in idList)
                     {
                         int count = !BuyAdditively ? Count - Util.GetCarriedItemCount(id) : Count;
                         if (count > 0)
                         {
                             BuyItem(id, (uint)count);
                         }
                     }
                 }
                 else if (BuyItemType == BuyItemActionType.Material)
                 {
                     foreach (var kv in Pb.MaterialList)
                     {
                         // only buy items if we don't have enough in bags...
                         int amount = kv.Value - (int)Ingredient.GetInBagItemCount(kv.Key);
                         if (amount > 0)
                         {
                             BuyItem(kv.Key, (uint)amount);
                         }
                     }
                 }
                 _concludingSw.Start();
             }
             if (_concludingSw.ElapsedMilliseconds >= 2000)
             {
                 Professionbuddy.Log("BuyItemAction Completed");
                 IsDone = true;
             }
         }
         if (!IsDone)
         {
             return(RunStatus.Success);
         }
     }
     return(RunStatus.Failure);
 }
Exemplo n.º 16
0
        protected override RunStatus Run(object context)
        {
            if (!IsDone)
            {
                if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible)
                {
                    WoWPoint movetoPoint = loc;
                    WoWUnit  unit        = null;
                    if (_entry == 0)
                    {
                        _entry = NpcEntry;
                    }
                    if (_entry == 0)
                    {
                        MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NearestVendor, 0);
                        var npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                                  ObjectManager.Me.Location, UnitNPCFlags.Vendor);
                        _entry      = (uint)npcResults.Entry;
                        movetoPoint = npcResults.Location;
                    }
                    unit = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == _entry).
                           OrderBy(o => o.Distance).FirstOrDefault();
                    if (unit != null)
                    {
                        movetoPoint = unit.Location;
                    }
                    else if (movetoPoint == WoWPoint.Zero)
                    {
                        movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry);
                    }
                    if (movetoPoint != WoWPoint.Zero && ObjectManager.Me.Location.Distance(movetoPoint) > 4.5)
                    {
                        Util.MoveTo(movetoPoint);
                    }
                    else if (unit != null)
                    {
                        unit.Target();
                        unit.Interact();
                    }

                    if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible &&
                        GossipFrame.Instance.GossipOptionEntries != null)
                    {
                        foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries)
                        {
                            if (ge.Type == GossipEntry.GossipEntryType.Vendor)
                            {
                                GossipFrame.Instance.SelectGossipOption(ge.Index);
                                return(RunStatus.Running);
                            }
                        }
                    }
                }
                else
                {
                    if (SellItemType == SellItemActionType.Specific)
                    {
                        List <uint> idList  = new List <uint>();
                        string[]    entries = ItemID.Split(',');
                        if (entries != null && entries.Length > 0)
                        {
                            foreach (var entry in entries)
                            {
                                uint temp = 0;
                                uint.TryParse(entry.Trim(), out temp);
                                idList.Add(temp);
                            }
                        }
                        else
                        {
                            Professionbuddy.Err("No ItemIDs are specified");
                            IsDone = true;
                            return(RunStatus.Failure);
                        }
                        List <WoWItem> itemList = ObjectManager.Me.BagItems.Where(u => idList.Contains(u.Entry)).Take((int)Count).ToList();
                        if (itemList != null)
                        {
                            using (new FrameLock()) {
                                foreach (WoWItem item in itemList)
                                {
                                    item.UseContainerItem();
                                }
                            }
                        }
                    }
                    else
                    {
                        List <WoWItem>        itemList  = null;
                        IEnumerable <WoWItem> itemQuery = from item in me.BagItems
                                                          where !Pb.ProtectedItems.Contains(item.Entry)
                                                          select item;
                        switch (SellItemType)
                        {
                        case SellItemActionType.Greys:
                            itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Poor).ToList();
                            break;

                        case SellItemActionType.Whites:
                            itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Common).ToList();
                            break;

                        case SellItemActionType.Greens:
                            itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Uncommon).ToList();
                            break;
                        }
                        if (itemList != null)
                        {
                            using (new FrameLock()) {
                                foreach (WoWItem item in itemList)
                                {
                                    item.UseContainerItem();
                                }
                            }
                        }
                    }
                    Professionbuddy.Log("SellItemAction Completed for {0}", ItemID);
                    IsDone = true;
                }
                return(RunStatus.Running);
            }
            return(RunStatus.Failure);
        }
Exemplo n.º 17
0
        protected override async Task Run()
        {
            if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible)
            {
                WoWPoint movetoPoint = _loc;
                if (_entry == 0)
                {
                    _entry = NpcEntry;
                }
                if (_entry == 0)
                {
                    MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NearestVendor, 0);
                    NpcResult npcResults = NpcQueries.GetNearestNpc(
                        StyxWoW.Me.MapId,
                        StyxWoW.Me.Location,
                        UnitNPCFlags.Vendor);
                    _entry      = (uint)npcResults.Entry;
                    movetoPoint = npcResults.Location;
                }
                WoWUnit unit = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == _entry).
                               OrderBy(o => o.Distance).FirstOrDefault();
                if (unit != null)
                {
                    movetoPoint = unit.Location;
                }
                else if (movetoPoint == WoWPoint.Zero)
                {
                    movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry);
                }
                if (movetoPoint != WoWPoint.Zero && StyxWoW.Me.Location.Distance(movetoPoint) > 4.5)
                {
                    Util.MoveTo(movetoPoint);
                }
                else if (unit != null)
                {
                    unit.Target();
                    unit.Interact();
                }

                if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible &&
                    GossipFrame.Instance.GossipOptionEntries != null)
                {
                    foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries)
                    {
                        if (ge.Type == GossipEntry.GossipEntryType.Vendor)
                        {
                            GossipFrame.Instance.SelectGossipOption(ge.Index);
                            return;
                        }
                    }
                }
            }
            else
            {
                if (SellItemType == SellItemActionType.Specific)
                {
                    var      idList  = new List <uint>();
                    string[] entries = ItemID.Split(',');
                    if (entries.Length > 0)
                    {
                        foreach (string entry in entries)
                        {
                            uint itemID;
                            if (!uint.TryParse(entry.Trim(), out itemID))
                            {
                                PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim());
                                continue;
                            }
                            idList.Add(itemID);
                        }
                    }
                    else
                    {
                        PBLog.Warn(Strings["Error_NoItemEntries"]);
                        IsDone = true;
                        return;
                    }
                    List <WoWItem> itemList = StyxWoW.Me.BagItems.Where(u => idList.Contains(u.Entry)).
                                              Take(Sell == DepositWithdrawAmount.All ? int.MaxValue : Count).ToList();
                    using (StyxWoW.Memory.AcquireFrame())
                    {
                        foreach (WoWItem item in itemList)
                        {
                            item.UseContainerItem();
                        }
                    }
                }
                else
                {
                    List <WoWItem>        itemList  = null;
                    IEnumerable <WoWItem> itemQuery = from item in Me.BagItems
                                                      where !ProtectedItemsManager.Contains(item.Entry) &&
                                                      !ProfessionbuddyBot.Instance.TradeskillTools.Contains(item.Entry)
                                                      select item;
                    switch (SellItemType)
                    {
                    case SellItemActionType.Greys:
                        itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Poor).ToList();
                        break;

                    case SellItemActionType.Whites:
                        itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Common).ToList();
                        break;

                    case SellItemActionType.Greens:
                        itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Uncommon).ToList();
                        break;

                    case SellItemActionType.Blues:
                        itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Rare).ToList();
                        break;
                    }
                    if (itemList != null)
                    {
                        using (StyxWoW.Memory.AcquireFrame())
                        {
                            foreach (WoWItem item in itemList)
                            {
                                item.UseContainerItem();
                            }
                        }
                    }
                }
                PBLog.Log("SellItemAction Completed for {0}", ItemID);
                IsDone = true;
            }
        }
Exemplo n.º 18
0
        List <BuyItemEntry> BuildItemList()
        {
            List <BuyItemEntry> list   = new List <BuyItemEntry>();
            List <uint>         idList = new List <uint>();

            string[] entries = ItemID.Split(',');
            if (entries != null && entries.Length > 0)
            {
                foreach (var entry in entries)
                {
                    uint temp = 0;
                    uint.TryParse(entry.Trim(), out temp);
                    idList.Add(temp);
                }
            }
            else
            {
                Professionbuddy.Err("No ItemIDs are specified");
                IsDone = true;
            }

            switch (ItemListType)
            {
            case ItemType.Item:
                foreach (uint id in idList)
                {
                    list.Add(new BuyItemEntry()
                    {
                        Id        = id,
                        BuyAmount = !BuyAdditively ? Amount - Util.GetCarriedItemCount(id) : Amount
                    });
                }
                break;

            case ItemType.MaterialList:
                foreach (var kv in Pb.MaterialList)
                {
                    list.Add(new BuyItemEntry()
                    {
                        Id = kv.Key, BuyAmount = (uint)kv.Value
                    });
                }
                break;

            case ItemType.RecipeMats:
                foreach (uint id in idList)
                {
                    Recipe recipe = (from tradeskill in Pb.TradeSkillList
                                     where tradeskill.Recipes.ContainsKey(id)
                                     select tradeskill.Recipes[id]).FirstOrDefault();
                    if (recipe != null)
                    {
                        foreach (var ingred in recipe.Ingredients)
                        {
                            // subtract whatever material we have in bags already
                            int toBuyAmount = (int)((ingred.Required * Amount) - Ingredient.GetInBagItemCount(ingred.ID));
                            if (toBuyAmount > 0)
                            {
                                list.Add(new BuyItemEntry()
                                {
                                    Id = ingred.ID, BuyAmount = (uint)toBuyAmount
                                });
                            }
                        }
                    }
                }
                break;
            }
            return(list);
        }
Exemplo n.º 19
0
        private Dictionary <uint, int> BuildItemList()
        {
            var itemList = new Dictionary <uint, int>();
            IEnumerable <WoWItem> tmpItemlist = from item in Me.BagItems
                                                where !item.IsConjured && !item.IsSoulbound && !item.IsDisabled
                                                select item;

            switch (ItemSelection)
            {
            case ItemSelectionType.Category:
                foreach (WoWItem item in tmpItemlist)
                {
                    // skip tradeskill tools. If tools need to be mailed then they should be selected by ID
                    if (ProfessionbuddyBot.Instance.TradeskillTools.Contains(item.Entry))
                    {
                        continue;
                    }
                    if (item.ItemInfo.ItemClass == Category &&
                        SubCategoryCheck(item) && !itemList.ContainsKey(item.Entry))
                    {
                        itemList.Add(
                            item.Entry,
                            Mail == DepositWithdrawAmount.Amount
                                                                        ? Amount
                                                                        : Util.GetCarriedItemCount(item.Entry));
                    }
                }
                break;

            case ItemSelectionType.IDs:
                string[] entries = ItemID.Split(',');
                if (entries.Length > 0)
                {
                    foreach (string entry in entries)
                    {
                        uint itemID;
                        if (!uint.TryParse(entry.Trim(), out itemID))
                        {
                            PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim());
                            continue;
                        }
                        itemList.Add(
                            itemID,
                            Mail == DepositWithdrawAmount.Amount
                                                                        ? Amount
                                                                        : Util.GetCarriedItemCount(itemID));
                    }
                }
                else
                {
                    PBLog.Warn("No ItemIDs are specified");
                    IsDone = true;
                }
                break;

            case ItemSelectionType.Quality:
                foreach (WoWItem item in tmpItemlist)
                {
                    // skip tradeskill tools. If tools need to be mailed then they should be selected by ID
                    if (ProfessionbuddyBot.Instance.TradeskillTools.Contains(item.Entry))
                    {
                        continue;
                    }
                    if (item.Quality == ItemQuality)
                    {
                        itemList.Add(
                            item.Entry,
                            Mail == DepositWithdrawAmount.Amount
                                                                        ? Amount
                                                                        : Util.GetCarriedItemCount(item.Entry));
                    }
                }
                break;
            }
            return(itemList);
        }