Kaynağa Gözat

some fixes but still some errors

master
gtheler 5 yıl önce
ebeveyn
işleme
bea4571ee7
3 değiştirilmiş dosya ile 14 ekleme ve 15 silme
  1. +2
    -2
      blackjack.conf
  2. +3
    -3
      src/blackjack.cpp
  3. +9
    -10
      src/tty.cpp

+ 2
- 2
blackjack.conf Dosyayı Görüntüle

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



+ 3
- 3
src/blackjack.cpp Dosyayı Görüntüle

// let's start by assuming the player does not need to do anything // let's start by assuming the player does not need to do anything
player->actionRequired = Libreblackjack::PlayerActionRequired::None; player->actionRequired = Libreblackjack::PlayerActionRequired::None;


std::list<PlayerHand>::iterator playerHand;
// std::list<PlayerHand>::iterator playerHand;
switch(nextAction) { switch(nextAction) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
hand.cards.clear(); hand.cards.clear();


// erase all the player's hands, create one, add and make it the current one // 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(); playerHand->cards.clear();
} }
playerInfo.hands.clear(); playerInfo.hands.clear();
case Libreblackjack::DealerAction::MoveOnToNextHand: case Libreblackjack::DealerAction::MoveOnToNextHand:
// see if we finished all the player's hands // see if we finished all the player's hands
if (++player->currentHand != player->hands.end()) { 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); info(Libreblackjack::Info::CardPlayer, playerCard, player->currentHand->id);


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

+ 9
- 10
src/tty.cpp Dosyayı Görüntüle

// clear dealer's hand // clear dealer's hand
dealerHand.cards.clear(); 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.clear();
hands.push_back(std::move(PlayerHand())); hands.push_back(std::move(PlayerHand()));
currentHand = hands.begin(); currentHand = hands.begin();


{ {
bool found = false; 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) { if (hand->id == handToSplit) {
found = true; found = true;
hand->id = p1; hand->id = p1;
exit(0); exit(0);
} }
for (auto hand : hands) {
std::cout << hand.id << " " << hand.cards.size() << std::endl;
}
// create a new hand // create a new hand
PlayerHand newHand; PlayerHand newHand;
newHand.id = p2; newHand.id = p2;
newHand.cards.push_back(cardToSplit); newHand.cards.push_back(cardToSplit);
hands.push_back(std::move(newHand)); hands.push_back(std::move(newHand));
} }
s = "Creating new hand #" + std::to_string(p2) + " with card " + card[cardToSplit].utf8();
currentHandId = p1; currentHandId = p1;
render = true;
break; break;
case Libreblackjack::Info::PlayerNextHand: case Libreblackjack::Info::PlayerNextHand:

Yükleniyor…
İptal
Kaydet