#pragma once
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
class Paddle;
class Ball;
class Arkanoid;

class Bonus
{
protected:
    inline static const float speed = 120;
    inline static const float radius = 15;

    sf::Vector2f m_position;
    float m_time;

public:
    Bonus(sf::Vector2f position);
    void update(float dt);
    virtual void draw(sf::RenderWindow& window) const = 0;
    virtual void activate(Arkanoid& game) = 0;
    virtual ~Bonus() = default;

    bool isColiding(const Paddle& paddle) const;
    // Класс Arkanoid должен быть дружественным, так как он может менять внутреннее объекта-бонуса
    friend class Arkanoid;
};

class TripleBallBonus : public Bonus {
public:
    TripleBallBonus(sf::Vector2f position): Bonus(position) {}; 
    void draw(sf::RenderWindow& window) const;
    void activate(Arkanoid& game); 
};

class EnlargePaddleBonus : public Bonus {
public:
    EnlargePaddleBonus(sf::Vector2f position): Bonus(position) {}; 
    void draw(sf::RenderWindow& window) const;
    void activate(Arkanoid& game); 
};

class ShrinkPaddleBonus : public Bonus {
public:
    ShrinkPaddleBonus(sf::Vector2f position): Bonus(position) {}; 
    void draw(sf::RenderWindow& window) const;
    void activate(Arkanoid& game); 
};

class SlowingBonus : public Bonus {
private:
    double mDuration = 10;
public:
    SlowingBonus(sf::Vector2f position): Bonus(position) {}; 
    void draw(sf::RenderWindow& window) const;
    void activate(Arkanoid& game); 
};

/*
 * Effects
 * */
#define _EFFECT_SLOWING_ID 0
class Effect {
protected:
    char effectId;
    double mStartTime;
    double mDuration;
public:
    Effect(char id, double start_time, double duration); 
    virtual ~Effect() = default;

    virtual void activate(Arkanoid& game) = 0;
    virtual void activate(Ball& ball) = 0;
    virtual void deactivate(Arkanoid& game) = 0;
    bool isExpired(double time);


    friend class SlowingBonus;
    friend class TripleBallBonus;
    friend class Arkanoid;
};

class SlowingEffect : public Effect {
private:
    float mSlowingFactor = 0.1;
    char id = _EFFECT_SLOWING_ID;
public:
    SlowingEffect(double start_time, double duration);
    void activate(Arkanoid& game);
    void activate(Ball& ball);
    void deactivate(Arkanoid& game); 
};
