#ifndef SMELTING_RULE_REGISTRY_HPP_
#define SMELTING_RULE_REGISTRY_HPP_

#include <list>

#include <SmeltingRule/SmeltingRule.hpp>

/**
 * @brief Registry of smelting rules.
 * 
 * These define how items should be processed by pots, electric furnace, etc. Use the
 * singleton instance in the global variable `smeltingRuleRegistry`.
 */
class SmeltingRuleRegistry
{
private:
    std::list<SmeltingRule*> rules;

    /**
     * @brief Register a smelting rule.
     * 
     * @param rule The rule.
     */
    void registerRule(SmeltingRule *rule);

    /**
     * @brief Register a basic smelting rule.
     * 
     * @param input The input stack (currently must have only 1 item).
     * @param output The output stack (any number of items).
     */
    void registerBasicRule(ItemStack input, ItemStack output);

public:
    /**
     * @brief Clean up the registry.
     */
    void shutdown();

    /**
     * @brief Register all smelting rules.
     * 
     * This is called from `main()`.
     */
    void registerAllRules();

    /**
     * @brief Returns true if the specified stack can be smelted.
     * 
     * @param stack The stack.
     */
    bool canSmelt(ItemStack &stack);

    /**
     * @brief Get the smelting result for the specified input.
     * 
     * @param input The input stack.
     * @return The result of smelting one unit from the input stack.
     */
    ItemStack getSmeltingResult(ItemStack &input);

    int getRuleCount();
};

extern SmeltingRuleRegistry smeltingRuleRegistry;

#endif