From 48b8ae049a7de986194b7f12a277f97a696f8e41 Mon Sep 17 00:00:00 2001 From: Sergio Valor Martinez Date: Thu, 29 Dec 2022 14:59:48 +0100 Subject: [PATCH] Testeados todos los logros. Los logros no funcionan con los trucos activados --- source/cheevos.cpp | 22 +++++++++++++++++++--- source/cheevos.h | 4 ++++ source/game.cpp | 23 +++++++++++++---------- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/source/cheevos.cpp b/source/cheevos.cpp index 3937201..1152da7 100644 --- a/source/cheevos.cpp +++ b/source/cheevos.cpp @@ -9,6 +9,9 @@ Cheevos::Cheevos(Screen *screen, options_t *options) // Inicializa los logros init(); + + // inicializa variables + enabled = true; } // Destructor @@ -115,11 +118,18 @@ void Cheevos::unlock(int id) return; } - if (!cheevos[index].completed) + if (cheevos[index].completed) { - cheevos[index].completed = true; - screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption, cheevos[index].icon); + return; } + + if (!enabled) + { + return; + } + + cheevos[index].completed = true; + screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption, cheevos[index].icon); } // Invalida un logro @@ -131,4 +141,10 @@ void Cheevos::invalidate(int id) return; } cheevos[index].valid = false; +} + +// Habilita o deshabilita los logros +void Cheevos::enable(bool value) +{ + enabled = value; } \ No newline at end of file diff --git a/source/cheevos.h b/source/cheevos.h index e25a88b..7c7ee37 100644 --- a/source/cheevos.h +++ b/source/cheevos.h @@ -27,6 +27,7 @@ private: // Variables std::vector cheevos; // Listado de logros + bool enabled; // Indica si los logros se pueden obtener // Inicializa los logros void init(); @@ -46,6 +47,9 @@ public: // Invalida un logro void invalidate(int id); + + // Habilita o deshabilita los logros + void enable(bool value); }; #endif diff --git a/source/game.cpp b/source/game.cpp index 1bc3770..e01b33f 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -82,6 +82,8 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as totalItems = getTotalItems(); initStats(); stats->addVisit(room->getName()); + const bool cheats = options->cheat.infiniteLives || options->cheat.invincible || options->cheat.jailEnabled; + cheevos->enable(!cheats); // Deshabilita los logros si hay trucos activados section->name = SECTION_PROG_GAME; section->subsection = 0; @@ -575,9 +577,10 @@ void Game::setScoreBoardColor() // Comprueba si ha finalizado el juego bool Game::checkEndGame() { - const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca - const bool haveTheItems = board.items >= int(totalItems * 0.9f) || options->cheat.jailEnabled; // Con mas del 90% de los items recogidos - const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta) + const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca + // const bool haveTheItems = board.items >= int(totalItems * 0.9f) || options->cheat.jailEnabled; // Con mas del 90% de los items recogidos + const bool haveTheItems = board.items == 2; + const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta) if (haveTheItems) { @@ -655,20 +658,20 @@ void Game::checkRestoringJail() counter++; } + // Incrementa el numero de vidas if (counter == 100) { counter = 0; board.lives++; JA_PlaySound(deathSound); - } - // Invalida el logro de completar el juego sin entrar a la jail - const bool haveTheItems = board.items >= int(totalItems * 0.9f) || options->cheat.jailEnabled; // Con mas del 90% de los items recogidos - if (!haveTheItems) - { - cheevos->invalidate(9); + // Invalida el logro de completar el juego sin entrar a la jail + const bool haveTheItems = board.items == 2; + if (!haveTheItems) + { + cheevos->invalidate(9); + } } - } // Inicializa el diccionario de las estadísticas