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

Manages different types of weapons in the game. More...

#include <weapon.h>

Public Member Functions

 Weapon ()
 Constructor for the Weapon class. More...
 
int giveRandWeapon ()
 Get a random weapon ID. More...
 
int giveRariWeapon (const std::string &rarity)
 Get a weapon ID based on its rarity. More...
 
std::string getName (int weaponId)
 Get the name of a weapon. More...
 
std::string getDescription (int weaponId)
 Get the description of a weapon. More...
 
int getDamage (int weaponId)
 Get the damage value of a weapon. More...
 
std::string getRarity (int weaponId)
 Get the rarity of a weapon. More...
 
bool getRanged (int weaponId)
 Check if a weapon is ranged. More...
 
bool getStun (int weaponId)
 Check if a weapon can stun. More...
 

Detailed Description

Manages different types of weapons in the game.

The Weapon class provides methods to retrieve weapons based on randomness or rarity and access various attributes of the weapons.

Constructor & Destructor Documentation

◆ Weapon()

Weapon::Weapon ( )

Constructor for the Weapon class.

Initializes the weapons data structure and populates it with predefined weapons.

Initializes the weapon system by seeding the random number generator and adding a predefined set of weapons to the system.

Member Function Documentation

◆ getDamage()

int Weapon::getDamage ( int  weaponId)

Get the damage value of a weapon.

Returns the damage value of the weapon with the specified ID.

Parameters
weaponIdThe ID of the weapon.
Returns
The damage value of the weapon.
Parameters
weaponIdThe ID of the weapon.
Returns
An integer representing the damage dealt by the weapon.

◆ getDescription()

std::string Weapon::getDescription ( int  weaponId)

Get the description of a weapon.

Returns the description of the weapon with the specified ID.

Parameters
weaponIdThe ID of the weapon.
Returns
The description of the weapon.
Parameters
weaponIdThe ID of the weapon.
Returns
A string representing the description of the weapon.

◆ getName()

std::string Weapon::getName ( int  weaponId)

Get the name of a weapon.

Returns the name of the weapon with the specified ID.

Parameters
weaponIdThe ID of the weapon.
Returns
The name of the weapon.
Parameters
weaponIdThe ID of the weapon.
Returns
A string representing the name of the weapon.

◆ getRanged()

bool Weapon::getRanged ( int  weaponId)

Check if a weapon is ranged.

Checks if the weapon with the specified ID is ranged.

Parameters
weaponIdThe ID of the weapon.
Returns
True if the weapon is ranged, otherwise false.

◆ getRarity()

std::string Weapon::getRarity ( int  weaponId)

Get the rarity of a weapon.

Returns the rarity of the weapon with the specified ID.

Parameters
weaponIdThe ID of the weapon.
Returns
The rarity level of the weapon.
Parameters
weaponIdThe ID of the weapon.
Returns
A string representing the rarity of the weapon.

◆ getStun()

bool Weapon::getStun ( int  weaponId)

Check if a weapon can stun.

Checks if the weapon with the specified ID has stun capability.

Parameters
weaponIdThe ID of the weapon.
Returns
True if the weapon can stun, otherwise false.
Parameters
weaponIdThe ID of the weapon.
Returns
True if the weapon has stun capability, otherwise false.

◆ giveRandWeapon()

int Weapon::giveRandWeapon ( )

Get a random weapon ID.

Returns a random weapon ID.

Returns
The ID of a randomly selected weapon.

Selects a random weapon from the available weapons.

Returns
An integer representing the ID of the randomly selected weapon.

◆ giveRariWeapon()

int Weapon::giveRariWeapon ( const std::string &  rarity)

Get a weapon ID based on its rarity.

Returns a weapon ID based on the specified rarity.

Parameters
rarityThe rarity level of the desired weapon (e.g., "common", "rare", "epic").
Returns
The ID of a weapon that matches the specified rarity.
Parameters
rarityThe rarity of the desired weapon (e.g., "Common", "Rare", "Epic").
Returns
An integer representing the ID of the randomly selected weapon with the specified rarity, or -1 if no such weapon exists.

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