This repository has been archived by the owner. It is now read-only.
Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
11,142 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Connection To Data Base | ||
Login/register | ||
Menu | ||
Data Base Design | ||
Insert/Updata/Delete in data base | ||
Market to sell and buy players | ||
Manage my Team | ||
Play a Game | ||
Collect 70 players Info from Internet (Drible, Shoot, Pass, Defense, Overall) | ||
Simulate a Game | ||
afterr login, will show a menu (Simulate Game, Manage Team, Market Team, History Of Games) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include <iostream> | ||
#include <sstream> | ||
#include <string> | ||
#include <stdexcept> | ||
using namespace std; | ||
|
||
#include "libsqlite.hpp" | ||
|
||
|
||
// // function to display the Menu after you logged in | ||
int MenuGame(int Player_ID){ | ||
char choice; | ||
|
||
Game: | ||
do | ||
{ | ||
|
||
cout << "*******************************\n"; | ||
cout << " 1 - Play Game."<< endl; | ||
cout << " 2 - Manage My Team "<< endl; | ||
cout << " 3 - Market."<< endl; | ||
cout << " 4 - Exit."<< endl; | ||
cout << " Enter your choice and press return: "; | ||
|
||
|
||
cin >> choice; | ||
|
||
} // end of do while | ||
while (choice >'5' || choice<'0' ); | ||
|
||
switch (choice) | ||
{ | ||
case '1': | ||
{ | ||
|
||
|
||
|
||
break; | ||
} // end case 1 play game | ||
case '2': | ||
{ | ||
|
||
|
||
break; | ||
}//end case 2 my team | ||
|
||
case '3':{ | ||
cout << "Market BallManager"<< endl; | ||
break; | ||
|
||
}// end case 3 market | ||
|
||
case '4':{ | ||
|
||
cout << "End of Program."<< endl; | ||
break; | ||
} | ||
|
||
default: | ||
{ | ||
cout << "Not a Valid Choice."<< endl; | ||
cout << "Choose again."<< endl; | ||
goto Game; | ||
|
||
break; | ||
}// end default case | ||
|
||
|
||
return 0; | ||
}// end of menu | ||
|
||
}// end of MenuGame function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <vector> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <string> | ||
#include <stdexcept> | ||
using namespace std; | ||
|
||
#include "libsqlite.hpp" | ||
#include "Menu.cpp" | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
int main() | ||
{ | ||
// Menu.cpp file | ||
menuu(); | ||
|
||
|
||
return 0; | ||
}// end of main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
#include <vector> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <string> | ||
#include <stdexcept> | ||
using namespace std; | ||
|
||
#include "libsqlite.hpp" | ||
#include "InGameMenu.cpp" | ||
|
||
|
||
|
||
int createTeam(int Player_ID, string teamName) | ||
{ | ||
|
||
cout << Player_ID<<endl; | ||
cout << "team name "; | ||
cout<< teamName<<endl; | ||
sqlite::sqlite db( "ball.sqlite" ); | ||
auto cur = db.get_statement(); | ||
|
||
// create the team in MyTeam table | ||
//try | ||
//{ | ||
// | ||
|
||
cur->set_sql( "INSERT INTO MyTeam (Player_ID, TeamName) VALUES (?,?);" ); | ||
|
||
cur->prepare(); | ||
cur->bind( 1, Player_ID ); | ||
cur->bind( 2, teamName ); | ||
int insertt =cur->step(); | ||
if(insertt=true) | ||
{ | ||
cout<<"insert true, "<<endl; | ||
} | ||
|
||
|
||
//} | ||
//catch( sqlite::exception e ) | ||
//{ | ||
//cerr << e.what() << endl; | ||
//return 1; | ||
//} // end if registatin fails i dk | ||
|
||
|
||
return 0; | ||
|
||
} | ||
|
||
// First menu, this will be showed when u start | ||
char menuu() | ||
{ | ||
char choice; | ||
|
||
MainMenu: | ||
do | ||
{ | ||
|
||
cout << "*******************************\n"; | ||
cout << " 1 - Login."<< endl; | ||
cout << " 2 - Register "<< endl; | ||
cout << " 3 - Credits."<< endl; | ||
cout << " 4 - Exit."<< endl; | ||
cout << " Enter your choice and press return: "; | ||
|
||
|
||
cin >> choice; | ||
|
||
} // end of do while | ||
while (choice >'5' || choice<'0' ); | ||
|
||
switch (choice) | ||
{ | ||
case '1': | ||
{ | ||
string username, password; | ||
bool Blog = false; | ||
// login part | ||
logs: | ||
cout << "ID: "; | ||
cin >> username ; | ||
cout << "Password: "; | ||
cin >> password ; | ||
cout << "Checking Data..." << endl ; | ||
|
||
// cheking on the data base | ||
|
||
sqlite::sqlite db( "ball.sqlite" ); | ||
auto cur = db.get_statement(); | ||
|
||
try | ||
{ | ||
|
||
cur->set_sql( "SELECT Player_ID FROM Player " | ||
"WHERE UserName = ? AND Password = ?;" ); | ||
cur->prepare(); | ||
|
||
cur->bind( 1, username ); | ||
cur->bind( 2, password ); | ||
int result= cur->step(); | ||
int Player_ID = cur->get_int(0); // to get the playerID (unique identification on DB) | ||
if (result == true){ | ||
cout<<"login Sucessful"<<endl; | ||
MenuGame(Player_ID); | ||
} | ||
else{ | ||
cout<<"Username of password are wrong"<<endl; | ||
} //end else case | ||
|
||
|
||
} | ||
catch( sqlite::exception e ) | ||
{ | ||
cerr << e.what() << endl; | ||
return 1; | ||
} | ||
|
||
|
||
break; | ||
} | ||
case '2': | ||
{ | ||
string username, email, password, veriyPassword, teamName; | ||
|
||
regist: | ||
// login part | ||
cout << "ID: "; | ||
cin >> username ; | ||
do{ | ||
cout << "Password: "; | ||
cin >> password ; | ||
cout << "Insert tha same password" << endl ; | ||
cout << "Repeat Password: "; | ||
cin >> veriyPassword ; | ||
} | ||
while(password != veriyPassword); | ||
cout << "Email: "; | ||
cin >> email ; | ||
cout << "Team Name: "; | ||
cin >> teamName ; | ||
cout << "Processing Data" << endl ; | ||
cout << ""<< endl; | ||
|
||
//check if already with same user name | ||
sqlite::sqlite db( "ball.sqlite" ); | ||
auto cur = db.get_statement(); | ||
|
||
try | ||
{ | ||
|
||
cur->set_sql( "SELECT * FROM Player " | ||
"WHERE UserName = ? OR Email = ?;" ); | ||
cur->prepare(); | ||
|
||
cur->bind( 1, username ); | ||
cur->bind( 2, email ); | ||
int result= cur->step(); | ||
if (result == true){ | ||
|
||
cout<<"The username or email are already in use!"<<endl; | ||
goto regist; | ||
} | ||
else{ | ||
|
||
//registin part | ||
|
||
// sqlite::sqlite db( "ball.sqlite" ); | ||
cur = db.get_statement(); | ||
|
||
try | ||
{ | ||
cur->set_sql( "INSERT INTO Player (UserName, Email,Password) " | ||
"VALUES (?, ?,?);" ); | ||
cur->prepare(); | ||
|
||
cur->bind( 1, username ); | ||
cur->bind( 2, email ); | ||
cur->bind( 3, password ); | ||
cur->step(); | ||
cout<<"Registed Sucessful"<<endl; | ||
cout<<endl<<endl; | ||
|
||
|
||
} | ||
catch( sqlite::exception e ) | ||
{ | ||
cerr << e.what() << endl; | ||
return 1; | ||
} // if registatin fails | ||
|
||
// // to get the playerID (unique identification on DB) | ||
|
||
|
||
// sqlite::sqlite db( "ball.sqlite" ); | ||
cur = db.get_statement(); | ||
|
||
try | ||
{ | ||
cur->set_sql( "SELECT Player_ID FROM Player " | ||
"WHERE UserName = ? AND Password = ?;" ); | ||
cur->prepare(); | ||
|
||
cur->bind( 1, username ); | ||
cur->bind( 2, password ); | ||
int result= cur->step(); | ||
int Player_ID = cur->get_int(0); | ||
//sqlite::sqlite3_close(db); | ||
cout<<teamName<<endl; | ||
cout<<Player_ID<<endl; | ||
|
||
cur = NULL; | ||
createTeam(Player_ID,teamName); // caling to create a team | ||
|
||
} | ||
catch( sqlite::exception e ) | ||
{ | ||
cerr << e.what() << endl; | ||
return 1; | ||
}// end of getting the ID | ||
|
||
} | ||
|
||
|
||
} | ||
catch( sqlite::exception e ) | ||
{ | ||
cerr << e.what() << endl; | ||
return 1; | ||
} // if checking if the user already exists fails | ||
|
||
|
||
|
||
break; | ||
} | ||
|
||
case '3': | ||
cout << "Group E7"<< endl; | ||
break; | ||
case '4': | ||
cout << "End of Program."<< endl; | ||
break; | ||
default: | ||
cout << "Not a Valid Choice."<< endl; | ||
cout << "Choose again."<< endl; | ||
goto MainMenu; | ||
break; | ||
} | ||
|
||
|
||
return 0; | ||
}// end of menu | ||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.