本文整理汇总了C++中CCard::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CCard::getValue方法的具体用法?C++ CCard::getValue怎么用?C++ CCard::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCard
的用法示例。
在下文中一共展示了CCard::getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dealCards
void CTable::dealCards(CPlayer *player, int numcards)
{
CCard *tmpCard;
CpduDealCardsFlex pdu;
char message[100] = { '\0' };
char vChar[3] = { '\0' };
char sChar;
if (numcards)
sprintf(message, "%s was dealt ", player->getUsername());
pdu.setDeal(0xffff, Hole);
for (; numcards > 0; numcards--)
{
tmpCard = deck_.popCard();
player->getHand()->addCard(tmpCard);
memset(vChar, 0x0, sizeof(vChar));
switch (tmpCard->getValue())
{
case (10): strcpy(vChar, "10"); break;
case (11): vChar[0] = 'J'; break;
case (12): vChar[0] = 'Q'; break;
case (13): vChar[0] = 'K'; break;
case (14): vChar[0] = 'A'; break;
default: itoa(tmpCard->getValue(), vChar, 10); break;
}
switch (tmpCard->getSuit())
{
case (1): sChar = 'C'; break; // Clubs
case (2): sChar = 'D'; break; // Diamonds
case (3): sChar = 'H'; break; // Hearts
case (4): sChar = 'S'; break; // Spades
}
sprintf(message, "%s [%s%c]", message, vChar, sChar);
pdu.addCard(tmpCard->getValue(), tmpCard->getSuit());
delete tmpCard;
}
pdu.sendDealCards(player);
setLog(message);
}
示例2: sendShowdown
int CpduShowdown::sendShowdown(CPlayer* player,
int numCards,
const char* message)
{
// Sending dummy cards for now!
CCard *pCard = player->getHand()->getCard();
int msglen = (message != NULL ? strlen(message) : 0);
length_ += numCards * sizeof(pdu_card) + msglen;
stuffHeader();
if (length_ < MAXBUFFERSIZE)
{
char* buf = value_ + PDU_HEADER_SIZE;
pdu_showdown data;
data.slot = htons(player->getSlot());
data.numCards = htons(numCards);
data.msglen = htons(msglen);
memcpy(buf, &data, sizeof(data));
buf += sizeof(data);
// copy cards to buffer
for (int i = 0; i < numCards; i++)
{
pdu_card card;
card.suit = htons(pCard->getSuit());
card.value = htons(pCard->getValue());
memcpy(buf, &card, sizeof(card));
buf += sizeof(card);
pCard = pCard->getNext();
}
// copy showdown message to buffer
if (msglen > 0)
memcpy(buf, message, msglen);
return broadcastTo(table_->getRing());
}
else
{
Sys_LogError("CpduShowdown: buffer size too small.\n");
return 0;
}
}
示例3: while
// In 7-stud, the odd chip goes to player with
// highest card of suit in this order:
// Spades, Hearts, Diamonds, Clubs.
CPlayer* Cplm_7Stud::getOddChipWinner(Winners& winners)
{
CPlayer* player = NULL;
u_int16_t highestCard = 0;
for (Winners::iterator it = winners.begin(),
end = winners.end();
it != end;
++it)
{
CWinner& winnerEntry = const_cast<CWinner&>(*it);
CPlayer* winner = winnerEntry.player_;
if (winner && winner->hasHand())
{
Chand* hand = winner->getHand();
if (hand)
{
CCard* card = hand->getCard();
while (card != NULL)
{
u_int16_t thisCard = card->getSuit() * 13 + card->getValue();
if (thisCard > highestCard)
{
highestCard = thisCard;
player = winner;
}
card = card->getNext();
}
}
}
}
if (!player)
player = getPlayerClosestToLeftOfDealer(winners);
return player;
}