Exemplo n.º 1
0
        int MergePrimaryResultRecipes(Item source, Item target)
        {
            var asResult = _recipeRepository.GetByPrimaryResult(source).ToArray();

            foreach (var r in asResult)
            {
                r.Result = target;
                _recipeRepository.Save(r);
            }
            return(asResult.Length);
        }
Exemplo n.º 2
0
        public static bool RecipeIsDuplicate(Recipe recipe, RecipeRepository repo)
        {
            var existing = repo.GetByPrimaryResult(recipe.Result).ToArray();

            if (!existing.Any())
            {
                return(false);
            }

            return(existing.Any(p => RecipesAreEqual(recipe, p)));
        }
Exemplo n.º 3
0
        public static void ImportRecipes(string headerPath, string materialPath)
        {
            string header;

            using (var sr = new StreamReader(headerPath))
                header = sr.ReadToEnd();


            string materials;

            using (var sr = new StreamReader(materialPath))
                materials = sr.ReadToEnd();


            using (var itemrepo = new ItemRepository())
            {
                var parser = new RecipeParser(itemrepo, new RecipeParserSettings(), header, string.Empty, materials);

                using (var reciperepo = new RecipeRepository())
                {
                    reciperepo.Begin();
                    foreach (var recipe in parser.Recipes)
                    {
                        var  existing = reciperepo.GetByPrimaryResult(recipe.Result);
                        bool skip     = false;
                        foreach (var e in existing)
                        {
                            var match = true;
                            foreach (var kvp in recipe.Materials)
                            {
                                if (!e.Materials.ContainsKey(kvp.Key) || e.Materials[kvp.Key] != kvp.Value)
                                {
                                    match = false;
                                }
                            }
                            if (match)
                            {
                                skip = true;
                            }
                        }

                        if (skip)
                        {
                            Console.WriteLine($"Skipping duplicate recipe for {recipe.Result.Name}");
                            continue;
                        }

                        reciperepo.Save(recipe);
                    }
                    reciperepo.End();
                }
            }
        }
Exemplo n.º 4
0
        void Cleanup(ItemRepository itemRepository, RecipeRepository recipeRepository)
        {
            foreach (var metal in GetOreTypes())
            {
                var crystal = $"Crystal {metal} Pure";
                var i       = itemRepository.GetByName(crystal).FirstOrDefault();
                if (i == null)
                {
                    continue;
                }

                foreach (var r in i.MadeFrom)
                {
                    recipeRepository.Delete(r);
                }

                itemRepository.Delete(i);
            }

            return;

            var item    = itemRepository.GetByName("Sapphire").FirstOrDefault();
            var recipes = recipeRepository.GetByPrimaryResult(item);

            foreach (var r in recipes)
            {
                recipeRepository.Delete(r);
            }

            item    = itemRepository.GetByName("Diamond").FirstOrDefault();
            recipes = recipeRepository.GetByPrimaryResult(item);
            foreach (var r in recipes)
            {
                recipeRepository.Delete(r);
            }
        }