fix coin/join logic
This commit is contained in:
@@ -1012,3 +1012,10 @@ void GameState::StoreRankingName( PlayerNumber pn, CString name )
|
||||
*aFeats[i].pStringToFill = name;
|
||||
}
|
||||
}
|
||||
|
||||
bool GameState::UsingPremiumAndPaying()
|
||||
{
|
||||
return
|
||||
(PREFSMAN->m_bVersusForOneCredit || PREFSMAN->m_bDoubleForOneCredit) &&
|
||||
PREFSMAN->m_iCoinMode == COIN_PAY;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
iNumSidesJoined++; // left side, and right side
|
||||
return iNumSidesJoined;
|
||||
};
|
||||
bool UsingPremiumAndPaying();
|
||||
|
||||
GameDef* GetCurrentGameDef();
|
||||
const StyleDef* GetCurrentStyleDef();
|
||||
|
||||
@@ -161,7 +161,7 @@ void ModeChoice::Load( int iIndex, CString sChoice )
|
||||
}
|
||||
}
|
||||
|
||||
int GetCreditsToPlayStyle( Style style )
|
||||
int GetCreditsRequiredToPlayStyle( Style style )
|
||||
{
|
||||
switch( GAMEMAN->GetStyleDefForStyle(style)->m_StyleType )
|
||||
{
|
||||
@@ -177,6 +177,21 @@ int GetCreditsToPlayStyle( Style style )
|
||||
}
|
||||
}
|
||||
|
||||
int GetSidesRequiredToPlayStyle( Style style )
|
||||
{
|
||||
switch( GAMEMAN->GetStyleDefForStyle(style)->m_StyleType )
|
||||
{
|
||||
case StyleDef::ONE_PLAYER_ONE_CREDIT:
|
||||
return 1;
|
||||
case StyleDef::TWO_PLAYERS_TWO_CREDITS:
|
||||
case StyleDef::ONE_PLAYER_TWO_CREDITS:
|
||||
return 2;
|
||||
default:
|
||||
ASSERT(0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool ModeChoice::IsPlayable( CString *why ) const
|
||||
{
|
||||
if( m_bInvalid )
|
||||
@@ -184,19 +199,19 @@ bool ModeChoice::IsPlayable( CString *why ) const
|
||||
|
||||
if ( m_style != STYLE_INVALID )
|
||||
{
|
||||
bool bUsingPremium = PREFSMAN->m_bVersusForOneCredit || PREFSMAN->m_bDoubleForOneCredit;
|
||||
int iNumCreditsInserted = GAMESTATE->m_iCoins/PREFSMAN->m_iCoinsPerCredit;
|
||||
int iNumCreditsRequired = GetCreditsToPlayStyle(m_style);
|
||||
int iNumCreditsRequired = GetCreditsRequiredToPlayStyle(m_style);
|
||||
int iNumSidesJoined = GAMESTATE->GetNumSidesJoined();
|
||||
int iNumSidesRequired = GetSidesRequiredToPlayStyle(m_style);
|
||||
|
||||
if( bUsingPremium )
|
||||
if( GAMESTATE->UsingPremiumAndPaying() )
|
||||
{
|
||||
if( iNumCreditsInserted < iNumCreditsRequired )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( iNumCreditsRequired != iNumSidesJoined )
|
||||
if( iNumSidesRequired != iNumSidesJoined )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -281,10 +296,9 @@ void ModeChoice::Apply( PlayerNumber pn ) const
|
||||
}
|
||||
|
||||
// If using a premium setting, subtract coins only after choosing a style.
|
||||
bool bUsingPremium = PREFSMAN->m_bVersusForOneCredit || PREFSMAN->m_bDoubleForOneCredit;
|
||||
int iNumCoinsInserted = GAMESTATE->m_iCoins;
|
||||
int iNumCoinsRequired = PREFSMAN->m_iCoinsPerCredit*GetCreditsToPlayStyle(m_style);
|
||||
if( bUsingPremium )
|
||||
int iNumCoinsRequired = PREFSMAN->m_iCoinsPerCredit*GetCreditsRequiredToPlayStyle(m_style);
|
||||
if( GAMESTATE->UsingPremiumAndPaying() )
|
||||
{
|
||||
ASSERT( iNumCoinsInserted >= iNumCoinsRequired );
|
||||
GAMESTATE->m_iCoins -= iNumCoinsRequired;
|
||||
|
||||
@@ -94,12 +94,12 @@ void ScreenSelect::Input( const DeviceInput& DeviceI, const InputEventType type,
|
||||
// LOG->Trace( "ScreenSelect::Input()" );
|
||||
|
||||
bool bUsingPremium = PREFSMAN->m_bVersusForOneCredit || PREFSMAN->m_bDoubleForOneCredit;
|
||||
if( bUsingPremium )
|
||||
if( GAMESTATE->UsingPremiumAndPaying() )
|
||||
{
|
||||
if( MenuI.IsValid() && MenuI.button==MENU_BUTTON_COIN && GAMESTATE->m_iCoins==PREFSMAN->m_iCoinsPerCredit*2 )
|
||||
this->UpdateSelectableChoices();
|
||||
}
|
||||
else // !bUsingPremium
|
||||
else
|
||||
{
|
||||
if( Screen::JoinInput(DeviceI, type, GameI, MenuI, StyleI) )
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ ScreenSelectStyle::ScreenSelectStyle( CString sClassName ) : ScreenSelect( sClas
|
||||
|
||||
m_sprJointPremium.SetName( "JointPremium" );
|
||||
|
||||
if( PREFSMAN->m_bVersusForOneCredit||PREFSMAN->m_bDoubleForOneCredit )
|
||||
if( GAMESTATE->UsingPremiumAndPaying() )
|
||||
{
|
||||
m_sprJointPremium.Load( THEME->GetPathToG(m_sName + " joint premium") );
|
||||
this->AddChild( &m_sprJointPremium );
|
||||
|
||||
@@ -71,7 +71,7 @@ ScreenTitleMenu::ScreenTitleMenu( CString sClassName ) : ScreenSelect( sClassNam
|
||||
|
||||
CodeDetector::RefreshCacheItems();
|
||||
|
||||
if( PREFSMAN->m_iCoinMode!=COIN_HOME && (PREFSMAN->m_bVersusForOneCredit||PREFSMAN->m_bDoubleForOneCredit) )
|
||||
if( GAMESTATE->UsingPremiumAndPaying() )
|
||||
{
|
||||
m_JointPremium.LoadFromAniDir( THEME->GetPathToB("ScreenTitleMenu joint premium") );
|
||||
this->AddChild( &m_JointPremium );
|
||||
|
||||
Reference in New Issue
Block a user