So the player needs to say whether they will attack "head" or "body" how would I do this?
Like you can type head or body now, but i want it so you HAVE to choose those options or else it will give you back a retry statement.
choice 1 is where one player attacks and choice 2 is where one player defends. both are strings
cout << player1 << ", where do you strike?" << endl << endl;
cin >> choice1;
while (choice1 != "head" && choice1 != "body") {
cout << "Wrong input, try again: ";
cin >> choice1;
};
Or you can make a string with possible answers as a substrings and then you can check if user's answer is inside that string (if it is, then user's input is correct).
1 2 3 4 5 6 7
string possibleAns = "head body legs arms";
cout << player1 << ", where do you strike?" << endl << endl;
cin >> choice1;
while (possibleAns.find(choice1) == string::npos) {
cout << "Wrong input, try again: ";
cin >> choice1;
};