• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Card函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Card函数的典型用法代码示例。如果您正苦于以下问题:C++ Card函数的具体用法?C++ Card怎么用?C++ Card使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Card函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	const char* counting = "counting";
	Player *cplayer = player_factory(counting);

	Hand chand;
	Hand chand1;
	Hand chand2;

	//I added this comment line

	Card c = Card(Card::ACE, Card::SPADES);
	Card d = Card(Card::FIVE, Card::CLUBS);

	Card f = Card(Card::SIX, Card::CLUBS);

	Card g = Card(Card::TWO, Card::CLUBS);

	Card e = Card(Card::FOUR, Card::SPADES);

	chand.add_card(c);
	chand.add_card(d);

	chand1.add_card(c);
	chand1.add_card(f);

	chand2.add_card(c);
	chand2.add_card(g);

	assert(cplayer->draw(e, chand) == true);
	assert(cplayer->draw(e, chand1) == true);
	assert(cplayer->draw(e, chand2) == true);

return 0;
}
开发者ID:bliminate,项目名称:Project_4,代码行数:35,代码来源:Player_test15.cpp


示例2: init

void Deck::init() {
    for (int i = 0; i < MAX_CARD_VALUE; ++i) {
        cards.push_back(Card(CLUBS, i));
        cards.push_back(Card(DIAMONDS, i));
        cards.push_back(Card(HEARTS, i));
        cards.push_back(Card(SPADES, i));
    }
}
开发者ID:ebaratte,项目名称:cpp-klondike,代码行数:8,代码来源:Deck.cpp


示例3: parseHand2

Hand2 parseHand2(json::Value value) {
    Hand2 hand;
    hand[0] = Card(value[size_t(0)]);
    hand[1] = Card(value[size_t(1)]);

    std::sort(hand.begin(), hand.end());

    return hand;
}
开发者ID:r0mai,项目名称:poker-player-rainbow-dash,代码行数:9,代码来源:Hand.cpp


示例4: IdenticeO

int IdenticeO(TMultime *m1, TMultime *m2)
{
	TMultime *x,*y;
	if(Card(m1)!=Card(m2)) return 0;
	for(x = m1->v , y = m2->v ; x < m1->s ; x+= m1->d, y+=m2->d){
		if(m1->fid(x,y)!=0) return 0;
		// if( *(char*)x != *(char*)y ) return 0;
	}
	return 1;
}
开发者ID:flaviusone,项目名称:Data-Structures,代码行数:10,代码来源:funcMO-1.c


示例5: TEST

TEST(PutDown, LessThanFour)
{
    std::vector<Card> j = std::vector<Card>();
    j.push_back(Card(1,5));
    j.push_back(Card(2,5));
    Player pj = Player(j,"NICK");
    std::vector<Card> pdj = pj.putDown(5);
    ASSERT_EQ(0, pdj.size());

}
开发者ID:ColinEaster,项目名称:Cloud11,代码行数:10,代码来源:testplayer.cpp


示例6: createDeck

void Game::createDeck(){
    for (int i = 1; i <= 52; i++){
        // Adding two of the same card because we use two decks
        deck.push_back(Card(i));
        deck.push_back(Card(i));
    }

    random_shuffle(deck.begin(), deck.end());
    random_shuffle(deck.begin(), deck.end());
    random_shuffle(deck.begin(), deck.end());
}
开发者ID:aaronjohnleonard,项目名称:sequence,代码行数:11,代码来源:game.cpp


示例7:

Deck::Deck()
{
    cards_.reserve(36);
    for (int i = 6; i <= Card::ACE; i++)
    {
        cards_.push_back(Card(i, Card::hearts));
        cards_.push_back(Card(i, Card::diamonds));
        cards_.push_back(Card(i, Card::spades));
        cards_.push_back(Card(i, Card::clubs));
    }
}
开发者ID:zackgomez,项目名称:ezdurak,代码行数:11,代码来源:Deck.cpp


示例8: main

int main()
{
   std::vector<Card> cards;
   // Correct
   cards.push_back(Card(SPADES, ACE));
   cards.push_back(Card(SPADES, TWO));
   // Wrong
   cards.push_back(Card(Suit::SPADES, Value::ACE));
   cards.push_back(Card(Suite::SPADES, Value::TWO));
   return 0;
}
开发者ID:KubaO,项目名称:stackoverflown,代码行数:11,代码来源:main.cpp


示例9: botmove

void botmove(){
	addressCard C = whichcardtake();
	if(C != NULL){
		doTake(Card(C));		
		doMeld(Card(C));
	}else{
		doDraw();
	}
	botmeld();
	infoCard off = whichcardoff();
	doOff(off);
}
开发者ID:qornanali,项目名称:Rummy-C,代码行数:12,代码来源:bot.c


示例10:

 Deck::Deck()
 {
     // fill the deck
     this->reserve(52);
     for(int i = 1; i <= 13; i++)
     {
         this->push_back(Card(Card::Spades, i));
         this->push_back(Card(Card::Clubs, i));
         this->push_back(Card(Card::Diamonds, i));
         this->push_back(Card(Card::Hearts, i));
     }
 }
开发者ID:Nobody-7,项目名称:tcpppl_answers,代码行数:12,代码来源:ex04.cpp


示例11: Reset

  void Game::Reset(int nEachType)
  {
    m_deck.clear();
    m_arena.clear();
    int count;
    int serial = 100;

    std::vector<Card::Face> faces;
    faces.push_back(Card::Goomba);
    faces.push_back(Card::Mushroom);
    faces.push_back(Card::Flower);
    faces.push_back(Card::Mario);
    faces.push_back(Card::Bowser);
    faces.push_back(Card::Cloud);
    faces.push_back(Card::Luigi);
    faces.push_back(Card::Star);

    std::vector<Card::Face>::const_iterator faceIt;

    for(count = 0; count < nEachType; count ++, serial ++)
    {
      for(faceIt = faces.begin(); faceIt != faces.end(); ++ faceIt)
      {
        m_deck.push_back(Card(*faceIt, serial));
      }
    }

    std::random_shuffle(m_deck.begin(), m_deck.end(), MarioRand);

    _DealOut();
  }
开发者ID:thenfour,项目名称:Archives,代码行数:31,代码来源:Game.cpp


示例12: if

bool SimpleXMLHandler::startElement(const QString &namespaceURI, const QString &localName,
                                    const QString &qName, const QXmlAttributes &attributes)
{
    // maybe check for double opening lines?
//qDebug("lol");
    if (qName == "LINES") {
        bool ok1 = true, ok2 = true;
        row = 0;
        readingCards = true;
        properties.resize(attributes.value("ColCount").toInt(&ok1));
//        cards.resize(attributes.value("RowCount").toInt(&ok2) - 1);
        if (!ok1 || !ok2 ) {
            errorStr = "Can't convert string to double.";
            return false;
        }
    } else if (!readingCards) {
        return true;
    } else if (qName == "LINE") {
        column = 0;
        currentCard = Card();
    } else if (qName == "CELL") {
        currentText.clear();
    }

    return true;
}
开发者ID:ABBAPOH,项目名称:ccgo,代码行数:26,代码来源:simplexmlhandler.cpp


示例13: Card

void Hand::clearHand()
{
	for (int i = 0; i < 5; i++)
	{
		_hand[i] = Card(); /*** Make this a 'NULL' card instead? ***/
	}
}
开发者ID:shanewilhelm,项目名称:5-Card-Poker,代码行数:7,代码来源:hand.cpp


示例14: charsToCard

Card charsToCard(char c0, char c1)
{
  if(c0 >= 'a' && c0 <= 'z') c0 += ('A' - 'a');
  if(c1 >= 'A' && c1 <= 'Z') c1 += ('a' - 'A');
  std::string c; c += c0; c += c1;
  return Card(c);
}
开发者ID:lvandeve,项目名称:oopoker,代码行数:7,代码来源:tools_terminal.cpp


示例15: afiMx

void afiMx(TMultime*m) /* afiseaza continut multime de Tx */
{ Tx *p = (Tx*)(m->v);
	int i = 0, n = Card(m);
	printf("      v1     v2   v3\n");
	for(; i < n; i++)
		printf("[%2i]%4i%7.2lf  %s\n", i, p[i].v1, p[i].v2, p[i].v3);
}
开发者ID:flaviusone,项目名称:Data-Structures,代码行数:7,代码来源:testMX-1.c


示例16: Texture

void Deck::fill(const bool shuffle) {
	// add card based with value for each front texture supplied
	auto add_card = [ this ](const unsigned int value, const std::vector<std::string> &textures) {
		for (auto &t : textures) {
			auto &c = this->add_child(Card(value, true, Texture(Card::TEXTURE_BACK, true)));
			c.face().texture(Texture("./resources/" + t, true));    // set card face texture
		}

	};    // add_card

	// strings refer to textures in the ./resources/ directory
	add_card(2, { "2_of_clubs.png", "2_of_diamonds.png", "2_of_hearts.png", "2_of_spades.png" });
	add_card(3, { "3_of_clubs.png", "3_of_diamonds.png", "3_of_hearts.png", "3_of_spades.png" });
	add_card(4, { "4_of_clubs.png", "4_of_diamonds.png", "4_of_hearts.png", "4_of_spades.png" });
	add_card(5, { "5_of_clubs.png", "5_of_diamonds.png", "5_of_hearts.png", "5_of_spades.png" });
	add_card(6, { "6_of_clubs.png", "6_of_diamonds.png", "6_of_hearts.png", "6_of_spades.png" });
	add_card(7, { "7_of_clubs.png", "7_of_diamonds.png", "7_of_hearts.png", "7_of_spades.png" });
	add_card(8, { "8_of_clubs.png", "8_of_diamonds.png", "8_of_hearts.png", "8_of_spades.png" });
	add_card(9, { "9_of_clubs.png", "9_of_diamonds.png", "9_of_hearts.png", "9_of_spades.png" });
	add_card(10, { "10_of_clubs.png", "10_of_diamonds.png", "10_of_hearts.png", "10_of_spades.png" });
	add_card(11,
	         { "jack_of_clubs.png", "jack_of_diamonds.png", "jack_of_hearts.png", "jack_of_spades.png" });    // jack
	add_card(12, { "queen_of_clubs.png", "queen_of_diamonds.png", "queen_of_hearts.png"
	               , "queen_of_spades.png" });    // queen
	add_card(13,
	         { "king_of_clubs.png", "king_of_diamonds.png", "king_of_hearts.png", "king_of_spades.png" });    // king
	add_card(14, { "ace_of_clubs.png", "ace_of_diamonds.png", "ace_of_hearts.png", "ace_of_spades.png" });    // ace

	if (shuffle)
		this->shuffle();

}    // fill
开发者ID:martensm,项目名称:CSC5210_Project_4,代码行数:32,代码来源:Deck.cpp


示例17: srand

	void Deck::init(int numDecks){
		numDecks = numDecks;
		numCards = numDecks * 52;
		vector<int> cardList;

		//Initialize List of Cards
		int cardAvailable = numCards, val, idx;
		for(int i=0;i<13;i++){
			for(int j=0;j<(numDecks*4);j++){
				cardList.insert(cardList.end(),i);
			}
		}

		//Shuffle the deck
		srand (time(NULL)); 
		for(int i=0;i<numCards;i++){
			if(cardAvailable >1 )
				idx = rand() % (cardAvailable);
			else
				idx = 0;
			val = cardList[idx];
			cardList.erase(cardList.begin()+idx);
			cardAvailable--;
			deckList.push_front(Card(val,false));
		}

		//Delete the cardlist
		vector<int>().swap(cardList);
	}
开发者ID:daichitenski,项目名称:VideoGameDesign,代码行数:29,代码来源:Deck.cpp


示例18: Exception

void Checker::claimMaster(ClaimMaster& res, Seat* s, Card::Suit suit)
{
    ManagerBase* m = s->manager();
    const Option& opt = m->option();
    if (opt.claimMasterWithKing &&
            !s->has(Card::KingBlack) && !s->has(Card::KingRed)) {
        throw Exception(CheckerExcp,ErrorCode::ClaimWithoutKing, "Must use king to claim");
    }
    int level = m->level();
    int n = 0;
    bool kingRed = false;
    if (suit == Card::King) {
        n = s->has(Card::KingBlack);
        if (n < 2) {
            n = s->has(Card::KingRed);
            kingRed = true;
        }
        if (n != 2) {
            throw Exception(CheckerExcp,ErrorCode::ClaimRequireKingPair);
        }
    } else {
        n = s->has(Card(suit, level));
    }
    if (n == 0) {
        throw Exception(CheckerExcp,ErrorCode::ClaimRequireMasterNumber);
    }
    const ClaimMaster& cm = m->master();
    if (cm.seat >= 0) {
        if (cm.seat == s->id() && (cm.card.isKing() || cm.card.suit() != suit)) {
            throw Exception(CheckerExcp,ErrorCode::ClaimAntiSelf);
        }
        if (n <= 1) {
            throw Exception(CheckerExcp,ErrorCode::ClaimWeak);
        }
        if (cm.pair) {
            if (suit != Card::King) {
                throw Exception(CheckerExcp,ErrorCode::ClaimWeak);
            } else if (cm.king.suit() == Card::King && !kingRed) {
                throw Exception(CheckerExcp,ErrorCode::ClaimWeak);
            }
        }
    }
    res.seat = s->id();
    res.card.set(suit, level);
    res.pair = n == 2;
    if (suit == Card::King) {
        if (s->has(Card::KingBlack) == 2) {
            res.king.set(Card::KingBlack);
        } else {
            res.king.set(Card::KingRed);
        }
    } else if (opt.claimMasterWithKing) {
        if (s->has(Card::KingBlack)) {
            res.king.set(Card::KingBlack);
        } else {
            res.king.set(Card::KingRed);
        }
    }
}
开发者ID:fortrue,项目名称:ssj,代码行数:59,代码来源:Checker.cpp


示例19: hand1

void PokerTest::sortTest()
{
   std::cout << "sort test" << std::endl;

   Hand hand1(Card(Rank::JACK,   Suit::HEART),
              Card(Rank::ACE,    Suit::HEART),
              Card(Rank::FIVE,   Suit::HEART),
              Card(Rank::SIX,    Suit::HEART),
              Card(Rank::TWO,    Suit::HEART));
   Hand hand2(Card(Rank::ACE,    Suit::SPADE),
              Card(Rank::FIVE,   Suit::SPADE),
              Card(Rank::FOUR,   Suit::SPADE),
              Card(Rank::THREE,  Suit::SPADE),
              Card(Rank::TWO,    Suit::SPADE));
   PokerGame game(hand1, hand2);
   std::cout << game;
}
开发者ID:demietank,项目名称:cpp605,代码行数:17,代码来源:PokerTest.cpp


示例20: clear

void Deck::reset () {
    clear ();
    for(int i=0;i<SUIT_COUNT;i++){
        for (int j=0;j<RANK_COUNT;j++){
            addCard (Card (Suit(i), Rank(j)));
        }
    }
}
开发者ID:tlulu,项目名称:Straights,代码行数:8,代码来源:Deck.cpp



注:本文中的Card函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CardServices函数代码示例发布时间:2022-05-30
下一篇:
C++ Capacity函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap