Skip to content

Commit

Permalink
Added Games variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Arubinu committed Apr 13, 2022
1 parent f372626 commit e69d5f8
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 91 deletions.
107 changes: 55 additions & 52 deletions RocketStats/Languages.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,57 +66,60 @@
#define LANG_IN_FILE 54
#define LANG_IN_FILE_TOOLTIP 55

#define LANG_GAMEMODE 56
#define LANG_RANK 57
#define LANG_DIVISION 58
#define LANG_MMR 59
#define LANG_MMRCHANGE 60
#define LANG_MMRCUMULCHANGE 61
#define LANG_WINS 62
#define LANG_LOSSES 63
#define LANG_STREAKS 64
#define LANG_WINRATIO 65
#define LANG_DEMOLITIONS 66
#define LANG_DEMOLITIONSMATCH 67
#define LANG_DEMOLITIONSCUMUL 68
#define LANG_DEATH 69
#define LANG_DEATHMATCH 70
#define LANG_DEATHCUMUL 71
#define LANG_BOOST 72
#define LANG_GAMES 56
#define LANG_GAMEMODE 57
#define LANG_RANK 58
#define LANG_DIVISION 59
#define LANG_MMR 60
#define LANG_MMRCHANGE 61
#define LANG_MMRCUMULCHANGE 62
#define LANG_WINS 63
#define LANG_LOSSES 64
#define LANG_STREAKS 65
#define LANG_WINRATIO 66
#define LANG_DEMOLITIONS 67
#define LANG_DEMOLITIONSMATCH 68
#define LANG_DEMOLITIONSCUMUL 69
#define LANG_DEATH 70
#define LANG_DEATHMATCH 71
#define LANG_DEATHCUMUL 72
#define LANG_BOOST 73

#define LANG_FILE_TITLE 73
#define LANG_FILE_GAMEMODE 74
#define LANG_FILE_RANK 75
#define LANG_FILE_DIVISION 76
#define LANG_FILE_MMR 77
#define LANG_FILE_MMRCHANGE 78
#define LANG_FILE_MMRCUMULCHANGE 79
#define LANG_FILE_WINS 80
#define LANG_FILE_LOSSES 81
#define LANG_FILE_STREAKS 82
#define LANG_FILE_WINRATIO 83
#define LANG_FILE_DEMOLITIONS 84
#define LANG_FILE_DEMOLITIONSMATCH 85
#define LANG_FILE_DEMOLITIONSCUMUL 86
#define LANG_FILE_DEATH 87
#define LANG_FILE_DEATHMATCH 88
#define LANG_FILE_DEATHCUMUL 89
#define LANG_FILE_BOOST 90
#define LANG_FILE_TITLE 74
#define LANG_FILE_GAMES 75
#define LANG_FILE_GAMEMODE 76
#define LANG_FILE_RANK 77
#define LANG_FILE_DIVISION 78
#define LANG_FILE_MMR 79
#define LANG_FILE_MMRCHANGE 80
#define LANG_FILE_MMRCUMULCHANGE 81
#define LANG_FILE_WINS 82
#define LANG_FILE_LOSSES 83
#define LANG_FILE_STREAKS 84
#define LANG_FILE_WINRATIO 85
#define LANG_FILE_DEMOLITIONS 86
#define LANG_FILE_DEMOLITIONSMATCH 87
#define LANG_FILE_DEMOLITIONSCUMUL 88
#define LANG_FILE_DEATH 89
#define LANG_FILE_DEATHMATCH 90
#define LANG_FILE_DEATHCUMUL 91
#define LANG_FILE_BOOST 92

#define LANG_HIDE_TITLE 91
#define LANG_HIDE_GAMEMODE 92
#define LANG_HIDE_RANK 93
#define LANG_HIDE_DIVISION 94
#define LANG_HIDE_MMR 95
#define LANG_HIDE_MMRCHANGE 96
#define LANG_HIDE_MMRCUMULCHANGE 97
#define LANG_HIDE_WINS 98
#define LANG_HIDE_LOSSES 99
#define LANG_HIDE_STREAKS 100
#define LANG_HIDE_WINRATIO 101
#define LANG_HIDE_DEMOLITIONS 102
#define LANG_HIDE_DEMOLITIONSMATCH 103
#define LANG_HIDE_DEMOLITIONSCUMUL 104
#define LANG_HIDE_DEATH 105
#define LANG_HIDE_DEATHMATCH 106
#define LANG_HIDE_DEATHCUMUL 107
#define LANG_HIDE_TITLE 93
#define LANG_HIDE_GAMES 94
#define LANG_HIDE_GAMEMODE 95
#define LANG_HIDE_RANK 96
#define LANG_HIDE_DIVISION 97
#define LANG_HIDE_MMR 98
#define LANG_HIDE_MMRCHANGE 99
#define LANG_HIDE_MMRCUMULCHANGE 100
#define LANG_HIDE_WINS 101
#define LANG_HIDE_LOSSES 102
#define LANG_HIDE_STREAKS 103
#define LANG_HIDE_WINRATIO 104
#define LANG_HIDE_DEMOLITIONS 105
#define LANG_HIDE_DEMOLITIONSMATCH 106
#define LANG_HIDE_DEMOLITIONSCUMUL 107
#define LANG_HIDE_DEATH 108
#define LANG_HIDE_DEATHMATCH 109
#define LANG_HIDE_DEATHCUMUL 110
34 changes: 28 additions & 6 deletions RocketStats/Managements/FileManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ void RocketStats::MigrateRemove()

void RocketStats::UpdateFiles(bool force)
{
WriteGames(force);
WriteGameMode(force);
WriteRank(force);
WriteDiv(force);
Expand All @@ -148,6 +149,7 @@ void RocketStats::ResetFiles()
last_rank = "";
last_division = "";

WriteInFile("RocketStats_Games.txt", std::to_string(0));
WriteInFile("RocketStats_GameMode.txt", "");
WriteInFile("RocketStats_Rank.txt", last_rank);
WriteInFile("RocketStats_RankName.txt", last_rank);
Expand Down Expand Up @@ -233,11 +235,17 @@ bool RocketStats::ReadConfig()
rs_preview_rank = config["settings"]["preview"];
if (config["settings"]["roman"].is_boolean())
rs_roman_numbers = config["settings"]["roman"];
if (config["settings"]["replace_mmr"].is_boolean())
rs_replace_mmr = config["settings"]["replace_mmr"];
if (config["settings"]["replace_mmrc"].is_boolean())
rs_replace_mmrc = config["settings"]["replace_mmrc"];

if (config["settings"]["files"].is_object() && !config["settings"]["files"].is_null())
{
if (config["settings"]["files"]["on"].is_boolean())
rs_in_file = config["settings"]["files"]["on"];
if (config["settings"]["files"]["games"].is_boolean())
rs_file_games = config["settings"]["files"]["games"];
if (config["settings"]["files"]["gm"].is_boolean())
rs_file_gm = config["settings"]["files"]["gm"];
if (config["settings"]["files"]["rank"].is_boolean())
Expand Down Expand Up @@ -276,6 +284,8 @@ bool RocketStats::ReadConfig()

if (config["settings"]["hides"].is_object() && !config["settings"]["hides"].is_null())
{
if (config["settings"]["hides"]["games"].is_boolean())
rs_hide_games = config["settings"]["hides"]["games"];
if (config["settings"]["hides"]["gm"].is_boolean())
rs_hide_gm = config["settings"]["hides"]["gm"];
if (config["settings"]["hides"]["rank"].is_boolean())
Expand Down Expand Up @@ -311,16 +321,15 @@ bool RocketStats::ReadConfig()

cvarManager->log("Config: hides loaded");
}
if (config["settings"]["replace_mmr"].is_boolean())
rs_replace_mmr = config["settings"]["replace_mmr"];
if (config["settings"]["replace_mmrc"].is_boolean())
rs_replace_mmrc = config["settings"]["replace_mmrc"];

cvarManager->log("Config: settings loaded");
}

if (config["always"].is_object() && !config["always"].is_null())
{
if (config["always"]["Games"].is_number_unsigned())
always.games = int(config["always"]["Games"]);

if (config["always"]["MMRCumulChange"].is_number())
always.MMRCumulChange = float(config["always"]["MMRCumulChange"]);

Expand Down Expand Up @@ -358,6 +367,9 @@ bool RocketStats::ReadConfig()
{
if (config["always_gm"][i].is_object() && !config["always_gm"][i].is_null())
{
if (config["always_gm"][i]["Games"].is_number_unsigned())
always_gm[i].games = int(config["always_gm"][i]["Games"]);

if (config["always_gm"][i]["MMRCumulChange"].is_number())
always_gm[i].MMRCumulChange = float(config["always_gm"][i]["MMRCumulChange"]);

Expand Down Expand Up @@ -420,6 +432,8 @@ void RocketStats::WriteConfig()
tmp["settings"]["float"] = rs_enable_float;
tmp["settings"]["preview"] = rs_preview_rank;
tmp["settings"]["roman"] = rs_roman_numbers;
tmp["settings"]["replace_mmr"] = rs_replace_mmr;
tmp["settings"]["replace_mmrc"] = rs_replace_mmrc;

// Save only existing themes
tmp["settings"]["themes"] = json::object();
Expand All @@ -432,6 +446,7 @@ void RocketStats::WriteConfig()

tmp["settings"]["files"] = json::object();
tmp["settings"]["files"]["on"] = rs_in_file;
tmp["settings"]["files"]["games"] = rs_file_games;
tmp["settings"]["files"]["gm"] = rs_file_gm;
tmp["settings"]["files"]["rank"] = rs_file_rank;
tmp["settings"]["files"]["div"] = rs_file_div;
Expand All @@ -452,6 +467,7 @@ void RocketStats::WriteConfig()
tmp["settings"]["files"]["boost"] = rs_file_boost;

tmp["settings"]["hides"] = json::object();
tmp["settings"]["hides"]["games"] = rs_hide_games;
tmp["settings"]["hides"]["gm"] = rs_hide_gm;
tmp["settings"]["hides"]["rank"] = rs_hide_rank;
tmp["settings"]["hides"]["div"] = rs_hide_div;
Expand All @@ -468,10 +484,9 @@ void RocketStats::WriteConfig()
tmp["settings"]["hides"]["death"] = rs_hide_death;
tmp["settings"]["hides"]["deathm"] = rs_hide_deathm;
tmp["settings"]["hides"]["deathc"] = rs_hide_deathc;
tmp["settings"]["replace_mmr"] = rs_replace_mmr;
tmp["settings"]["replace_mmrc"] = rs_replace_mmrc;

tmp["always"] = json::object();
tmp["always"]["Games"] = always.games;
tmp["always"]["MMRCumulChange"] = always.MMRCumulChange;
tmp["always"]["Win"] = always.win;
tmp["always"]["Loss"] = always.loss;
Expand All @@ -486,6 +501,7 @@ void RocketStats::WriteConfig()
for (int i = 0; i < always_gm.size(); ++i)
{
tmp["always_gm"][i] = json::object();
tmp["always_gm"][i]["Games"] = always_gm[i].games;
tmp["always_gm"][i]["MMRCumulChange"] = always_gm[i].MMRCumulChange;
tmp["always_gm"][i]["Win"] = always_gm[i].win;
tmp["always_gm"][i]["Loss"] = always_gm[i].loss;
Expand All @@ -501,6 +517,12 @@ void RocketStats::WriteConfig()
cvarManager->log("===== !WriteConfig =====");
}

void RocketStats::WriteGames(bool force)
{
if (force || (rs_in_file && rs_file_games))
WriteInFile("RocketStats_Games.txt", (rs_hide_games ? theme_hide_value : std::to_string(GetStats().games)));
}

void RocketStats::WriteGameMode(bool force)
{
if (force || (rs_in_file && rs_file_gm))
Expand Down
58 changes: 34 additions & 24 deletions RocketStats/Managements/GameManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,19 @@ void RocketStats::GameEnd(std::string eventName)
// Game as ended
is_game_ended = true;

++always.games;
++session.games;
++stats[current.playlist].games;
++always_gm[current.playlist].games;

if (my_team_num == winningTeam.GetTeamNum())
{
cvarManager->log("===== Game Won =====");
// On Win, Increase streak and Win Number
always.win++;
session.win++;
stats[current.playlist].win++;
always_gm[current.playlist].win++;
++always.win;
++session.win;
++stats[current.playlist].win;
++always_gm[current.playlist].win;

if (stats[current.playlist].streak < 0)
{
Expand All @@ -71,10 +76,10 @@ void RocketStats::GameEnd(std::string eventName)
}
else
{
always.streak++;
session.streak++;
stats[current.playlist].streak++;
always_gm[current.playlist].streak++;
++always.streak;
++session.streak;
++stats[current.playlist].streak;
++always_gm[current.playlist].streak;
}

SetRefresh(RefreshFlags_Refresh);
Expand All @@ -84,10 +89,10 @@ void RocketStats::GameEnd(std::string eventName)
{
cvarManager->log("===== Game Lost =====");
// On Loose, Increase loose Number and decrease streak
always.loss++;
session.loss++;
stats[current.playlist].loss++;
always_gm[current.playlist].loss++;
++always.loss;
++session.loss;
++stats[current.playlist].loss;
++always_gm[current.playlist].loss;

if (stats[current.playlist].streak > 0)
{
Expand All @@ -98,10 +103,10 @@ void RocketStats::GameEnd(std::string eventName)
}
else
{
always.streak--;
session.streak--;
stats[current.playlist].streak--;
always_gm[current.playlist].streak--;
--always.streak;
--session.streak;
--stats[current.playlist].streak;
--always_gm[current.playlist].streak;
}

SetRefresh(RefreshFlags_Refresh);
Expand Down Expand Up @@ -131,10 +136,15 @@ void RocketStats::GameDestroyed(std::string eventName)
// Check if Game Ended, if not, RAGE QUIT or disconnect
if (is_game_started == true && is_game_ended == false)
{
always.loss++;
session.loss++;
stats[current.playlist].loss++;
always_gm[current.playlist].loss++;
++always.games;
++session.games;
++stats[current.playlist].games;
++always_gm[current.playlist].games;

++always.loss;
++session.loss;
++stats[current.playlist].loss;
++always_gm[current.playlist].loss;

if (stats[current.playlist].streak > 0)
{
Expand All @@ -145,10 +155,10 @@ void RocketStats::GameDestroyed(std::string eventName)
}
else
{
always.streak--;
session.streak--;
stats[current.playlist].streak--;
always_gm[current.playlist].streak--;
--always.streak;
--session.streak;
--stats[current.playlist].streak;
--always_gm[current.playlist].streak;
}

WriteStreak();
Expand Down
6 changes: 4 additions & 2 deletions RocketStats/Managements/OverlayManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,11 @@ void RocketStats::RefreshVars()
SetCVar("rs_enable_float", rs_enable_float);
SetCVar("rs_preview_rank", rs_preview_rank);
SetCVar("rs_roman_numbers", rs_roman_numbers);
SetCVar("rs_replace_mmr", rs_replace_mmr);
SetCVar("rs_replace_mmrc", rs_replace_mmrc);

SetCVar("rs_in_file", rs_in_file);
SetCVar("rs_file_games", rs_file_games);
SetCVar("rs_file_gm", rs_file_gm);
SetCVar("rs_file_rank", rs_file_rank);
SetCVar("rs_file_div", rs_file_div);
Expand All @@ -279,6 +282,7 @@ void RocketStats::RefreshVars()
SetCVar("rs_file_deathc", rs_file_deathc);
SetCVar("rs_file_boost", rs_file_boost);

SetCVar("rs_hide_games", rs_hide_games);
SetCVar("rs_hide_gm", rs_hide_gm);
SetCVar("rs_hide_rank", rs_hide_rank);
SetCVar("rs_hide_div", rs_hide_div);
Expand All @@ -295,8 +299,6 @@ void RocketStats::RefreshVars()
SetCVar("rs_hide_death", rs_hide_death);
SetCVar("rs_hide_deathm", rs_hide_deathm);
SetCVar("rs_hide_deathc", rs_hide_deathc);
SetCVar("rs_replace_mmr", rs_replace_mmr);
SetCVar("rs_replace_mmrc", rs_replace_mmrc);
}

Element RocketStats::CalculateElement(json& element, Options& options, bool& check)
Expand Down
Loading

0 comments on commit e69d5f8

Please sign in to comment.