Ya funcionan las puntuaciones online
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#include "common/jscore.h"
|
||||
#include "common/utils.h"
|
||||
#include "const.h"
|
||||
#include "director.h"
|
||||
#include "common/utils.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
// Constructor
|
||||
@@ -37,6 +39,9 @@ Director::Director(std::string path)
|
||||
initInput();
|
||||
|
||||
screen = new Screen(window, renderer, asset, options, GAME_WIDTH, GAME_HEIGHT);
|
||||
|
||||
// Inicializa los servicios online
|
||||
initOnline();
|
||||
}
|
||||
|
||||
Director::~Director()
|
||||
@@ -170,6 +175,7 @@ bool Director::setFileList()
|
||||
asset->add(prefix + "/data/config/score.bin", t_data, false);
|
||||
asset->add(prefix + "/data/config/demo.bin", t_data);
|
||||
asset->add(prefix + "/data/config/config.bin", t_data, false);
|
||||
asset->add(prefix + "/data/config/jailer_id.txt", t_data, false);
|
||||
asset->add(prefix + "/data/config/gamecontrollerdb.txt", t_data);
|
||||
|
||||
// Musicas
|
||||
@@ -316,6 +322,9 @@ bool Director::loadConfigFile()
|
||||
options->keepAspect = true;
|
||||
options->borderSize = 0.0f;
|
||||
options->borderEnabled = false;
|
||||
options->online.gameID = "coffee_crisis";
|
||||
options->online.jailerID = "";
|
||||
options->online.score = 0;
|
||||
|
||||
// Indicador de éxito en la carga
|
||||
bool success = true;
|
||||
@@ -498,4 +507,56 @@ void Director::run()
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inicializa los servicios online
|
||||
void Director::initOnline()
|
||||
{
|
||||
// Obtiene la información online
|
||||
if (jscore::initOnlineScore(options->online.gameID))
|
||||
{
|
||||
screen->showText("Conectado a jaildoctor.duckdns.org");
|
||||
std::cout << "Conectado a jaildoctor.duckdns.org" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->showText("Fallo al conectar a jaildoctor.duckdns.org");
|
||||
std::cout << "Fallo al conectar a jaildoctor.duckdns.org" << std::endl;
|
||||
}
|
||||
|
||||
// Obten el Jailer ID
|
||||
std::fstream f;
|
||||
f.open(asset->get("jailer_id.txt"), std::ios::in);
|
||||
if (f.is_open())
|
||||
{
|
||||
std::string str;
|
||||
if (getline(f, options->online.jailerID))
|
||||
{
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
f.close();
|
||||
|
||||
if (options->online.jailerID == "")
|
||||
{
|
||||
screen->showText("No ha especificado ningun Jailer ID");
|
||||
std::cout << "No ha especificado ningun Jailer ID" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->showText(options->online.jailerID + " ha iniciado sesion");
|
||||
std::cout << options->online.jailerID << " ha iniciado sesion" << std::endl;
|
||||
}
|
||||
|
||||
// Obten la puntuación online
|
||||
const int points = jscore::getUserPoints(options->online.gameID, options->online.jailerID);
|
||||
if (points == 0)
|
||||
{
|
||||
screen->showText("No se ha podido obtener la puntuacion online");
|
||||
std::cout << "No se ha podido obtener la puntuacion online" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
options->online.score = points;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user