Bladeren bron

some fixes but still some errors

master
gtheler 5 jaren geleden
bovenliggende
commit
bea4571ee7
3 gewijzigde bestanden met toevoegingen van 14 en 15 verwijderingen
  1. +2
    -2
      blackjack.conf
  2. +3
    -3
      src/blackjack.cpp
  3. +9
    -10
      src/tty.cpp

+ 2
- 2
blackjack.conf Bestand weergeven

@@ -1,5 +1,5 @@
; flat_bet = 1
arranged_cards = 3,8,16
rng_seed = 5
; arranged_cards = 3,8,16
; rng_seed = 5
; delay = 0


+ 3
- 3
src/blackjack.cpp Bestand weergeven

@@ -81,7 +81,7 @@ void Blackjack::deal(void) {
// let's start by assuming the player does not need to do anything
player->actionRequired = Libreblackjack::PlayerActionRequired::None;

std::list<PlayerHand>::iterator playerHand;
// std::list<PlayerHand>::iterator playerHand;
switch(nextAction) {
// -------------------------------------------------------------------------
@@ -111,7 +111,7 @@ void Blackjack::deal(void) {
hand.cards.clear();

// erase all the player's hands, create one, add and make it the current one
for (playerHand = playerInfo.hands.begin(); playerHand != playerInfo.hands.end(); ++playerHand) {
for (auto playerHand = playerInfo.hands.begin(); playerHand != playerInfo.hands.end(); ++playerHand) {
playerHand->cards.clear();
}
playerInfo.hands.clear();
@@ -281,7 +281,7 @@ void Blackjack::deal(void) {
case Libreblackjack::DealerAction::MoveOnToNextHand:
// see if we finished all the player's hands
if (++player->currentHand != player->hands.end()) {
unsigned int playerCard = drawCard(&(*player->currentHand));
unsigned int playerCard = drawCard(&(*playerInfo.currentHand));
info(Libreblackjack::Info::CardPlayer, playerCard, player->currentHand->id);

if (std::abs(player->currentHand->value()) == 21) {

+ 9
- 10
src/tty.cpp Bestand weergeven

@@ -114,10 +114,13 @@ void Tty::info(Libreblackjack::Info msg, int p1, int p2) {
// clear dealer's hand
dealerHand.cards.clear();

// erase all of our hands, create one, add and make it the current one
for (auto hand : hands) {
hand.cards.clear();
// erase all of our hands
{
for (auto hand = hands.begin(); hand != hands.end(); ++hand) {
hand->cards.clear();
}
}
// create one, add and make it the current one
hands.clear();
hands.push_back(std::move(PlayerHand()));
currentHand = hands.begin();
@@ -200,8 +203,7 @@ void Tty::info(Libreblackjack::Info msg, int p1, int p2) {

{
bool found = false;
std::list<PlayerHand>::iterator hand;
for (hand = hands.begin(); hand != hands.end(); ++hand) {
for (auto hand = hands.begin(); hand != hands.end(); ++hand) {
if (hand->id == handToSplit) {
found = true;
hand->id = p1;
@@ -214,18 +216,15 @@ void Tty::info(Libreblackjack::Info msg, int p1, int p2) {
exit(0);
}
for (auto hand : hands) {
std::cout << hand.id << " " << hand.cards.size() << std::endl;
}
// create a new hand
PlayerHand newHand;
newHand.id = p2;
newHand.cards.push_back(cardToSplit);
hands.push_back(std::move(newHand));
}
s = "Creating new hand #" + std::to_string(p2) + " with card " + card[cardToSplit].utf8();
currentHandId = p1;
render = true;
break;
case Libreblackjack::Info::PlayerNextHand:

Laden…
Annuleren
Opslaan