source: network-game/server/DataAccess.h@ 4c00935

Last change on this file since 4c00935 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
Line 
1#ifndef _DATA_ACCESS_H
2#define _DATA_ACCESS_H
3
4#include <string>
5#include <list>
6
7#include <mysql/mysql.h>
8
9#include "../common/Player.h"
10
11using namespace std;
12
13class DataAccess {
14public:
15 DataAccess();
16 ~DataAccess();
17
18 Player* getPlayer(string username);
19 list<Player*>* getPlayers();
20 bool verifyPassword(string encrypted, string password);
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);
30
31 int insert(string table, string rows, string values);
32 int update(string table, string values, string where);
33 MYSQL_RES *select(string table, string filter);
34
35private:
36 MYSQL *connection, mysql;
37};
38
39#endif
Note: See TracBrowser for help on using the repository browser.