Skip to content

Commit

Permalink
add basic rating over time (technically sessions, not time) calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jun 8, 2017
1 parent d50db3e commit dae82c0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,7 @@ void Profile::CalculateStatsFromScores(LoadingWindow* ld) {

SCOREMAN->RecalculateSSRs(ld);
SCOREMAN->CalcPlayerRating(m_fPlayerRating, m_fPlayerSkillsets);
//SCOREMAN->RatingOverTime();
}

void Profile::CalculateStatsFromScores() {
Expand Down
43 changes: 43 additions & 0 deletions src/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,49 @@ const vector<HighScore*> ScoresAtRate::GetScores() const {
}
*/

void ScoreManager::RatingOverTime() {
auto compdate = [](HighScore* a, HighScore* b) { return (a->GetDateTime() < b->GetDateTime()); };


vector<bool> wasvalid;
sort(AllScores.begin(), AllScores.end(), compdate);

for (auto& n : AllScores) {
wasvalid.emplace_back(n->GetEtternaValid());
n->SetEtternaValid(false);
}

float doot = 10.f;
float doot2[8];
LOG->Warn("wer");
if (AllScores.empty())
return;

DateTime lastvalidday = AllScores.front()->GetDateTime();
lastvalidday.StripTime();

CalcPlayerRating(doot, doot2);
LOG->Warn(lastvalidday.GetString());

DateTime finalvalidday = AllScores.back()->GetDateTime();
finalvalidday.StripTime();
while (lastvalidday != finalvalidday) {
for (auto& n : AllScores) {
DateTime date = n->GetDateTime();
date.StripTime();

if (lastvalidday < date) {
lastvalidday = date;
break;
}

n->SetEtternaValid(true);
}
CalcPlayerRating(doot, doot2);
LOG->Trace("%f", doot);
}
}

ScoresForChart::ScoresForChart() {
bestGrade = Grade_Invalid;
ScoresByRate.clear();
Expand Down
5 changes: 1 addition & 4 deletions src/ScoreManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,16 @@ class ScoreManager

bool KeyHasScores(const string& ck) { return pscores.count(ck) == 1; }
bool HasAnyScores() { return !AllScores.empty(); }


void RatingOverTime();

XNode *CreateNode() const;
void LoadFromNode(const XNode* node);

ScoresForChart* GetScoresForChart(const string& ck);
vector<string> GetSortedKeys();


void PushSelf(lua_State *L);


vector<HighScore*> GetAllScores() { return AllScores; }
void RegisterScore(HighScore* hs) { AllScores.emplace_back(hs); }
void AddToKeyedIndex(HighScore* hs) { ScoresByKey.emplace(hs->GetScoreKey(), hs); }
Expand Down

0 comments on commit dae82c0

Please sign in to comment.