diff --git a/source/enter_name.cpp b/source/enter_name.cpp index af419dc..f6de6db 100644 --- a/source/enter_name.cpp +++ b/source/enter_name.cpp @@ -167,4 +167,23 @@ int EnterName::findIndex(char character) const } } return 0; -} \ No newline at end of file +} + +// Devuelve un nombre al azar +std::string EnterName::getRandomName() +{ + static constexpr std::array NAMES = { + "BAL1", "TABE", "DOC", "MON", "SAM1", "JORDI", "JDES", "PEPE"}; + return std::string(NAMES[rand() % NAMES.size()]); +} +// Obtiene el nombre final introducido +std::string EnterName::getFinalName() +{ + auto name = trim(name_.substr(0, position_)); + if (name.empty()) + { + name = getRandomName(); + } + name_ = name; + return name_; +} diff --git a/source/enter_name.h b/source/enter_name.h index 139d7fc..5e329c4 100644 --- a/source/enter_name.h +++ b/source/enter_name.h @@ -21,8 +21,8 @@ public: void incIndex(); // Incrementa el índice del carácter en la lista void decIndex(); // Decrementa el índice del carácter en la lista - std::string getFinalName() const { return trim(name_.substr(0, position_)); } // Obtiene el nombre final introducido - std::string getCurrentName() const { return trim(name_); } // Obtiene el nombre actual en proceso + std::string getFinalName(); // Obtiene el nombre final introducido + std::string getCurrentName() const { return trim(name_); } // Obtiene el nombre actual en proceso int getPosition() const { return position_; } // Posición actual del carácter editado bool getPositionOverflow() const { return position_overflow_; } // Indica si la posición excede el límite @@ -37,4 +37,5 @@ private: void updateNameFromCharacterIndex(); // Actualiza "name_" según "character_index_" void initCharacterIndex(const std::string &name); // Inicializa índices desde el nombre int findIndex(char character) const; // Busca el índice de un carácter en "character_list_" + static std::string getRandomName(); // Devuelve un nombre al azar }; \ No newline at end of file diff --git a/source/player.cpp b/source/player.cpp index a8f4397..516ef8d 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -150,11 +150,6 @@ void Player::setInputEnteringName(InputAction input) break; case InputAction::START: last_enter_name_ = getRecordName(); - if (last_enter_name_.empty()) - { - const std::array NAMES = {"BAL1", "TABE", "DOC", "MON", "SAM1", "JORDI", "JDES", "PEPE"}; - last_enter_name_ = NAMES.at(rand() % NAMES.size()); - } break; default: break; diff --git a/source/player.h b/source/player.h index a754d8b..bc88c1a 100644 --- a/source/player.h +++ b/source/player.h @@ -122,7 +122,7 @@ public: int getPosX() const { return static_cast(pos_x_); } int getPosY() const { return pos_y_; } int getPowerUpCounter() const { return power_up_counter_; } - std::string getRecordName() const { return enter_name_ ? enter_name_->getFinalName() : ""; } + std::string getRecordName() const { return enter_name_ ? enter_name_->getFinalName() : "xxx"; } int getScore() const { return score_; } int getScoreBoardPanel() const { return scoreboard_panel_; } int getWidth() const { return WIDTH_; } diff --git a/source/utils.cpp b/source/utils.cpp index 77c8d3c..33e8eb5 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -474,31 +474,6 @@ constexpr Color hsvToRgb(HSV hsv) static_cast(roundf((b + m) * 255))); } -/*ColorCycle generateMirroredCycle(Color base) -{ - ColorCycle result{}; - HSV baseHSV = rgbToHsv(base); - - for (size_t i = 0; i < COLOR_CYCLE_SIZE; ++i) - { - float t = static_cast(i) / (COLOR_CYCLE_SIZE - 1); - float hueShift = 25.0f * t; // reducido de 45 a 25 - float satShift = 0.0f; // sin cambio de saturación - float valShift = 0.07f * sinf(t * 3.1415926f); // brillo más suave - - HSV adjusted = { - fmodf(baseHSV.h + hueShift, 360.0f), - fminf(1.0f, fmaxf(0.0f, baseHSV.s + satShift)), - fminf(1.0f, fmaxf(0.0f, baseHSV.v + valShift))}; - - Color c = hsvToRgb(adjusted); - result[i] = c; - result[2 * COLOR_CYCLE_SIZE - 1 - i] = c; // espejo - } - - return result; -}*/ - ColorCycle generateMirroredCycle(Color base, ColorCycleStyle style) { ColorCycle result{};