- added a number of new local player stats to track as per etherpad game count achievements

This commit is contained in:
SoftCoder 2018-06-02 07:02:43 -07:00
parent e573ec8690
commit 00db8cf249
2 changed files with 61 additions and 3 deletions

View File

@ -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<SteamAchievementName>::getString(ACH_WIN_ONE_GAME).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_ONE_GAME).c_str(),true);
}
if(gamesWonCount >= 50 && playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_FIFTY_GAMES).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_FIFTY_GAMES).c_str(),true);
}
if(gamesWonCount >= 100 && playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_ONE_HUNDRED_GAMES).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_ONE_HUNDRED_GAMES).c_str(),true);
}
if(gamesWonCount >= 250 && playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES).c_str(),true);
}
if(gamesWonCount >= 500 && playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_FIVE_HUNDRED_GAMES).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_FIVE_HUNDRED_GAMES).c_str(),true);
}
if(gamesWonCount > 1000 && playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_OVER_THOUSAND_GAMES).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_OVER_THOUSAND_GAMES).c_str(),true);
}
if (NetworkManager::getInstance().isNetworkGame()) {
if(playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_ONE_GAME_ONLINE).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_ONE_GAME_ONLINE).c_str(),true);
}
if(gamesWonCount >= 50 && playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_FIFTY_GAMES_ONLINE).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_FIFTY_GAMES_ONLINE).c_str(),true);
}
if(gamesWonCount >= 100 && playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_ONE_HUNDRED_GAMES_ONLINE).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_ONE_HUNDRED_GAMES_ONLINE).c_str(),true);
}
if(gamesWonCount >= 250 && playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE).c_str(),true);
}
if(gamesWonCount >= 500 && playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE).c_str(),true);
}
if(gamesWonCount > 1000 && playerLocalStats.getBool(EnumParser<SteamAchievementName>::getString(ACH_WIN_OVER_THOUSAND_GAMES_ONLINE).c_str()) == false) {
playerLocalStats.setBool(EnumParser<SteamAchievementName>::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);

View File

@ -42,13 +42,36 @@ inline EnumParser<SteamStatName>::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<SteamAchievementName>::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