Files
jaildoctors_dilemma/source/cheevos.cpp

117 lines
2.4 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.valid = true;
c.id = 1;
c.caption = "SHINY THINGS";
c.description = "Get 25\% of the items";
cheevos.push_back(c);
c.id = 2;
c.caption = "HALF THE WORK";
c.description = "Get 50\% of the items";
cheevos.push_back(c);
c.id = 3;
c.caption = "GETTING THERE";
c.description = "Get 75\% of the items";
cheevos.push_back(c);
c.id = 4;
c.caption = "THE COLLECTOR";
c.description = "Get 100\% of the items";
cheevos.push_back(c);
c.id = 5;
c.caption = "WANDERING AROUND";
c.description = "Visit 20 rooms";
cheevos.push_back(c);
c.id = 6;
c.caption = "I GOT LOST";
c.description = "Visit 40 rooms";
cheevos.push_back(c);
c.id = 7;
c.caption = "I LIKE TO EXPLORE";
c.description = "Visit all rooms";
cheevos.push_back(c);
c.id = 8;
c.caption = "FINISH THE GAME";
c.description = "Complete the game";
cheevos.push_back(c);
c.id = 9;
c.caption = "I WAS SUCKED BY A HOLE";
c.description = "Complete the game without entering the jail";
cheevos.push_back(c);
c.id = 10;
c.caption = "MY LITTLE PROJECTS";
c.description = "Complete the game with all items";
cheevos.push_back(c);
c.id = 11;
c.caption = "I LIKE MY MULTICOLOURED FRIENDS";
c.description = "Complete the game without dying";
cheevos.push_back(c);
c.id = 12;
c.caption = "SHIT PROJECTS DONE FAST";
c.description = "Complete the game in under 30 minutes";
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("ACHIEVEMENT UNLOCKED!", cheevos[index].caption);
}
}