forked from jaildesigner-jailgames/jaildoctors_dilemma
64 lines
1.0 KiB
C++
64 lines
1.0 KiB
C++
#include "cheevos.h"
|
|
|
|
// Constructor
|
|
Cheevos::Cheevos(Screen *screen, options_t *options)
|
|
{
|
|
// Copia la dirección de los objetos
|
|
this->options = options;
|
|
this->screen = screen;
|
|
|
|
// Inicializa los logros
|
|
init();
|
|
}
|
|
|
|
// Destructor
|
|
Cheevos::~Cheevos()
|
|
{
|
|
cheevos.clear();
|
|
}
|
|
|
|
// Inicializa los logros
|
|
void Cheevos::init()
|
|
{
|
|
cheevos_t c;
|
|
c.completed = false;
|
|
|
|
c.id = 1;
|
|
c.caption = "SALTA";
|
|
cheevos.push_back(c);
|
|
|
|
c.id = 2;
|
|
c.caption = "OBTEN 3 ITEMS";
|
|
cheevos.push_back(c);
|
|
}
|
|
|
|
// Busca un logro por id y devuelve el indice
|
|
int Cheevos::findCheevo(int id)
|
|
{
|
|
for (int i = 0; i < (int)cheevos.size(); ++i)
|
|
{
|
|
if (cheevos[i].id == id)
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
// Desbloquea un logro
|
|
void Cheevos::unlockCheevo(int id)
|
|
{
|
|
const int index = findCheevo(id);
|
|
|
|
if (index == -1)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!cheevos[index].completed)
|
|
{
|
|
cheevos[index].completed = true;
|
|
screen->showNotification(cheevos[index].caption);
|
|
}
|
|
} |