From 00db8cf249fec2c2e5dcf8c9b8d1f0abb8474dc8 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sat, 2 Jun 2018 07:02:43 -0700 Subject: [PATCH] - added a number of new local player stats to track as per etherpad game count achievements --- source/glest_game/game/game.cpp | 35 +++++++++++++++++++++++++++++++++ source/glest_game/steam/steam.h | 29 ++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 756c4317..553217c1 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -5290,13 +5290,48 @@ void saveStatsToSteam(Game* game, Stats& endStats) { if (endStats.getVictory(factionIndex)) { double elapsedGameMinutes = (game->getWorld()->getStats()->getFramesToCalculatePlaytime() / GameConstants::updateFps / 60.0); if(elapsedGameMinutes >= MIN_PLAY_TIME_MINUTES) { + int gamesWonCount = playerLocalStats.getInt("games-won",0) + 1; + playerLocalStats.setInt("games-won",gamesWonCount); + if(playerLocalStats.getBool(EnumParser::getString(ACH_WIN_ONE_GAME).c_str()) == false) { playerLocalStats.setBool(EnumParser::getString(ACH_WIN_ONE_GAME).c_str(),true); } + if(gamesWonCount >= 50 && playerLocalStats.getBool(EnumParser::getString(ACH_WIN_FIFTY_GAMES).c_str()) == false) { + playerLocalStats.setBool(EnumParser::getString(ACH_WIN_FIFTY_GAMES).c_str(),true); + } + if(gamesWonCount >= 100 && playerLocalStats.getBool(EnumParser::getString(ACH_WIN_ONE_HUNDRED_GAMES).c_str()) == false) { + playerLocalStats.setBool(EnumParser::getString(ACH_WIN_ONE_HUNDRED_GAMES).c_str(),true); + } + if(gamesWonCount >= 250 && playerLocalStats.getBool(EnumParser::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES).c_str()) == false) { + playerLocalStats.setBool(EnumParser::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES).c_str(),true); + } + if(gamesWonCount >= 500 && playerLocalStats.getBool(EnumParser::getString(ACH_WIN_FIVE_HUNDRED_GAMES).c_str()) == false) { + playerLocalStats.setBool(EnumParser::getString(ACH_WIN_FIVE_HUNDRED_GAMES).c_str(),true); + } + if(gamesWonCount > 1000 && playerLocalStats.getBool(EnumParser::getString(ACH_WIN_OVER_THOUSAND_GAMES).c_str()) == false) { + playerLocalStats.setBool(EnumParser::getString(ACH_WIN_OVER_THOUSAND_GAMES).c_str(),true); + } + + if (NetworkManager::getInstance().isNetworkGame()) { if(playerLocalStats.getBool(EnumParser::getString(ACH_WIN_ONE_GAME_ONLINE).c_str()) == false) { playerLocalStats.setBool(EnumParser::getString(ACH_WIN_ONE_GAME_ONLINE).c_str(),true); } + if(gamesWonCount >= 50 && playerLocalStats.getBool(EnumParser::getString(ACH_WIN_FIFTY_GAMES_ONLINE).c_str()) == false) { + playerLocalStats.setBool(EnumParser::getString(ACH_WIN_FIFTY_GAMES_ONLINE).c_str(),true); + } + if(gamesWonCount >= 100 && playerLocalStats.getBool(EnumParser::getString(ACH_WIN_ONE_HUNDRED_GAMES_ONLINE).c_str()) == false) { + playerLocalStats.setBool(EnumParser::getString(ACH_WIN_ONE_HUNDRED_GAMES_ONLINE).c_str(),true); + } + if(gamesWonCount >= 250 && playerLocalStats.getBool(EnumParser::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE).c_str()) == false) { + playerLocalStats.setBool(EnumParser::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE).c_str(),true); + } + if(gamesWonCount >= 500 && playerLocalStats.getBool(EnumParser::getString(ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE).c_str()) == false) { + playerLocalStats.setBool(EnumParser::getString(ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE).c_str(),true); + } + if(gamesWonCount > 1000 && playerLocalStats.getBool(EnumParser::getString(ACH_WIN_OVER_THOUSAND_GAMES_ONLINE).c_str()) == false) { + playerLocalStats.setBool(EnumParser::getString(ACH_WIN_OVER_THOUSAND_GAMES_ONLINE).c_str(),true); + } } //printf("\nPlayer won the game with at least 10 minutes of play: %f!\n",elapsedGameMinutes); diff --git a/source/glest_game/steam/steam.h b/source/glest_game/steam/steam.h index 10b86771..4780b5cc 100644 --- a/source/glest_game/steam/steam.h +++ b/source/glest_game/steam/steam.h @@ -42,13 +42,36 @@ inline EnumParser::EnumParser() { enum SteamAchievementName { ACH_WIN_ONE_GAME, - ACH_WIN_ONE_GAME_ONLINE + ACH_WIN_FIFTY_GAMES, + ACH_WIN_ONE_HUNDRED_GAMES, + ACH_WIN_TWO_HUNDRED_FIFTY_GAMES, + ACH_WIN_FIVE_HUNDRED_GAMES, + ACH_WIN_OVER_THOUSAND_GAMES, + + ACH_WIN_ONE_GAME_ONLINE, + ACH_WIN_FIFTY_GAMES_ONLINE, + ACH_WIN_ONE_HUNDRED_GAMES_ONLINE, + ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE, + ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE, + ACH_WIN_OVER_THOUSAND_GAMES_ONLINE + }; template <> inline EnumParser::EnumParser() { - enumMap["ACH_WIN_ONE_GAME"] = ACH_WIN_ONE_GAME; - enumMap["ACH_WIN_ONE_GAME_ONLINE"] = ACH_WIN_ONE_GAME_ONLINE; + enumMap["ACH_WIN_ONE_GAME"] = ACH_WIN_ONE_GAME; + enumMap["ACH_WIN_FIFTY_GAMES"] = ACH_WIN_FIFTY_GAMES; + enumMap["ACH_WIN_ONE_HUNDRED_GAMES"] = ACH_WIN_ONE_HUNDRED_GAMES; + enumMap["ACH_WIN_TWO_HUNDRED_FIFTY_GAMES"] = ACH_WIN_TWO_HUNDRED_FIFTY_GAMES; + enumMap["ACH_WIN_FIVE_HUNDRED_GAMES"] = ACH_WIN_FIVE_HUNDRED_GAMES; + enumMap["ACH_WIN_OVER_THOUSAND_GAMES"] = ACH_WIN_OVER_THOUSAND_GAMES; + + enumMap["ACH_WIN_ONE_GAME_ONLINE"] = ACH_WIN_ONE_GAME_ONLINE; + enumMap["ACH_WIN_FIFTY_GAMES_ONLINE"] = ACH_WIN_FIFTY_GAMES_ONLINE; + enumMap["ACH_WIN_ONE_HUNDRED_GAMES_ONLINE"] = ACH_WIN_ONE_HUNDRED_GAMES_ONLINE; + enumMap["ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE"] = ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE; + enumMap["ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE"] = ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE; + enumMap["ACH_WIN_OVER_THOUSAND_GAMES_ONLINE"] = ACH_WIN_OVER_THOUSAND_GAMES_ONLINE; } class Steam