diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp index 6c4eff0..766be6c 100644 --- a/source/code/BlockGame.cpp +++ b/source/code/BlockGame.cpp @@ -325,6 +325,11 @@ void BlockGame::NewGame( unsigned int ticks) { lastAImove = ticks+3000; } //NewGame +void BlockGame::FinalizeBlockGameInfo() { + replayInfo.extra.name = name; + replayInfo.extra.score = score; + replayInfo.extra.seconds = gameEndedAfter; +} //Prints "winner" and ends game void BlockGame::setPlayerWon() { @@ -346,6 +351,7 @@ void BlockGame::setPlayerWon() { //The AI have defeated a human player Stats::getInstance()->addOne("defeatedByAI"+itoa(getAIlevel())); } + FinalizeBlockGameInfo(); } hasWonTheGame = true; } @@ -362,6 +368,7 @@ void BlockGame::setDraw() { if (recordStats) { Stats::getInstance()->addOne("totalDraws"); } + FinalizeBlockGameInfo(); } @@ -1004,6 +1011,7 @@ void BlockGame::SetGameOver() { if (recordStats) { TimeHandler::addTime("playTime",TimeHandler::ms2ct(gameEndedAfter)); } + FinalizeBlockGameInfo(); } bGameOver = true; if (stageClear) { diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index b778c56..5436780 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp @@ -109,13 +109,25 @@ struct BlockGameAction { } }; +struct BlockGameInfoExtra { + std::string name; + int score = 0; + int seconds = 0; + template + void serialize( Archive & ar ) + { + ar( CEREAL_NVP(name), CEREAL_NVP(score), CEREAL_NVP(seconds) ); + } +}; + struct BlockGameInfo { BlockGameStartInfo startInfo; std::deque actions; + BlockGameInfoExtra extra; template void serialize( Archive & ar ) { - ar( CEREAL_NVP(startInfo), CEREAL_NVP(actions) ); + ar( CEREAL_NVP(startInfo), CEREAL_NVP(actions), CEREAL_NVP(extra) ); } }; @@ -300,6 +312,7 @@ private: void MouseMove(int x); //Send then the mouse moves void MouseUp(); //Send then the mouse goes up void MoveCursorTo(int x, int y); + void FinalizeBlockGameInfo(); /////////////////////////////////////////////////////////////////////////// /////////////////////////// AI starts here! /////////////////////////////// ///////////////////////////////////////////////////////////////////////////