#include <BlockRegistry/BlockRegistry.hpp>
#include <GraphicsContext/GraphicsContext.hpp>
#include <Material/Material.hpp>
#include <Milestone/BrickByBrickMilestone/BrickByBrickMilestone.hpp>
#include <Milestone/BronzeAgeMilestone/BronzeAgeMilestone.hpp>
#include <Milestone/CarpentryMilestone/CarpentryMilestone.hpp>
#include <Milestone/DiggingDeeperMilestone/DiggingDeeperMilestone.hpp>
#include <Milestone/MetalWorkingMilestone/MetalWorkingMilestone.hpp>
#include <Milestone/StoneAgeMilestone/StoneAgeMilestone.hpp>
#include <Milestone/ElectronicsMilestone/ElectronicsMilestone.hpp>
#include <Color/Color.hpp>

const std::string CarpentryMilestone::ID = "main:Carpentry";

CarpentryMilestone::CarpentryMilestone() :
    Milestone(
        Material::basicAxe,
        Material::basicAxe,
        "Carpentry"
    )
{
    addAchievement(
        BasicAxe,
        Material::basicAxe,
        Material::basicAxe,
        "Construct the basic axe",
        "*Collect {block|main:stone|1} and {item|main:stick|8}.\n"
        "*{action|Construct} the {item|main:basicAxe} (open your inventory).\n"
        "@manualConstruct|main:basicAxe|1|main:stone|1|main:stick|8\n",
        Dependency{StoneAgeMilestone::ID, StoneAgeMilestone::CollectStone}
    );

    addAchievement(
        CollectWood,
        Material::treeIcon,
        Material::treeIcon,
        "Collect wood",
        formatString(
            "*Select the {item|main:basicAxe} in the side bar.\n"
            "*You will now be able to click and hold a tree.\n"
            "*Chop down the tree and collect the wood ($+logs$+).",

            GraphicsContext::colorstr(Color::itemEmphasis), GraphicsContext::colorstr(glm::vec4(1.0f))
        ),
        Dependency{ID, BasicAxe}
    );

    addAchievement(
        Cactus,
        blockRegistry.getBlockByName("main:cactusLog").iconMaterial,
        blockRegistry.getBlockByName("main:cactusLog").iconMaterial,
        "Collect a cactus",
        "*Select the {item|main:basicAxe} in the side bar.\n"
        "*You will now be able to click and hold a {block|main:cactusLog}.\n"
        "*Collect the {block|main:cactusLog}.\n",
        Dependency{ID, BasicAxe}
    );

    addAchievement(
        ConstructTable,
        blockRegistry.getBlockByName("main:constructTable").iconMaterial,
        blockRegistry.getBlockByName("main:constructTable").iconMaterial,
        "Construction table",
        formatString(
            "*You can {action|construct} {block|main:planks} from $+logs$+.\n"
            "*Make a total of {block|main:planks|12}.\n"
            "*{action|Construct} a {block|main:constructTable}.\n"
            "@manualConstruct|main:constructTable|1|main:planks|12\n"
            "*Select the {block|main:constructTable} in the sidebar.\n"
            "*Right-click on a block to place the table.\n"
            "*Right-click the placed construction table block to open it.\n"
            "*You'll now see more items you can construct.\n",

            GraphicsContext::colorstr(Color::itemEmphasis), GraphicsContext::colorstr(glm::vec4(1.0f))
        ),
        Dependency{ID, CollectWood}
    );

    addAchievement(
        Crate,
        blockRegistry.getBlockByName("main:crate").iconMaterial,
        blockRegistry.getBlockByName("main:crate").iconMaterial,
        "The crate",
        "*Collect {block|main:planks|6} and {item|main:stick|12}.\n"
        "*{action|Construct} the {block|main:crate}.\n"
        "@constructTable|main:crate|1|main:planks|6|main:stick|12\n"
        "*Place and open the crate.\n",
        Dependency{ID, ConstructTable}
    );

    addAchievement(
        MakeWoodPulp,
        Material::woodPulp,
        Material::woodPulp,
        "Make wood pulp",
        "*Place the {block|main:grindingBowl} and right-click to open it.\n"
        "*Place {block|main:planks} into the {inputSlot}.\n"
        "*Keep clicking the {action|Grind} button until the planks are processed.\n"
        "@itemProc|main:grindingBowl|main:planks|1|main:woodPulp|1\n"
        "*Take the {item|main:woodPulp} out of the bowl.\n",
        Dependency{BrickByBrickMilestone::ID, BrickByBrickMilestone::MakeGrindingBowl}
    );

    addAchievement(
        StoneAxe,
        Material::stoneAxe,
        Material::stoneAxe,
        "Construct the stone axe",
        "*Collect {block|main:stone|3} and {item|main:stick|8}.\n"
        "*{action|Construct} the {item|main:stoneAxe}.\n"
        "@constructTable|main:stoneAxe|1|main:stone|3|main:stick|8\n",
        Dependency{CarpentryMilestone::ID, CarpentryMilestone::ConstructTable}
    );

    addAchievement(
        BronzeAxe,
        Material::bronzeAxe,
        Material::bronzeAxe,
        "Construct the bronze axe",
        "*{action|Construct} the {item|main:bronzeAxe}.\n"
        "@constructTable|main:bronzeAxe|1|main:bronzeIngot|3|main:stick|8\n",
        Dependency{BronzeAgeMilestone::ID, BronzeAgeMilestone::MakeBronze}
    );

    addAchievement(
        IronAxe,
        Material::ironAxe,
        Material::ironAxe,
        "Construct the iron axe",
        "*{action|Construct} the {item|main:ironAxe}.\n"
        "@constructTable|main:ironAxe|1|main:ironIngot|3|main:stick|8\n",
        Dependency{MetalWorkingMilestone::ID, MetalWorkingMilestone::MineIron}
    );

    addAchievement(
        SteelAxe,
        Material::steelAxe,
        Material::steelAxe,
        "Construct the steel axe",
        "*{action|Construct} the {item|main:steelAxe}.\n"
        "@constructTable|main:steelAxe|1|main:steelIngot|3|main:stick|8\n",
        Dependency{MetalWorkingMilestone::ID, MetalWorkingMilestone::MakeSteel}
    );

    addAchievement(
        DiamondAxe,
        Material::diamondAxe,
        Material::diamondAxe,
        "Construct the diamond axe",
        "*{action|Construct} the {item|main:diamondAxe}.\n"
        "@constructTable|main:diamondAxe|1|main:diamond|3|main:stick|8\n",
        Dependency{DiggingDeeperMilestone::ID, DiggingDeeperMilestone::MineDiamonds}
    );

    addAchievement(
        Charcoal,
        Material::charcoal,
        Material::charcoal,
        "Make charcoal",
        "*{action|Smelt} the {block|main:planks} to get {item|main:charcoal}.\n"
        "@itemProc|main:stonePot|main:planks|1|main:charcoal|1\n"
        "*Take the {item|main:charcoal} out of the pot.\n",
        Dependency{BronzeAgeMilestone::ID, BronzeAgeMilestone::StonePot}
    );

    addAchievement(
        Torches,
        blockRegistry.getBlockByName("main:torch").iconMaterial,
        blockRegistry.getBlockByName("main:torch").iconMaterial,
        "Make torches",
        "*{action|Construct} {block|main:torch|8}.\n"
        "@manualConstruct|main:torch|8|main:charcoal|1|main:stick|8\n",
        Dependency{ID, Charcoal}
    );

    addAchievement(
        MakePaper,
        Material::paperSheet,
        Material::paperSheet,
        "Make paper",
        "*Open the {machine|main:engineeringTable}.\n"
        "*In the {icon|recipeBookIcon}{menu|Recipes} tab, {action|SET} the {item|main:paperSheet} recipe.\n"
        "*Place the ingredients into the inputs slots on the left.\n"
        "*Power the engineering table by placing a {item|main:battery} in the {rechargeSlot},"
        " or by connecting power through {block|main:copperWire}.\n"
        "*Wait for {item|main:paperSheet} to be constructed, and pick it up.\n"
        "@engTable|main:paperSheet|1|main:woodPulp|8\n",
        Dependency{ID, MakeWoodPulp},
        Dependency{ElectronicsMilestone::ID, ElectronicsMilestone::EngineeringTable}
    );
}