#ifndef MPOT_HPP_
#define MPOT_HPP_

#include <vector>

#include <Machine/Machine.hpp>
#include <ItemStack/ItemStack.hpp>
#include <Item/IInventory.hpp>

/**
 * @brief The "pot" machine, used for the stone and iron pots.
 */
class MPot : public Machine, public IInventory
{
private:
    std::vector<ItemStack> m_stacks;
    uint32_t m_temperature;
    uint32_t progress;
    uint32_t m_fuelCurrent;
    uint32_t m_fuelBatch;

    ItemStack& fuelSlot();
    ItemStack& inputSlot();
    ItemStack& outputSlot();

public:
    MPot(LocalWorld &world, glm::ivec3 pos);

    /**
     * @brief Get the current temperature.
     */
    uint32_t getTemperature();

    /**
     * @brief Get the current progress.
     */
    uint32_t getProgress();

    /**
     * @brief Get the amount of fuel currently left.
     */
    uint32_t getFuelCurrent();

    /**
     * @brief Get the total amount of fuel from the last batch.
     */
    uint32_t getFuelBatch();

    /**
     * @brief Returns true if this is an iron pot (false otherwise).
     */
    bool isIron();

    /**
     * @brief Get the amount of progress which counts as 'completed' smelting.
     * 
     * @param isIron Is the pot iron?
     * @return The amount of progress that counts as 'completed' smelting.
     */
    static uint32_t getCompletedProgress(bool isIron);

    virtual void serializeState(std::vector<uint8_t> &outBytes) override;
    virtual void deserializeState(const uint8_t *data, size_t size) override;
    virtual int getNumSlots() override;
    virtual ItemStack getStackInSlot(int slot) override;
    virtual void setStackInSlot(int slot, ItemStack stack) override;
    virtual bool isAllowedStackInSlot(int slot, ItemStack stack) override;
    virtual void update() override;
};

#endif