X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=progcomp%2Fjudge%2Fmanager%2Fgame.h;fp=progcomp%2Fjudge%2Fmanager%2Fgame.h;h=1212b891e924d9a4cd741b1fe66a1eb4ddd6f25d;hp=0000000000000000000000000000000000000000;hb=88fc5a96c424e9a451b98f3b680bc1980345320d;hpb=e3b15cd5dea739f7523920d83bda592db95a7b93;ds=sidebyside diff --git a/progcomp/judge/manager/game.h b/progcomp/judge/manager/game.h new file mode 100644 index 0000000..1212b89 --- /dev/null +++ b/progcomp/judge/manager/game.h @@ -0,0 +1,88 @@ +#ifndef MAIN_H +#define MAIN_H + +#include "stratego.h" +#include "ai_controller.h" +#include "human_controller.h" + + + +/** + * Class to manage the game + */ +class Game +{ + public: + Game(const char * redPath, const char * bluePath, const bool enableGraphics, double newStallTime = 1.0, const bool allowIllegal=false, FILE * newLog = NULL, const Piece::Colour & newRevealed = Piece::BOTH, int maxTurns = 5000, const bool printBoard = false); + Game(const char * fromFile, const bool enableGraphics, double newStallTime = 1.0, const bool allowIllegal=false, FILE * newLog = NULL, const Piece::Colour & newRevealed = Piece::BOTH, int maxTurns = 5000, const bool printBoard = false); + virtual ~Game(); + + + + void Wait(double wait); + + Piece::Colour Setup(const char * redName, const char * blueName); + MovementResult Play(); + void PrintEndMessage(const MovementResult & result); + + + static void HandleBrokenPipe(int signal); + void ReadUserCommand(); + + const Piece::Colour Turn() const {return turn;} + void ForceTurn(const Piece::Colour & newTurn) {turn = newTurn;} + int TurnCount() const {return turnCount;} + + static Game * theGame; + public: + int logMessage(const char * format, ...); + FILE * GetLogFile() const {return log;} + Controller * red; + Controller * blue; + private: + Piece::Colour turn; + + public: + Board theBoard; + private: + const bool graphicsEnabled; + double stallTime; + public: + const bool allowIllegalMoves; + + private: + FILE * log; + + public: + const Piece::Colour reveal; + int turnCount; + + static bool gameCreated; + + FILE * input; + + int maxTurns; + const bool printBoard; + +}; + +class FileController : public Controller +{ + public: + FileController(const Piece::Colour & newColour, FILE * newFile) : Controller(newColour, "file"), file(newFile) {} + virtual ~FileController() {} + + virtual void Message(const char * string) {} //Don't send messages + virtual MovementResult QuerySetup(const char * opponentName, std::string setup[]); + virtual MovementResult QueryMove(std::string & buffer); + virtual bool Valid() const {return file != NULL;} + + private: + FILE * file; + + +}; + + + +#endif //MAIN_H