fix: corregida logica per obrir i entrar a la jail. ja no mira el nom de la habitacio sino el numero
This commit is contained in:
@@ -94,12 +94,12 @@ void Debug::setDebugFile(const std::string& path) {
|
||||
|
||||
// Convierte string a SceneManager::Scene (para debug.yaml)
|
||||
static auto sceneFromString(const std::string& s) -> SceneManager::Scene {
|
||||
if (s == "LOGO") { return SceneManager::Scene::LOGO; }
|
||||
if (s == "LOGO") { return SceneManager::Scene::LOGO; }
|
||||
if (s == "LOADING") { return SceneManager::Scene::LOADING_SCREEN; }
|
||||
if (s == "TITLE") { return SceneManager::Scene::TITLE; }
|
||||
if (s == "TITLE") { return SceneManager::Scene::TITLE; }
|
||||
if (s == "CREDITS") { return SceneManager::Scene::CREDITS; }
|
||||
if (s == "DEMO") { return SceneManager::Scene::DEMO; }
|
||||
if (s == "ENDING") { return SceneManager::Scene::ENDING; }
|
||||
if (s == "DEMO") { return SceneManager::Scene::DEMO; }
|
||||
if (s == "ENDING") { return SceneManager::Scene::ENDING; }
|
||||
if (s == "ENDING2") { return SceneManager::Scene::ENDING2; }
|
||||
return SceneManager::Scene::GAME; // Fallback seguro
|
||||
}
|
||||
@@ -107,14 +107,22 @@ static auto sceneFromString(const std::string& s) -> SceneManager::Scene {
|
||||
// Convierte SceneManager::Scene a string (para debug.yaml)
|
||||
static auto sceneToString(SceneManager::Scene scene) -> std::string {
|
||||
switch (scene) {
|
||||
case SceneManager::Scene::LOGO: return "LOGO";
|
||||
case SceneManager::Scene::LOADING_SCREEN: return "LOADING";
|
||||
case SceneManager::Scene::TITLE: return "TITLE";
|
||||
case SceneManager::Scene::CREDITS: return "CREDITS";
|
||||
case SceneManager::Scene::DEMO: return "DEMO";
|
||||
case SceneManager::Scene::ENDING: return "ENDING";
|
||||
case SceneManager::Scene::ENDING2: return "ENDING2";
|
||||
default: return "GAME";
|
||||
case SceneManager::Scene::LOGO:
|
||||
return "LOGO";
|
||||
case SceneManager::Scene::LOADING_SCREEN:
|
||||
return "LOADING";
|
||||
case SceneManager::Scene::TITLE:
|
||||
return "TITLE";
|
||||
case SceneManager::Scene::CREDITS:
|
||||
return "CREDITS";
|
||||
case SceneManager::Scene::DEMO:
|
||||
return "DEMO";
|
||||
case SceneManager::Scene::ENDING:
|
||||
return "ENDING";
|
||||
case SceneManager::Scene::ENDING2:
|
||||
return "ENDING2";
|
||||
default:
|
||||
return "GAME";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,10 @@ class Debug {
|
||||
void setDebugFile(const std::string& path); // Establece la ruta del archivo debug.yaml
|
||||
void loadFromFile(); // Carga la configuración de debug desde debug.yaml
|
||||
void saveToFile() const; // Guarda la configuración de debug en debug.yaml
|
||||
[[nodiscard]] auto getSpawnSettings() const -> const SpawnSettings& { return spawn_settings_; } // Obtiene los valores de spawn
|
||||
void setSpawnSettings(const SpawnSettings& s) { spawn_settings_ = s; } // Establece los valores de spawn
|
||||
[[nodiscard]] auto getInitialScene() const -> SceneManager::Scene { return initial_scene_; } // Obtiene la escena inicial de debug
|
||||
void setInitialScene(SceneManager::Scene s) { initial_scene_ = s; } // Establece la escena inicial de debug
|
||||
[[nodiscard]] auto getSpawnSettings() const -> const SpawnSettings& { return spawn_settings_; } // Obtiene los valores de spawn
|
||||
void setSpawnSettings(const SpawnSettings& s) { spawn_settings_ = s; } // Establece los valores de spawn
|
||||
[[nodiscard]] auto getInitialScene() const -> SceneManager::Scene { return initial_scene_; } // Obtiene la escena inicial de debug
|
||||
void setInitialScene(SceneManager::Scene s) { initial_scene_ = s; } // Establece la escena inicial de debug
|
||||
|
||||
private:
|
||||
static Debug* debug; // [SINGLETON] Objeto privado
|
||||
@@ -55,14 +55,14 @@ class Debug {
|
||||
~Debug() = default; // Destructor
|
||||
|
||||
// Variables
|
||||
std::map<std::string, std::string> watches_; // Watch window: valores persistentes (key→value)
|
||||
std::vector<std::string> slot_; // One-shot: textos que se limpian cada frame
|
||||
std::vector<std::string> log_; // Log persistente
|
||||
int x_ = 0; // Posicion donde escribir el texto de debug
|
||||
int y_ = 0; // Posición donde escribir el texto de debug
|
||||
bool enabled_ = false; // Indica si esta activo el modo debug
|
||||
std::string debug_file_path_; // Ruta del archivo debug.yaml
|
||||
SpawnSettings spawn_settings_; // Configuración de spawn para debug
|
||||
std::map<std::string, std::string> watches_; // Watch window: valores persistentes (key→value)
|
||||
std::vector<std::string> slot_; // One-shot: textos que se limpian cada frame
|
||||
std::vector<std::string> log_; // Log persistente
|
||||
int x_ = 0; // Posicion donde escribir el texto de debug
|
||||
int y_ = 0; // Posición donde escribir el texto de debug
|
||||
bool enabled_ = false; // Indica si esta activo el modo debug
|
||||
std::string debug_file_path_; // Ruta del archivo debug.yaml
|
||||
SpawnSettings spawn_settings_; // Configuración de spawn para debug
|
||||
SceneManager::Scene initial_scene_ = SceneManager::Scene::GAME; // Escena inicial en debug
|
||||
};
|
||||
|
||||
|
||||
@@ -88,8 +88,13 @@ namespace Defaults::Localization {
|
||||
constexpr const char* LANGUAGE = "ca"; // Idioma por defecto (en = inglés, ca = catalán)
|
||||
} // namespace Defaults::Localization
|
||||
|
||||
namespace Defaults::Game::Items {
|
||||
constexpr const float PERCENT_TO_OPEN_THE_JAIL = 0.9F; // Porcentaje de items necesarios para abrir la jail
|
||||
} // namespace Defaults::Game::Items
|
||||
|
||||
namespace Defaults::Game::Room {
|
||||
constexpr const char* INITIAL = "03.yaml"; // Habitación de inicio
|
||||
constexpr const char* END_ROOM = "01"; // Habitación final (jail)
|
||||
} // namespace Defaults::Game::Room
|
||||
|
||||
namespace Defaults::Game::Player {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace GameControl {
|
||||
// Disponible en todos los builds — refresca el color del jugador según cheats
|
||||
inline std::function<void()> refresh_player_color;
|
||||
}
|
||||
} // namespace GameControl
|
||||
|
||||
#ifdef _DEBUG
|
||||
namespace GameControl {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "game/defaults.hpp" // Para Defaults::Game
|
||||
#include "game/gameplay/collision_map.hpp" // Para CollisionMap
|
||||
#include "game/gameplay/enemy_manager.hpp" // Para EnemyManager
|
||||
#include "game/gameplay/item_manager.hpp" // Para ItemManager
|
||||
@@ -82,7 +83,7 @@ void Room::initializeRoom(const Data& room) {
|
||||
|
||||
// Abre la jail para poder entrar
|
||||
void Room::openTheJail() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (data_->jail_is_open && name_ == "THE JAIL") {
|
||||
if (data_->jail_is_open && number_ == Defaults::Game::Room::END_ROOM) {
|
||||
// Elimina el último enemigo (Bry debe ser el último enemigo definido en el fichero)
|
||||
if (!enemy_manager_->isEmpty()) {
|
||||
enemy_manager_->removeLastEnemy();
|
||||
|
||||
@@ -61,6 +61,7 @@ class Room {
|
||||
~Room(); // NOLINT(modernize-use-equals-default, performance-trivially-destructible) -- defined in .cpp for unique_ptr with forward declarations
|
||||
|
||||
// --- Funciones ---
|
||||
[[nodiscard]] auto getNumber() const -> const std::string& { return number_; } // Devuelve el numero de la habitación
|
||||
[[nodiscard]] auto getName() const -> const std::string& { return name_; } // Devuelve el nombre de la habitación
|
||||
[[nodiscard]] auto getBGColor() const -> Uint8 { return stringToColor(bg_color_); } // Devuelve el color de la habitación
|
||||
[[nodiscard]] auto getBorderColor() const -> Uint8 { return stringToColor(border_color_); } // Devuelve el color del borde
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace SceneManager {
|
||||
TITLE_WITHOUT_LOADING_SCREEN // Al título sin pantalla de carga
|
||||
};
|
||||
|
||||
// --- Variables de estado globales ---
|
||||
inline Scene current = Scene::LOGO; // Escena actual (en _DEBUG sobrescrito por Director tras cargar debug.yaml)
|
||||
// --- Variables de estado globales ---
|
||||
inline Scene current = Scene::LOGO; // Escena actual (en _DEBUG sobrescrito por Director tras cargar debug.yaml)
|
||||
inline Options options = Options::LOGO_TO_LOADING_SCREEN; // Opciones de la escena actual
|
||||
inline Scene scene_before_restart = Scene::LOGO; // escena a relanzar tras RESTART_CURRENT
|
||||
|
||||
|
||||
@@ -720,9 +720,11 @@ void Game::setScoreBoardColor() { // NOLINT(readability-convert-member-function
|
||||
|
||||
// Comprueba si ha finalizado el juego
|
||||
auto Game::checkEndGame() -> bool {
|
||||
const bool IS_ON_THE_ROOM = room_->getName() == "THE JAIL"; // Estar en la habitación que toca
|
||||
const bool HAVE_THE_ITEMS = scoreboard_data_->items >= int(total_items_ * 0.9F) || Options::cheats.jail_is_open == Options::Cheat::State::ENABLED; // Con mas del 90% de los items recogidos
|
||||
const bool IS_ON_THE_DOOR = player_->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
||||
const bool IS_ON_THE_ROOM = room_->getNumber() == Defaults::Game::Room::END_ROOM; // Estar en la habitación que toca
|
||||
const bool HAVE_THE_ITEMS =
|
||||
scoreboard_data_->items >= int(total_items_ * Defaults::Game::Items::PERCENT_TO_OPEN_THE_JAIL) ||
|
||||
Options::cheats.jail_is_open == Options::Cheat::State::ENABLED; // Con mas del 90% de los items recogidos
|
||||
const bool IS_ON_THE_DOOR = player_->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
||||
|
||||
scoreboard_data_->jail_is_open = HAVE_THE_ITEMS;
|
||||
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "game/game_control.hpp" // Para GameControl (refresh_player_color)
|
||||
#include "game/options.hpp" // Para Options
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "game/ui/notifier.hpp" // Para Notifier
|
||||
|
||||
#include "game/game_control.hpp" // Para GameControl (refresh_player_color)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include "core/system/debug.hpp" // Para Debug
|
||||
#endif
|
||||
@@ -500,14 +499,30 @@ static const std::vector<ConsoleCommand> COMMANDS = {
|
||||
SceneManager::Scene target = SceneManager::current;
|
||||
std::string name = "current";
|
||||
if (args.size() >= 3) {
|
||||
if (args[2] == "GAME") { target = SceneManager::Scene::GAME; name = "GAME"; }
|
||||
else if (args[2] == "LOGO") { target = SceneManager::Scene::LOGO; name = "LOGO"; }
|
||||
else if (args[2] == "LOADING") { target = SceneManager::Scene::LOADING_SCREEN; name = "LOADING"; }
|
||||
else if (args[2] == "TITLE") { target = SceneManager::Scene::TITLE; name = "TITLE"; }
|
||||
else if (args[2] == "CREDITS") { target = SceneManager::Scene::CREDITS; name = "CREDITS"; }
|
||||
else if (args[2] == "ENDING") { target = SceneManager::Scene::ENDING; name = "ENDING"; }
|
||||
else if (args[2] == "ENDING2") { target = SceneManager::Scene::ENDING2; name = "ENDING2"; }
|
||||
else { return "Unknown scene: " + args[2]; }
|
||||
if (args[2] == "GAME") {
|
||||
target = SceneManager::Scene::GAME;
|
||||
name = "GAME";
|
||||
} else if (args[2] == "LOGO") {
|
||||
target = SceneManager::Scene::LOGO;
|
||||
name = "LOGO";
|
||||
} else if (args[2] == "LOADING") {
|
||||
target = SceneManager::Scene::LOADING_SCREEN;
|
||||
name = "LOADING";
|
||||
} else if (args[2] == "TITLE") {
|
||||
target = SceneManager::Scene::TITLE;
|
||||
name = "TITLE";
|
||||
} else if (args[2] == "CREDITS") {
|
||||
target = SceneManager::Scene::CREDITS;
|
||||
name = "CREDITS";
|
||||
} else if (args[2] == "ENDING") {
|
||||
target = SceneManager::Scene::ENDING;
|
||||
name = "ENDING";
|
||||
} else if (args[2] == "ENDING2") {
|
||||
target = SceneManager::Scene::ENDING2;
|
||||
name = "ENDING2";
|
||||
} else {
|
||||
return "Unknown scene: " + args[2];
|
||||
}
|
||||
}
|
||||
Debug::get()->setInitialScene(target);
|
||||
Debug::get()->saveToFile();
|
||||
|
||||
Reference in New Issue
Block a user