本文整理汇总了C++中CBuffer::PopCard方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::PopCard方法的具体用法?C++ CBuffer::PopCard怎么用?C++ CBuffer::PopCard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::PopCard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
void CTable::Load()
{
int SavShowCards = 0;
FILE* sav = fopen( GAMESDIR "/solitair.sav", "rb" );
if( sav == NULL ) return;
fread( &SavShowCards, 1, sizeof( SavShowCards ), sav );
if( ( SavShowCards != 3 ) && ( SavShowCards != 1 ) )
{
return;
}
ShowCards = SavShowCards;
fread( &win_counter, 1, sizeof( win_counter ), sav );
CCard card;
unsigned char CardsStored;
CBuffer buffer;
//Restore BLOCK
block.RemoveAll();
fread( &CardsStored, 1, sizeof( CardsStored ), sav );
buffer.RemoveAll();
for( unsigned char i = 0; i < CardsStored; i++ )
{
fread( &card, 1, sizeof( card ), sav );
buffer.PushCard( card, true );
}
for( unsigned char i = 0; i < CardsStored; i++ )
{
block.PushCard( buffer.PopCard(), true );
}
//Restore Wastepile
fread( &CardsStored, 1, sizeof( CardsStored ), sav );
buffer.RemoveAll();
for( unsigned char i = 0; i < CardsStored; i++ )
{
fread( &card, 1, sizeof( card ), sav );
buffer.PushCard( card, true );
}
for( unsigned char i = 0; i < CardsStored; i++ )
{
wastepile.PushCard( buffer.PopCard(), true );
}
//Restore HAND
int HSource;
fread( &HSource, 1, sizeof( HSource ), sav );
switch( HSource )
{
case 0:
hand.SetSource(NULL);
break;
case BLOCK:
hand.SetSource(&block);
break;
case WASTEPILE:
hand.SetSource(&wastepile);
break;
case FOUNDATION1:
hand.SetSource(&foundation[0]);
break;
case FOUNDATION2:
hand.SetSource(&foundation[1]);
break;
case FOUNDATION3:
hand.SetSource(&foundation[2]);
break;
case FOUNDATION4:
hand.SetSource(&foundation[3]);
break;
case TABLEAU1:
hand.SetSource(&tableau[0]);
break;
case TABLEAU2:
hand.SetSource(&tableau[1]);
break;
case TABLEAU3:
hand.SetSource(&tableau[2]);
break;
case TABLEAU4:
hand.SetSource(&tableau[3]);
break;
case TABLEAU5:
hand.SetSource(&tableau[4]);
break;
case TABLEAU6:
hand.SetSource(&tableau[5]);
//.........这里部分代码省略.........
示例2: DoAction
void CTable::DoAction()
{
CBuffer buffer;
CCard tmp;
CSlot* fnd = NULL;
CSlot* tab = NULL;
switch( act_slot )
{
case BLOCK :
/* move 3 cards to wastepile */
//check IncreaseSelection and DecreaseSelection
//regarding increaseSelection (all) or (+1)
if( 0 != hand.GetCardsStored() ) return;
buffer.RemoveAll();
if( block.GetCardsStored() != 0 )
{
tmp = block.PopCard();
tmp.Flip();
wastepile.PushCard( tmp );
if( 3 == ShowCards )
{
tmp = block.PopCard();
tmp.Flip();
wastepile.PushCard( tmp );
tmp = block.PopCard();
tmp.Flip();
wastepile.PushCard( tmp );
}
act_slot = WASTEPILE;
}
else
{
if( wastepile.GetCardsStored() )
{
tmp = wastepile.PopCard();
while( tmp.IsValid() )
{
tmp.Flip();
block.PushCard( tmp, true );
tmp = wastepile.PopCard();
}
}
}
changed[ WASTEPILE ] = true;
changed[ BLOCK ] = true;
ChangeSelection( );
return;
case WASTEPILE :
/* put one card to hand */
/* or put back from the hand */
if( hand.GetCardsStored() )
{
if( hand.GetSource() == &wastepile )
{
tmp = hand.PopCard();
wastepile.PushCard( tmp, true );
hand.SetSource( NULL );
}
}
else
{
tmp = wastepile.PopCard();
if( false == tmp.IsValid() ) break;
if( false == hand.PushCard( tmp ) )
{
wastepile.PushCard( tmp, true );
}
hand.SetSource( &wastepile );
}
changed[ WASTEPILE ] = true;
changed[ HAND ] = true;
return;
case FOUNDATION1 :
case FOUNDATION2 :
case FOUNDATION3 :
case FOUNDATION4 : fnd = &foundation[act_slot - FOUNDATION1]; break;
//.........这里部分代码省略.........