treballant en Background i Stage
This commit is contained in:
+75
-70
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "stage_interface.h"
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "stage_interface.h"
|
||||
#include <functional> // ⬅️ Para std::function
|
||||
|
||||
enum class PowerCollectionState {
|
||||
ENABLED,
|
||||
@@ -18,79 +18,84 @@ enum class StageStatus {
|
||||
};
|
||||
|
||||
class StageData {
|
||||
private:
|
||||
int power_to_complete_;
|
||||
int min_menace_;
|
||||
int max_menace_;
|
||||
std::string name_;
|
||||
StageStatus status_;
|
||||
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 = "");
|
||||
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_; }
|
||||
// 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; }
|
||||
// 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_;
|
||||
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();
|
||||
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();
|
||||
|
||||
// Métodos principales para Game
|
||||
void initialize();
|
||||
void reset();
|
||||
bool advanceToNextStage();
|
||||
private:
|
||||
PowerChangeCallback power_change_callback_;
|
||||
|
||||
// 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;
|
||||
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;
|
||||
|
||||
private:
|
||||
void createDefaultStages();
|
||||
bool validateStageIndex(size_t index) const;
|
||||
void updateStageStatuses();
|
||||
void createDefaultStages();
|
||||
bool validateStageIndex(size_t index) const;
|
||||
void updateStageStatuses();
|
||||
};
|
||||
Reference in New Issue
Block a user