Ejemplo n.º 1
0
void MainWindow::setdie()
{
    srand(time(NULL));
    disconnect(sell_button,SIGNAL(clicked()),this,SLOT(sell()));
    disconnect(buy_button,SIGNAL(clicked()),this,SLOT(purchase()));
    int y=(rand()%6+1);
    dice_display[0]->setText(QString::number(y));
    int z=(rand()%6+1);
    dice_display[1]->setText(QString::number(z));
    int x=y+z;
//    x=4;//-------------------------------------------------------------------------------------------------------------------
    int i=1;
    std::cout<<"chance is:-"<<chance<<"\n";
    chance=chance%number_of_players;
    show_frames();
    update_current_player();
    if(chance==0)
    {
        prev=index1;
        while(i<=x)
        {
           index1=(index1+1)%32;
           player[0]->b->setParent(window);
           player[0]->b->setGeometry(button[index1]->x(),button[index1]->y(),player_width,player_height);
           player[0]->b->show();
           i++;
           dice->setEnabled(false);
           delay();
           dice->setEnabled(true);
        }
        set_current_card();
        if(x!=12)
        {
            chance=1;
        }
        next=index1;
        if(abs(prev-next)>19)
        {
            player[0]->rounds++;
            player[0]->balance+=1500;
        }
        std::cout<<"Index1 is:-"<<index1<<"\n";
        update_info(0,index1,x);
        score_board_update();
        after_roll();
        //player1_score->setText(QString::number(player[0]->balance));
        //setting the value of score--------------
    }
    else if(chance==1)
    {
        prev=index2;
        while(i<=x)
        {
            index2=(index2+1)%32;
            player[1]->b->setParent(window);
            player[1]->b->setGeometry(button[index2]->x(),button[index2]->y(),player_width,player_height);
            player[1]->b->show();
            i++;
            dice->setEnabled(false);
        delay();
            dice->setEnabled(true);
        }
        set_current_card();
        if(x!=12)
            {
               chance=2;
            }
            next=index2;
            if(abs(prev-next)>19)
            {
                player[1]->rounds++;
                player[1]->balance+=1500;
            }
            update_info(1,index2,x);
            score_board_update();
            after_roll();
            //player2_score->setText(QString::number(player[1]->balance));
            //setting the value
            std::cout<<"Index2 is:-"<<index2<<"\n";
    }
    else if(chance==2)
    {
        prev=index3;
        while(i<=x)
        {
            index3=(index3+1)%32;
            player[2]->b->setParent(window);
            player[2]->b->setGeometry(button[index3]->x(),button[index3]->y(),player_width,player_height);
            player[2]->b->show();
            i++;
            dice->setEnabled(false);
            delay();
            dice->setEnabled(true);
        }
            set_current_card();
            if(x!=12)
            {
               chance=3;
            }
        std::cout<<"Index3 is:-"<<index3<<"\n";
        next=index3;
        if(abs(prev-next)>19)
        {
            player[2]->rounds++;
            player[2]->balance+=1500;
        }
        update_info(2,index3,x);
        score_board_update();
        after_roll();
        //player3_score->setText(QString::number(player[2]->balance));
    }
    else if(chance==3)
    {
         prev=index4;
        while(i<=x)
        {
            index4=(index4+1)%32;
            player[3]->b->setParent(window);
            player[3]->b->setGeometry(button[index4]->x(),button[index4]->y(),player_width,player_height);
            player[3]->b->show();
            i++;
            dice->setEnabled(false);
            delay();
            dice->setEnabled(true);
        }
        set_current_card();
            if(x!=12)
            {
               chance=0;
            }
        std::cout<<"Index4 is:-"<<index4<<"\n";
        next=index4;
        if(abs(prev-next)>19)
        {
            player[3]->rounds++;
            player[3]->balance+=1500;
        }
        update_info(3,index4,x);
        score_board_update();
        after_roll();
        //player4_score->setText(QString::number(player[3]->balance));
    }
}
Ejemplo n.º 2
0
void store_curr_player(struct game *myGame, struct move *currMove){
    
    currMove->player = myGame->players[myGame->current_player];
    update_current_player(myGame);

}