#include <WorldTypeRegistry/WorldTypeRegistry.hpp>
#include <WorldType/SurvivalWorldType/SurvivalWorldType.hpp>
#include <WorldType/FlatWorldType/FlatWorldType.hpp>

WorldTypeRegistry worldTypeRegistry;

WorldTypeRegistry::~WorldTypeRegistry()
{
    for (const auto &[key, value] : worldTypes)
    {
        delete value;
    }
}

void WorldTypeRegistry::registerAllWorldTypes()
{
    registerWorldType<SurvivalWorldType>("main:survival");
    registerWorldType<FlatWorldType>("main:flat");
}

WorldType* WorldTypeRegistry::getByID(std::string id)
{
    auto it = worldTypes.find(id);
    if (it == worldTypes.end())
    {
        return nullptr;
    }

    return it->second;
}

int WorldTypeRegistry::getTotalWorldTypes()
{
    return (int) worldTypes.size();
}