From 00e6f6e92449d5655411611fb5f23cd87ddc124f Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 8 Jun 2013 16:11:02 -0400 Subject: [PATCH] Make Pay mode work like Free Third time's a charm. Removing Pay mode without causing breakage to the Lua API. This is the first step. --- src/GameCommand.cpp | 40 +--------------------------------- src/GameState.cpp | 27 +++++------------------ src/ScreenAttract.cpp | 28 ++++++------------------ src/ScreenSystemLayer.cpp | 37 +++++-------------------------- src/ScreenWithMenuElements.cpp | 8 ------- 5 files changed, 19 insertions(+), 121 deletions(-) diff --git a/src/GameCommand.cpp b/src/GameCommand.cpp index 4776f98736..fbc10b0f7e 100644 --- a/src/GameCommand.cpp +++ b/src/GameCommand.cpp @@ -493,18 +493,10 @@ bool GameCommand::IsPlayable( RString *why ) const if ( m_pStyle ) { - int iCredits = GAMESTATE->m_iCoins / PREFSMAN->m_iCoinsPerCredit; + int iCredits = NUM_PLAYERS; const int iNumCreditsPaid = GetNumCreditsPaid(); const int iNumCreditsRequired = GetCreditsRequiredToPlayStyle(m_pStyle); - switch( GAMESTATE->GetCoinMode() ) - { - case CoinMode_Home: - case CoinMode_Free: - iCredits = NUM_PLAYERS; // not iNumCreditsPaid - default: break; - } - /* With PREFSMAN->m_bDelayedCreditsReconcile disabled, enough credits must * be paid. (This means that enough sides must be joined.) Enabled, simply * having enough credits lying in the machine is sufficient; we'll deduct the @@ -520,23 +512,6 @@ bool GameCommand::IsPlayable( RString *why ) const return false; } - /* If you've paid too much already, don't allow the mode. (If we allow this, - * the credits will be "refunded" in Apply(), but that's confusing.) */ - /* Do allow the mode if they've already joined in more credits than - * are required. Otherwise, people who put in two credits to play - * doubles on a doubles-premium machiune will get locked out. - * the refund logic isn't that awkward because you never see the - * credits number jump up - the credits display is hidden if both - * sides are joined. -Chris */ - /* - if( PREFSMAN->m_iCoinMode == COIN_PAY && iNumCreditsPaid > iNumCreditsRequired ) - { - if( why ) - *why = ssprintf( "too many credits paid (%i > %i)", iNumCreditsPaid, iNumCreditsRequired ); - return false; - } - */ - /* If both sides are joined, disallow singles modes, since easy to select * them accidentally, instead of versus mode. */ if( m_pStyle->m_StyleType == StyleType_OnePlayerOneSide && @@ -662,19 +637,6 @@ void GameCommand::ApplySelf( const vector &vpns ) const { GAMESTATE->SetCurrentStyle( m_pStyle ); - // It's possible to choose a style that didn't have enough players joined. - // If enough players aren't joined, then we need to subtract credits - // for the sides that will be joined as a result of applying this option. - if( GAMESTATE->GetCoinMode() == CoinMode_Pay ) - { - int iNumCreditsRequired = GetCreditsRequiredToPlayStyle(m_pStyle); - int iNumCreditsPaid = GetNumCreditsPaid(); - int iNumCreditsOwed = iNumCreditsRequired - iNumCreditsPaid; - GAMESTATE->m_iCoins.Set( GAMESTATE->m_iCoins - iNumCreditsOwed * PREFSMAN->m_iCoinsPerCredit ); - LOG->Trace( "Deducted %i coins, %i remaining", - iNumCreditsOwed * PREFSMAN->m_iCoinsPerCredit, GAMESTATE->m_iCoins.Get() ); - } - // If only one side is joined and we picked a style that requires both // sides, join the other side. switch( m_pStyle->m_StyleType ) diff --git a/src/GameState.cpp b/src/GameState.cpp index 7da1e2dd0a..ec4301f7c2 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -361,13 +361,7 @@ void GameState::Reset() void GameState::JoinPlayer( PlayerNumber pn ) { - /* If joint premium and we're not taking away a credit for the 2nd join, - * give the new player the same number of stage tokens that the old player - * has. */ - if( GetCoinMode() == CoinMode_Pay && GetPremium() == Premium_2PlayersFor1Credit && GetNumSidesJoined() == 1 ) - m_iPlayerStageTokens[pn] = m_iPlayerStageTokens[this->GetMasterPlayerNumber()]; - else - m_iPlayerStageTokens[pn] = PREFSMAN->m_iSongsPerPlay; + m_iPlayerStageTokens[pn] = PREFSMAN->m_iSongsPerPlay; m_bSideIsJoined[pn] = true; @@ -489,17 +483,7 @@ bool GameState::JoinPlayers() int GameState::GetCoinsNeededToJoin() const { - int iCoinsToCharge = 0; - - if( GetCoinMode() == CoinMode_Pay ) - iCoinsToCharge = PREFSMAN->m_iCoinsPerCredit; - - // If joint premium, don't take away a credit for the second join. - if( GetPremium() == Premium_2PlayersFor1Credit && - GetNumSidesJoined() == 1 ) - iCoinsToCharge = 0; - - return iCoinsToCharge; + return 0; } /* Game flow: @@ -2055,10 +2039,9 @@ bool GameState::IsEventMode() const CoinMode GameState::GetCoinMode() const { - if( IsEventMode() && GamePreferences::m_CoinMode == CoinMode_Pay ) - return CoinMode_Free; - else - return GamePreferences::m_CoinMode; + if( GamePreferences::m_CoinMode == CoinMode_Home ) + return CoinMode_Home; + return CoinMode_Free; } ThemeMetric DISABLE_PREMIUM_IN_EVENT_MODE("GameState","DisablePremiumInEventMode"); diff --git a/src/ScreenAttract.cpp b/src/ScreenAttract.cpp index 8f122c104c..7477967ce3 100644 --- a/src/ScreenAttract.cpp +++ b/src/ScreenAttract.cpp @@ -83,29 +83,15 @@ bool ScreenAttract::AttractInput( const InputEventPlus &input, ScreenWithMenuEle // fall through case GAME_BUTTON_START: case GAME_BUTTON_COIN: - switch( GAMESTATE->GetCoinMode() ) - { - case CoinMode_Pay: - LOG->Trace("ScreenAttract::AttractInput: COIN_PAY (%i/%i, %i)", - GAMESTATE->m_iCoins.Get(), - PREFSMAN->m_iCoinsPerCredit.Get(), - GAMESTATE->GetNumSidesJoined() ); - if( GAMESTATE->m_iCoins < PREFSMAN->m_iCoinsPerCredit && GAMESTATE->GetNumSidesJoined() == 0 ) - return true; - // fall through - case CoinMode_Home: - case CoinMode_Free: - if( pScreen->IsTransitioning() ) - return false; + if( pScreen->IsTransitioning() ) + return false; - // HandleGlobalInputs() already played the coin sound. Don't play it again. - if( input.MenuI != GAME_BUTTON_COIN ) - SCREENMAN->PlayStartSound(); + // HandleGlobalInputs() already played the coin sound. Don't play it again. + if( input.MenuI != GAME_BUTTON_COIN ) + SCREENMAN->PlayStartSound(); - pScreen->Cancel( SM_GoToStartScreen ); - return true; - default: FAIL_M("Invalid Coin Mode! Aborting..."); - } + pScreen->Cancel( SM_GoToStartScreen ); + return true; default: break; } diff --git a/src/ScreenSystemLayer.cpp b/src/ScreenSystemLayer.cpp index 830ad78f18..3904c99a16 100644 --- a/src/ScreenSystemLayer.cpp +++ b/src/ScreenSystemLayer.cpp @@ -97,38 +97,13 @@ namespace } else // bShowCreditsMessage { + if( GAMESTATE->PlayersCanJoin() ) + return CREDITS_NOT_PRESENT.GetValue(); + CoinMode mode = GAMESTATE->GetCoinMode(); - switch( mode ) - { - case CoinMode_Home: - if( GAMESTATE->PlayersCanJoin() ) - return CREDITS_PRESS_START.GetValue(); - else - return CREDITS_NOT_PRESENT.GetValue(); - - case CoinMode_Pay: - { - int iCredits = GAMESTATE->m_iCoins / PREFSMAN->m_iCoinsPerCredit; - int iCoins = GAMESTATE->m_iCoins % PREFSMAN->m_iCoinsPerCredit; - RString sCredits = CREDITS_CREDITS; - // todo: allow themers to change these strings -aj - if( iCredits > 0 || PREFSMAN->m_iCoinsPerCredit == 1 ) - sCredits += ssprintf(" %d", iCredits); - if( PREFSMAN->m_iCoinsPerCredit > 1 ) - sCredits += ssprintf(" %d/%d", iCoins, PREFSMAN->m_iCoinsPerCredit.Get() ); - if( iCredits >= MAX_NUM_CREDITS ) - sCredits += " " + CREDITS_MAX.GetValue(); - return sCredits; - } - case CoinMode_Free: - if( GAMESTATE->PlayersCanJoin() ) - return CREDITS_FREE_PLAY.GetValue(); - else - return CREDITS_NOT_PRESENT.GetValue(); - - default: - FAIL_M(ssprintf("Invalid CoinMode: %i", mode)); - } + if( mode == CoinMode_Home ) + return CREDITS_PRESS_START.GetValue(); + return CREDITS_FREE_PLAY.GetValue(); } } diff --git a/src/ScreenWithMenuElements.cpp b/src/ScreenWithMenuElements.cpp index 6ec6ca04cd..5cde6d05d6 100644 --- a/src/ScreenWithMenuElements.cpp +++ b/src/ScreenWithMenuElements.cpp @@ -134,14 +134,6 @@ void ScreenWithMenuElements::BeginScreen() /* Evaluate FirstUpdateCommand. */ this->PlayCommand( "FirstUpdate" ); - - /* If AutoJoin and a player is already joined, then try to join a player. (If no players - * are joined, they'll join on the first JoinInput.) */ - if( GAMESTATE->GetCoinMode() == CoinMode_Pay && GAMESTATE->m_bAutoJoin.Get() ) - { - if( GAMESTATE->GetNumSidesJoined() > 0 && GAMESTATE->JoinPlayers() ) - SCREENMAN->PlayStartSound(); - } } void ScreenWithMenuElements::HandleScreenMessage( const ScreenMessage SM )