#ifndef FUEL_RULE_REGISTRY_HPP_
#define FUEL_RULE_REGISTRY_HPP_

#include <vector>
#include <FuelRule/FuelRule.hpp>

/**
 * @brief Registry of fuel rules.
 * 
 * This defines a set of rules which decide how much fuel to extract from an item. This
 * applies to items that can be used in the "fuel" slot of pots, steam generators etc.
 * 
 * Use the global singleton instance `fuelRuleRegistry`.
 */
class FuelRuleRegistry
{
private:
    std::vector<FuelRule*> rules;

    /**
     * @brief Register a new rule.
     * 
     * @param rule The rule.
     */
    void registerRule(FuelRule *rule);

    /**
     * @brief Define that an item which can be merged into `fuelStack` has `amount` fuel.
     * 
     * @param fuelStack An item is matched by this rule if it can be merged into this stack.
     * @param amount The amount of fuel in a unit.
     */
    void registerBasicFuel(ItemStack fuelStack, uint32_t amount);

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

    /**
     * @brief Register all the fuel rules.
     */
    void registerAllRules();

    /**
     * @brief Determine if the specified stack contains fuel.
     * 
     * @param stack The stack.
     */
    bool isValidFuel(ItemStack &stack);

    /**
     * @brief Get the amount of fuel per unit of the specified stack.
     * 
     * @param stack The stack.
     * @return The amount of fuel per unit.
     */
    uint32_t getFuelAmount(ItemStack &stack);

    int getRuleCount();
};

extern FuelRuleRegistry fuelRuleRegistry;

#endif