This commit is contained in:
Kyzentun
2014-09-14 21:06:27 -06:00
12 changed files with 145 additions and 60 deletions
+37 -4
View File
@@ -314,6 +314,8 @@ void GameState::Reset()
m_iGameSeed = rand();
m_iStageSeed = rand();
m_AdjustTokensBySongCostForFinalStageCheck= true;
m_pCurSong.Set( GetDefaultSong() );
m_pPreferredSong = NULL;
m_pCurCourse.Set( NULL );
@@ -1061,6 +1063,36 @@ bool GameState::IsFinalStageForAnyHumanPlayer() const
return GetSmallestNumStagesLeftForAnyHumanPlayer() == 1;
}
bool GameState::IsFinalStageForEveryHumanPlayer() const
{
int song_cost= 1;
if(m_pCurSong != NULL)
{
if(m_pCurSong->IsLong())
{
song_cost= 2;
}
else if(m_pCurSong->IsMarathon())
{
song_cost= 3;
}
}
// If we're on gameplay or evaluation, they set this to false because those
// screens have already had the stage tokens subtracted.
song_cost*= m_AdjustTokensBySongCostForFinalStageCheck;
int num_on_final= 0;
int num_humans= 0;
FOREACH_HumanPlayer(p)
{
if(m_iPlayerStageTokens[p] - song_cost <= 0)
{
++num_on_final;
}
++num_humans;
}
return num_on_final >= num_humans;
}
bool GameState::IsAnExtraStage() const
{
if( this->GetMasterPlayerNumber() == PlayerNumber_Invalid )
@@ -1098,10 +1130,11 @@ Stage GameState::GetCurrentStage() const
else if( m_PlayMode == PLAY_MODE_ENDLESS ) return Stage_Endless;
else if( IsExtraStage() ) return Stage_Extra1;
else if( IsExtraStage2() ) return Stage_Extra2;
//else if( IsFinalStageForAnyHumanPlayer() ) return Stage_Final;
// above function behaves weirdly, it will always return final stage if any player is
// on final stage, rather than the last remaining player. The below method seems to make a bit more sense.
else if(m_iPlayerStageTokens[PLAYER_1] == 0 && m_iPlayerStageTokens[PLAYER_2] == 0) return Stage_Final;
// Previous logic did not factor in current song length, or the fact that
// players aren't allowed to start a song with 0 tokens. This new
// function also has logic for handling the Gameplay and Evaluation cases
// which used to require workarounds on the theme side. -Kyz
else if(IsFinalStageForEveryHumanPlayer()) return Stage_Final;
else
{
switch( this->m_iCurrentStageIndex )
+4
View File
@@ -204,6 +204,9 @@ public:
*
* This resets whenever a player joins or continues. */
int m_iPlayerStageTokens[NUM_PLAYERS];
// This is necessary so that IsFinalStageForEveryHumanPlayer knows to
// adjust for the current song cost.
bool m_AdjustTokensBySongCostForFinalStageCheck;
RString sExpandedSectionName;
@@ -218,6 +221,7 @@ public:
int GetNumStagesLeft( PlayerNumber pn ) const;
int GetSmallestNumStagesLeftForAnyHumanPlayer() const;
bool IsFinalStageForAnyHumanPlayer() const;
bool IsFinalStageForEveryHumanPlayer() const;
bool IsAnExtraStage() const;
bool IsAnExtraStageAndSelectionLocked() const;
bool IsExtraStage() const;
+11
View File
@@ -75,6 +75,17 @@ static const int NUM_SHOWN_RADAR_CATEGORIES = 5;
AutoScreenMessage( SM_PlayCheer );
REGISTER_SCREEN_CLASS( ScreenEvaluation );
ScreenEvaluation::ScreenEvaluation()
{
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck= false;
}
ScreenEvaluation::~ScreenEvaluation()
{
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck= true;
}
void ScreenEvaluation::Init()
{
LOG->Trace( "ScreenEvaluation::Init()" );
+2
View File
@@ -49,6 +49,8 @@ enum DetailLine
class ScreenEvaluation : public ScreenWithMenuElements
{
public:
ScreenEvaluation();
virtual ~ScreenEvaluation();
virtual void Init();
virtual bool Input( const InputEventPlus &input );
virtual void HandleScreenMessage( const ScreenMessage SM );
+2
View File
@@ -325,6 +325,7 @@ ScreenGameplay::ScreenGameplay()
m_pSongBackground = NULL;
m_pSongForeground = NULL;
m_bForceNoNetwork = false;
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck= false;
}
void ScreenGameplay::Init()
@@ -928,6 +929,7 @@ void ScreenGameplay::InitSongQueues()
ScreenGameplay::~ScreenGameplay()
{
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck= true;
if( this->IsFirstUpdate() )
{
/* We never received any updates. That means we were deleted without being
+15 -5
View File
@@ -1317,11 +1317,21 @@ public:
lua_pushstring(L, pi.sMatchingElement);
return 3;
}
static int GetPathF( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathF(SArg(1),SArg(2)) ); return 1; }
static int GetPathG( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathG(SArg(1),SArg(2)) ); return 1; }
static int GetPathB( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathB(SArg(1),SArg(2)) ); return 1; }
static int GetPathS( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathS(SArg(1),SArg(2)) ); return 1; }
static int GetPathO( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathO(SArg(1),SArg(2)) ); return 1; }
// GENERAL_GET_PATH uses lua_toboolean instead of BArg because that makes
// it optional. -Kyz
#define GENERAL_GET_PATH(get_path_name) \
static int get_path_name(T* p, lua_State* L) \
{ \
lua_pushstring(L, p->get_path_name( \
SArg(1), SArg(2), lua_toboolean(L, 3))); \
return 1; \
}
GENERAL_GET_PATH(GetPathF);
GENERAL_GET_PATH(GetPathG);
GENERAL_GET_PATH(GetPathB);
GENERAL_GET_PATH(GetPathS);
GENERAL_GET_PATH(GetPathO);
#undef GENERAL_GET_PATH
static int RunLuaScripts( T* p, lua_State *L ) { p->RunLuaScripts(SArg(1)); return 1; }