本文整理汇总了C++中Hand::isBlackjack方法的典型用法代码示例。如果您正苦于以下问题:C++ Hand::isBlackjack方法的具体用法?C++ Hand::isBlackjack怎么用?C++ Hand::isBlackjack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hand
的用法示例。
在下文中一共展示了Hand::isBlackjack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DealButtonProc
LRESULT CALLBACK DealButtonProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
if (msg == WM_LBUTTONDOWN) {
TCHAR buff[64];
GetWindowText(hTextboxBetAmount, buff, 20);
int bet = _ttoi(buff);
/*
for (int i = 0; buff[i] != NULL; i++) {
if (! std::isdigit(buff[i]) ) {
MessageBox(
GameEngine::getInstance()->getHWnd(),
L"Invalid bet amount.",
L"Error",
NULL);
return 0;
}
}
*/
// int bet = atoi(buff);
Table* table = GameEngine::getInstance()->getTable();
User* user = GameEngine::getInstance()->getUser();
// Can player bet this much?
if (bet > user->getBalance()) {
MessageBox(
GameEngine::getInstance()->getHWnd(),
L"Insufficient funds available to place this bet.",
L"Error",
NULL);
return 0;
}
if (bet == 0) {
MessageBox(
GameEngine::getInstance()->getHWnd(),
L"Must bet more than $0.",
L"Error",
NULL);
return 0;
}
Hand* dealerHand = new Hand();
Hand* playerHand = new Hand();
playerHand->setBetAmount(bet);
user->setBalance(user->getBalance() - bet);
dealerHand->dealCard(true);
dealerHand->dealCard(false);
playerHand->dealCard(false);
playerHand->dealCard(false);
table->setDealerHand(dealerHand);
table->setPlayerHand(playerHand);
GameEngine::getInstance()->setState(GameEngine::STATE_PLAYING);
PlaySound(L"sound-chips.wav", NULL, SND_FILENAME | SND_ASYNC);
//
// Check if we have blackjack, if so player
// wins right away. Otherwise move to substate
// "playing"
//
if (playerHand->isBlackjack()) {
table->setState(TABLE_STATE_FINISHED);
updateTextarea(hStaticTableMiddleMessage, "Blackjack! Player Wins.");
// Play YAY sound
PlaySound(L"sound-yay.wav", NULL, SND_FILENAME | SND_ASYNC);
// Update user balance.
user->setBalance(user->getBalance() + (bet*2));
} else {
table->setState(TABLE_STATE_PLAYING);
}
//
// Force redraw of window, which should now render the new
// card data.
//
// https://msdn.microsoft.com/en-us/library/dd162911%28VS.85%29.aspx
// http://stackoverflow.com/questions/2325894/difference-between-invalidaterect-and-redrawwindow
//
RedrawWindow(GameEngine::getInstance()->getHWnd(), NULL, NULL,
RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
//.........这里部分代码省略.........