Persistent Coins (#1405)

On Coin Insert, a file Save/Coin.ini is created if it does not exist, which stores the number of coins currrently in m_iCoins. Whenever m_iCoins is update, the Coin.ini is updated.

On boot, Coin.ini is read and m_iCoins is set to that value. If coins in coin.ini file is greater then MAX_NUM_CREDITS then reset the value to 0.
This commit is contained in:
Tyler Brekke
2017-02-17 08:21:38 -08:00
committed by Colby Klein
parent 4b3507f195
commit 8f332653e1
7 changed files with 49 additions and 1 deletions
+4
View File
@@ -5,6 +5,7 @@
#include "GameManager.h"
#include "GameState.h"
#include "AnnouncerManager.h"
#include "Bookkeeper.h"
#include "PlayerOptions.h"
#include "ProfileManager.h"
#include "Profile.h"
@@ -718,6 +719,9 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
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() );
//Credit Used, make sure to update CoinsFile
BOOKKEEPER->WriteCoinsFile(GAMESTATE->m_iCoins.Get());
}
// If only one side is joined and we picked a style that requires both