Пример #1
0
        private static void GenerateOriginalsFile(TechGroup group, TechCategory category, List <TechType> list, string fileName)
        {
            var printyPrints = new List <string>();

            printyPrints.AddRange(EmUtils.CommentTextLinesCentered(new string[]
            {
                "This file was generated with original recipes in the game",
                "You can copy individual entries from this file to use in your personal overrides",
                "--------------------------------------------------------------------------------",
                $"PdaGroup: {group} - PdaCategory:{category}",
                "--------------------------------------------------------------------------------",
            }));

            var originals = new ModifiedRecipeList();

            foreach (TechType craftable in list)
            {
                originals.Add(new ModifiedRecipe(craftable));
            }

            printyPrints.Add(originals.PrettyPrint());

            File.WriteAllLines(FileLocations.OriginalsFolder + fileName, printyPrints.ToArray(), Encoding.UTF8);

            QuickLogger.Debug($"{fileName} file not found. File generated.");
        }
Пример #2
0
        public void CreateFromClases_ThenTest_SampleModifiedRecipes()
        {
            var curedReginaldRecipe = new ModifiedRecipe()
            {
                ItemID        = TechType.CuredReginald.ToString(),
                AmountCrafted = 1,
                Ingredients   =
                {
                    new EmIngredient(TechType.Reginald.ToString(), 1),
                    new EmIngredient(TechType.Salt.ToString(), 1)
                },
                Unlocks =
                {
                    TechType.NutrientBlock.ToString()
                }
            };

            var origRecipeList = new ModifiedRecipeList
            {
                curedReginaldRecipe
            };

            string serialized = origRecipeList.PrettyPrint();

            string samples2File = SampleFileDirectory + "ModifiedRecipes_Samples2.txt";

            File.WriteAllText(samples2File, serialized);

            var readingRecipeList = new ModifiedRecipeList();

            string reserialized = File.ReadAllText(samples2File);

            bool success = readingRecipeList.FromString(reserialized);

            Assert.IsTrue(success);

            Assert.AreEqual(origRecipeList.Count, readingRecipeList.Count);

            // nutrientBlockRecipe
            ModifiedRecipe curedReginald = origRecipeList[0];

            Assert.AreEqual(curedReginald.ItemID, curedReginaldRecipe.ItemID);
            Assert.AreEqual(curedReginald.AmountCrafted, curedReginaldRecipe.AmountCrafted);
            Assert.AreEqual(curedReginald.Ingredients.Count, curedReginaldRecipe.Ingredients.Count);
            Assert.AreEqual(curedReginald.Ingredients[0].ItemID, curedReginaldRecipe.Ingredients[0].ItemID);
            Assert.AreEqual(curedReginald.Ingredients[1].ItemID, curedReginaldRecipe.Ingredients[1].ItemID);
            Assert.AreEqual(curedReginald.Ingredients[0].Required, curedReginaldRecipe.Ingredients[0].Required);
            Assert.AreEqual(curedReginald.Ingredients[1].Required, curedReginaldRecipe.Ingredients[1].Required);
            Assert.AreEqual(curedReginald.ForceUnlockAtStart, curedReginaldRecipe.ForceUnlockAtStart);
            Assert.AreEqual(curedReginald.Unlocks.Count, curedReginaldRecipe.Unlocks.Count);
            Assert.AreEqual(curedReginald.Unlocks[0], curedReginaldRecipe.Unlocks[0]);
        }
        public void CreateFromClases_ThenTest_SampleModifiedRecipes()
        {
            var curedReginaldRecipe = new ModifiedRecipe()
            {
                ItemID        = TechType.CuredReginald,
                AmountCrafted = 1,
            };

            curedReginaldRecipe.AddUnlock(TechType.NutrientBlock);
            curedReginaldRecipe.AddIngredient(TechType.Reginald, 1);
            curedReginaldRecipe.AddIngredient(TechType.Salt, 1);

            var origRecipeList = new ModifiedRecipeList
            {
                curedReginaldRecipe
            };

            string serialized = origRecipeList.PrettyPrint();

            string samples2File = SampleFileDirectory + "ModifiedRecipes_Samples2.txt";

            File.WriteAllText(samples2File, serialized);

            var readingRecipeList = new ModifiedRecipeList();

            string reserialized = File.ReadAllText(samples2File);

            bool success = readingRecipeList.FromString(reserialized);

            Assert.IsTrue(success);

            Assert.AreEqual(origRecipeList.Count, readingRecipeList.Count);

            // nutrientBlockRecipe
            ModifiedRecipe curedReginald = origRecipeList[0];

            Assert.AreEqual(curedReginald.ItemID, curedReginaldRecipe.ItemID);
            Assert.AreEqual(curedReginald.AmountCrafted, curedReginaldRecipe.AmountCrafted);
            Assert.AreEqual(curedReginald.IngredientsCount, curedReginaldRecipe.IngredientsCount);
            Assert.AreEqual(curedReginald.GetIngredient(0).ItemID, curedReginaldRecipe.GetIngredient(0).ItemID);
            Assert.AreEqual(curedReginald.GetIngredient(1).ItemID, curedReginaldRecipe.GetIngredient(1).ItemID);
            Assert.AreEqual(curedReginald.GetIngredient(0).Required, curedReginaldRecipe.GetIngredient(0).Required);
            Assert.AreEqual(curedReginald.GetIngredient(1).Required, curedReginaldRecipe.GetIngredient(1).Required);
            Assert.AreEqual(curedReginald.ForceUnlockAtStart, curedReginaldRecipe.ForceUnlockAtStart);
            Assert.AreEqual(curedReginald.UnlocksCount, curedReginaldRecipe.UnlocksCount);
            Assert.AreEqual(curedReginald.GetUnlock(0), curedReginaldRecipe.GetUnlock(0));
        }
        public void Deserialize_Other()
        {
            const string sample = "ModdifiedRecipes: " +
                                  "(ItemID:FiberMesh; AmountCrafted:1; Ingredients:(ItemID:CreepvinePiece; Required:1; ); )," +
                                  "(ItemID:Silicone; AmountCrafted:1; Ingredients:(ItemID:CreepvineSeedCluster; Required:1; ); )," +
                                  "(ItemID:PrecursorIonBattery; AmountCrafted:1; Ingredients:(ItemID:PrecursorIonCrystal; Required:1; ), (ItemID:Gold; Required:1; ), (ItemID:Silver; Required:1; ), (ItemID:Battery; Required:1; ); )," +
                                  "(ItemID:PrecursorIonPowerCell; AmountCrafted:1;Ingredients:(ItemID:PrecursorIonBattery; Required:2; ), (ItemID:Silicone; Required:1; ), (ItemID:PowerCell; Required:1; ); )," +
                                  "(ItemID:FilteredWater; AmountCrafted:2; Ingredients:(ItemID:Bladderfish; Required:1; ); )," +
                                  "(ItemID:FireExtinguisher; AmountCrafted:1; Ingredients:(ItemID:Titanium; Required:1; ); )," +
                                  "(ItemID:PrecursorKey_Purple; AmountCrafted:1; Ingredients:(ItemID:PrecursorIonCrystal; Required:1; ), (ItemID:Diamond; Required:1; ); ); ";

            var recipes = new ModifiedRecipeList();

            bool success = recipes.FromString(sample);

            Assert.IsTrue(success);

            Console.WriteLine(recipes.PrettyPrint());
        }
Пример #5
0
        private static void GenerateOriginalsFile(string key, List <TechType> list, string fileName)
        {
            var printyPrints = new List <string>();

            printyPrints.AddRange(EmUtils.CommentTextLinesCentered(new string[]
            {
                "This file was generated with original recipes in the game",
                "You can copy individual entries from this file to use in your personal overrides",
                "--------------------------------------------------------------------------------",
            }));

            var originals = new ModifiedRecipeList();

            foreach (TechType craftable in list)
            {
                originals.Add(new ModifiedRecipe(craftable));
            }

            printyPrints.Add(originals.PrettyPrint());

            File.WriteAllLines(OriginalsFolder + fileName, printyPrints.ToArray());

            Logger.Log($"{fileName} file not found. File generated.");
        }