forked from jaildesigner-jailgames/jaildoctors_dilemma
Empezando a trabajar con los logros
This commit is contained in:
@@ -1,13 +1,64 @@
|
||||
#include "cheevos.h"
|
||||
|
||||
// Constructor
|
||||
Cheevos::Cheevos(options_t *options)
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user