passant linters a vore si trobe variables sense inicialitzar

This commit is contained in:
2025-08-17 00:23:59 +02:00
parent ada5025c65
commit 327987447d
55 changed files with 516 additions and 474 deletions
+26 -21
View File
@@ -3,11 +3,12 @@
#include <algorithm>
#include <fstream>
#include <sstream>
#include <utility>
// Implementación de StageData
StageData::StageData(int power_to_complete, int min_menace, int max_menace, const std::string& name)
StageData::StageData(int power_to_complete, int min_menace, int max_menace, std::string name)
: status_(StageStatus::LOCKED),
name_(name),
name_(std::move(name)),
power_to_complete_(power_to_complete),
min_menace_(min_menace),
max_menace_(max_menace) {}
@@ -59,7 +60,7 @@ void StageManager::createDefaultStages() {
stages_.emplace_back(950, 7 + (4 * 7), 7 + (4 * 10), "Maestría");
}
bool StageManager::loadStagesFromFile(const std::string& filename) {
auto StageManager::loadStagesFromFile(const std::string& filename) -> bool {
std::ifstream file(filename);
if (!file.is_open()) {
return false; // No se pudo abrir el archivo
@@ -119,7 +120,7 @@ bool StageManager::loadStagesFromFile(const std::string& filename) {
return !stages_.empty();
}
bool StageManager::advanceToNextStage() {
auto StageManager::advanceToNextStage() -> bool {
if (!isCurrentStageCompleted() || current_stage_index_ >= stages_.size() - 1) {
return false;
}
@@ -130,7 +131,7 @@ bool StageManager::advanceToNextStage() {
return true;
}
bool StageManager::jumpToStage(size_t target_stage_index) {
auto StageManager::jumpToStage(size_t target_stage_index) -> bool {
if (!validateStageIndex(target_stage_index)) {
return false;
}
@@ -150,7 +151,7 @@ bool StageManager::jumpToStage(size_t target_stage_index) {
return true;
}
bool StageManager::subtractPower(int amount) {
auto StageManager::subtractPower(int amount) -> bool {
if (amount <= 0 || current_power_ < amount) {
return false;
}
@@ -168,18 +169,18 @@ void StageManager::disablePowerCollection() {
power_collection_state_ = PowerCollectionState::DISABLED;
}
std::optional<StageData> StageManager::getCurrentStage() const {
auto StageManager::getCurrentStage() const -> std::optional<StageData> {
return getStage(current_stage_index_);
}
std::optional<StageData> StageManager::getStage(size_t index) const {
auto StageManager::getStage(size_t index) const -> std::optional<StageData> {
if (!validateStageIndex(index)) {
return std::nullopt;
}
return stages_[index];
}
bool StageManager::isCurrentStageCompleted() const {
auto StageManager::isCurrentStageCompleted() const -> bool {
auto current_stage = getCurrentStage();
if (!current_stage.has_value()) {
return false;
@@ -188,24 +189,28 @@ bool StageManager::isCurrentStageCompleted() const {
return current_power_ >= current_stage->getPowerToComplete();
}
bool StageManager::isGameCompleted() const {
auto StageManager::isGameCompleted() const -> bool {
return current_stage_index_ >= stages_.size() - 1 && isCurrentStageCompleted();
}
double StageManager::getProgressPercentage() const {
if (stages_.empty()) return 0.0;
auto StageManager::getProgressPercentage() const -> double {
if (stages_.empty()) {
return 0.0;
}
int total_power_needed = getTotalPowerNeededToCompleteGame();
if (total_power_needed == 0) return 100.0;
if (total_power_needed == 0) {
return 100.0;
}
return (static_cast<double>(total_power_) / total_power_needed) * 100.0;
}
double StageManager::getCurrentStageProgressPercentage() const {
auto StageManager::getCurrentStageProgressPercentage() const -> double {
return getCurrentStageProgressFraction() * 100.0;
}
double StageManager::getCurrentStageProgressFraction() const {
auto StageManager::getCurrentStageProgressFraction() const -> double {
auto current_stage = getCurrentStage();
if (!current_stage.has_value()) {
return 0.0;
@@ -221,7 +226,7 @@ double StageManager::getCurrentStageProgressFraction() const {
return std::min(fraction, 1.0);
}
int StageManager::getPowerNeededForCurrentStage() const {
auto StageManager::getPowerNeededForCurrentStage() const -> int {
auto current_stage = getCurrentStage();
if (!current_stage.has_value()) {
return 0;
@@ -230,7 +235,7 @@ int StageManager::getPowerNeededForCurrentStage() const {
return std::max(0, current_stage->getPowerToComplete() - current_power_);
}
int StageManager::getTotalPowerNeededToCompleteGame() const {
auto StageManager::getTotalPowerNeededToCompleteGame() const -> int {
int total_power_needed = 0;
for (const auto& stage : stages_) {
total_power_needed += stage.getPowerToComplete();
@@ -239,7 +244,7 @@ int StageManager::getTotalPowerNeededToCompleteGame() const {
}
// Implementación de la interfaz IStageInfo
bool StageManager::canCollectPower() const {
auto StageManager::canCollectPower() const -> bool {
return power_collection_state_ == PowerCollectionState::ENABLED;
}
@@ -267,7 +272,7 @@ void StageManager::addPower(int amount) {
updateStageStatuses();
}
int StageManager::getCurrentMenaceLevel() const {
auto StageManager::getCurrentMenaceLevel() const -> int {
auto current_stage = getCurrentStage();
if (!current_stage.has_value()) {
return 0;
@@ -278,7 +283,7 @@ int StageManager::getCurrentMenaceLevel() const {
// Gestión de callbacks
void StageManager::setPowerChangeCallback(PowerChangeCallback callback) {
power_change_callback_ = callback;
power_change_callback_ = std::move(callback);
}
void StageManager::removePowerChangeCallback() {
@@ -286,7 +291,7 @@ void StageManager::removePowerChangeCallback() {
}
// Métodos privados
bool StageManager::validateStageIndex(size_t index) const {
auto StageManager::validateStageIndex(size_t index) const -> bool {
return index < stages_.size();
}