예제 #1
0
  // returns currently best matching recipe for ingredients, cooking- and
  // ageingtime
  public BRecipe getAgeRecipe(float wood, float time, boolean distilled) {
    BRecipe bestRecipe = getBestRecipe(wood, time, distilled);

    if (bestRecipe != null) {
      if (bestRecipe.needsToAge()) {
        return bestRecipe;
      }
    }
    return null;
  }
예제 #2
0
  // best recipe for current state of potion, STILL not always returns the
  // correct one...
  public BRecipe getBestRecipe(float wood, float time, boolean distilled) {
    float quality = 0;
    int ingredientQuality;
    int cookingQuality;
    int woodQuality;
    int ageQuality;
    BRecipe bestRecipe = null;
    for (BRecipe recipe : recipes) {
      ingredientQuality = getIngredientQuality(recipe);
      cookingQuality = getCookingQuality(recipe, distilled);

      if (ingredientQuality > -1 && cookingQuality > -1) {
        if (recipe.needsToAge() || time > 0.5) {
          // needs riping in barrel
          ageQuality = getAgeQuality(recipe, time);
          woodQuality = getWoodQuality(recipe, wood);
          P.p.debugLog(
              "Ingredient Quality: "
                  + ingredientQuality
                  + " Cooking Quality: "
                  + cookingQuality
                  + " Wood Quality: "
                  + woodQuality
                  + " age Quality: "
                  + ageQuality
                  + " for "
                  + recipe.getName(5));

          // is this recipe better than the previous best?
          if ((((float) ingredientQuality + cookingQuality + woodQuality + ageQuality) / 4)
              > quality) {
            quality = ((float) ingredientQuality + cookingQuality + woodQuality + ageQuality) / 4;
            bestRecipe = recipe;
          }
        } else {
          P.p.debugLog(
              "Ingredient Quality: "
                  + ingredientQuality
                  + " Cooking Quality: "
                  + cookingQuality
                  + " for "
                  + recipe.getName(5));
          // calculate quality without age and barrel
          if ((((float) ingredientQuality + cookingQuality) / 2) > quality) {
            quality = ((float) ingredientQuality + cookingQuality) / 2;
            bestRecipe = recipe;
          }
        }
      }
    }
    if (bestRecipe != null) {
      P.p.debugLog("best recipe: " + bestRecipe.getName(5) + " has Quality= " + quality);
    }
    return bestRecipe;
  }