public static StashItemsFiltered RemoveItem(Dictionary <ItemType, List <StashItemsFiltered> > items, ItemType type, ref bool needLowLvl)
        {
            bool temp = needLowLvl;
            StashItemsFiltered thisItem = null;

            if (!type.IsWeapon())
            {
                thisItem = ChooseItem(items[type], ref needLowLvl);
            }
            else
            {
                List <StashItemsFiltered> weapons2h = items[ItemType.Wep2h].Where(i => i.category == ItemType.Wep2h).ToList();
                List <StashItemsFiltered> weapons1h = items[ItemType.Wep1h].Where(i => i.category == ItemType.Wep1h).ToList();
                if (weapons2h.Count > 0)
                {
                    thisItem = ChooseItem(weapons2h, ref needLowLvl);
                }
                else
                {
                    thisItem = ChooseItem(weapons1h, ref needLowLvl);
                }
            }
            items[type].Remove(thisItem);

            return(thisItem);
        }
Exemple #2
0
        public static StashItemsFiltered Copy(StashItemsFiltered inputItem)
        {
            StashItemsFiltered result = new StashItemsFiltered();

            result.category       = inputItem.category;
            result.subCategory    = inputItem.subCategory;
            result.icon           = inputItem.icon;
            result.id             = inputItem.id;
            result.itlvl          = inputItem.itlvl;
            result.typeName       = inputItem.typeName;
            result.x              = inputItem.x;
            result.y              = inputItem.y;
            result.w              = inputItem.w;
            result.h              = inputItem.h;
            result.quadLayout     = inputItem.quadLayout;
            result.picked         = inputItem.picked;
            result.identified     = inputItem.identified;
            result.frameType      = inputItem.frameType;
            result.inventoryIndex = inputItem.inventoryIndex;
            return(result);
        }
        public static List <StashItemsFiltered> MakeSets(Dictionary <ItemType, List <StashItemsFiltered> > itemsPerType)
        {
            List <StashItemsFiltered> result = new List <StashItemsFiltered>();
            bool needLowLvl     = true;
            bool weaponsChoosen = false;

            foreach (var itemTypeEntry in itemsPerType)
            {
                if (itemTypeEntry.Key.ToString() != "Wep1h" && itemTypeEntry.Key.ToString() != "Wep2h")
                {
                    StashItemsFiltered newItem = RemoveItem(itemsPerType, itemTypeEntry.Key, ref needLowLvl);
                    result.Add(newItem);// (newItem.category+" iLvl:"+newItem.itlvl + " id:" + newItem.id);

                    if (newItem.category == ItemType.Ring)
                    {
                        StashItemsFiltered secondRing = RemoveItem(itemsPerType, itemTypeEntry.Key, ref needLowLvl);
                        result.Add(secondRing); //(secondRing.category + " iLvl:" + newItem.itlvl + " id:" + secondRing.id);
                    }
                }
                else
                {
                    if (weaponsChoosen)
                    {
                        continue;
                    }
                    StashItemsFiltered wep = RemoveItem(itemsPerType, itemTypeEntry.Key, ref needLowLvl);
                    result.Add(wep);
                    if (wep.typeName == "Wep1h")
                    {
                        StashItemsFiltered wep2nd = RemoveItem(itemsPerType, itemTypeEntry.Key, ref needLowLvl);
                        result.Add(wep2nd);
                    }
                    weaponsChoosen = true;
                }
            }
            return(result);
        }
        public void PickSetButtonClick()
        {
            List <StashItemsFiltered> set = null;
            int setsNo = SetCalculation.HowManySets(itemsPerType);

            if (setsNo > 0)
            {
                Dictionary <ItemType, List <StashItemsFiltered> > itemsPerTypeCopy = new Dictionary <ItemType, List <StashItemsFiltered> >();
                foreach (var typeEntry in itemsPerType)
                {
                    List <StashItemsFiltered> newList = new List <StashItemsFiltered>();
                    foreach (StashItemsFiltered item in typeEntry.Value)
                    {
                        StashItemsFiltered newItem = StashItemsFiltered.Copy(item);
                        newList.Add(newItem);
                    }
                    itemsPerTypeCopy.Add(typeEntry.Key, newList);
                }

                set = SetCalculation.MakeSets(itemsPerTypeCopy);

                kb.SendDown(Keys.ControlKey);
                {
                    foreach (StashItemsFiltered item in set)
                    {
                        Tuple <int, int> click = Coordinates.GetClickCoordinates(item.x, item.y, item.quadLayout);
                        Thread.Sleep(50);
                        mouse.MouseLeftClick(click.Item1, click.Item2);
                    }
                }
                kb.SendUp(Keys.ControlKey);

                SetItemsPicked(set);
                Thread.Sleep(2000);
                RefreshStash();
            }
        }
        public static StashItemsFiltered ChooseItem(List <StashItemsFiltered> items, ref bool needLowLvl)
        {
            Debug.Write("need low: " + needLowLvl + " ");
            StashItemsFiltered result = null;

            if (needLowLvl)
            {
                foreach (var item in items)
                {
                    if (item.picked)
                    {
                        continue;
                    }
                    if (item.identified)
                    {
                        continue;
                    }
                    if (item.frameType != 2)
                    {
                        continue;
                    }
                    if (item.itlvl < 75)
                    {
                        result     = item;
                        needLowLvl = false;
                        break;
                    }
                }
            }
            else
            {
                foreach (var item in items)
                {
                    if (item.picked)
                    {
                        continue;
                    }
                    if (item.identified)
                    {
                        continue;
                    }
                    if (item.frameType != 2)
                    {
                        continue;
                    }
                    if (item.itlvl > 74)
                    {
                        result = item;
                        break;
                    }
                }
            }
            if (result == null)
            {
                foreach (var item in items)
                {
                    if (item.picked)
                    {
                        continue;
                    }
                    if (item.identified)
                    {
                        continue;
                    }
                    if (item.frameType != 2)
                    {
                        continue;
                    }
                    result = item;
                    break;
                }
            }
            Debug.Write(result.typeName + " " + result.itlvl + Environment.NewLine);
            return(result);
        }
Exemple #6
0
        public static List <StashItemsFiltered> GetSetCollectionItemsFromWeb(Account acc, DataGridView gridTabsUsage)
        {
            List <int> setTabsIndexes = new List <int>();

            for (int r = 0; r < gridTabsUsage.Rows.Count; r++)
            {
                if (gridTabsUsage.Rows[r].Cells["Usage"].Value.ToString() == "SetCollection")
                {
                    setTabsIndexes.Add(r);
                }
            }
            List <StashItemsFiltered> result = new List <StashItemsFiltered>();

            foreach (var tabIndex in setTabsIndexes)
            {
                string url  = "https://pathofexile.com/character-window/get-stash-items?league=bestiary&tabs=0&tabIndex=" + tabIndex + "&accountName=" + acc.Name;
                string json = WebTools.getPrivateStashJSON(acc, url);
                //do to: read cookie expiration date, read new cookie only when expired.
                //string json = WebTools.getPrivateStashJSON("8dcfe28b4cd5d1ca884e2f2d539f8057", url);

                JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                jsonSerializer.MaxJsonLength = Int32.MaxValue;
                PrivateStash ro = jsonSerializer.Deserialize <PrivateStash>(json);

                foreach (var item in ro.items)
                {
                    StashItemsFiltered newItem = new StashItemsFiltered();
                    newItem.quadLayout = ro.quadLayout;
                    Dictionary <string, object> bla = (Dictionary <string, object>)item;

                    foreach (var propertyEntry in bla)
                    {
                        switch (propertyEntry.Key)
                        {
                        case "category":
                        {
                            Dictionary <string, object> categoryDict = (Dictionary <string, object>)propertyEntry.Value;

                            String typeLine = "";
                            String icon     = "";
                            if (bla.ContainsKey("typeLine"))
                            {
                                typeLine = (String)bla["typeLine"];
                            }

                            if (bla.ContainsKey("icon"))
                            {
                                icon = (String)bla["icon"];
                            }

                            foreach (var categoryEntry in categoryDict)
                            {
                                if (categoryEntry.Key == "maps" && typeLine.Contains("Offering"))
                                {
                                    newItem.category = ItemType.Fragment;
                                }
                                else if (categoryEntry.Key == "armour" || categoryEntry.Key == "accessories")
                                {
                                    String subcat = (String)((object[])categoryEntry.Value)[0];
                                    newItem.category = ItemTypeUtils.FromString(subcat);
                                }
                                else if (categoryEntry.Key == "weapons")
                                {
                                    if (icon.Contains("OneHand"))
                                    {
                                        newItem.category = ItemType.Wep1h;
                                    }
                                    else if (icon.Contains("TwoHand"))
                                    {
                                        newItem.category = ItemType.Wep2h;
                                    }
                                    else
                                    {
                                        throw new NotImplementedException("not implemented wep recognition");
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        newItem.category = ItemTypeUtils.FromString(categoryEntry.Key);
                                    }
                                    catch (Exception e)
                                    {
                                        Debug.WriteLine("eh.");
                                    }
                                }

                                object[] subCat = (object[])categoryEntry.Value;
                                if (subCat.Count() > 0)
                                {
                                    newItem.subCategory = subCat[0].ToString();
                                }
                            }
                            break;
                        }

                        case "typeLine":
                        {
                            string typeLinel = (string)propertyEntry.Value;
                            newItem.typeName = typeLinel;
                            break;
                        }

                        case "icon":
                        {
                            string icon = (string)propertyEntry.Value;
                            newItem.icon = icon;
                            break;
                        }

                        case "id":
                        {
                            string id = (string)propertyEntry.Value;
                            newItem.id = id;
                            break;
                        }

                        case "ilvl":
                        {
                            Int32 ilvl = (Int32)propertyEntry.Value;
                            newItem.itlvl = ilvl;
                            break;
                        }

                        case "x":
                        {
                            Int32 x = (Int32)propertyEntry.Value;
                            newItem.x = x;
                            break;
                        }

                        case "y":
                        {
                            Int32 y = (Int32)propertyEntry.Value;
                            newItem.y = y;
                            break;
                        }

                        case "w":
                        {
                            Int32 w = (Int32)propertyEntry.Value;
                            newItem.w = w;
                            break;
                        }

                        case "h":
                        {
                            Int32 h = (Int32)propertyEntry.Value;
                            newItem.h = h;
                            break;
                        }

                        case "identified":
                        {
                            bool identified = (bool)propertyEntry.Value;
                            newItem.identified = identified;
                            break;
                        }

                        case "frameType":
                        {
                            Int32 frameType = (Int32)propertyEntry.Value;
                            newItem.frameType = frameType;
                            break;
                        }

                        case "inventoryId":
                        {
                            int inventoryId = int.Parse(((string)propertyEntry.Value).Replace("Stash", ""));
                            newItem.inventoryIndex = inventoryId;
                            break;
                        }
                        }
                    }

                    result.Add(newItem);
                }
            }
            return(result);
        }