コード例 #1
0
ファイル: BIngredients.java プロジェクト: jookes/Brewery
  // returns the quality regarding the ageing time conditioning given Recipe
  public int getAgeQuality(BRecipe recipe, float time) {
    int quality =
        10 - Math.round(Math.abs(time - recipe.getAge()) * ((float) recipe.getDifficulty() / 2));

    if (quality > 0) {
      return quality;
    }
    return 0;
  }
コード例 #2
0
ファイル: BIngredients.java プロジェクト: jookes/Brewery
  // returns the quality regarding the barrel wood conditioning given Recipe
  public int getWoodQuality(BRecipe recipe, float wood) {
    if (recipe.getWood() == 0) {
      // type of wood doesnt matter
      return 10;
    }
    int quality = 10 - Math.round(recipe.getWoodDiff(wood) * recipe.getDifficulty());

    if (quality > 0) {
      return quality;
    }
    return 0;
  }
コード例 #3
0
ファイル: BIngredients.java プロジェクト: jookes/Brewery
 // returns the quality of the ingredients conditioning given recipe, -1 if
 // no recipe is near them
 public int getIngredientQuality(BRecipe recipe) {
   float quality = 10;
   int count;
   int badStuff = 0;
   if (recipe.isMissingIngredients(ingredients)) {
     // when ingredients are not complete
     return -1;
   }
   for (Material ingredient : ingredients.keySet()) {
     count = ingredients.get(ingredient);
     if (recipe.amountOf(ingredient) == 0) {
       // this ingredient doesnt belong into the recipe
       if (count > (getIngredientsCount() / 2)) {
         // when more than half of the ingredients dont fit into the
         // recipe
         return -1;
       }
       badStuff++;
       if (badStuff < ingredients.size()) {
         // when there are other ingredients
         quality -= count * (recipe.getDifficulty() / 2);
         continue;
       } else {
         // ingredients dont fit at all
         return -1;
       }
     }
     // calculate the quality
     quality -=
         ((float) Math.abs(count - recipe.amountOf(ingredient))
                 / recipe.allowedCountDiff(recipe.amountOf(ingredient)))
             * 10.0;
   }
   if (quality >= 0) {
     return Math.round(quality);
   }
   return -1;
 }