Change ScoreKeeper's api to take TapNotes instead of the scores.

This commit is contained in:
Steve Checkoway
2006-07-10 05:15:52 +00:00
parent 5a01cb9c3f
commit 1aa51dd1d1
7 changed files with 46 additions and 36 deletions
+15 -12
View File
@@ -690,10 +690,13 @@ void Player::Update( float fDeltaTime )
m_pNoteField->DidHoldNote( iTrack, HNS_Held, bBright ); // bright ghost flash m_pNoteField->DidHoldNote( iTrack, HNS_Held, bBright ); // bright ghost flash
} }
tn.HoldResult.fLife = fLife;
tn.HoldResult.hns = hns;
if( hns != HNS_None ) if( hns != HNS_None )
{ {
/* this note has been judged */ /* this note has been judged */
HandleHoldScore( hns, tns ); HandleHoldScore( tn );
if( m_pPlayerStageStats != NULL ) if( m_pPlayerStageStats != NULL )
m_pPlayerStageStats->hnsLast = hns; m_pPlayerStageStats->hnsLast = hns;
@@ -702,9 +705,6 @@ void Player::Update( float fDeltaTime )
m_vHoldJudgment[iTrack]->SetHoldJudgment( hns ); m_vHoldJudgment[iTrack]->SetHoldJudgment( hns );
} }
tn.HoldResult.fLife = fLife;
tn.HoldResult.hns = hns;
} }
} }
@@ -1277,9 +1277,9 @@ void Player::HandleStep( int col, const RageTimer &tm, bool bHeld )
NSMAN->ReportTiming( fNoteOffset,pn ); NSMAN->ReportTiming( fNoteOffset,pn );
if( m_pPrimaryScoreKeeper ) if( m_pPrimaryScoreKeeper )
m_pPrimaryScoreKeeper->HandleTapScore( score ); m_pPrimaryScoreKeeper->HandleTapScore( tn );
if( m_pSecondaryScoreKeeper ) if( m_pSecondaryScoreKeeper )
m_pSecondaryScoreKeeper->HandleTapScore( score ); m_pSecondaryScoreKeeper->HandleTapScore( tn );
switch( tn.type ) switch( tn.type )
{ {
@@ -1569,7 +1569,8 @@ void Player::RandomizeNotes( int iNoteRow )
void Player::HandleTapRowScore( unsigned row ) void Player::HandleTapRowScore( unsigned row )
{ {
TapNoteScore scoreOfLastTap = NoteDataWithScoring::LastTapNoteWithResult( m_NoteData, row ).result.tns; const TapNote &lastTN = NoteDataWithScoring::LastTapNoteWithResult( m_NoteData, row );
TapNoteScore scoreOfLastTap = lastTN.result.tns;
int iNumTapsInRow = m_NoteData.GetNumTracksWithTapOrHoldHead(row); int iNumTapsInRow = m_NoteData.GetNumTracksWithTapOrHoldHead(row);
ASSERT_M( iNumTapsInRow > 0, ssprintf("%d, %u",iNumTapsInRow,row) ); ASSERT_M( iNumTapsInRow > 0, ssprintf("%d, %u",iNumTapsInRow,row) );
@@ -1619,9 +1620,9 @@ void Player::HandleTapRowScore( unsigned row )
const int iOldCombo = iCurCombo; const int iOldCombo = iCurCombo;
if( m_pPrimaryScoreKeeper != NULL ) if( m_pPrimaryScoreKeeper != NULL )
m_pPrimaryScoreKeeper->HandleTapRowScore( scoreOfLastTap, iNumTapsInRow ); m_pPrimaryScoreKeeper->HandleTapRowScore( lastTN, iNumTapsInRow );
if( m_pSecondaryScoreKeeper != NULL ) if( m_pSecondaryScoreKeeper != NULL )
m_pSecondaryScoreKeeper->HandleTapRowScore( scoreOfLastTap, iNumTapsInRow ); m_pSecondaryScoreKeeper->HandleTapRowScore( lastTN, iNumTapsInRow );
if( m_pPlayerStageStats ) if( m_pPlayerStageStats )
{ {
@@ -1713,8 +1714,10 @@ void Player::HandleTapRowScore( unsigned row )
} }
void Player::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) void Player::HandleHoldScore( const TapNote &tn )
{ {
HoldNoteScore holdScore = tn.HoldResult.hns;
TapNoteScore tapScore = tn.result.tns;
bool NoCheating = true; bool NoCheating = true;
#ifdef DEBUG #ifdef DEBUG
NoCheating = false; NoCheating = false;
@@ -1727,9 +1730,9 @@ void Player::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore )
return; return;
if( m_pPrimaryScoreKeeper ) if( m_pPrimaryScoreKeeper )
m_pPrimaryScoreKeeper->HandleHoldScore(holdScore, tapScore ); m_pPrimaryScoreKeeper->HandleHoldScore( tn );
if( m_pSecondaryScoreKeeper ) if( m_pSecondaryScoreKeeper )
m_pSecondaryScoreKeeper->HandleHoldScore(holdScore, tapScore ); m_pSecondaryScoreKeeper->HandleHoldScore( tn );
// TODO: Remove use of PlayerNumber. // TODO: Remove use of PlayerNumber.
PlayerNumber pn = m_pPlayerState->m_PlayerNumber; PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
+1 -1
View File
@@ -82,7 +82,7 @@ protected:
void DisplayJudgedRow( int iIndexThatWasSteppedOn, TapNoteScore score, int iTrack ); void DisplayJudgedRow( int iIndexThatWasSteppedOn, TapNoteScore score, int iTrack );
void OnRowCompletelyJudged( int iStepIndex ); void OnRowCompletelyJudged( int iStepIndex );
void HandleTapRowScore( unsigned row ); void HandleTapRowScore( unsigned row );
void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ); void HandleHoldScore( const TapNote &tn );
void DrawTapJudgments(); void DrawTapJudgments();
void DrawHoldJudgments(); void DrawHoldJudgments();
+5 -6
View File
@@ -11,15 +11,14 @@
* Results are injected directly into GameState. * Results are injected directly into GameState.
*/ */
#include "Attack.h"
#include "GameConstantsAndTypes.h" // for TapNoteScore and HoldNoteScore
class NoteData; class NoteData;
class Inventory; class Inventory;
class Song; class Song;
class Steps; class Steps;
class PlayerState; class PlayerState;
class PlayerStageStats; class PlayerStageStats;
struct TapNote;
struct AttackArray;
class ScoreKeeper class ScoreKeeper
{ {
@@ -47,9 +46,9 @@ public:
/* Note that pNoteData will include any transformations due to modifiers. */ /* Note that pNoteData will include any transformations due to modifiers. */
virtual void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ) = 0; // before a song plays (called multiple times if course) virtual void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ) = 0; // before a song plays (called multiple times if course)
virtual void HandleTapScore( TapNoteScore score ) = 0; virtual void HandleTapScore( const TapNote &tn ) = 0;
virtual void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ) = 0; virtual void HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow ) = 0;
virtual void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) = 0; virtual void HandleHoldScore( const TapNote &tn ) = 0;
}; };
#endif #endif
+8 -3
View File
@@ -332,8 +332,10 @@ void ScoreKeeperNormal::AddScore( TapNoteScore score )
// LOG->Trace( "score: %i", iScore ); // LOG->Trace( "score: %i", iScore );
} }
void ScoreKeeperNormal::HandleTapScore( TapNoteScore score ) void ScoreKeeperNormal::HandleTapScore( const TapNote &tn )
{ {
TapNoteScore score = tn.result.tns;
if( score == TNS_HitMine ) if( score == TNS_HitMine )
{ {
if( !m_pPlayerStageStats->bFailed ) if( !m_pPlayerStageStats->bFailed )
@@ -346,9 +348,10 @@ void ScoreKeeperNormal::HandleTapScore( TapNoteScore score )
} }
} }
void ScoreKeeperNormal::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ) void ScoreKeeperNormal::HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow )
{ {
ASSERT( iNumTapsInRow >= 1 ); ASSERT( iNumTapsInRow >= 1 );
TapNoteScore scoreOfLastTap = lastTN.result.tns;
// Update dance points. // Update dance points.
if( !m_pPlayerStageStats->bFailed ) if( !m_pPlayerStageStats->bFailed )
@@ -417,8 +420,10 @@ void ScoreKeeperNormal::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNum
} }
void ScoreKeeperNormal::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) void ScoreKeeperNormal::HandleHoldScore( const TapNote &tn )
{ {
HoldNoteScore holdScore = tn.HoldResult.hns;
// update dance points totals // update dance points totals
if( !m_pPlayerStageStats->bFailed ) if( !m_pPlayerStageStats->bFailed )
m_pPlayerStageStats->iActualDancePoints += HoldNoteScoreToDancePoints( holdScore ); m_pPlayerStageStats->iActualDancePoints += HoldNoteScoreToDancePoints( holdScore );
+3 -3
View File
@@ -52,9 +52,9 @@ public:
// before a song plays (called multiple times if course) // before a song plays (called multiple times if course)
void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ); void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData );
void HandleTapScore( TapNoteScore score ); void HandleTapScore( const TapNote &tn );
void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ); void HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow );
void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ); void HandleHoldScore( const TapNote &tn );
// This must be calculated using only cached radar values so that we can // This must be calculated using only cached radar values so that we can
// do it quickly. // do it quickly.
+8 -5
View File
@@ -8,7 +8,7 @@
#include "PrefsManager.h" #include "PrefsManager.h"
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include "PlayerState.h" #include "PlayerState.h"
#include "NoteTypes.h"
ThemeMetric<float> ATTACK_DURATION_SECONDS ("ScoreKeeperRave","AttackDurationSeconds"); ThemeMetric<float> ATTACK_DURATION_SECONDS ("ScoreKeeperRave","AttackDurationSeconds");
@@ -23,8 +23,9 @@ void ScoreKeeperRave::OnNextSong( int iSongInCourseIndex, const Steps* pSteps, c
} }
void ScoreKeeperRave::HandleTapScore( TapNoteScore score ) void ScoreKeeperRave::HandleTapScore( const TapNote &tn )
{ {
TapNoteScore score = tn.result.tns;
float fPercentToMove = 0; float fPercentToMove = 0;
switch( score ) switch( score )
{ {
@@ -36,12 +37,13 @@ void ScoreKeeperRave::HandleTapScore( TapNoteScore score )
#define CROSSED( val ) (fOld < val && fNew >= val) #define CROSSED( val ) (fOld < val && fNew >= val)
#define CROSSED_ATTACK_LEVEL( level ) CROSSED(1.f/NUM_ATTACK_LEVELS*(level+1)) #define CROSSED_ATTACK_LEVEL( level ) CROSSED(1.f/NUM_ATTACK_LEVELS*(level+1))
void ScoreKeeperRave::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ) void ScoreKeeperRave::HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow )
{ {
TapNoteScore scoreOfLastTap = lastTN.result.tns;
float fPercentToMove; float fPercentToMove;
switch( scoreOfLastTap ) switch( scoreOfLastTap )
{ {
default: ASSERT(0); DEFAULT_FAIL( scoreOfLastTap );
case TNS_W1: fPercentToMove = PREFSMAN->m_fSuperMeterPercentChange[SE_W1]; break; case TNS_W1: fPercentToMove = PREFSMAN->m_fSuperMeterPercentChange[SE_W1]; break;
case TNS_W2: fPercentToMove = PREFSMAN->m_fSuperMeterPercentChange[SE_W2]; break; case TNS_W2: fPercentToMove = PREFSMAN->m_fSuperMeterPercentChange[SE_W2]; break;
case TNS_W3: fPercentToMove = PREFSMAN->m_fSuperMeterPercentChange[SE_W3]; break; case TNS_W3: fPercentToMove = PREFSMAN->m_fSuperMeterPercentChange[SE_W3]; break;
@@ -52,8 +54,9 @@ void ScoreKeeperRave::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTa
AddSuperMeterDelta( fPercentToMove ); AddSuperMeterDelta( fPercentToMove );
} }
void ScoreKeeperRave::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) void ScoreKeeperRave::HandleHoldScore( const TapNote &tn )
{ {
TapNoteScore tapScore = tn.result.tns;
float fPercentToMove = 0; float fPercentToMove = 0;
switch( tapScore ) switch( tapScore )
{ {
+3 -3
View File
@@ -13,9 +13,9 @@ public:
ScoreKeeperRave( PlayerState* pPlayerState, PlayerStageStats* pPlayerStageStats ); ScoreKeeperRave( PlayerState* pPlayerState, PlayerStageStats* pPlayerStageStats );
virtual ~ScoreKeeperRave() { } virtual ~ScoreKeeperRave() { }
void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ); // before a song plays (called multiple times if course) void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ); // before a song plays (called multiple times if course)
void HandleTapScore( TapNoteScore score ); void HandleTapScore( const TapNote &tn );
void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ); void HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow );
void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ); void HandleHoldScore( const TapNote &tn );
protected: protected:
void LaunchAttack( AttackLevel al ); void LaunchAttack( AttackLevel al );