Example #1
0
void NPC::Buy(Hero & h) {
    int size = itemForSale.size(), index =0, number = 0;
    ShowItemsByIndex(itemForSale);
    cout << "Enter the index of the items you want to purcahse\n";
    cin >> index;
    if (index >= size) {
        cout << "Wrong Index! I don't want to do businees with fools /Smile\n";
        return;
    }
    cout << "Etner the number of " << itemForSale[index].GetName() << " you want to purchase";
    cin >> number;
    h.PurchaseItem(itemForSale[index],number);
    cout << "Thanks for coming\n";
}
Example #2
0
void NPC::TradeSpecialItem(Hero & h) {
    int size = specialItem.size();
    srand(time(NULL));
    int index = rand() % size;
    cout << "You are lucky today and I have something special to you\n";
    cout << specialItem[index].GetName() << "  $" << specialItem[index].GetBuyPrice() << endl;
    cout << "  " << specialItem[index].GetDescription() << endl;

    cout << "\nDo you want to buy it? Enter Y to confirm and everything else otherwise\n";
    string input;
    cin >> input;
    if (input == "Y" || input == "y") {
        h.PurchaseItem(specialItem[index]);
    }

}