Ya funcionan las puntuaciones online
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "game.h"
|
||||
#include "common/jscore.h"
|
||||
|
||||
// Constructor
|
||||
Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, options_t *options)
|
||||
@@ -54,6 +55,7 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
|
||||
Game::~Game()
|
||||
{
|
||||
saveScoreFile();
|
||||
sendOnlineScore();
|
||||
saveDemoFile();
|
||||
|
||||
// Restaura el metodo de control
|
||||
@@ -725,6 +727,28 @@ bool Game::saveScoreFile()
|
||||
return success;
|
||||
}
|
||||
|
||||
// Sube la puntuación online
|
||||
bool Game::sendOnlineScore()
|
||||
{
|
||||
const int score = players.at(0)->getScore();
|
||||
if (score <= options->online.score)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (jscore::updateUserPoints("coffee_crisis", options->online.jailerID, score))
|
||||
{
|
||||
options->online.score = score;
|
||||
screen->showText("PUNTUACION ENVIADA: " + std::to_string(score) + " PUNTOS");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->showText("NO SE HA PODIDO ENVIAR LA PUNTUACION");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Guarda el fichero de datos para la demo
|
||||
bool Game::saveDemoFile()
|
||||
{
|
||||
@@ -1659,7 +1683,9 @@ void Game::renderScoreBoard()
|
||||
|
||||
// HI-SCORE
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset3, lang->getText(56));
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, updateScoreText(hiScore));
|
||||
// textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, updateScoreText(hiScore));
|
||||
const std::string txt = jscore::getUserName(0) + " - " + updateScoreText((Uint32)jscore::getPoints(0));
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, txt);
|
||||
}
|
||||
|
||||
// Actualiza las variables del jugador
|
||||
@@ -3581,6 +3607,9 @@ void Game::runGameOverScreen()
|
||||
// Guarda los puntos
|
||||
saveScoreFile();
|
||||
|
||||
// Sube la puntuación online
|
||||
sendOnlineScore();
|
||||
|
||||
// Reinicia el menu
|
||||
gameOverMenu->reset();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user