package inf101.v18.rogue101.items;

import inf101.v18.rogue101.objects.IItem;

import java.util.List;

public interface IContainer extends IItem {
    /**
     * Retrieves an item from a container in index i
     *
     * @param i The index of an element
     * @return An IItem
     * @throws IndexOutOfBoundsException If the index is out of range.
     */
    IItem get(int i);

    /**
     * Adds an item to a container.
     *
     * @return True if the container was not full
     * @param item The item to add to the container
     */
    boolean addItem(IItem item);

    /**
     * Gets a list with everything inside a container.
     *
     * @return A list of Objects extending IItem
     */
    List<IItem> getContent();

    /**
     * Checks if we can add anything at all to the container.
     *
     * @return True if it has no space left
     */
    boolean hasSpace();

    /**
     * Returns the message to show the user upon interacting with the container.
     *
     * @return A message
     */
    default String getInteractMessage() {
        return "Items in " + getName() + ": ";
    }

    /**
     * Gets the first item from the container of a specified type.
     *
     * @param clazz The class type to accept
     * @return An IItem or null
     */
    IItem getFirst(Class<?> clazz);

    /**
     * Removes an element at index i from the container.
     *
     * @param i The index of an element
     */
    void remove(int i);
}