I'm trying to reduce clutter on my main file by shifting things over to void functions in other classes whenever possible.
inputs inp;
inventory inv;
void drink(){
if(inp.input == "drink-fortify-potion" || inp.input == "fortify-potion" || inp.input == "drink-fortify"){
if(inv.fortifypotions > 0){
inv.fortifypotions--;
inv.agility++;
inv.strength++;
cout << "You quickly down the fortify potion. The taste is awful, but you feel more agile and stronger." << endl;
cout << "It's almost like it's a drug." << endl;
}else{
cout << "You don't have any." << endl;
}
}else if(inp.input == "drink-health-potion" || inp.input == "health-potion" || inp.input == "drink-health"){
if(inv.healthpotions > 0){
inv.healthpotions--;
inv.health = inv.health + 25;
if(inv.health > inv.health){
inv.health = inv.maxhealth;
}
cout << "You quickly down the health potion. It has an odd, medicinal taste." << endl;
}else{
cout << "You don't have any." << endl;
}
}else if(inp.input == "drink-mana-potion" || inp.input == "mana-potion" || inp.input == "drink-mana"){
if(inv.manapotions > 0){
inv.manapotions--;
inv.mana = inv.mana + 15;
if(inv.mana > inv.maxmana){
inv.mana = inv.maxmana;
}
cout << "You quickly down the mana potion. It has an odd, fruity taste." << endl;
}else{
cout << "You don't have any." << endl;
}
}
}
This is the void I'm trying to call with drink();
, but when used in the main class, it gives me the error of "Was not declared in this scope". I'm sure I've hooked it up right, as it's the same method as is used by other voids I have, and they all work fine. The only difference in this one is that it incorporates a CMD input and if statements.
Aucun commentaire:
Enregistrer un commentaire