|
|
|
|
|
|
|
|
// see if we finished all the player's hands |
|
|
// see if we finished all the player's hands |
|
|
if (++playerStats.currentHand != playerStats.hands.end()) { |
|
|
if (++playerStats.currentHand != playerStats.hands.end()) { |
|
|
unsigned int playerCard = drawCard(&(*playerStats.currentHand)); |
|
|
unsigned int playerCard = drawCard(&(*playerStats.currentHand)); |
|
|
|
|
|
player->playerValue = playerStats.currentHand->value(); |
|
|
info(Libreblackjack::Info::CardPlayer, playerCard, playerStats.currentHand->id); |
|
|
info(Libreblackjack::Info::CardPlayer, playerCard, playerStats.currentHand->id); |
|
|
|
|
|
|
|
|
if (std::abs(playerStats.currentHand->value()) == 21) { |
|
|
|
|
|
|
|
|
if (std::abs(player->playerValue) == 21) { |
|
|
player->actionRequired = Libreblackjack::PlayerActionRequired::None; |
|
|
player->actionRequired = Libreblackjack::PlayerActionRequired::None; |
|
|
nextAction = Libreblackjack::DealerAction::MoveOnToNextHand; |
|
|
nextAction = Libreblackjack::DealerAction::MoveOnToNextHand; |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
for (auto playerHand : playerStats.hands) { |
|
|
for (auto playerHand : playerStats.hands) { |
|
|
if (playerHand.busted() == false) { // busted hands have already been solved |
|
|
if (playerHand.busted() == false) { // busted hands have already been solved |
|
|
player->playerValue = std::abs(playerHand.value()); |
|
|
|
|
|
|
|
|
player->playerValue = playerHand.value(); |
|
|
|
|
|
|
|
|
if (std::abs(player->dealerValue) > std::abs(player->playerValue)) { |
|
|
if (std::abs(player->dealerValue) > std::abs(player->playerValue)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
playerStats.handsDoubled++; |
|
|
playerStats.handsDoubled++; |
|
|
|
|
|
|
|
|
playerCard = drawCard(&(*playerStats.currentHand)); |
|
|
playerCard = drawCard(&(*playerStats.currentHand)); |
|
|
unsigned int playerTotal = playerStats.currentHand->value(); |
|
|
|
|
|
|
|
|
player->playerValue = playerStats.currentHand->value(); |
|
|
info(Libreblackjack::Info::CardPlayer, playerCard, playerStats.currentHand->id); |
|
|
info(Libreblackjack::Info::CardPlayer, playerCard, playerStats.currentHand->id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (playerStats.currentHand->busted()) { |
|
|
if (playerStats.currentHand->busted()) { |
|
|
info(Libreblackjack::Info::PlayerLosses, 1e3*playerStats.currentHand->bet, playerTotal); |
|
|
|
|
|
|
|
|
info(Libreblackjack::Info::PlayerLosses, 1e3*playerStats.currentHand->bet, player->playerValue); |
|
|
playerStats.result -= playerStats.currentHand->bet; |
|
|
playerStats.result -= playerStats.currentHand->bet; |
|
|
playerStats.bustsPlayer++; |
|
|
playerStats.bustsPlayer++; |
|
|
playerStats.losses++; |
|
|
playerStats.losses++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// deal a card to the first hand |
|
|
// deal a card to the first hand |
|
|
playerCard = drawCard(&(*playerStats.currentHand)); |
|
|
playerCard = drawCard(&(*playerStats.currentHand)); |
|
|
|
|
|
player->playerValue = playerStats.currentHand->value(); |
|
|
info(Libreblackjack::Info::CardPlayer, playerCard, playerStats.currentHand->id); |
|
|
info(Libreblackjack::Info::CardPlayer, playerCard, playerStats.currentHand->id); |
|
|
|
|
|
|
|
|
// aces get dealt only one card |
|
|
// aces get dealt only one card |
|
|
|
|
|
|
|
|
if (++playerStats.currentHand != playerStats.hands.end()) { |
|
|
if (++playerStats.currentHand != playerStats.hands.end()) { |
|
|
info(Libreblackjack::Info::PlayerNextHand, (*playerStats.currentHand).id); |
|
|
info(Libreblackjack::Info::PlayerNextHand, (*playerStats.currentHand).id); |
|
|
playerCard = drawCard(&(*playerStats.currentHand)); |
|
|
playerCard = drawCard(&(*playerStats.currentHand)); |
|
|
|
|
|
player->playerValue = playerStats.currentHand->value(); |
|
|
info(Libreblackjack::Info::CardPlayer, playerCard, playerStats.currentHand->id); |
|
|
info(Libreblackjack::Info::CardPlayer, playerCard, playerStats.currentHand->id); |
|
|
|
|
|
|
|
|
// if the player got an ace or 21 again, we are done |
|
|
// if the player got an ace or 21 again, we are done |
|
|
|
|
|
|
|
|
nextAction = Libreblackjack::DealerAction::MoveOnToNextHand; |
|
|
nextAction = Libreblackjack::DealerAction::MoveOnToNextHand; |
|
|
return 1; |
|
|
return 1; |
|
|
} else { |
|
|
} else { |
|
|
// player->playerValue = playerTotal; |
|
|
|
|
|
// player->dealerValue = dealerTotal; |
|
|
|
|
|
player->actionRequired = Libreblackjack::PlayerActionRequired::Play; |
|
|
player->actionRequired = Libreblackjack::PlayerActionRequired::Play; |
|
|
nextAction = Libreblackjack::DealerAction::AskForPlay; |
|
|
nextAction = Libreblackjack::DealerAction::AskForPlay; |
|
|
return 1; |
|
|
return 1; |
|
|
|
|
|
|
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
// player->playerValue = playerTotal; |
|
|
|
|
|
// player->dealerValue = dealerTotal; |
|
|
|
|
|
|
|
|
|
|
|
player->actionRequired = Libreblackjack::PlayerActionRequired::Play; |
|
|
player->actionRequired = Libreblackjack::PlayerActionRequired::Play; |
|
|
nextAction = Libreblackjack::DealerAction::AskForPlay; |
|
|
nextAction = Libreblackjack::DealerAction::AskForPlay; |
|
|
return 1; |
|
|
return 1; |
|
|
|
|
|
|
|
|
///ip+hit+detail |
|
|
///ip+hit+detail |
|
|
///ip+hit+detail This command can be abbreviated as `h`. |
|
|
///ip+hit+detail This command can be abbreviated as `h`. |
|
|
playerCard = drawCard(&(*playerStats.currentHand)); |
|
|
playerCard = drawCard(&(*playerStats.currentHand)); |
|
|
|
|
|
player->playerValue = playerStats.currentHand->value(); |
|
|
info(Libreblackjack::Info::CardPlayer, playerCard, playerStats.currentHand->id); |
|
|
info(Libreblackjack::Info::CardPlayer, playerCard, playerStats.currentHand->id); |
|
|
|
|
|
|
|
|
if (playerStats.currentHand->busted()) { |
|
|
if (playerStats.currentHand->busted()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
|
|
|
|
|
|
// player->playerValue = playerTotal; |
|
|
|
|
|
// player->dealerValue = dealerTotal; |
|
|
|
|
|
player->actionRequired = Libreblackjack::PlayerActionRequired::Play; |
|
|
player->actionRequired = Libreblackjack::PlayerActionRequired::Play; |
|
|
nextAction = Libreblackjack::DealerAction::AskForPlay; |
|
|
nextAction = Libreblackjack::DealerAction::AskForPlay; |
|
|
return 1; |
|
|
return 1; |