1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
#include<iostream>
#include<string>
using namespace std;
struct character {
int age;
string gender;
string name;
string race;
string clss;
};
void invalidEntry(void) {
cout << "Invalid entry, try again.\n";
}
int main() {
//initialize variables
string getRace;
character player;
player.race="none";
player.gender="none";
string charName = "null";
string charCorrect;
string charGender="none";
string change="none";
cout << "Welcome to Akalon." << endl;
cout << "What is your gender? Male, or Female.\n";
for(;player.race=="none"&&charGender=="none";) {
cin >> charGender;
if (charGender=="Male"||charGender=="male"||charGender=="m"||charGender=="M"||charGender=="MALE") {
player.gender="Male";
cout << player.gender << " selected." << endl;
}
else if (charGender=="Female"||charGender=="female"||charGender=="f"||charGender=="F"||charGender=="FEMALE") {
player.gender="Female";
cout << player.gender << endl;
}
else {
invalidEntry();
cout << "Male, or Female?\n";
player.gender="none";
charGender="none";
}
}
cout << "What is your name, ";
if (player.gender=="Male") {cout << "boy?" << endl;}
if (player.gender=="Female") {cout << "girl?" << endl;}
cin >> player.name;
cout << "Hello, " << player.name;
cout << ". Which race are you then? " << endl;
cout << "Human\nOrc\n";
//fore loop that checks if the player has entered a correct value, if not, it loops.
for(;player.race=="none";){
//start of race for loop
//Race selection
cin >> getRace;
if (getRace=="human" || getRace=="Human" || getRace=="h" ||getRace=="H") {
player.race="Human";
cout << "A noble choice, Human.\n";
}
else if (getRace=="orc" || getRace=="Orc" ||getRace== "o" || getRace=="O") {
player.race="Orc";
cout<< "For honor, Orc.\n";
}
else {
invalidEntry();
cout << "Human, or Orc.\n";
}
} //end of race for loop
//check if the player is sure about the entered values
cout << "You have chosen the name " << player.name << " the gender " << player.gender << " and the race " << player.race << "." << endl;
cout << "Is this correct? y/n\n";
//another for loop to ensure correct entry
for(;charCorrect!="y"&& charCorrect!="n"&&charCorrect!="yes"&&charCorrect!="no";) {
cin >> charCorrect;
if (charCorrect=="n" || charCorrect=="no" || charCorrect=="NO" ||charCorrect=="N" && change!="changed") {
cout << "What would you like to change?\nName/Race/Gender/Everything\n";
for(;change!="name";) {
cin >> change;
if (change=="name")
{ //start of name
for(;player.name!="null"&&change!="changed";) {
player.name="null";
cout << "What would you like to change your name to?" << endl;
cin >> player.name;
cout << "Very well, " << player.name << ".";
change="changed";
charCorrect="yes";
}
} // end of name
else if (change=="race") { // start of race
player.race="none";
getRace="none";
cout << "What would you like your race to be, \nHuman, or Orc?" << endl;
for(;player.race=="none";){
//start of race for loop
//Race selection
cin >> getRace;
if (getRace=="human" || getRace=="Human" || getRace=="h" ||getRace=="H") {
player.race="Human";
cout << "Okay, Human.\n";
charCorrect="yes";
break;
}
else if (getRace=="orc" || getRace=="Orc" ||getRace== "o" || getRace=="O") {
player.race="Orc";
cout<< "It is done, Orc.\n";
charCorrect="yes";
break;
}
else {
invalidEntry();
cout << "Human, or Orc.\n";
}
//end of player.race=none for loop
}
} // end of race
else if (change=="gender") {//start of gender
player.gender="none";
charGender="none";
cout << "So what gender are you?" << endl;
for(;player.gender=="none"&&charGender=="none";) {
cin >> charGender;
if (charGender=="Male"||charGender=="male"||charGender=="m"||charGender=="M"||charGender=="MALE") {
player.gender="Male";
cout << player.gender << " selected." << endl;
charCorrect="yes";
change="changed";
break;
}
else if (charGender=="Female"||charGender=="female"||charGender=="f"||charGender=="F"||charGender=="FEMALE") {
player.gender="Female";
cout << player.gender << " selected." << endl;
charCorrect="yes";
change="changed";
break;
}
else {
invalidEntry();
cout << "Male, or Female?";
player.gender="none";
charGender="none";
break;
}
} //end of gender for loop
} //end of gender
else if (change=="all"||change=="everything") {
player.name="null";
player.race="none";
player.gender="none";
charGender="none";
cout << "So gender would you like to be, Male or Female?";
for(;player.race=="none"&&charGender=="none";) {
cin >> charGender;
if (charGender=="Male"||charGender=="male"||charGender=="m"||charGender=="M"||charGender=="MALE") {
player.gender="Male";
cout << player.gender << " selected." << endl;
}
else if (charGender=="Female"||charGender=="female"||charGender=="f"||charGender=="F"||charGender=="FEMALE") {
player.gender="Female";
cout << player.gender << " selected." << endl;
}
else {
invalidEntry();
cout << "Male, or Female?";
player.gender="none";
charGender="none";
}
}//end of all gender for loop
{//start of all name
cout << "What would you like to change your name to?" << endl;
cin >> player.name;
cout << "Very well, " << player.name << ".";
//end of all name
}
//start of all race
cout << "What race would you like to be?";
for(;player.race=="none";){
//start of all race for loop
//Race selection
cin >> getRace;
if (getRace=="human" || getRace=="Human" || getRace=="h" ||getRace=="H") {
player.race="Human";
cout << "A noble choice, Human.\n";
charCorrect="yes";
change="changed";
break;
}
else if (getRace=="orc" || getRace=="Orc" ||getRace== "o" || getRace=="O") {
player.race="Orc";
cout<< "For honor, Orc.\n";
charCorrect="yes";
change="changed";
break;
}
else {
invalidEntry();
cout << "Human, or Orc.\n";
}
}//end of race for loop
} //end of everything/all
/* else if (change!="race"&&change!="Race"&&change!="gender"&&change!="Gender"&&change!="all"&&change!="All"&&change!="everything"&&change!="Everything"&&change!="changed") {
change="none";
invalidEntry();
cout << "WHY ARE YOU HERE";
cout << change;
}*/
//end of y/n for loop
}
cout << "Your name is now " << player.name << ". Your Race is " << player.race << " and you are a " << player.gender << "." << endl;
break;
} //charcorrect=n close brace
else if (charCorrect=="y" || charCorrect=="yes" || charCorrect=="Y" || charCorrect=="Yes"|| charCorrect=="YES") {
cout << "Very Well." << endl;
break;
}//charcorrect=y close brace
else {
invalidEntry();
cout << "Please choose Yes or No";
} // correct = yes close brace
}// correct = yes/no question close brace
cout << "Continuation message, you are in a forest, or something similar.";
return 0;
} // end main brace
|