void Shop::buyPotion(Human& human) { costDisplay(potionCost, human.getGold()); display->ask("\n| Would you like to buy a potion? [y/n]: "); if (strncmp("y", display->getInputBuffer(), 1) == 0) { if(human.getGold() >= potionCost) { human.setPotionCount(human.getPotionCount() + 1); human.decreaseGoldBy(potionCost); } else { display->text("\n[!] You're bad at math, huh?\n"); } } }
void Shop::buy(Human& human, Armor armor) { display->showAttributes(armor); costDisplay(armor.getPrice(), human.getGold()); display->ask("\n| Would you like to buy this item? [y/n]: "); if (strncmp("y", display->getInputBuffer(), 1) == 0) { if (armor.getPrice() <= human.getGold()) { human.setArmor(armor); human.decreaseGoldBy(armor.getPrice()); } else { display->text("\n[!]You cannot afford this item\n"); } } }
void Shop::buy(Human& human, Weapon weapon) { display->showAttributes(weapon); costDisplay(weapon.getPrice(), human.getGold()); display->ask("\n| Would you like buy this item? [y/n]: "); if (strncmp("y", display->getInputBuffer(), 1) == 0) { if (weapon.getPrice() <= human.getGold()) { human.setWeapon(weapon); human.decreaseGoldBy(weapon.getPrice()); } else { display->text("You cannot afford this item\n"); } } }