private List <Bot.FactoryResource> BuildItem(CommerceItem item, Bot.Location productionLocation) { CommerceItemBuild buildItem = buildItemList.Where(b => b.CommerceItem == item).FirstOrDefault(); if (buildItem == null) { throw new ArgumentOutOfRangeException("CommerceItem item"); } log.Info("Checking if I can Building item " + buildItem.Button.ToString() + " at " + buildItem.Building.ToString()); var store = BuildingMatch.Create().Where(b => b.Building == buildItem.Building).FirstOrDefault(); SelectBuilding(store); var required = resourceReader.GetRequiredResources(buildItem.Button, buildItem.Resources); log.Info("It requires : " + string.Join(",", required)); if (required.Count > 0) { log.Info("I can't I need: " + string.Join(",", required)); return(required); } log.Info("I can ..."); log.Info("Building item " + buildItem.Button.ToString()); touch.Swipe(buildItem.Button, buildItem.Button, productionLocation, 4, true); var requiredFinal = resourceReader.GetRequiredResources(buildItem.Button, buildItem.Resources); log.Info("Finished build item, I need to build: " + string.Join(",", requiredFinal)); return(requiredFinal.ToList()); }
public bool CraftLevel8() { var startFactory = BuildingMatch.Create().Where(b => b.Building == Building.SmallFactory).FirstOrDefault(); SelectBuilding(startFactory); for (var i = 0; i < 8; i++) { PickupItemsFromNextFactory(); } SelectBuilding(startFactory); // Harware store var items1 = BuildItem(CommerceItem.Hammer, Bot.Location.ProductionQueueL8); // Farmers market var items2 = BuildItem(CommerceItem.Vegetable, Bot.Location.ProductionQueueL8); // Building Supplies Store BuildItem(CommerceItem.Nails, Bot.Location.ProductionQueueL8); BuildItem(CommerceItem.Nails, Bot.Location.ProductionQueueL8); var items3 = BuildItem(CommerceItem.Nails, Bot.Location.ProductionQueueL8); var requiredResources = items1.Concat(items2) .Concat(items3) .Distinct() .Where(r => r != FactoryResource.Ignore); log.Info("The factory needs to build: " + string.Join(",", requiredResources)); if (requiredResources.Count() > 0) { SelectBuilding(startFactory); if (requiredResources.Contains(FactoryResource.Metal)) { BuildAtAllL8Factories(FactoryResource.Metal); } else if (requiredResources.Contains(FactoryResource.Wood)) { BuildAtAllL8Factories(FactoryResource.Wood); } else { BuildFactoryItem(FactoryResource.Seeds); touch.ClickAt(Bot.Location.RightButton); BuildFactoryItem(FactoryResource.Seeds); touch.ClickAt(Bot.Location.RightButton); BuildFactoryItem(FactoryResource.Seeds); touch.ClickAt(Bot.Location.RightButton); } return(true); } else { return(false); } }
public static BuildingMatch Get(Building building) { return(BuildingMatch.Create().Where(b => b.Building == building).FirstOrDefault()); }
public bool Craft() { var massProductionFactory = BuildingMatch.Create().Where(b => b.Building == Building.MassProductionFactory).FirstOrDefault(); log.Debug(massProductionFactory.Building.ToString()); ///SelectBuilding(massProductionFactory); return(true); /* * for (var i = 0; i < 8; i++) * { * PickupItemsFromNextFactory(); * } * * // Harware store * var items1 = BuildItem(CommerceItem.Hammer); * * //Furniture store * var items2 = BuildItem(CommerceItem.Table); * if (items2.Contains(FactoryResource.Ignore)) * { * items2 = BuildItem(CommerceItem.Chair); * } * * // Donut shop * //var items6 = BuildItem(CommerceItem.BreadRoll); * //items6 = BuildItem(CommerceItem.GreenSmoothie); * var items6 = BuildItem(CommerceItem.Donut); * * // Home appliances * var items8 = BuildItem(CommerceItem.BBQGrill); * * // Farmers market * var items4 = BuildItem(CommerceItem.FlourBag); * * // Gardening supplies * var items7 = BuildItem(CommerceItem.TreeSapling); * if (items7.Contains(FactoryResource.Ignore)) * { * items7 = BuildItem(CommerceItem.GardenFurniture); * } * * // Fashion store * var items5 = BuildItem(CommerceItem.Cap); * if (items5.Contains(FactoryResource.Ignore)) * { * items5 = BuildItem(CommerceItem.Shoe); * } * if (items5.Contains(FactoryResource.Ignore)) * { * items5 = BuildItem(CommerceItem.Watch); * } * * // Fast food restaurant * BuildItem(CommerceItem.IceCreamSandwich); * * // Building Supplies Store * BuildItem(CommerceItem.Nails); * BuildItem(CommerceItem.Nails); * var items3 = BuildItem(CommerceItem.Nails); * * var requiredResources = items1.Concat(items2) * .Concat(items3).Concat(items4).Concat(items5).Concat(items6).Concat(items7).Concat(items8) * .Distinct() * .Where(r => r != FactoryResource.Ignore); * * log.Info("The factory needs to build: " + string.Join(",", requiredResources)); * * if (requiredResources.Count() > 0) * { * SelectBuilding(massProductionFactory); * * if (requiredResources.Contains(FactoryResource.Metal)) * { * BuildAtAllFactories(FactoryResource.Metal); * } * else if (requiredResources.Contains(FactoryResource.Wood)) * { * BuildAtAllFactories(FactoryResource.Wood); * } * else * { * BuildFactoryItemIfNeeded(FactoryResource.Metal, requiredResources); * touch.ClickAt(Bot.Location.RightButton); * BuildFactoryItemIfNeeded(FactoryResource.Wood, requiredResources); * touch.ClickAt(Bot.Location.RightButton); * * var slowItem = FactoryResource.Textiles; * BuildFactoryItem(slowItem); * touch.ClickAt(Bot.Location.RightButton); * BuildFactoryItem(slowItem); * touch.ClickAt(Bot.Location.RightButton); * BuildFactoryItem(slowItem); * touch.ClickAt(Bot.Location.RightButton); * * BuildFactoryItem(FactoryResource.SugarAndSpices); * touch.ClickAt(Bot.Location.RightButton); * BuildFactoryItemIfNeeded(FactoryResource.Seeds, requiredResources); * touch.ClickAt(Bot.Location.RightButton); * BuildFactoryItemIfNeeded(FactoryResource.Metal, requiredResources); * } * * return true; * } * else * { * return false; * } */ }