// ---------------------------------------------------------------------------
// CIAUpdateFwPurchaseOperation::PurchaseL
// 
// ---------------------------------------------------------------------------
//
MNcdOperation* CIAUpdateFwPurchaseOperation::PurchaseL()
    {
    IAUPDATE_TRACE("[IAUPDATE] CIAUpdateFwPurchaseOperation::PurchaseL() begin");

    MNcdOperation* operation( NULL );
    
    MNcdNodePurchase* purchase( 
        Node().Node().QueryInterfaceLC< MNcdNodePurchase >() );
    
    if ( purchase )
        {
        // Purchase interface exists. So, we can do purchasing.
        if ( !purchase->IsPurchased() )
            {
            IAUPDATE_TRACE("[IAUPDATE] Item was not purchased yet");

            // Only do purchase operation if we have not already done purchasing
            // and the purchase option is usable and not obsolete.
            RCatalogsArray< MNcdPurchaseOption > options( 
                purchase->PurchaseOptionsL() );
            CleanupResetAndDestroyPushL( options );
            
            // Notice, IsUsableL() will leave with KNcdErrorObsolete if the option
            // is obsolete. Let it leave then, because we could not purchase then
            // anyways.
            if( options.Count() == 1 
                && options[ 0 ]->IsFree() 
                && options[ 0 ]->IsUsableL() )
                {
                IAUPDATE_TRACE("[IAUPDATE] Purchase option was correct.");

                operation = purchase->PurchaseL( *options[ 0 ], *this );
                
                if( !operation )
                    {
                    // Could not create the operation for some reason.
                    IAUPDATE_TRACE("[IAUPDATE] ERROR Could not create the operation.");
                    User::Leave( KErrGeneral );
                    }
                }
            else
                {
                // Wrong kind of purchase information gotten from the server.
                IAUPDATE_TRACE("[IAUPDATE] ERROR Wrong purchase info from server.");
                User::Leave( KErrGeneral );
                }
            CleanupStack::PopAndDestroy( &options );
            }
        CleanupStack::PopAndDestroy( purchase );
        }
    else
        {
        IAUPDATE_TRACE("[IAUPDATE] Purchase interface was not found.");
        User::Leave( KErrNotFound );
        }

    IAUPDATE_TRACE("[IAUPDATE] CIAUpdateFwPurchaseOperation::PurchaseL() end");

    return operation;
    }
Exemple #2
0
void MainWindow::if_normal_card(int player_id,int card_id)
{
    std::cout<<"\ninside normal card...\n";
    if(array_of_cards[card_id].owner==0)
    {
        buy_button->setEnabled(true);
        pid=player_id;
        cid=card_id;
        connect(buy_button,SIGNAL(clicked()),this,SLOT(purchase()));
        std::cout<<"\nbuy_button connected...\n";
    }
    else
    {
        if((player_id+1)==array_of_cards[card_id].owner)
        {
            sell_button->setEnabled(true);
            build_button->setEnabled(true);
            pid=player_id;
            cid=card_id;
            connect(sell_button,SIGNAL(clicked()),this,SLOT(sell()));
            connect(build_button,SIGNAL(clicked()),this,SLOT(renovate()));
        }
        else
        {
            sell_button->setEnabled(false);
            build_button->setEnabled(false);
            buy_button->setEnabled(false);
            pay_rent(player_id,card_id);
        }
    }
}
Exemple #3
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));
    }
}
Exemple #4
0
BottomBar::BottomBar() {

    currentPlayerNum = 0;
    bank = new Bank;
    freePark = new Player(0);
    communityCount = 0;
    chanceCount = 0;

    //creating shuffled index
    for( int i = 0; i < 10; i++){
        index[i] = i;
    }
    int random1 = -1;
    int random2 = -1;
    int tempNum = -1;
    
    for(int i = 0; i < 50; i++){
	random1 = rand()%10;
	random2 = rand()%10;

	tempNum = index[random1];
	index[random1] = index[random2];
	index[random2] = tempNum;	
    }

    //setting up the Community Chest cards
    community = new Card*[10];

    community[index[0]] = new CardMove();
    community[index[1]] = new CardMoney();
    community[index[2]] = new CardMoney();
    community[index[3]] = new CardMove();
    community[index[4]] = new CardMoney();
    community[index[5]] = new CardMoney();
    community[index[6]] = new CardMove();
    community[index[7]] = new CardMoney();
    community[index[8]] = new CardMoney();
    community[index[9]] = new CardMoney();

    //Community Card 0
    community[index[0]]->setCardText("./community/community0.png");
    community[index[0]]->setAmount(0);

    //Community Card 1
    community[index[1]]->setCardText("./community/community1.png");
    community[index[1]]->setAmount(75);

    //Community Card 2
    community[index[2]]->setCardText("./community/community2.png");
    community[index[2]]->setAmount(150);

    //Community Card 3
    community[index[3]]->setCardText("./community/community3.png");
    community[index[3]]->setAmount(24);

    //Community Card 4
    community[index[4]]->setCardText("./community/community4.png");
    community[index[4]]->setAmount(100);

    //Community Card 5
    community[index[5]]->setCardText("./community/community5.png");
    community[index[5]]->setAmount(20);

    //Community Card 6
    community[index[6]]->setCardText("./community/community6.png");
    community[index[6]]->setAmount(39);

    //Community Card 7
    community[index[7]]->setCardText("./community/community7.png");
    community[index[7]]->setAmount(15);

    //Community Card 8
    community[index[8]]->setCardText("./community/community8.png");
    community[index[8]]->setAmount(200);
    
    //Community Card 9
    community[index[9]]->setCardText("./community/community9.png");
    community[index[9]]->setAmount(20);   


    //setting up the Chance cards
    chance = new Card*[10];

    chance[index[0]] = new CardMove();
    chance[index[1]] = new CardMove();
    chance[index[2]] = new CardMoney();
    chance[index[3]] = new CardMove();
    chance[index[4]] = new CardMoney();
    chance[index[5]] = new CardMoney();
    chance[index[6]] = new CardMove();
    chance[index[7]] = new CardMoney();
    chance[index[8]] = new CardMove();
    chance[index[9]] = new CardMoney();

    //Chance Card 0
    chance[index[0]]->setCardText("./chance/chance0.png");
    chance[index[0]]->setAmount(0);

    //Chance Card 1
    chance[index[1]]->setCardText("./chance/chance1.png");
    chance[index[1]]->setAmount(28);

    //Chance Card 2
    chance[index[2]]->setCardText("./chance/chance2.png");
    chance[index[2]]->setAmount(50);

    //Chance Card 3
    chance[index[3]]->setCardText("./chance/chance3.png");
    chance[index[3]]->setAmount(11);

    //Chance Card 4
    chance[index[4]]->setCardText("./chance/chance4.png");
    chance[index[4]]->setAmount(100);

    //Chance Card 5
    chance[index[5]]->setCardText("./chance/chance5.png");
    chance[index[5]]->setAmount(15);

    //Chance Card 6
    chance[index[6]]->setCardText("./chance/chance6.png");
    chance[index[6]]->setAmount(15);

    //Chance Card 7
    chance[index[7]]->setCardText("./chance/chance7.png");
    chance[index[7]]->setAmount(15);

    //Chance Card 8
    chance[index[8]]->setCardText("./chance/chance8.png");
    chance[index[8]]->setAmount(5);
    
    //Chance Card 9
    chance[index[9]]->setCardText("./chance/chance9.png");
    chance[index[9]]->setAmount(100);

 

    //setting up all the buttons 
    rollButton = new QPushButton("Roll Dice");
    upgradeButton = new QPushButton("Upgrade");
    purchaseButton = new QPushButton("Purchase");
    player1Button = new QPushButton("See Player 1");
    player2Button = new QPushButton("See Player 2");
    player3Button = new QPushButton("See Player 3");
    player4Button = new QPushButton("See Player 4");
    endTurnButton = new QPushButton("End Turn");

    layout = new QGridLayout;
    layout->addWidget(endTurnButton, 0, 0, 0);
    layout->addWidget(upgradeButton, 0, 1, 0);
    layout->addWidget(purchaseButton, 0, 2, 0);
    layout->addWidget(rollButton, 0, 3, 0);  
    layout->addWidget(player1Button, 1, 0, 0);
    layout->addWidget(player2Button, 1, 1, 0);
    layout->addWidget(player3Button, 1, 2, 0);
    layout->addWidget(player4Button, 1, 3, 0);
    

    this->setMaximumSize(QSize(800, 100));

    bottomWidget = new QWidget(this);
    bottomWidget->setLayout(layout);
    setWidget(bottomWidget);

    //connecting buttons
    connect(player1Button, SIGNAL(clicked()), this, SLOT(seePlayer1()) );
    connect(player2Button, SIGNAL(clicked()), this, SLOT(seePlayer2()) );
    connect(player3Button, SIGNAL(clicked()), this, SLOT(seePlayer3()) );
    connect(player4Button, SIGNAL(clicked()), this, SLOT(seePlayer4()) );
    connect(rollButton, SIGNAL(clicked()), this, SLOT(rollDice()) );
    connect(endTurnButton, SIGNAL(clicked()), this, SLOT(endTurn()) );
    connect(purchaseButton, SIGNAL(clicked()), this, SLOT(purchase()) );
    connect(upgradeButton, SIGNAL(clicked()), this, SLOT(upgrade()) );

    //disabling the endTurnButton
    endTurnButton->setEnabled(false);
    purchaseButton->setEnabled(false);
    upgradeButton->setEnabled(false);
}