From 84d910d2fc3843b3d3fa22990615343804d3e318 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Wed, 13 Jul 2011 15:22:04 -0400 Subject: [PATCH] Prepair for better couple/routine stat tracking. ...gah, what a bad pun. --- src/NoteData.cpp | 218 ++++++++++++++++++++++++++++++++++++++++++++--- src/NoteData.h | 69 +++++++++++++++ 2 files changed, 276 insertions(+), 11 deletions(-) diff --git a/src/NoteData.cpp b/src/NoteData.cpp index 50265d5b65..78880dfbbe 100644 --- a/src/NoteData.cpp +++ b/src/NoteData.cpp @@ -459,6 +459,31 @@ int NoteData::GetLastRow() const return iOldestRowFoundSoFar; } +bool NoteData::IsTap(const TapNote &tn, const int row) const +{ + return (tn.type != TapNote::empty && tn.type != TapNote::mine + && tn.type != TapNote::lift && tn.type != TapNote::fake + && GAMESTATE->GetProcessedTimingData()->IsJudgableAtRow(row)); +} + +bool NoteData::IsMine(const TapNote &tn, const int row) const +{ + return (tn.type == TapNote::mine + && GAMESTATE->GetProcessedTimingData()->IsJudgableAtRow(row)); +} + +bool NoteData::IsLift(const TapNote &tn, const int row) const +{ + return (tn.type == TapNote::lift + && GAMESTATE->GetProcessedTimingData()->IsJudgableAtRow(row)); +} + +bool NoteData::IsFake(const TapNote &tn, const int row) const +{ + return (tn.type == TapNote::fake + || !GAMESTATE->GetProcessedTimingData()->IsJudgableAtRow(row)); +} + int NoteData::GetNumTapNotes( int iStartIndex, int iEndIndex ) const { int iNumNotes = 0; @@ -466,10 +491,7 @@ int NoteData::GetNumTapNotes( int iStartIndex, int iEndIndex ) const { FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE( *this, t, r, iStartIndex, iEndIndex ) { - const TapNote &tn = GetTapNote(t, r); - if( tn.type != TapNote::empty && tn.type != TapNote::mine - && tn.type != TapNote::lift && tn.type != TapNote::fake - && GAMESTATE->GetProcessedTimingData()->IsJudgableAtRow(r) ) + if (this->IsTap(GetTapNote(t, r), r)) iNumNotes++; } } @@ -500,8 +522,7 @@ int NoteData::GetNumMines( int iStartIndex, int iEndIndex ) const for( int t=0; tGetProcessedTimingData()->IsJudgableAtRow(r)) + if (this->IsMine(GetTapNote(t, r), r)) iNumMines++; } @@ -640,8 +661,7 @@ int NoteData::GetNumLifts( int iStartIndex, int iEndIndex ) const for( int t=0; tGetProcessedTimingData()->IsJudgableAtRow(r)) + if( this->IsLift(GetTapNote(t, r), r)) iNumLifts++; } @@ -655,14 +675,190 @@ int NoteData::GetNumFakes( int iStartIndex, int iEndIndex ) const for( int t=0; tGetProcessedTimingData()->IsJudgableAtRow(r)) - iNumFakes++; + if( this->IsFake(GetTapNote(t, r), r)) + iNumFakes++; } return iNumFakes; } +bool NoteData::IsPlayer1(const int track, const TapNote &tn) const +{ + if (this->IsComposite()) + { + return tn.pn == PLAYER_1; + } + return track < (this->GetNumTracks() / 2); +} + +pair NoteData::GetNumTapNotesTwoPlayer( int iStartIndex, int iEndIndex ) const +{ + pair num(0, 0); + for( int t=0; tIsTap(tn, r)) + { + if (this->IsPlayer1(t, tn)) + num.first++; + else + num.second++; + } + } + } + return num; +} + +pair NoteData::GetNumRowsWithSimultaneousTapsTwoPlayer(int minTaps, + int startRow, + int endRow) const +{ + pair num(0, 0); + FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( *this, r, startRow, endRow ) + { + pair found(0, 0); + for( int t=0; tIsTap(tn, r)) + { + if (this->IsPlayer1(t, tn)) + found.first++; + else + found.second++; + } + } + if (found.first >= minTaps) + num.first++; + if (found.second >= minTaps) + num.second++; + } + return num; +} + +pair NoteData::GetNumJumpsTwoPlayer( int iStartIndex, int iEndIndex ) const +{ + return GetNumRowsWithSimultaneousTapsTwoPlayer( 2, iStartIndex, iEndIndex ); +} + +pair NoteData::GetNumHandsTwoPlayer( int iStartIndex, int iEndIndex ) const +{ + return GetNumRowsWithSimultaneousTapsTwoPlayer( 3, iStartIndex, iEndIndex ); +} + +pair NoteData::GetNumQuadsTwoPlayer( int iStartIndex, int iEndIndex ) const +{ + return GetNumRowsWithSimultaneousTapsTwoPlayer( 4, iStartIndex, iEndIndex ); +} + +pair NoteData::GetNumHoldNotesTwoPlayer( int iStartIndex, int iEndIndex ) const +{ + pair num(0, 0); + for( int t=0; tsecond.type != TapNote::hold_head || + lBegin->second.subType != TapNote::hold_head_hold ) + continue; + if (!GAMESTATE->GetProcessedTimingData()->IsJudgableAtRow(lBegin->first)) + continue; + if (this->IsPlayer1(t, lBegin->second)) + num.first++; + else + num.second++; + } + } + return num; +} + +pair NoteData::GetNumMinesTwoPlayer( int iStartIndex, int iEndIndex ) const +{ + pair num(0, 0); + for( int t=0; tIsMine(tn, r)) + { + if (this->IsPlayer1(t, tn)) + num.first++; + else + num.second++; + } + } + } + return num; +} + +pair NoteData::GetNumRollsTwoPlayer( int iStartIndex, int iEndIndex ) const +{ + pair num(0, 0); + for( int t=0; tsecond.type != TapNote::hold_head || + lBegin->second.subType != TapNote::hold_head_roll ) + continue; + if (!GAMESTATE->GetProcessedTimingData()->IsJudgableAtRow(lBegin->first)) + continue; + if (this->IsPlayer1(t, lBegin->second)) + num.first++; + else + num.second++; + } + } + return num; +} + +pair NoteData::GetNumLiftsTwoPlayer( int iStartIndex, int iEndIndex ) const +{ + pair num(0, 0); + for( int t=0; tIsLift(tn, r)) + { + if (this->IsPlayer1(t, tn)) + num.first++; + else + num.second++; + } + } + } + return num; +} + +pair NoteData::GetNumFakesTwoPlayer( int iStartIndex, int iEndIndex ) const +{ + pair num(0, 0); + for( int t=0; tIsFake(tn, r)) + { + if (this->IsPlayer1(t, tn)) + num.first++; + else + num.second++; + } + } + } + return num; +} + /* int NoteData::GetNumMinefields( int iStartIndex, int iEndIndex ) const { diff --git a/src/NoteData.h b/src/NoteData.h index 60a37093ed..df8d6a5856 100644 --- a/src/NoteData.h +++ b/src/NoteData.h @@ -90,7 +90,46 @@ private: // There's no point in inserting empty notes into the map. // Any blank space in the map is defined to be empty. vector m_TapNotes; + + /** + * @brief Determine whether this note is for Player 1 or Player 2. + * @param track the track/column the note is in. + * @param tn the note in question. Required for routine mode. + * @return true if it's for player 1, false for player 2. */ + bool IsPlayer1(const int track, const TapNote &tn) const; + + /** + * @brief Determine if the note in questino should be counted as a tap. + * @param tn the note in question. + * @param row the row it lives in. + * @return true if it's a tap, false otherwise. */ + bool IsTap(const TapNote &tn, const int row) const; + + /** + * @brief Determine if the note in questino should be counted as a mine. + * @param tn the note in question. + * @param row the row it lives in. + * @return true if it's a mine, false otherwise. */ + bool IsMine(const TapNote &tn, const int row) const; + + /** + * @brief Determine if the note in questino should be counted as a lift. + * @param tn the note in question. + * @param row the row it lives in. + * @return true if it's a lift, false otherwise. */ + bool IsLift(const TapNote &tn, const int row) const; + + /** + * @brief Determine if the note in questino should be counted as a fake. + * @param tn the note in question. + * @param row the row it lives in. + * @return true if it's a fake, false otherwise. */ + bool IsFake(const TapNote &tn, const int row) const; + pair GetNumRowsWithSimultaneousTapsTwoPlayer(int minTaps = 2, + int startRow = 0, + int endRow = MAX_NOTE_ROW) const; + public: void Init(); @@ -241,6 +280,8 @@ public: { return GetNumRowsWithSimultaneousTaps( 2, iStartIndex, iEndIndex ); } + + // This row needs at least iMinSimultaneousPresses either tapped or held. bool RowNeedsAtLeastSimultaneousPresses( int iMinSimultaneousPresses, int row ) const; @@ -261,6 +302,34 @@ public: int GetNumLifts( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const; int GetNumFakes( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const; + // the couple/routine style variants of the above. + pair GetNumTapNotesTwoPlayer(int startRow = 0, + int endRow = MAX_NOTE_ROW) const; + + pair GetNumJumpsTwoPlayer(int startRow = 0, + int endRow = MAX_NOTE_ROW) const; + + pair GetNumHandsTwoPlayer(int startRow = 0, + int endRow = MAX_NOTE_ROW) const; + + pair GetNumQuadsTwoPlayer(int startRow = 0, + int endRow = MAX_NOTE_ROW) const; + + pair GetNumHoldNotesTwoPlayer(int startRow = 0, + int endRow = MAX_NOTE_ROW) const; + + pair GetNumMinesTwoPlayer(int startRow = 0, + int endRow = MAX_NOTE_ROW) const; + + pair GetNumRollsTwoPlayer(int startRow = 0, + int endRow = MAX_NOTE_ROW) const; + + pair GetNumLiftsTwoPlayer(int startRow = 0, + int endRow = MAX_NOTE_ROW) const; + + pair GetNumFakesTwoPlayer(int startRow = 0, + int endRow = MAX_NOTE_ROW) const; + // Transformations void LoadTransformed(const NoteData& original, int iNewNumTracks,