#include <MaceratorRule/IngotToDustMaceratorRule/IngotToDustMaceratorRule.hpp>
#include <ItemRegistry/ItemRegistry.hpp>

ItemStack IngotToDustMaceratorRule::getMaceratorOutput(ItemStack &input)
{
    std::string inputName = input.getItem()->name;
    if (inputName.substr(inputName.size()-5, 5) != "Ingot")
    {
        return ItemStack();
    }

    std::string outputName = inputName.substr(0, inputName.size()-5) + "Dust";
    if (itemRegistry.getItemByName(outputName) == nullptr)
    {
        return ItemStack();
    }

    return ItemStack(outputName, 1);
}