本文整理汇总了C++中CardList::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ CardList::clear方法的具体用法?C++ CardList::clear怎么用?C++ CardList::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CardList
的用法示例。
在下文中一共展示了CardList::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
void GameBoard::initialize(const CardList& cards)
{
CardList columnCards;
columnCards.reserve(6);
const int k_numColumnsInFirstGroup = 4;
const int k_numColumnsInSecondGroup = 6;
const int k_numCardsInColumnFisrtGroup = 5;
const int k_numCardsInColumnSecondGroup = 4;
for(int i = 0; i < k_numColumnsInFirstGroup; i++)
{
CardList::const_iterator it_from = cards.begin() + i * k_numCardsInColumnFisrtGroup;
CardList::const_iterator it_to = cards.begin() + (i + 1) * k_numCardsInColumnFisrtGroup;
columnCards.insert(columnCards.begin(), it_from, it_to);
m_cardColumns[i].initialize(columnCards);
columnCards.clear();
}
const int k_totalCardsInFirstGroup = 20; //k_numColumnsInFirstGroup * k_numCardsInColumnFisrtGroup;
for(int i = 0; i < k_numColumnsInSecondGroup; i++)
{
CardList::const_iterator it_from = cards.begin() + k_totalCardsInFirstGroup + i * k_numCardsInColumnSecondGroup;
CardList::const_iterator it_to = cards.begin() + k_totalCardsInFirstGroup + (i + 1) * k_numCardsInColumnSecondGroup;
columnCards.insert(columnCards.begin(), it_from, it_to);
m_cardColumns[k_numColumnsInFirstGroup + i].initialize(columnCards);
columnCards.clear();
}
m_cardDeck.initialize(SpiderGame::k_seriesToPass);
m_buildedStackDeck.reset();
m_scoreBoard.reset();
}
示例2: main
void main()
{
Game game = Game();
CardList cards;
//Player playerOne;
BeastCubeManager beastCube(&game);
Hand gameHand(0);
//Hand::playerOneCards = (CardFactory::getCards(5));
//Hand::playerTwoCards = (CardFactory::getCards(4));
//Hand::convertToMenu(1, Hand::playerOneCards);
Hand::drawHand();
Menu m(Hand::handBuffer, &gAssets, Hand::playerOneHand);
m.anchor(0);
//Make beasts
for(int cube = 1; cube < CubeSet::connected().count(); ++cube) {
LOG("###---Player %i---\n", cube);
//CardList c = (CardFactory::getCards(2));
CardFactory::getCards(&cards, 2);
for(int i = 0; i < cards.count(); i++)
{
LOG("###Card for beast creation: %i %i\n", cards[i].type, cards[i].power);
}
Card beastCards[] = {cards.pop_back(), cards.pop_back()};
Beast m = BeastFactory::createBeast(beastCards, 2);
LOG("###Beast created:\n Type: %i\n Attack:%i\n Health:%i\n Resolve:%i\n Anger:%i\n\n",
m.type, m.attack, m.health, m.resolve, m.anger);
beastCube.init(cube, m);
cards.clear();
}
struct MenuEvent e;
uint8_t item;
int target = 0;
while(1)
{
System::paint();
while (m.pollEvent(&e)) {
if(game.newTurn)
{
//LOG("New turn!\n");
//Hand::drawCard(game.activePlayerIndex + 1);
//if(game.activePlayerIndex == 0)
// m.init(Hand::handBuffer, &gAssets, Hand::playerOneHand);
//else
// m.init(Hand::handBuffer, &gAssets, Hand::playerTwoHand);
Hand::drawHand();
game.newTurn = false;
}
switch (e.type) {
case MENU_ITEM_PRESS:
// // Game Buddy is not clickable, so don't do anything on press
// if (e.item >= 3) {
// // Prevent the default action
// continue;
// } else {
// m.anchor(e.item);
// }
// if (e.item == 4) {
// static unsigned randomIcon = 0;
// randomIcon = (randomIcon + 1) % e.item;
// m.replaceIcon(e.item, Hand::playerOneHand[randomIcon].icon, Hand::playerOneHand[randomIcon].label);
// }
if(target != 0)
{
Card c;
c = Hand::playerOneCards[e.item];
game.cardAction(&beastCube.beasts[target], &c);
beastCube.refresh(target);
game.newTurn = true;
}
break;
case MENU_EXIT:
// this is not possible when pollEvent is used as the condition to the while loop.
// NOTE: this event should never have its default handler skipped.
ASSERT(false);
break;
case MENU_NEIGHBOR_ADD:
//LOG("found cube %d on side %d of menu (neighbor's %d side)\n",
//e.neighbor.neighbor, e.neighbor.masterSide, e.neighbor.neighborSide);
target = e.neighbor.neighbor;
break;
case MENU_NEIGHBOR_REMOVE:
//LOG("lost cube %d on side %d of menu (neighbor's %d side)\n",
// e.neighbor.neighbor, e.neighbor.masterSide, e.neighbor.neighborSide);
if(e.neighbor.neighbor == target)
//.........这里部分代码省略.........
示例3: CardsPageDataSource
/// \todo Split up into smaller testing units
TEST_F( libRocketDataGridTest, DataSourceModel )
{
// Disable assertion handling prompts for these tests (just report instead)
// nom::set_assertion_handler(log_assert_handler, nullptr);
// Disable assertion handling prompts for these tests and ignore the report
// nom::set_assertion_handler(null_assert_handler, nullptr);
// Buffer objects used for verifying storage model results
nom::StringList row;
nom::StringList cols;
cols.push_back( "name" );
cols.push_back( "num" );
this->model.reset( new CardsPageDataSource("cards_db") );
// Baseline sanity tests
EXPECT_TRUE( this->model != nullptr );
EXPECT_EQ( "cards", this->model->table_name() )
<< "Table name string should be the default initialized value.";
EXPECT_EQ( true, this->model->empty() )
<< "Resulting storage size should be empty (zero).";
// NOM_LOG_INFO( NOM_LOG_CATEGORY_TEST, this->model->dump() );
// Creation tests
CardList cards;
cards.push_back( Card( 0, "Geezard", 999 ) );
EXPECT_EQ( 1, this->model->append_cards( cards ) )
<< "Resulting storage size should be one item.";
EXPECT_EQ( 2, this->model->append_card( Card( 89, "testme", 22 ) ) )
<< "Resulting storage size should be two items.";
// Overwrite 'testme' card
EXPECT_EQ( 2, this->model->insert_card( 1, Card( 1, "Fungar", 777 ) ) )
<< "Resulting storage size should remain two.";
EXPECT_EQ( false, this->model->empty() )
<< "Storage should not be empty.";
// NOM_LOG_INFO( NOM_LOG_CATEGORY_TEST, this->model->dump() );
// Destruction tests
// Destroy 'Fungar' card
EXPECT_EQ( 1, this->model->erase_card( 1 ) )
<< "Resulting storage size should be one.";
// ...and verify the results
row.clear();
this->model->row(row, 0, cols );
EXPECT_EQ( "Geezard", row.at(0) );
EXPECT_EQ( "999", row.at(1) );
cards.clear();
cards.push_back( Card( 2, "Bite Bug", 2 ) );
cards.push_back( Card( 3, "Red Bat", 5 ) );
cards.push_back( Card( 89, "Diablos", 666 ) );
// Overwrite all but the first card in the model, shifting said first card to
// the end of the container.
EXPECT_EQ( 4, this->model->insert_cards( 0, cards ) )
<< "Resulting storage size should be four items.";
// Ensure that the first card is at the end of the container
row.clear();
this->model->row( row, this->model->num_rows() - 1, cols );
EXPECT_EQ( "Geezard", row.at(0) );
EXPECT_EQ( "999", row.at(1) );
// NOM_LOG_INFO( NOM_LOG_CATEGORY_TEST, this->model->dump() );
// Destroy all but 'Geezard' card
EXPECT_EQ( 1, this->model->erase_cards( 0, 3 ) )
<< "The Geezard card should be the only item remaining.";
// ...and verify the results
row.clear();
this->model->row(row, 0, cols );
EXPECT_EQ( "Geezard", row.at(0) );
EXPECT_EQ( "999", row.at(1) );
this->model->erase_cards();
EXPECT_EQ( true, this->model->empty() )
<< "Resulting storage size should be emptied (zero).";
row.clear();
this->model->erase_cards();
NOM_LOG_INFO( NOM_LOG_CATEGORY_TEST, this->model->dump() );
}