#pragma once

#include <sql.h>
#include <Text.h>
#include <InitDatei.h>
#include <Array.h>

using namespace Framework;
using namespace sql;

namespace Admin_Recht
{
    const int MSStarten = 66;
    const int MSBeenden = 67;
    const int MSPausieren = 68;
    const int MSMCChange = 69;
}

class MSDatenbank
{
private:
    Datenbank *datenbank;
    CRITICAL_SECTION cs;
    int ref;

public:
    // Konstruktor
    MSDatenbank( InitDatei *zIni );
    // Destruktor
    ~MSDatenbank();
    // nicht constant
    void lock();
    void unlock();
    int istAdministrator( const char *name, const char *passwort );
    bool adminHatRecht( int id, int recht );
    bool proveKlient( int num, int sNum );
    Text *getKlientKey( int cId );
    void unregisterKlient( int num, int sNum );
    bool setServerStatus( int id, int status );
    bool setMaxClients( int id, int maxC );
    bool serverIstNichtPausiert( int id );
    int getMinigameOptionList( char *minigame, RCArray< Text > *zOptionList );
    int getMinigameBestscore( char *options, char *minigame, Text *zPlayer );
    int getMinigameBestscore( char *minigame, Array< int > *zScoreList, RCArray< Text > *zPlayerList, RCArray< Text > *zOptionList );
    bool updateMinigameScore( int score, char *option, int cId, char *minigame, int sId, Text *zFileName );
    Text *getMinigameCaptureFileName( char *option, char *minigame );
    int getMinigameServer( char *minigame, char *option );
    bool getMinigameServer( char *minigame, char *option, Text *zIp, Text *zPort );
    // constant
    Text *getLetzterFehler() const;
    // Reference Counting
    MSDatenbank *getThis();
    MSDatenbank *release();
};