/** * Makes the player eat the specified food * * @param food - Specified food to eat */ public void eat(Food food) { if (hasFood(food, 1)) { removeFood(food, 1); increaseHealth(food.getHealthRegenAmount()); } else { Sys.print("You don't have any " + food.getName() + " to eat!"); } }
/** * Removes the amount of food to its stack * * @param food - Food to control * @param amount - Amount to decrease by */ public void removeFood(Food food, int amount) { food.setStack(food.getStack() - amount); Sys.print(amount + " " + food.getName() + " was removed from your inventory!"); }
/** * Adds the amount of food to its stack * * @param food - Food to control * @param amount - Amount to increase by */ public void addFood(Food food, int amount) { food.setStack(food.getStack() + amount); Sys.print(amount + " " + food.getName() + " was added to your inventory!"); }