Skip to content

Commit 53d7912

Browse files
committed
fix(recipe): Remove quality rounding for match calculation
1 parent b6606f5 commit 53d7912

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

src/main/java/com/dre/brewery/BIngredients.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void add(ItemStack ingredient, RecipeItem rItem) {
136136
/**
137137
* Add an ingredient to this based on the given RecipeItem
138138
*
139-
* @param rItem the RecipeItem that matches the ingredient
139+
* @param rItem the RecipeItem that matches the ingredient
140140
*/
141141
public void addGeneric(RecipeItem rItem) {
142142
add(rItem.toIngredientGeneric());
@@ -265,6 +265,7 @@ public List<Ingredient> getIngredientList() {
265265
public @Nullable BRecipe getBestRecipe(BarrelWoodType wood, float time, boolean distilled) {
266266
return getBestRecipeFull(wood, time, distilled).getSuccessRecipe();
267267
}
268+
268269
/**
269270
* best recipe for current state of potion, STILL not always returns the correct one...
270271
*/
@@ -288,21 +289,21 @@ public BestRecipeResult getBestRecipeFull(BarrelWoodType wood, float time, boole
288289
RecipeEvaluation completeRecipeEval;
289290

290291
RecipeEvaluation ingredientEval = getIngredientQualityFull(recipe);
291-
int ingredientQuality = ingredientEval.getQuality();
292+
float ingredientQuality = ingredientEval.getQuality();
292293

293294
RecipeEvaluation cookingEval = getCookingQualityFull(recipe, distilled);
294-
int cookingQuality = cookingEval.getQuality();
295+
float cookingQuality = cookingEval.getQuality();
295296

296297
// age and wood quality cannot be fatal, only need to check ingredient and cooking
297298
boolean isFatal = ingredientEval.isFatal() || cookingEval.isFatal();
298299

299300
if (recipe.needsToAge() || time > 0.5) {
300301
// needs riping in barrel
301302
RecipeEvaluation ageEval = getAgeQualityFull(recipe, time);
302-
int ageQuality = ageEval.getQuality();
303+
float ageQuality = ageEval.getQuality();
303304

304305
RecipeEvaluation woodEval = getWoodQualityFull(recipe, wood);
305-
int woodQuality = woodEval.getQuality();
306+
float woodQuality = woodEval.getQuality();
306307

307308
// is this recipe better than the previous best?
308309
Logging.debugLog("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality +
@@ -352,6 +353,7 @@ public BestRecipeResult getBestRecipeFull(BarrelWoodType wood, float time, boole
352353
public @Nullable BRecipe getCookRecipe() {
353354
return getCookRecipeFull().getSuccessRecipe();
354355
}
356+
355357
public BestRecipeResult getCookRecipeFull() {
356358
BestRecipeResult result = getBestRecipeFull(BarrelWoodType.ANY, 0, false);
357359

@@ -395,6 +397,7 @@ public BCauldronRecipe getCauldronRecipe() {
395397
public @Nullable BRecipe getDistillRecipe(BarrelWoodType wood, float time) {
396398
return getDistillRecipeFull(wood, time).getSuccessRecipe();
397399
}
400+
398401
public BestRecipeResult getDistillRecipeFull(BarrelWoodType wood, float time) {
399402
BestRecipeResult result = getBestRecipeFull(wood, time, true);
400403

@@ -417,6 +420,7 @@ public BestRecipeResult getDistillRecipeFull(BarrelWoodType wood, float time) {
417420
public @Nullable BRecipe getAgeRecipe(BarrelWoodType wood, float time, boolean distilled) {
418421
return getAgeRecipeFull(wood, time, distilled).getSuccessRecipe();
419422
}
423+
420424
public BestRecipeResult getAgeRecipeFull(BarrelWoodType wood, float time, boolean distilled) {
421425
BestRecipeResult result = getBestRecipeFull(wood, time, distilled);
422426

@@ -436,8 +440,9 @@ public BestRecipeResult getAgeRecipeFull(BarrelWoodType wood, float time, boolea
436440
* returns the quality of the ingredients conditioning given recipe, -1 if no recipe is near them
437441
*/
438442
public int getIngredientQuality(BRecipe recipe) {
439-
return getIngredientQualityFull(recipe).getQuality();
443+
return Math.round(getIngredientQualityFull(recipe).getQuality());
440444
}
445+
441446
public RecipeEvaluation getIngredientQualityFull(BRecipe recipe) {
442447
RecipeEvaluation eval = new RecipeEvaluation();
443448

@@ -480,8 +485,9 @@ public RecipeEvaluation getIngredientQualityFull(BRecipe recipe) {
480485
* returns the quality regarding the cooking-time conditioning given Recipe
481486
*/
482487
public int getCookingQuality(BRecipe recipe, boolean distilled) {
483-
return getCookingQualityFull(recipe, distilled).getQuality();
488+
return Math.round(getCookingQualityFull(recipe, distilled).getQuality());
484489
}
490+
485491
public RecipeEvaluation getCookingQualityFull(BRecipe recipe, boolean distilled) {
486492
RecipeEvaluation eval = new RecipeEvaluation();
487493
if (recipe.needsDistilling() != distilled) {
@@ -511,7 +517,7 @@ public int getDistillQuality(BRecipe recipe, byte distillRuns) {
511517
* returns the quality regarding the barrel wood conditioning given Recipe
512518
*/
513519
public int getWoodQuality(BRecipe recipe, BarrelWoodType wood) {
514-
return getWoodQualityFull(recipe, wood).getQuality();
520+
return Math.round(getWoodQualityFull(recipe, wood).getQuality());
515521
}
516522

517523
public RecipeEvaluation getWoodQualityFull(BRecipe recipe, BarrelWoodType wood) {
@@ -532,6 +538,7 @@ public RecipeEvaluation getWoodQualityFull(BRecipe recipe, BarrelWoodType wood)
532538
}
533539
return eval;
534540
}
541+
535542
// At difficulty 1, distances 0-5 have quality 10, 10, 9, 8, 7, 6
536543
// At difficulty 5, distances 0-5 have quality 10, 8, 4, 1, 0, 0
537544
// At difficulty 10, distances 0-5 have quality 10, 5, 0, 0, 0, 0
@@ -558,8 +565,9 @@ private int getWoodQualityNew(BRecipe recipe, BarrelWoodType wood) {
558565
* returns the quality regarding the ageing time conditioning given Recipe
559566
*/
560567
public int getAgeQuality(BRecipe recipe, float time) {
561-
return getAgeQualityFull(recipe, time).getQuality();
568+
return Math.round(getAgeQualityFull(recipe, time).getQuality());
562569
}
570+
563571
public RecipeEvaluation getAgeQualityFull(BRecipe recipe, float time) {
564572
RecipeEvaluation eval = new RecipeEvaluation();
565573
if (!BUtil.isClose(time, recipe.getAge())) {

src/main/java/com/dre/brewery/recipe/RecipeEvaluation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ private boolean hasFatalDefect() {
9494
* If there are fatal defects, or if the quality is deducted to less than 0,the quality will be -1.
9595
* @return the quality
9696
*/
97-
public int getQuality() {
97+
public float getQuality() {
9898
float quality = getTrueQuality();
9999
if (quality < 0) {
100100
return -1;
101101
}
102-
return Math.round(quality);
102+
return quality;
103103
}
104104

105105
/**

0 commit comments

Comments
 (0)