X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=manager%2Fgame.h;h=1212b891e924d9a4cd741b1fe66a1eb4ddd6f25d;hp=9a02044e1dbc8f5ee383600ee5f96c006e7443cb;hb=7f7bc05439b70b3139086086608996de3c9ae2ed;hpb=4a3c0478160e7e9b637a12e7cf22f8da61b66ad2 diff --git a/manager/game.h b/manager/game.h index 9a02044..1212b89 100644 --- a/manager/game.h +++ b/manager/game.h @@ -13,29 +13,33 @@ 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); + 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); - bool Setup(const char * redName, const char * blueName); + 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; - private: + public: int logMessage(const char * format, ...); + FILE * GetLogFile() const {return log;} Controller * red; Controller * blue; + private: Piece::Colour turn; public: @@ -48,10 +52,37 @@ class Game private: FILE * log; - Piece::Colour reveal; + + 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