He tornat a deixar el progres del fondo que fa tope en la ultima fase, no en el final del joc

This commit is contained in:
2025-08-17 08:20:38 +02:00
parent 142603db71
commit b359a73d50
3 changed files with 14 additions and 1 deletions

View File

@@ -56,7 +56,7 @@ Game::Game(Player::Id player_id, int current_stage, bool demo)
pause_manager_(std::make_unique<PauseManager>([this](bool is_paused) { onPauseStateChanged(is_paused); })), pause_manager_(std::make_unique<PauseManager>([this](bool is_paused) { onPauseStateChanged(is_paused); })),
stage_manager_(std::make_unique<StageManager>()), stage_manager_(std::make_unique<StageManager>()),
balloon_manager_(std::make_unique<BalloonManager>(stage_manager_.get())), balloon_manager_(std::make_unique<BalloonManager>(stage_manager_.get())),
background_(std::make_unique<Background>(stage_manager_->getTotalPowerNeededToCompleteGame())), background_(std::make_unique<Background>(stage_manager_->getPowerNeededToReachStage(stage_manager_->getTotalStages() - 1))),
fade_in_(std::make_unique<Fade>()), fade_in_(std::make_unique<Fade>()),
fade_out_(std::make_unique<Fade>()), fade_out_(std::make_unique<Fade>()),
tabe_(std::make_unique<Tabe>()), tabe_(std::make_unique<Tabe>()),

View File

@@ -243,6 +243,18 @@ auto StageManager::getTotalPowerNeededToCompleteGame() const -> int {
return total_power_needed; 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 // Implementación de la interfaz IStageInfo
auto StageManager::canCollectPower() const -> bool { auto StageManager::canCollectPower() const -> bool {
return power_collection_state_ == PowerCollectionState::ENABLED; return power_collection_state_ == PowerCollectionState::ENABLED;

View File

@@ -75,6 +75,7 @@ class StageManager : public IStageInfo {
[[nodiscard]] auto getCurrentPower() const -> int { return current_power_; } // Obtiene el poder actual [[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 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 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 [[nodiscard]] auto getTotalStages() const -> size_t { return stages_.size(); } // Obtiene el número total de fases
// --- Seguimiento de progreso --- // --- Seguimiento de progreso ---