public void BatteriesContainThreeIngredientsTest() { var recipes = RecipeRandomizer.Randomize(Environment.CurrentDirectory); Assert.IsNotNull(recipes); Assert.IsTrue(recipes.RecipesByType.ContainsKey((int)TechType.Battery)); Assert.IsTrue(recipes.RecipesByType[(int)TechType.Battery].Ingredients.Sum(i => i.Amount) == 3); }
private static void ManageSettingsFile() { string settingsPath = Path.Combine(GetSubnauticaRandomizerDirectory(), "config.json"); if (File.Exists(settingsPath)) { try { Settings.Instance = JsonConvert.DeserializeObject <Settings>(File.ReadAllText(settingsPath)); } catch (Exception ex) { LogError("Error parsing config.json"); LogError(ex.ToString()); Settings.Instance = new Settings(); } } else { Settings.Instance = new Settings(); } if (string.IsNullOrEmpty(Settings.Instance.RecipeSeed)) { var recipes = RecipeRandomizer.Randomize(QPatch.GetSubnauticaRandomizerDirectory()); if (recipes.RecipesByType.Values.Count > 0) { Settings.Instance.RecipeSeed = recipes.ToBase64String(); WriteSettingsFile(settingsPath); } Settings.Instance.Recipes = recipes; } else { try { Settings.Instance.Recipes = Recipes.FromBase64String(Settings.Instance.RecipeSeed); } catch (Exception ex) { LogError(ex.ToString()); Settings.Instance.Recipes = new Recipes(); } WriteSettingsFile(settingsPath); } }