#pragma once

#include "IWorldGenerationPhase.h"
#include "IWorldGenerationStep.h"
#include <unordered_map>
#include <memory>
#include <functional>

namespace warfactory {

class PhaseRegistry {
private:
    std::unordered_map<std::string, std::function<std::unique_ptr<IWorldGenerationPhase>()>> phase_factories;
    std::unordered_map<std::string, std::function<std::unique_ptr<IWorldGenerationStep>()>> step_factories;

public:
    static PhaseRegistry& getInstance();

    template<typename PhaseType>
    void registerPhase(const std::string& phase_name) {
        phase_factories[phase_name] = []() {
            return std::make_unique<PhaseType>();
        };
    }

    template<typename StepType>
    void registerStep(const std::string& step_name) {
        step_factories[step_name] = []() {
            return std::make_unique<StepType>();
        };
    }

    std::unique_ptr<IWorldGenerationPhase> createPhase(const std::string& phase_name);
    std::unique_ptr<IWorldGenerationStep> createStep(const std::string& step_name);

    std::vector<std::string> getRegisteredPhases() const;
    std::vector<std::string> getRegisteredSteps() const;
};

} // namespace warfactory