Skip to content
PHONGNGYUEN1 edited this page Sep 11, 2024 · 8 revisions

Food is a subclass of Consumable Items. It represents the items that can resolve the hunger of the player's animal in the game. The items used will extend from this class while implementing their texture. This class has an additional field of the amount the stat's hunger will increase depending on the food type which will later increase the existing value by the call of useItem function and accessing CombatStatCompnent function addHunger to increase it.

Expected Behaviour

  • To manage the effects, the function useItem has been modified to apply the effects for each call. The effects for each consumable item will be later implemented in its subclasses.
  • To apply the effects to hunger stats, the food apply effects will have to interact with the player stats using function applyEffect()
  • Usage Tracking: The class tracks the number of uses left for the potion. Each use tracks the number of uses left for the potion. Each use decreases the available quantity, eventually rendering the potion useless once the quantity reaches zero.

Usage

public class AbstractFood extends ConsumableItem {
    /**
     * The feeding effect that food can apply on animals
     */
    protected AbstractEffect feedingEffect;

    public AbstractFood(String name, int itemCode, int limit, int quantity, FeedEffect feedingEffect) {
        super(name, itemCode, limit, quantity);
        this.feedingEffect = feedingEffect;
    }
    public AbstractEffect getFeedingEffect() {
        return this.feedingEffect;
    }

    public void applyFeedingEffect() {
        this.feedingEffect.apply();
    }

Other subclasses of Food are:

Clone this wiki locally