Question: Finish the functions in Room.h based on the comments. Make sure to fix any errors. Room.H #ifndef ROOM _ H #define ROOM _ H #include
Finish the functions in Room.h based on the comments. Make sure to fix any errors.
Room.H
#ifndef ROOMH
#define ROOMH
#include
#include
#include
class Room
public:
enum class Name exit cell, closet, pantry, NW gate, NE E SE S SW W numHallwayRooms ;
enum class Direction N S E W none ;
Room;
~Room;
Uses the findif algorithm to see if the action matches any direction in the doorways map. The method needs to indicate a valid move and which room the player would then be entering
bool exitRoomDirection direction, Name& nextRoom;
Uses passed in values to add a door to the map
void addDoorDirection direction, Name room;
Checks to see if the key is in the room. If it is change hasKay to false and return true, otherwise just return false
bool pickupKey;
A setter that simply changes hasKey to true. Used in randomizeKey function.
void dropKey;
private:
Name name Name::NW ;
std::map doorways;
bool hasKey false ;
;
#endif ROOMH
Room.cpp
#include "Room.h
Room::Room
Room::~Room
bool Room::exitRoom
return name Name::exit;
void Room::addDoorDirection direction, Name room
doorwaysdirection room;
bool Room::pickupKey
if hasKey
hasKey false;
return true;
return false;
void Room::dropKey
hasKey true;
Player.h
#ifndef PLAYERH
#define PLAYERH
#include "Object.h
#include "Room.h
class Player:public Object
public:
void update;
private:
void changeGameState;
void displayIllegalMove;
getAction;
int health;
bool hasKey false ;
;
#endif PLAYERH
Player.cpp
#include "Player.h
Player::Player
void Player::updateRoom::Name currentRoom
void Player::changeGameState
void Player::displayIllegalMove
void Player::getAction
Object.h
#ifndef OBJECTH
#define OBJECTH
#include
#include "Room.h
class Object
public:
virtual void update;
static std::randomdevice seed;
static std::defaultrandomengine engine;
protected:
Room::Name currentRoom Room::Name::cell ;
;
#endif OBJECTH
Object.cpp
#include "Object.h
std::randomdevice Object::seed;
std::defaultrandomengine Object::engine;
Object::Object
currentRoom Room::Name::cell;
void Object::update
Guard.h
#ifndef GUARDH
#define GUARDH
#include "Object.h
class Guard: public Object
public:
Guard;
void update;
private:
bool clockwise true ;
;
#endif GUARDH
Guard.cpp
#include "Guard.h
Guard::Guard
updates the guards position
void Guard::update
Source.cpp
#include
#include
#include
#include
#include
#include
#include "Room.h
#include "Player.h
#include "Guard.h
Bigger map
guard chasing.
find key and exit.
bonus:guard moves towards player.
GUI Functions
void splashScreen;
Engine Functions
std::map buildMap;
void randomizeKeystd::map& dungeonMap;
bool gameIsNotDoneconst Player& player, const Guard& guard;
void displayGameDoneconst Player& player, const Guard& guard, const std::map& dungeonMap;
int main
Splash Screen
systemCLR;
splashScreen;
set up game
std::map dungeonMap buildMap;
Player player;
Guard guard;
Until Game Termination Condition Do:
while gameIsNotDoneplayer guard
Display Game State
systemCLS;
std::cout P:intplayergetCurrentRoom std::endl;
std::cout G:intguardgetCurrentRoom std::endl;
player.updatedungeonMap;
guard.updatedungeonMap;
Display Termination Game State
displayGameDoneplayer guard, dungeonMap;
return ;
std::map buildMap
enum class Name cell, gate, armory, jailers, exit ;
std::map dungeonMap;
std::ifstream fin;
fin.opendungeonLayouttxt;
if finisopen
int name;
int numDoors;
while name intRoom::Name::numHallwayRooms
fin name numDoors;
for int i; i numDoors; i
int direction;
int room;
fin direction room;
dungeonMapRoom::NamenameaddDoorRoom::DirectiondirectionRoom::Nameroom;
randomizeKeydungeonMap;
return dungeonMap;
void randomizeKeystd::map& dungeonMap
std::bernoullidistribution closetVsPantry;
if closetVsPantryObject::engine
dungeonMapRoom::Name::closetdropKey;
else
dungeonMapRoom::Name::pantrydropKey;
void clearConsole
systemcls;
void pauseConsole
systemPAUSE;
void displayGameDoneconst Player& player, const Guard& guard, const std::map& dungeonMap
clearConsole;
if playergetHealth
if playergetCurrentRoom Room::Name::exit
std::cout "You found the key and escaped!" std::endl;
else ifplayergetCurrentRoom guard.getCurrentRoom
std::cout "The guard caught you and you are thrown back in your cell!" std::endl;
else
std::cout "YOU DIED...RIP." std::endl;
std::cout std::endl;
pauseConsole;
Check the endofgame conditions. If the player is out
of health or the player has reached the exit
then the game is over.
bool gameIsNotDoneconst Player& player, const Guard& guard
return
player.getHealth
player.getCurrentRoom Room::Name::exit
player.getCurrentRoom guard.getCurrentRoom
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
