Question: #include #include #include #include #include struct Room { enum class Name { cell, gate, armory, jailers, exit } ; enum class Direction { N ,

#include
#include
#include
#include
#include
struct Room
{
enum class Name { cell, gate, armory, jailers, exit };
enum class Direction { N, S, E, W, none };
std::string message;// the message displayed when in the room.
std::vector doors;// the directions in which there are doors.
std::vector connectedRoom;// the name of the room in which the corresponding door leads.
//NOTE:: these two vectors will eventually become a std::map after the STL level.
bool hasKey{ false }; //whether or not the player has picked up the key.
};
struct Player
{
Room::Name currentRoom{ Room::Name::cell };
int health{10};
bool hasKey{ false };
};
/* GUI Functions */
void clearConsole();
void pauseConsole();
void splashScreen();
void displayGameState(const Player& player, const std::vector& map);
void displayGameDone(const Player& player, const std::vector& map);
void displayIllegalMove(const Player& player, Room::Direction action);
Room::Direction getAction();
/* Engine Functions*/
std::vector buildMap();
void randomizeKey(std::vector& map);
bool changeGameState(Room::Direction action, Player& player, std::vector& map);
bool gameIsNotDone(const Player& player);
int main(){
/*Splash Screen*/
clearConsole();
splashScreen();
/*set up game*/
std::vector map{ buildMap()};
Player player;
/*Until Game Termination Condition*/
while (gameIsNotDone(player))
{
/*Display Game State*/
clearConsole();
displayGameState(player, map);
/*Collect Player Action*/
Room::Direction action{ getAction()};
/*Update Game State*/
if (!changeGameState(action, player, map))
{
displayIllegalMove(player, action);
}
}
/*Display Termination Game State*/
displayGameDone(player, map);
return 0;
}
std::vector buildMap()
{
std::vector map;
map.push_back(
{
"A small, dark prison cell with doors South and East.",
{Room::Direction::S, Room::Direction::E},
{Room::Name::armory, Room::Name::gate},
false
});
map.push_back(
{
"A large, torchlit room with doors West, South, and East.
There is daylight entering under the door to the East.",
{Room::Direction::W, Room::Direction::S, Room::Direction::E},
{Room::Name::cell, Room::Name::jailers, Room::Name::exit},
false
});
map.push_back(
{
"A store room with doors North and East.",
{Room::Direction::N, Room::Direction::E},
{Room::Name::cell, Room::Name::jailers},
false
});
map.push_back(
{
"A jailer's barracks with doors West and North.",
{Room::Direction::W, Room::Direction::N},
{Room::Name::armory, Room::Name::gate},
true
});
map.push_back(
{
"YOU FOUND THE KEY AND ESCAPED!",
{},
{},
false
});
return map;
}
void clearConsole(){
system("cls");
}
void pauseConsole(){
system("PAUSE");
}
void splashScreen(){
std::cout "DUNGEON ADVENTURE" std::endl;
std::cout std::endl;
std::cout "Your name here (2020)" std::endl;
std::cout "CPSC 2376, Programming II, Level 1 Quest" std::endl;
std::cout "UA Little Rock, Computer Science Dept." std::endl;
std::cout std::endl;
std::cout "INSTRUCTIONS:" std::endl;
std::cout std::endl;
std::cout "Find the key and get out of the dungeon!" std::endl;
std::cout std::endl;
std::cout "(North)" std::endl;
std::cout " w " std::endl;
std::cout "|" std::endl;
std::cout "(West) a --+-- d (East)" std::endl;
std::cout "|" std::endl;
std::cout " s " std::endl;
std::cout "(South)" std::endl;
std::cout std::endl;
pauseConsole();
}
//Task 1: Change the vector of rooms to a map. (moderate)
This is the easiest change. Change the std::vector
 #include #include #include #include #include struct Room { enum class Name

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!