我开始编写视频扑克程序,但遇到了一些问题。
我有一个保持功能,如下所示:
void Game::Hold( bool& choice )
{
if( choice == true )
{
Console::BackgroundColor(Red);
Console::ForegroundColor(Black);
cout << "HOLD";
Console::BackgroundColor(Black);
Console::ForegroundColor(Red);
}
else
cout << "HOLD";
}
这个功能可以让我屏蔽文本,让玩家知道哪些牌被选中,哪些没有。我遇到的问题是第一个和最后一个“持有”如果被持有就不会被阻挡。
到目前为止,这是我调用该Hold
函数的代码:
void Game::Play( void )
{
Menu();
Console::Clear();
Deck nGame;
nGame.Shuffle();
Game Hand;
Card currentHand[ 5 ];
bool p_Hold[ 5 ] = { 0 , 0 , 0, 0, 0 };
for( int i = 0; i < 5; i++ )
currentHand[ i ] = nGame.Draw();
cout << "Type in which cards you would like to hold. Type \"d\" when done.\n\n";
char uChoice[ 5 ] = {};
for( int i = 0; i < 5; i++ )
{
if( uChoice[ i ] == 'd' )
break;
for( int i = 0; i < 5; i++ )
cout << " " << currentHand[ i ] << " ";
cout << endl;
for( int i = 0; i < 5; i++ )
{
cout << " ";
Hand.Hold( p_Hold[ i ] );
cout << " ";
}
cout << "\n\n\nWould you like to hold Card " << i + 1 << "? (1 = Yes/0 = No): ";
cin.get( uChoice[ i ] );
cin.clear();
cin.ignore( INT_MAX, '\n' );
cout << endl;
if( cin.good() )
{
for( int i = 0; i < 5; i++ )
{
if( uChoice[ i ] == '1' )
p_Hold[ i ] = true;
else
p_Hold[ i ] = false;
}
}
}
}