Code:
Character Player;
cin >> CharacterClass;
for(;;) {
if (CharacterClass == "d" || CharacterClass == "D") {
CharacterClassvar = Dwarf;
Player.BaseExperiencePoints = 0;
Player.BaseHitPoints = 50;
Player.BaseStrength = 7;
Player.BaseManaPoints = 10;
Player.BaseAccuracy = 2;
cout << "Welcome dwarf to the world of Bazeor full of treachery and villany." << endl;
};
if (CharacterClass == "e" || CharacterClass == "E") {
CharacterClassvar = Elf;
Player.BaseExperiencePoints = 0;
Player.BaseHitPoints = 40;
Player.BaseStrength = 2;
Player.BaseManaPoints = 50;
Player.BaseAccuracy = 8;
cout << "Welcome elf to the world of Bazeor full of treachery and villany." << endl;
};
if (CharacterClass == "h" || CharacterClass == "H") {
CharacterClassvar = Human;
Player.BaseExperiencePoints = 0;
Player.BaseHitPoints = 45;
Player.BaseStrength = 4;
Player.BaseManaPoints = 30;
Player.BaseAccuracy = 5;
cout << "Welcome human to the world of Bazeor full of treachery and villany." << endl;
};
system("PAUSE");
if (CharacterClassvar == Human || Elf || Dwarf) {
break; }
};
Why aren't you using a switch/case here?
also to streamline this:
Code:
cout << "Welcome dwarf to the world of Bazeor full of treachery and villany." << endl;
Code:
cout << "Welcome elf to the world of Bazeor full of treachery and villany." << endl;
Code:
cout << "Welcome human to the world of Bazeor full of treachery and villany." << endl;
try this instead:
Code:
Character Player;
cin >> CharacterClass;
for(;;) {
if (CharacterClass == "d" || CharacterClass == "D") {
CharacterClassvar = Dwarf;
Player.BaseExperiencePoints = 0;
Player.BaseHitPoints = 50;
Player.BaseStrength = 7;
Player.BaseManaPoints = 10;
Player.BaseAccuracy = 2;
};
if (CharacterClass == "e" || CharacterClass == "E") {
CharacterClassvar = Elf;
Player.BaseExperiencePoints = 0;
Player.BaseHitPoints = 40;
Player.BaseStrength = 2;
Player.BaseManaPoints = 50;
Player.BaseAccuracy = 8;
};
if (CharacterClass == "h" || CharacterClass == "H") {
CharacterClassvar = Human;
Player.BaseExperiencePoints = 0;
Player.BaseHitPoints = 45;
Player.BaseStrength = 4;
Player.BaseManaPoints = 30;
Player.BaseAccuracy = 5;
};
cout << "Welcome "<<tolower(CharacterClassvar)<< " to the world of Bazeor full of treachery and villany." << endl;
system("PAUSE");
if (CharacterClassvar == Human || Elf || Dwarf) {
break; }
};
this way you only need to type it once
So how's the game going?