diff --git a/source/sections/game.cpp b/source/sections/game.cpp index edbadbd..825a4d9 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -56,7 +56,7 @@ Game::Game(Player::Id player_id, int current_stage, bool demo) pause_manager_(std::make_unique([this](bool is_paused) { onPauseStateChanged(is_paused); })), stage_manager_(std::make_unique()), balloon_manager_(std::make_unique(stage_manager_.get())), - background_(std::make_unique(stage_manager_->getTotalPowerNeededToCompleteGame())), + background_(std::make_unique(stage_manager_->getPowerNeededToReachStage(stage_manager_->getTotalStages() - 1))), fade_in_(std::make_unique()), fade_out_(std::make_unique()), tabe_(std::make_unique()), diff --git a/source/stage.cpp b/source/stage.cpp index 8416bf7..e663f90 100644 --- a/source/stage.cpp +++ b/source/stage.cpp @@ -243,6 +243,18 @@ auto StageManager::getTotalPowerNeededToCompleteGame() const -> int { return total_power_needed; } +auto StageManager::getPowerNeededToReachStage(size_t target_stage_index) const -> int { + if (!validateStageIndex(target_stage_index)) { + return 0; + } + + int power_needed = 0; + for (size_t i = 0; i < target_stage_index; ++i) { + power_needed += stages_[i].getPowerToComplete(); + } + return power_needed; +} + // Implementación de la interfaz IStageInfo auto StageManager::canCollectPower() const -> bool { return power_collection_state_ == PowerCollectionState::ENABLED; diff --git a/source/stage.h b/source/stage.h index bbaac25..4150c55 100644 --- a/source/stage.h +++ b/source/stage.h @@ -75,6 +75,7 @@ class StageManager : public IStageInfo { [[nodiscard]] auto getCurrentPower() const -> int { return current_power_; } // Obtiene el poder actual [[nodiscard]] auto getTotalPower() const -> int { return total_power_; } // Obtiene el poder total acumulado [[nodiscard]] auto getTotalPowerNeededToCompleteGame() const -> int; // Poder total necesario para completar el juego + [[nodiscard]] auto getPowerNeededToReachStage(size_t target_stage_index) const -> int; // Poder necesario para llegar a la fase X [[nodiscard]] auto getTotalStages() const -> size_t { return stages_.size(); } // Obtiene el número total de fases // --- Seguimiento de progreso ---