101 lines
3.0 KiB
C++
101 lines
3.0 KiB
C++
#pragma once
|
|
|
|
#include "stage_interface.h"
|
|
#include <vector>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <functional> // ⬅️ Para std::function
|
|
|
|
enum class PowerCollectionState {
|
|
ENABLED,
|
|
DISABLED
|
|
};
|
|
|
|
enum class StageStatus {
|
|
LOCKED,
|
|
IN_PROGRESS,
|
|
COMPLETED
|
|
};
|
|
|
|
class StageData {
|
|
private:
|
|
int power_to_complete_;
|
|
int min_menace_;
|
|
int max_menace_;
|
|
std::string name_;
|
|
StageStatus status_;
|
|
|
|
public:
|
|
StageData(int power_to_complete, int min_menace, int max_menace, const std::string& name = "");
|
|
|
|
// Getters
|
|
int getPowerToComplete() const { return power_to_complete_; }
|
|
int getMinMenace() const { return min_menace_; }
|
|
int getMaxMenace() const { return max_menace_; }
|
|
const std::string& getName() const { return name_; }
|
|
StageStatus getStatus() const { return status_; }
|
|
|
|
// Setters
|
|
void setStatus(StageStatus status) { status_ = status; }
|
|
|
|
// Utilidades
|
|
bool isCompleted() const { return status_ == StageStatus::COMPLETED; }
|
|
};
|
|
|
|
class StageManager : public IStageInfo { // ⬅️ Hereda de la interfaz
|
|
private:
|
|
std::vector<StageData> stages_;
|
|
int current_power_;
|
|
int total_power_;
|
|
size_t current_stage_index_;
|
|
PowerCollectionState power_collection_state_;
|
|
|
|
public:
|
|
StageManager();
|
|
|
|
// Métodos principales para Game
|
|
void initialize();
|
|
void reset();
|
|
bool advanceToNextStage();
|
|
|
|
// Gestión de poder
|
|
bool subtractPower(int amount);
|
|
void enablePowerCollection();
|
|
void disablePowerCollection();
|
|
|
|
// Navegación avanzada
|
|
bool jumpToStage(size_t target_stage_index);
|
|
|
|
// Consultas de estado
|
|
std::optional<StageData> getCurrentStage() const;
|
|
std::optional<StageData> getStage(size_t index) const;
|
|
size_t getCurrentStageIndex() const { return current_stage_index_; }
|
|
int getCurrentPower() const { return current_power_; }
|
|
int getTotalPower() const { return total_power_; }
|
|
int getTotalPowerNeededToCompleteGame() const; // ⬅️ Nuevo método
|
|
size_t getTotalStages() const { return stages_.size(); }
|
|
|
|
// Progreso
|
|
bool isCurrentStageCompleted() const;
|
|
bool isGameCompleted() const;
|
|
double getProgressPercentage() const; // Progreso total del juego
|
|
double getCurrentStageProgressPercentage() const; // Progreso de la fase actual (0-100%)
|
|
double getCurrentStageProgressFraction() const; // Progreso de la fase actual (0.0-1.0)
|
|
int getPowerNeededForCurrentStage() const;
|
|
|
|
// ===== IMPLEMENTACIÓN DE IStageInfo =====
|
|
// (Esto es lo que ven Player y Balloon)
|
|
bool canCollectPower() const override;
|
|
void addPower(int amount) override;
|
|
int getCurrentMenaceLevel() const override;
|
|
using PowerChangeCallback = std::function<void(int)>;
|
|
void setPowerChangeCallback(PowerChangeCallback callback);
|
|
void removePowerChangeCallback();
|
|
|
|
private:
|
|
PowerChangeCallback power_change_callback_;
|
|
|
|
void createDefaultStages();
|
|
bool validateStageIndex(size_t index) const;
|
|
void updateStageStatuses();
|
|
}; |