Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
tudo a funcionar mais comments
  • Loading branch information
“craciun2” committed Mar 12, 2018
1 parent 5c555fa commit 92e405ed85dddc106e732edfc1f22175c112adad
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
@@ -20,7 +20,7 @@
public:



//method to change the password
void changePassword(int Player_ID, sqlite::sqlite &db )
{
newpass:
@@ -73,8 +73,8 @@
cout << "Input your favourite club"<< endl;
cin>> favourite_club;

// updting edtails on BD
//sqlite::sqlite db( "ball.sqlite" );
// updting details on BD

auto cur = db.get_statement();
cur->set_sql( " UPDATE Player SET Email = ? , Mentality = ? , Age = ? , Nationality = ? , Club = ? WHERE Player_ID = ? ; " );
cur->prepare();
@@ -99,10 +99,9 @@
} // end updateDetails

// sqlite::sqlite &db
// geting the details from the database and show
void printDetails(int Player_ID, sqlite::sqlite &db)
{
// showing details from the user
//sqlite::sqlite db( "ball.sqlite" );
auto cur = db.get_statement();
cur->set_sql( " SELECT * FROM Player WHERE Player_ID = ? ; " );
cur->prepare();
@@ -123,7 +122,7 @@
}


}
}// end printDetails

};// end clas PlayerInfo

@@ -156,19 +155,22 @@
case '1':
{


cout<< "Not available yet..."<< endl ;
goto MenuInGame;

break;
} // end case 1 play game
case '2':
{

cout<< "Not available yet..."<< endl ;
goto MenuInGame;

break;
}//end case 2 my team

case '3':{
cout << "Market BallManager"<< endl;
cout<< "Not available yet..."<< endl ;
goto MenuInGame;
break;

}// end case 3 market
@@ -231,7 +233,7 @@


return 0;
}// end of menu
}// end of menuSettings

break;
} // end Menu Setings
@@ -8,7 +8,7 @@ using namespace std;
#include "libsqlite.hpp"
#include "Menu.cpp"


// this the main part, my plan was to connect the code from everyone here, i think its the best way to do it

int main()
{
@@ -18,7 +18,8 @@ int main()
//PlayerInfo pi;
//pi.changePassword(7, db );
//return 0;




int Player_ID = menuu();

@@ -12,7 +12,7 @@ using namespace std;
#include "md5.h"


// this funcition to ecrypt the password, i did some research on internet, is not mine.
// this funcition to encrypt the password, i did some research on internet, is not mine.
string hashPassword(string password)
{
string ecryptedPassword;
@@ -21,6 +21,8 @@ string hashPassword(string password)
return ecryptedPassword;
}


// this funcition is simply to insert into the database ( creates the team for each player when registing)
int createTeam(int Player_ID, string teamName )
{

@@ -93,7 +95,7 @@ char menuu()

if (result == true){
cout<<"login Sucessful"<<endl;
MenuGame(Player_ID, db);
MenuGame(Player_ID, db); // if the login sucesful it goes to the InGameMenu
return Player_ID; // returning to the main the Player ID
}
else{
@@ -138,7 +140,7 @@ char menuu()



//check if already with same user name
//check if already took the same user name or email
try
{
sqlite::sqlite db( "ball.sqlite" );
@@ -152,10 +154,10 @@ char menuu()
int result= cur->step();
if (result == true)
{
cout<<"The username or email are already in use! Try Again"<<endl;
cout<<"The username or email are already in use! Try Again With diferrent details"<<endl;
goto regist;
}//end of if case
else
else // if no one already took that usarname or email, is going to regist him
{
ecryptedPassword = hashPassword(password); // ecrypting the password
//registin part
@@ -169,8 +171,8 @@ char menuu()
cur->step();
cout<<"Registed Sucessful"<<endl;
cout<<endl<<endl;
// // to get the playerID (unique identification on DB)

//to get the Player_ID (unique identification on database)
cur = db.get_statement();
cur->set_sql( "SELECT Player_ID FROM Player "
"WHERE UserName = ? AND Password = ?;" );
@@ -179,7 +181,7 @@ char menuu()
cur->bind( 2, password );
int result= cur->step();
int Player_ID = cur->get_int(0);
//sqlite::sqlite3_close(db);

cur = NULL;
createTeam(Player_ID,teamName); // create the team for the player (inserting in dabase)
// end of getting the ID
@@ -35,7 +35,7 @@ g++ --std=c++14 Main.cpp md5.cpp -o HAS -lsqlite3 -o main_program && ./main_prog
g++ pass.cpp md5.cpp -o main_program && ./main_program


g++ ncurses.cpp -lncurses




0 comments on commit 92e405e

Please sign in to comment.