TheCOSCGameProject  1.0
Public Member Functions | List of all members
RoomContent Class Reference

Manages the content within a room, including items, enemies, and NPCs. More...

#include <room.h>

Public Member Functions

 RoomContent ()
 Constructor for RoomContent. More...
 
void enemyRoom ()
 Clears the room content, making it empty. More...
 
void gamblingRoom ()
 Sets up a gambling room with an NPC. More...
 
void lockedRoom ()
 
void addItem (const std::string &item)
 Adds an item to the room. More...
 
void addEnemy (const EnemyStruct &enemy)
 Adds an enemy to the room. More...
 
void displayContent () const
 Displays the contents of the room. More...
 
int getRoomType ()
 Gets the type of the room. More...
 
std::string getRoomDesc ()
 Gets the description of the room. More...
 
NPCgetNPC ()
 Gets the NPC in the room. More...
 
std::vector< EnemyStructgetEnemies ()
 Gets the enemies in the room. More...
 
void clearEnemies ()
 
void clearText ()
 
void addCoordinates (int x, int y)
 Sets the coordinates for this room. More...
 
std::pair< int, int > getCoordinates ()
 Gets the coordinates for this room. More...
 
bool getVisited ()
 Gets whether or not the room has been visited. More...
 
void setVisited (bool hasVisited)
 Sets whether or not the room has been visited. More...
 
GamegetNonGamblingGame ()
 
std::vector< std::string > getItems ()
 
void displayRoomItems ()
 
bool collect (Player *player)
 
int getCoins ()
 
bool emptyItems ()
 

Detailed Description

Manages the content within a room, including items, enemies, and NPCs.

The RoomContent class is responsible for handling the contents of a room, such as items that can be collected, enemies that can be fought, and NPCs that can be interacted with.

Constructor & Destructor Documentation

◆ RoomContent()

RoomContent::RoomContent ( )

Constructor for RoomContent.

Constructor for RoomContent class.

Initializes an empty room content.

Initializes a RoomContent object by randomly generating a room type (either empty or gambling room). Depending on the room type, it populates the room with appropriate items, enemies, or NPCs.

Member Function Documentation

◆ addCoordinates()

void RoomContent::addCoordinates ( int  x,
int  y 
)

Sets the coordinates for this room.

Add coordinates to the room.

Parameters
xThe x coordinate.
yThe y coordinate.
xThe x-coordinate of the room.
yThe y-coordinate of the room.

◆ addEnemy()

void RoomContent::addEnemy ( const EnemyStruct enemy)

Adds an enemy to the room.

Add an enemy to the room.

Parameters
enemyThe enemy to add.
enemyThe enemy to add to the room.

◆ addItem()

void RoomContent::addItem ( const std::string &  item)

Adds an item to the room.

Add an item to the room.

Parameters
itemThe name of the item to add.

◆ clearEnemies()

void RoomContent::clearEnemies ( )

◆ clearText()

void RoomContent::clearText ( )

◆ collect()

bool RoomContent::collect ( Player player)

◆ displayContent()

void RoomContent::displayContent ( ) const

Displays the contents of the room.

Display the content of the room.

Prints the coordinates, visited status, items, enemies, and NPC details of the room to the console.

◆ displayRoomItems()

void RoomContent::displayRoomItems ( )

◆ emptyItems()

bool RoomContent::emptyItems ( )

◆ enemyRoom()

void RoomContent::enemyRoom ( )

Clears the room content, making it empty.

Generate an empty room with random enemies and items.

This method reads enemy and item details from files, then randomly adds them to the room based on predefined probabilities.

◆ gamblingRoom()

void RoomContent::gamblingRoom ( )

Sets up a gambling room with an NPC.

Generate a gambling room with a random NPC and game.

This method creates an NPC with a random gambling game (either TicTacToe or BlackJack). It reads NPC names from a file and assigns one to the NPC.

◆ getCoins()

int RoomContent::getCoins ( )

◆ getCoordinates()

std::pair< int, int > RoomContent::getCoordinates ( )

Gets the coordinates for this room.

Get the coordinates of the room.

Returns
The coordinates for this room
A pair of integers representing the x and y coordinates of the room.

◆ getEnemies()

std::vector< EnemyStruct > RoomContent::getEnemies ( )

Gets the enemies in the room.

Get the list of enemies in the room.

Returns
A vector of enemies present in the room.
A vector of EnemyStructs representing the enemies in the room.

◆ getItems()

std::vector< std::string > RoomContent::getItems ( )

◆ getNonGamblingGame()

Game * RoomContent::getNonGamblingGame ( )

◆ getNPC()

NPC & RoomContent::getNPC ( )

Gets the NPC in the room.

Get the NPC in the room.

Returns
A reference to the NPC in the room.

◆ getRoomDesc()

std::string RoomContent::getRoomDesc ( )

Gets the description of the room.

Get the description of the room.

Returns
A string containing the room description.
A string describing the room and its contents.

◆ getRoomType()

int RoomContent::getRoomType ( )

Gets the type of the room.

Get the type of the room.

Returns
An integer representing the room type.
An integer representing the room type (0 for empty room, 1 for gambling room).

◆ getVisited()

bool RoomContent::getVisited ( )

Gets whether or not the room has been visited.

Check if the room has been visited.

Returns
Whether or not the room has been visited
True if the room has been visited, false otherwise.

◆ lockedRoom()

void RoomContent::lockedRoom ( )

◆ setVisited()

void RoomContent::setVisited ( bool  hasVisited)

Sets whether or not the room has been visited.

Set the visited status of the room.

Parameters
hasVisitedWhether or not the room has been visited
hasVisitedBoolean value to set the visited status.

The documentation for this class was generated from the following files: