2 Commits

6 changed files with 38 additions and 14 deletions

View File

@@ -9,6 +9,9 @@ Cheevos::Cheevos(Screen *screen, options_t *options)
// Inicializa los logros // Inicializa los logros
init(); init();
// inicializa variables
enabled = true;
} }
// Destructor // Destructor
@@ -115,12 +118,19 @@ void Cheevos::unlock(int id)
return; return;
} }
if (!cheevos[index].completed) if (cheevos[index].completed)
{ {
return;
}
if (!enabled)
{
return;
}
cheevos[index].completed = true; cheevos[index].completed = true;
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption, cheevos[index].icon); screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption, cheevos[index].icon);
} }
}
// Invalida un logro // Invalida un logro
void Cheevos::invalidate(int id) void Cheevos::invalidate(int id)
@@ -132,3 +142,9 @@ void Cheevos::invalidate(int id)
} }
cheevos[index].valid = false; cheevos[index].valid = false;
} }
// Habilita o deshabilita los logros
void Cheevos::enable(bool value)
{
enabled = value;
}

View File

@@ -27,6 +27,7 @@ private:
// Variables // Variables
std::vector<cheevos_t> cheevos; // Listado de logros std::vector<cheevos_t> cheevos; // Listado de logros
bool enabled; // Indica si los logros se pueden obtener
// Inicializa los logros // Inicializa los logros
void init(); void init();
@@ -46,6 +47,9 @@ public:
// Invalida un logro // Invalida un logro
void invalidate(int id); void invalidate(int id);
// Habilita o deshabilita los logros
void enable(bool value);
}; };
#endif #endif

View File

@@ -161,7 +161,8 @@ void Ending::checkEventHandler()
switch (eventHandler->key.keysym.scancode) switch (eventHandler->key.keysym.scancode)
{ {
case SDL_SCANCODE_ESCAPE: case SDL_SCANCODE_ESCAPE:
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
break; break;
case SDL_SCANCODE_B: case SDL_SCANCODE_B:

View File

@@ -195,7 +195,8 @@ void Ending2::checkEventHandler()
switch (eventHandler->key.keysym.scancode) switch (eventHandler->key.keysym.scancode)
{ {
case SDL_SCANCODE_ESCAPE: case SDL_SCANCODE_ESCAPE:
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
break; break;
case SDL_SCANCODE_B: case SDL_SCANCODE_B:

View File

@@ -82,6 +82,8 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
totalItems = getTotalItems(); totalItems = getTotalItems();
initStats(); initStats();
stats->addVisit(room->getName()); 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->name = SECTION_PROG_GAME;
section->subsection = 0; section->subsection = 0;
@@ -125,7 +127,7 @@ void Game::checkEventHandler()
reLoadTextures(); reLoadTextures();
} }
if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0)) if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
{ {
switch (eventHandler->key.keysym.scancode) switch (eventHandler->key.keysym.scancode)
{ {
@@ -655,20 +657,20 @@ void Game::checkRestoringJail()
counter++; counter++;
} }
// Incrementa el numero de vidas
if (counter == 100) if (counter == 100)
{ {
counter = 0; counter = 0;
board.lives++; board.lives++;
JA_PlaySound(deathSound); JA_PlaySound(deathSound);
}
// Invalida el logro de completar el juego sin entrar a la jail // 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 const bool haveTheItems = board.items >= int(totalItems * 0.9f);
if (!haveTheItems) if (!haveTheItems)
{ {
cheevos->invalidate(9); cheevos->invalidate(9);
} }
}
} }
// Inicializa el diccionario de las estadísticas // Inicializa el diccionario de las estadísticas

View File

@@ -82,7 +82,7 @@ void Logo::checkEventHandler()
} }
// Comprueba las teclas que se han pulsado // Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYUP && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONUP)) if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONUP))
{ {
switch (eventHandler->key.keysym.scancode) switch (eventHandler->key.keysym.scancode)
{ {