#include "classicgraphicsfactory.h"

ClassicGraphicsFactory::ClassicGraphicsFactory(const std::shared_ptr<kku::CoreFactory>& core_factory) :
    _core_factory(core_factory) 
{}



auto ClassicGraphicsFactory::generate(Type type) const -> SpriteData
{
    auto shape = _core_factory->getRectangle();
    auto trail = _core_factory->getRectangle();
    shape->setRect(kku::Area<float>{0.f, 0.f, 20.f, 20.f});
    trail->setRect(kku::Area<float>{0.f, 0.f, 20.f, 20.f});

    kku::Color color;

    switch (type)
    {
    case Type::UP:
        color = kku::Color{255, 0, 0, 255};
        break;

    case Type::DOWN:
        color = kku::Color{0, 255, 0, 255};
        break;

    case Type::LEFT:
        color = kku::Color{0, 0, 255, 255};
        break;

    case Type::RIGHT:
        color = kku::Color{255, 0, 255, 255};
        break;

    default:    // yellow
        color = kku::Color{255, 239, 0, 255};
    }

    shape->setColor(color);
    trail->setColor(color);

    return SpriteData{shape, trail, color};
}

std::shared_ptr<ClassicNoteGraphics> ClassicGraphicsFactory::createSprite(Type type) const
{
    const auto data = generate(type);
    return std::make_shared<ClassicNoteGraphics>(ClassicNoteGraphics::Init{data.shape, data.trail, data.color});
}

std::shared_ptr<ClassicSelectionGraphics> ClassicGraphicsFactory::createSelection() const
{
    const auto shape = _core_factory->getRectangle();
    return std::make_shared<ClassicSelectionGraphics>(ClassicSelectionGraphics::Init{shape, kku::Color{51, 153, 255, 120}});
}
