Last change
on this file since 53643ca was 53643ca, checked in by Dmitry Portnoy <dmp1488@…>, 10 years ago |
Server loads user profile and game history info from the database, saves game history to the db after every game, and uses a lua settings file to load db settings
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[53643ca] | 1 | #ifndef _DATA_ACCESS_H
|
---|
[36082e8] | 2 | #define _DATA_ACCESS_H
|
---|
| 3 |
|
---|
[59061f6] | 4 | #include <string>
|
---|
[b128109] | 5 | #include <list>
|
---|
[59061f6] | 6 |
|
---|
| 7 | #include <mysql/mysql.h>
|
---|
| 8 |
|
---|
[edfd1d0] | 9 | #include "../common/Player.h"
|
---|
[59061f6] | 10 |
|
---|
| 11 | using namespace std;
|
---|
| 12 |
|
---|
[36082e8] | 13 | class DataAccess {
|
---|
| 14 | public:
|
---|
| 15 | DataAccess();
|
---|
| 16 | ~DataAccess();
|
---|
| 17 |
|
---|
[b128109] | 18 | Player* getPlayer(string username);
|
---|
| 19 | list<Player*>* getPlayers();
|
---|
| 20 | bool verifyPassword(string encrypted, string password);
|
---|
[53643ca] | 21 | int insertPlayer(string username, string password, Player::PlayerClass playerClass);
|
---|
| 22 | // this method needs to be more rebust. maybe pass in a player object amd
|
---|
| 23 | // the method could use the player id to find the player and update any
|
---|
| 24 | // attributes that changed
|
---|
| 25 | int updatePlayer(string username, string password);
|
---|
| 26 |
|
---|
| 27 | int* getPlayerRecord(int playerId);
|
---|
| 28 | int** getPlayerGameHistory(int playerId, unsigned int& numGames);
|
---|
| 29 | int saveGameHistory(int playerId, int team, int blueScore, int redScore);
|
---|
[59061f6] | 30 |
|
---|
| 31 | int insert(string table, string rows, string values);
|
---|
[b128109] | 32 | int update(string table, string values, string where);
|
---|
[59061f6] | 33 | MYSQL_RES *select(string table, string filter);
|
---|
| 34 |
|
---|
| 35 | private:
|
---|
| 36 | MYSQL *connection, mysql;
|
---|
[36082e8] | 37 | };
|
---|
| 38 |
|
---|
| 39 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.