Moved my stuff away so that the initial code given to students is next to each other.
This commit is contained in:
parent
6ca6516877
commit
f4c9d71aa8
81
main.cpp
81
main.cpp
@ -52,45 +52,6 @@ int main()
|
|||||||
EndGame(player);
|
EndGame(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player PromptForPlayer()
|
|
||||||
{
|
|
||||||
std::string name = "";
|
|
||||||
std::cout << "Enter your player name:" << std::endl;
|
|
||||||
std::getline(std::cin, name);
|
|
||||||
|
|
||||||
std::string charClass_str = "";
|
|
||||||
do
|
|
||||||
{
|
|
||||||
std::cout << std::endl << "Enter your character class, (F)ighter, (W)izard, or (R)ogue:" << std::endl;
|
|
||||||
std::getline(std::cin, charClass_str);
|
|
||||||
} while(charClass_str != "F" &&
|
|
||||||
charClass_str != "W" &&
|
|
||||||
charClass_str != "R");
|
|
||||||
|
|
||||||
CharClass charClass;
|
|
||||||
if(charClass_str == "F")
|
|
||||||
charClass = CharClass::FIGHTER;
|
|
||||||
else if(charClass_str == "W")
|
|
||||||
charClass = CharClass::WIZARD;
|
|
||||||
else if(charClass_str == "R")
|
|
||||||
charClass = CharClass::ROGUE;
|
|
||||||
|
|
||||||
return Player(name, charClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
char PromptTravel()
|
|
||||||
{
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
char travel = 'K';
|
|
||||||
std::cout << "Travel: (C)ave, (D)esert, (F)oothills, or return to the (K)ing:" << std::endl;
|
|
||||||
std::cin >> travel;
|
|
||||||
|
|
||||||
if(travel == 'K' || travel == 'C' || travel == 'D' || travel == 'F')
|
|
||||||
return travel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Player Intro()
|
Player Intro()
|
||||||
{
|
{
|
||||||
// intro text & setup
|
// intro text & setup
|
||||||
@ -158,3 +119,45 @@ void EndGame(Player &player)
|
|||||||
// show total enemies killed & total gold found
|
// show total enemies killed & total gold found
|
||||||
// THE END
|
// THE END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// MY IMPLEMENTATION
|
||||||
|
Player PromptForPlayer()
|
||||||
|
{
|
||||||
|
std::string name = "";
|
||||||
|
std::cout << "Enter your player name:" << std::endl;
|
||||||
|
std::getline(std::cin, name);
|
||||||
|
|
||||||
|
std::string charClass_str = "";
|
||||||
|
do
|
||||||
|
{
|
||||||
|
std::cout << std::endl << "Enter your character class, (F)ighter, (W)izard, or (R)ogue:" << std::endl;
|
||||||
|
std::getline(std::cin, charClass_str);
|
||||||
|
} while(charClass_str != "F" &&
|
||||||
|
charClass_str != "W" &&
|
||||||
|
charClass_str != "R");
|
||||||
|
|
||||||
|
CharClass charClass;
|
||||||
|
if(charClass_str == "F")
|
||||||
|
charClass = CharClass::FIGHTER;
|
||||||
|
else if(charClass_str == "W")
|
||||||
|
charClass = CharClass::WIZARD;
|
||||||
|
else if(charClass_str == "R")
|
||||||
|
charClass = CharClass::ROGUE;
|
||||||
|
|
||||||
|
return Player(name, charClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
char PromptTravel()
|
||||||
|
{
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
char travel = 'K';
|
||||||
|
std::cout << "Travel: (C)ave, (D)esert, (F)oothills, or return to the (K)ing:" << std::endl;
|
||||||
|
std::cin >> travel;
|
||||||
|
|
||||||
|
if(travel == 'K' || travel == 'C' || travel == 'D' || travel == 'F')
|
||||||
|
return travel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user