Ejemplo n.º 1
0
        public Planner(string configFile, string sortConfigName)
        {
            ConfigFile = configFile;

            string            json    = File.ReadAllText(Directory.GetCurrentDirectory() + "\\" + configFile);
            JObject           jObject = JObject.Parse(json);
            List <SortConfig> configs = JsonConvert.DeserializeObject <List <SortConfig> >(jObject["sortConfigs"].ToString());

            config = configs.Where(x => x.name == sortConfigName).Single();

            InitializeInventory();
            InitializeStashData();
            CreatePlan();
        }
Ejemplo n.º 2
0
        public static bool ControlChaosRecipeReqs(ItemTab target, Item item, SortConfig config)
        {
            var ChaosTabsSource       = config.targetTabs.Where(x => x.chaosRecipeCount > 0);
            var ChaosTabsSourceSorted = ChaosTabsSource.OrderBy(x => x.order).ToList();

            foreach (TargetTab tab in ChaosTabsSourceSorted)
            {
                int matchesCount = 0;

                foreach (Item i in target.items)
                {
                    if (MatchTargetTabItem(i, tab))
                    {
                        matchesCount++;
                    }
                }

                bool thisType = false;
                if (MatchTargetTabItem(item, tab))
                {
                    thisType = true;
                }

                if (thisType == false)
                {
                    if (matchesCount != tab.chaosRecipeCount)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (matchesCount >= tab.chaosRecipeCount)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public static bool MoveItemToChaosRecipeTab(ItemTab source, ItemTab target, Item item, MoveOrganizer organizer, SortConfig config)
        {
            Item itemCopy = new Item();

            itemCopy.inventoryId = item.inventoryId;
            itemCopy.x           = item.x;
            itemCopy.y           = item.y;

            if (!ControlChaosRecipeReqs(target, item, config))
            {
                return(false);
            }

            bool removed = source.RemoveItem(item);
            bool added   = target.AddItem(item);

            if (added == false)
            {
                //Failed add, insert item in List<Item> for source again
                source.items.Add(item);
            }
            else
            {
                organizer.MoveItem(source, target, itemCopy);
            }

            return(removed && added);
        }