//
//  game.hpp   --- Handles game control informatio
//
#ifndef GAME_HPP
#define GAME_HPP

#include    "bag.hpp"


extern "C" int sort_dirs( const void *a, const void *b);

#define MAX_GAME_DESC           32
#define MAX_HISTORY_FILENAME    12
#define GAME_CONTROL_MAX_FILENAME   8

//
// GameControl class is used to control how the game is organized and played.
//
class GameControl
{
public:
    int     releaseLevel;                   // release level of data file
    char    gameDesc[ MAX_GAME_DESC +1 ];   // description of this game
    char    historyFilename[ MAX_HISTORY_FILENAME + 1 ];
    BOOL    allowDuplicateBalls;            // TRUE iff duplicates valid
    int     minNum;                         // minimum number / machine
    int     maxNum;                         // maximum number / machine
    int     totalBalls;                     // total number of balls / machine
    int     nBallsPicked;                   // number balls picked / machine

    char    gameName[ GAME_CONTROL_MAX_FILENAME + 1 ]; // name of game control file
    Bag     dirBag;                         // bag of directory entries
    
    GameControl();
    ~GameControl();
    BOOL    readGame(char*name);            // read game info file
    BOOL    writeGame();                    // write current game info file
    BOOL    writeGame(char*name);           // write game info file
    void    showGameInfo(GameControl& aGame);  // show game info to user
    BOOL    editGameInfo();                 // get game info from user
    int     getGameDir();                   // get game directory
    void    emptyDirBag();
    BOOL    showGameDir( int nEntries = 10, int startIndex = 0);
    BOOL    selectGame();                   // select a game
    char    *baseName(char* aName);         // return ptr w/o .GAM extn
};

#endif
