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(); }
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); }
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); }