BlackJack::BlackJack(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::BlackJack)
{
    ui->setupUi(this);
    deck = new CardDeck();

    // initialize card hands as null pointers
    playerHand = nullptr;
    dealerHand = nullptr;

    // connect QActions with Toolbar buttons
    ui->tb_newGame->setDefaultAction(ui->actionNewGame);
    ui->tb_dealHand->setDefaultAction(ui->actionDeal_Hand);
    ui->tb_shuffleDeck->setDefaultAction(ui->actionShuffle_Deck);
    ui->tb_hit_me->setDefaultAction(ui->actionHit_Me);
    ui->tb_stay->setDefaultAction(ui->actionStay);

    // connect QActions with proper slots
    connect(ui->actionNewGame, SIGNAL(triggered()), this, SLOT(newGame()));
    connect(ui->actionDeal_Hand, SIGNAL(triggered()), this, SLOT(dealHand()));
    connect(ui->actionShuffle_Deck, SIGNAL(triggered()), this, SLOT(shuffleDeck()));
    // new signal slot syntax:
    connect(ui->actionHit_Me, &QAction::triggered, this, &BlackJack::hitMe);
    connect(ui->actionStay, &QAction::triggered, this, &BlackJack::stay);

    // start!
    dealHand();
}
Esempio n. 2
0
void Scopa::startMatch(bool jumpControl) {
    if(!jumpControl && !matchHasEnded()) { throw exception(exception::MATCH_HAS_NOT_ENDED); }
    pointsMatch[PLAYER_ZERO] = 0;
    pointsMatch[PLAYER_ONE]  = 0;

    moveAll(table,deck);
    moveAll(hand[PLAYER_ZERO],deck);
    moveAll(hand[PLAYER_ONE],deck);
    moveAll(capturedPile[PLAYER_ZERO],deck);
    moveAll(capturedPile[PLAYER_ONE],deck);

    dealTable();
    dealHand(PLAYER_ZERO);
    dealHand(PLAYER_ONE);
}
Esempio n. 3
0
void playGame(){
    //take each players bet
    betTaker();
    //deal all players their  intial hand
    dealHand();
    //display each players hand
    displayHand();
    //loop through each player
    int i;
    for (i = 0; i < numPlayers; i++){
        printf("Player %d:\n", i+1);
        int hit = hitDecide(i);
        while (hit == 1) {
            dealCard(i, 0);
            displayHand();
            hit = hitDecide(i);
        }
    }
    //hit for the computer
    computerHit();
    
    for (i = 0; i < numPlayers; i++){
        int winner = evaluate(i);
        int money = distributeWinnings(winner, i);
        keepTrackOfWinnings(money, i);
    }
}
void BlackJack::newGame()
{
    qDebug() << "new game";

    ui->sb_dealerScore->setValue(0);
    ui->sb_playerScore->setValue(0);

    shuffleDeck();
    dealHand();
}
Esempio n. 5
0
void Scopa::startRound() {
    if(!hand[PLAYER_ZERO].empty() || !hand[PLAYER_ONE].empty()) { throw exception(exception::HANDS_ARE_NOT_EMPTY); }
    
    dealHand(PLAYER_ZERO);
    dealHand(PLAYER_ONE);
}