Example #1
0
void apothecary(){
    clear_screen();
    bool bought=true;

    cout << "You have " << player.money << " Vi, " << player.health << "/" << player.max_health << " health," << endl;
    cout << player.max_power << " power, and " << player.defence << " defence." << endl;
    cout << endl;
    cout << "[Lyla]: I have lots of high quality potions for sale. Would you like:" << endl;
    cout << "Small health potion: Heals 20 hp for 1 Vi? (1)" << endl;
    cout << "Medium health potion: Heals 80 hp for 3 Vi? (2)" << endl;
    cout << "Large health potion? Heals 150 hp for 5 Vi? (3)" << endl;
    cout << "Small upper health potion? Increases max health by 5 for 10 Vi? (4)" << endl;
    cout << "Medium upper health potion? Increases max health by 20 for 15 Vi? (5)" << endl;
    cout << "Large upper health potion? Increases max health by 50 for 30 Vi? (6)" << endl;
    cout << "Defence potion? Increases defence by 20% for 15 Vi? (7)" << endl;
    cout << "Or maybe a power potion? Increases your power by 20% for 15 Vi? (8)" << endl;

    cout << "\n=====================================================================\n" << endl;

    cout << "We also have a very large health potion, heal 300 hp for 9 Vi? (9)" << endl;
    cout << "And a huge health potion to heal 500 hp for 14 Vi? (10)" << endl;
    cout << "Or you could just get out of here> (11)" << endl;

    int choice=inputI("["+player.name+"]: ");

    if (choice==1&&player.money>=1){
        player.money-=1;
        player.health+=20;
    }else if (choice==2&&player.money>=3){
        player.money-=3;
        player.health+=80;
    }else if (choice==3&&player.money>=5){
        player.money-=5;
        player.health+=150;
    }else if (choice==4&&player.money>=10){
        player.money-=10;
        player.max_health+=5;
    }else if (choice==5&&player.money>=15){
        player.money-=15;
        player.max_health+=20;
    }else if (choice==6&&player.money>=30){
        player.money-=30;
        player.max_health+=50;
    }else if (choice==7&&player.money>=15){
        player.money-=15;
        player.defence*=1.2;
    } else if (choice==8&&player.money>=15){
        player.money-=15;
        player.max_power*=1.2;
        player.reset_power();
    }else if (choice==11){
        player.check();
        town();
    }else if (choice==9 && player.money>=9){
        player.money-=9;
        player.health+=300;
    }else if (choice==10 && player.money>=14){
        player.money-=14;
        player.health+=500;
    }else{
        cout << "[Lyla] You don't have that kind of cash!";
        bought=false;
    }

    if(bought){cout << "Thanks for your purchase!" << endl;}

    player.check();
    player.clean();
    enter();
    apothecary();
}
Example #2
0
void doctor() {
    clear_screen();
    int choice;
    float amount;
    //string s;
    float cost;

    cout << "[Doctor]: Hello, patient. What can I do for you?" << endl;
    cout << "[Doctor]: I am capable of fully healing you (1)" <<
        "\nLetting you decide how much to heal (2)" <<
        "\nOr showing you to the door (3)" << endl;

    choice=inputI(": ");

    if (choice==1 && player.health < player.max_health){
        clear_screen();

        cost=(player.max_health-player.health)/15;
        cost=floorf(cost*10+.5)/10;

        if(player.money >= cost){
            cout << "[Doctor]: That will be " << cost << " Vi. Are you sure?" << endl;

            if (lower(inputS(": "))=="yes"){
                player.reset_health();
                player.money-=cost;
            }else {
                doctor();
            }
        }

    } else if (choice==2){
        clear_screen();

        cout << "[Doctor]: Exactly how much would you like me to heal?" << endl;
        cout << "[Doctor]: You seems to have " << player.health << "/" << player.max_health << " health." << endl;
        amount=inputF(": ");

        if (amount > player.max_health-player.health){
            amount=player.max_health-player.health;
        }

        cost=amount/10;

        cost=floorf(cost*10+.5)/10;

        if (cost>player.money){
            cout << "[Doctor]: Your insurance won't cover that!!!" << endl;
            enter();
            doctor();
        }

        cout << "That will be " << cost << " Vi. Are you sure?" << endl;

        if(lower(inputS(": "))=="yes"){
            player.health+=amount;
            player.money-=cost;

            player.check();
            player.clean();
        } else {
            doctor();
        }
    } else if (choice==3){
        town();
    } else {
        doctor();
    }
}