5 #include "ai_controller.h"
6 #include "human_controller.h"
7 #include "network_controller.h"
12 * Class to manage the game
13 * Bit messy since I keep adding on parameters :P
18 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, double newTimeoutTime = 2.0, bool server=false, bool client=false);
19 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, double newTimeoutTime = 2.0);
24 void Wait(double wait);
26 Piece::Colour Setup(const char * redName, const char * blueName);
27 MovementResult CheckVictoryAttrition();
28 MovementResult Play();
29 void PrintEndMessage(const MovementResult & result);
32 static void HandleBrokenPipe(int signal);
33 void ReadUserCommand();
35 const Piece::Colour Turn() const {return turn;}
36 void ForceTurn(const Piece::Colour & newTurn) {turn = newTurn;}
37 int TurnCount() const {return turnCount;}
39 static Game * theGame;
40 static int Tokenise(std::vector<std::string> & buffer, std::string & str, char split = ' '); //Helper - Split a string into tokens
42 int logMessage(const char * format, ...);
43 FILE * GetLogFile() const {return log;}
52 const bool graphicsEnabled;
55 const bool allowIllegalMoves;
61 const Piece::Colour reveal;
64 static bool gameCreated;
69 const bool printBoard;
76 class FileController : public Controller
79 FileController(const Piece::Colour & newColour, FILE * newFile) : Controller(newColour, "file"), file(newFile) {}
80 virtual ~FileController() {}
82 virtual void Message(const char * string) {} //Don't send messages
83 virtual MovementResult QuerySetup(const char * opponentName, std::string setup[]);
84 virtual MovementResult QueryMove(std::string & buffer);
85 virtual bool Valid() const {return file != NULL;}