/// <summary> /// Checks if a piece of food is of the type the creature prefers /// </summary> /// <param name="f">The piece of food to check</param> /// <returns>If the piece of food is of the type the creature prefer</returns> private bool foodIsPreferred(FoodSource f) { bool b = false; if (f.isPlant() && diet * 2 <= 1) { b = true; } else if (!f.isPlant() && diet * 2 >= 1) //Both use >= / <= since omnivores shouldn't really have any preference { b = true; } else { b = false; } return b; }
/// <summary> /// Gets how nourishing a given FoodSource is, by applying the multiplication that will /// be applied to the food based on diet when it is eaten /// </summary> /// <param name="f">The foodsource to look</param> /// <returns>The energy the creature would get if it ate the foodsource</returns> private int getNourishmentAmt(FoodSource f) { double ret = 0; if (f.isPlant()) { double inverseDiet = 1 - diet; ret = f.getFoodValue() * inverseDiet; } else { ret = f.getFoodValue() * diet; } return (int)ret; }