Colocados los disparadores de los logros en su sitio

This commit is contained in:
2022-12-29 14:08:42 +01:00
parent f590101047
commit c0d4eddde7
7 changed files with 117 additions and 9 deletions

View File

@@ -23,6 +23,7 @@ void Cheevos::init()
cheevos_t c;
c.completed = false;
c.valid = true;
c.icon = 2;
c.id = 1;
c.caption = "SHINY THINGS";
@@ -86,7 +87,7 @@ void Cheevos::init()
}
// Busca un logro por id y devuelve el indice
int Cheevos::findCheevo(int id)
int Cheevos::find(int id)
{
for (int i = 0; i < (int)cheevos.size(); ++i)
{
@@ -100,18 +101,34 @@ int Cheevos::findCheevo(int id)
}
// Desbloquea un logro
void Cheevos::unlockCheevo(int id)
void Cheevos::unlock(int id)
{
const int index = findCheevo(id);
const int index = find(id);
if (index == -1)
{
return;
}
if (!cheevos[index].valid)
{
return;
}
if (!cheevos[index].completed)
{
cheevos[index].completed = true;
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption);
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption, cheevos[index].icon);
}
}
// Invalida un logro
void Cheevos::invalidate(int id)
{
const int index = find(id);
if (index == -1)
{
return;
}
cheevos[index].valid = false;
}