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

const std::string IndustrialRevolutionMilestone::ID = "main:IndustrialRevolution";

IndustrialRevolutionMilestone::IndustrialRevolutionMilestone() :
    Milestone(
        blockRegistry.getBlockByName("main:conveyorBelt").iconMaterial,
        blockRegistry.getBlockByName("main:beltMotor").iconMaterial,
        "Industrial Revolution"
    )
{
    addAchievement(
        MakeConveyorBelt,
        blockRegistry.getBlockByName("main:conveyorBelt").iconMaterial,
        blockRegistry.getBlockByName("main:conveyorBelt").iconMaterial,
        "Construct a conveyor belt",
        "*{action|Construct} a {block|main:conveyorBelt}.\n"
        "@engTable|main:conveyorBelt|16|main:planks|1|main:steelIngot|3|main:rubber|4\n",
        Dependency{MetalWorkingMilestone::ID, MetalWorkingMilestone::MakeSteel},
        Dependency{BrickByBrickMilestone::ID, BrickByBrickMilestone::MakeRubber},
        Dependency{ElectronicsMilestone::ID, ElectronicsMilestone::EngineeringTable}
    );

    addAchievement(
        NudgeConveyorBelt,
        blockRegistry.getBlockByName("main:conveyorBelt").iconMaterial,
        blockRegistry.getBlockByName("main:conveyorBelt").iconMaterial,
        "Nudge a conveyor belt",
        "*Place a {block|main:conveyorBelt} somewhere in the world.\n"
        "*Right-click the wheels on the conveyor belt to nudge it manually.",
        Dependency{ID, MakeConveyorBelt}
    );

    addAchievement(
        PlaceItemOnBelt,
        blockRegistry.getBlockByName("main:conveyorBelt").iconMaterial,
        blockRegistry.getBlockByName("main:conveyorBelt").iconMaterial,
        "Place an item on a conveyor belt.",
        "*Right-click the {action|top} of a {block|main:conveyorBelt} while {action|holding an item}.\n"
        "*The item will be placed on the conveyor belt.\n",
        Dependency{ID, MakeConveyorBelt}
    );

    addAchievement(
        MakeBeltMotor,
        blockRegistry.getBlockByName("main:conveyorBelt").iconMaterial,
        blockRegistry.getBlockByName("main:beltMotor").iconMaterial,
        "Construct a belt motor",
        "*{action|Construct} a {block|main:beltMotor}.\n"
        "@engTable|main:beltMotor|1|main:conveyorBelt|1|main:nickelIngot|2|main:coil|1|main:battery|1\n",
        Dependency{ID, MakeConveyorBelt},
        Dependency{ElectronicsMilestone::ID, ElectronicsMilestone::MakeBattery},
        Dependency{MetalWorkingMilestone::ID, MetalWorkingMilestone::MineNickel},
        Dependency{ElectronicsMilestone::ID, ElectronicsMilestone::MakeCoil}
    );

    addAchievement(
        PowerBelt,
        blockRegistry.getBlockByName("main:beltMotor").iconMaterial,
        blockRegistry.getBlockByName("main:beltMotor").iconMaterial,
        "Power a conveyor belt",
        "*Place a {block|main:beltMotor}, and connect some {block|main:conveyorBelt} to it.\n"
        "*Connect the bottom of the belt motor with {block|main:copperWire} connected to a power source.\n"
        "*Place an item on the conveyor belt (e.g. by clicking the top of one while holding an item).\n"
        "*Watch the conveyor belt move automatically.",
        Dependency{ID, MakeBeltMotor}
    );

    addAchievement(
        MakeSteelClaws,
        Material::steelClaws,
        Material::steelClaws,
        "Construct steel claws",
        "*{action|Construct} {item|main:steelClaws}.\n"
        "@engTable|main:steelClaws|1|main:steelIngot|3\n",
        Dependency{MetalWorkingMilestone::ID, MetalWorkingMilestone::MakeSteel}
    );

    addAchievement(
        MakeItemExtractor,
        blockRegistry.getBlockByName("main:itemExtractor").iconMaterial,
        blockRegistry.getBlockByName("main:itemExtractor").iconMaterial,
        "Construct an item extractor",
        "*{action|Construct} a {block|main:itemExtractor}.\n"
        "@engTable|main:itemExtractor|1|main:beltMotor|1|main:steelClaws|1|main:tinCasing|1\n",
        Dependency{ID, MakeBeltMotor},
        Dependency{ID, MakeSteelClaws},
        Dependency{ElectronicsMilestone::ID, ElectronicsMilestone::MakeTinCasing}
    );

    addAchievement(
        AttachItemExtractor,
        blockRegistry.getBlockByName("main:itemExtractor").iconMaterial,
        blockRegistry.getBlockByName("main:itemExtractor").iconMaterial,
        "Attach an item extractor",
        "*Place a {block|main:itemExtractor} attached to a machine with an inventory. Examples:\n"
        "*{machine|main:crate}\n"
        "*{machine|main:macerator}\n"
        "*{machine|main:electricFurnace}",
        Dependency{ID, MakeItemExtractor}
    );
}