Handling for renamed or removed Recipes

This commit is contained in:
Sn0wStorm
2013-09-05 17:45:44 +02:00
parent 8a5f19899c
commit 4bd011f232
2 changed files with 22 additions and 3 deletions
+21 -2
View File
@@ -47,14 +47,33 @@ public class Brew {
// loading from file
public Brew(int uid, BIngredients ingredients, int quality, int distillRuns, float ageTime, float wood, String recipe, Boolean unlabeled) {
potions.put(uid, this);
this.ingredients = ingredients;
this.quality = quality;
this.distillRuns = distillRuns;
this.ageTime = ageTime;
this.wood = wood;
this.currentRecipe = BIngredients.getRecipeByName(recipe);
this.unlabeled = unlabeled;
potions.put(uid, this);
if (recipe != null && !recipe.equals("")) {
currentRecipe = BIngredients.getRecipeByName(recipe);
if (currentRecipe == null) {
if (quality > 0) {
if (ageTime > 0.5) {
currentRecipe = ingredients.getAgeRecipe(wood, ageTime, distillRuns > 0);
} else if (distillRuns > 0) {
currentRecipe = ingredients.getdistillRecipe(wood, ageTime);
} else {
currentRecipe = ingredients.getBestRecipe(wood, ageTime, distillRuns > 0);
}
if (currentRecipe != null) {
this.quality = calcQuality();
P.p.log("Brew was made from Recipe: '" + recipe + "' which could not be found. '" + currentRecipe.getName(5) + "' used instead!");
} else {
P.p.errorLog("Brew was made from Recipe: '" + recipe + "' which could not be found!");
}
}
}
}
}
// returns a Brew by its UID