GRA RPG  DM & KK
Projekt na PO3
DBcontroler Class Reference

Class responsible for database operation. More...

#include <DBcontroler.h>

Public Member Functions

 DBcontroler ()
 Constructor establishing a connection to the database. More...
 
 ~DBcontroler ()
 Destructor disconnection to the database. More...
 
bool checkUser (int id)
 Function check the user exists in the database. More...
 
bool checkUser (std::string login)
 Function check the user exists in the database. More...
 
void updateChampion (Champion *champ)
 Update function for data downloaded from player and amending the values in the database. More...
 
void addChampion (Champion *champ, int class_hero, int idUser)
 Function adding a new character to the database. More...
 
void addHeroes (int idUser)
 Function to assign the created champion to the user. More...
 
void deleteHeroes (int idUser, int idChampion)
 function removing to player's character. More...
 
void deleteHeroe (int idUser)
 function removing to player's character. More...
 
bool addUser (std::string login, std::string password)
 Function adding a new user. More...
 
MYSQL_ROW getUser (std::string login, std::string password)
 Function finding user id. More...
 
MYSQL_RES * getChampions (int id)
 Function finding all player's champions. More...
 
MYSQL_ROW getProf (int id)
 Function finds what class the characters is. More...
 
ChampiongetChampion (int id)
 Function creates a new character

Parameters
id- champion's id
Returns
Pointer to new character
More...
 
MYSQL_RES * randomChampion (int id)
 Function finding 3 random character different to given id More...
 

Detailed Description

Class responsible for database operation.

Constructor & Destructor Documentation

◆ DBcontroler()

DBcontroler::DBcontroler ( )

Constructor establishing a connection to the database.

◆ ~DBcontroler()

DBcontroler::~DBcontroler ( )

Destructor disconnection to the database.

Member Function Documentation

◆ addChampion()

void DBcontroler::addChampion ( Champion champ,
int  class_hero,
int  idUser 
)

Function adding a new character to the database.

Parameters
champ- Champion class object with generated basic statistics
class_hero- player's chosen character class
idUser- player's id

◆ addHeroes()

void DBcontroler::addHeroes ( int  idUser)

Function to assign the created champion to the user.

Parameters
idUser- player's id

◆ addUser()

bool DBcontroler::addUser ( std::string  login,
std::string  password 
)

Function adding a new user.

Parameters
login- player's login
password- player's password
Returns
confirm adding new user - true or false

◆ checkUser() [1/2]

bool DBcontroler::checkUser ( int  id)

Function check the user exists in the database.

Parameters
id- id user
Returns
true or false

◆ checkUser() [2/2]

bool DBcontroler::checkUser ( std::string  login)

Function check the user exists in the database.

Parameters
login- login given by user
Returns
true or false

◆ deleteHeroe()

void DBcontroler::deleteHeroe ( int  idUser)

function removing to player's character.

Parameters
idUser- player's id

◆ deleteHeroes()

void DBcontroler::deleteHeroes ( int  idUser,
int  idChampion 
)

function removing to player's character.

Parameters
idUser- player's id
idChampion- player's character id

◆ getChampion()

Champion * DBcontroler::getChampion ( int  id)

Function creates a new character

Parameters
id- champion's id
Returns
Pointer to new character

◆ getChampions()

MYSQL_RES * DBcontroler::getChampions ( int  id)

Function finding all player's champions.

Parameters
id- user's id
Returns
Rows with all player's champions

◆ getProf()

MYSQL_ROW DBcontroler::getProf ( int  id)

Function finds what class the characters is.

Parameters
id- champion's id
Returns
Row with id proffesion

◆ getUser()

MYSQL_ROW DBcontroler::getUser ( std::string  login,
std::string  password 
)

Function finding user id.

Parameters
login- user's login
password- user's password
Returns
Row with user's id

◆ randomChampion()

MYSQL_RES * DBcontroler::randomChampion ( int  id)

Function finding 3 random character different to given id

Parameters
id- character's id
Returns
Rows with champions data

◆ updateChampion()

void DBcontroler::updateChampion ( Champion champ)

Update function for data downloaded from player and amending the values in the database.

Parameters
champ- player's object