#include "stage.h"
#include <algorithm> // Para min
#include <vector>    // Para vector

namespace Stage
{

    std::vector<Stage> stages;      // Variable con los datos de cada pantalla
    int power = 0;                  // Poder acumulado en la fase
    int total_power = 0;            // Poder total necesario para completar el juego
    int number = 0;                 // Fase actual
    bool power_can_be_added = true; // Habilita la recolecta de poder

    // Devuelve una fase
    Stage get(int index) { return stages.at(std::min(9, index)); }

    // Inicializa las variables del namespace Stage
    void init()
    {
        stages.clear();
        stages.emplace_back(Stage(200, 7 + (4 * 1), 7 + (4 * 3)));
        stages.emplace_back(Stage(300, 7 + (4 * 2), 7 + (4 * 4)));
        stages.emplace_back(Stage(600, 7 + (4 * 3), 7 + (4 * 5)));
        stages.emplace_back(Stage(600, 7 + (4 * 3), 7 + (4 * 5)));
        stages.emplace_back(Stage(600, 7 + (4 * 4), 7 + (4 * 6)));
        stages.emplace_back(Stage(600, 7 + (4 * 4), 7 + (4 * 6)));
        stages.emplace_back(Stage(650, 7 + (4 * 5), 7 + (4 * 7)));
        stages.emplace_back(Stage(750, 7 + (4 * 5), 7 + (4 * 7)));
        stages.emplace_back(Stage(850, 7 + (4 * 6), 7 + (4 * 8)));
        stages.emplace_back(Stage(950, 7 + (4 * 7), 7 + (4 * 10)));

        power = 0;
        total_power = 0;
        number = 0;
    }

    // Añade poder
    void addPower(int amount)
    {
        if (power_can_be_added)
        {
            power += amount;
            total_power += amount;
        }
    }
}