X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=judge%2Fmanager%2Fstratego.h;h=46d10fa6e015b5f3d1e962f07614cdaa493176b5;hp=fe73aa13ff0b4311c3d10acea02c493f9b6dd610;hb=9ff3dd5f6a7d0b7a97f9f498346464c146d730f1;hpb=1a03b2543b67f0551e62babec4cd119f1e0e4640 diff --git a/judge/manager/stratego.h b/judge/manager/stratego.h index fe73aa1..46d10fa 100644 --- a/judge/manager/stratego.h +++ b/judge/manager/stratego.h @@ -6,9 +6,8 @@ #include - - #include "graphics.h" - #include "array.h" +#include "graphics.h" +#include "array.h" #include @@ -29,6 +28,9 @@ class Piece typedef enum {RED=0, BLUE=1, NONE=2, BOTH=3} Colour; //Used for the allegiance of the pieces - terrain counts as NONE. + static Colour OppositeColour(const Colour & compare); + + Piece(const Type & newType, const Colour & newColour) : type(newType), colour(newColour), beenRevealed(false) {} virtual ~Piece() {} @@ -58,6 +60,7 @@ class Piece public: + #ifdef BUILD_GRAPHICS class TextureManager : public Graphics::TextureManager, private Array { public: @@ -73,10 +76,14 @@ class Piece switch (colour) { case RED: - return Graphics::Colour(1,0,0); + return Graphics::Colour(1.0,0.5,0.5); break; case BLUE: - return Graphics::Colour(0,0,1); + #ifdef __MACOSX__ //Horrible HACK to make pieces green on Mac OSX, because Blue doesn't exist on this operating system. + return Graphics::Colour(0,1.0,0); + #else + return Graphics::Colour(0.5,0.5,1.0); + #endif //__MACOSX__ break; case NONE: return Graphics::Colour(0.5,0.5,0.5); @@ -86,7 +93,7 @@ class Piece break; } } - + #endif //BUILD_GRAPHICS @@ -106,10 +113,11 @@ class Board virtual ~Board(); //Destructor void Print(FILE * stream, const Piece::Colour & reveal=Piece::BOTH); //Print board - void PrintPretty(FILE * stream, const Piece::Colour & reveal=Piece::BOTH); //Print board using colour + void PrintPretty(FILE * stream, const Piece::Colour & reveal=Piece::BOTH, bool showRevealed=true); //Print board using colour + #ifdef BUILD_GRAPHICS void Draw(const Piece::Colour & reveal=Piece::BOTH, bool showRevealed = true); //Draw board - + #endif //BUILD_GRAPHICS bool AddPiece(int x, int y, const Piece::Type & newType, const Piece::Colour & newColour); //Add piece to board @@ -123,12 +131,12 @@ class Board static bool LegalResult(const MovementResult & result) { - return (result == MovementResult::OK || result == MovementResult::DIES || result == MovementResult::KILLS || result == MovementResult::BOTH_DIE || result == MovementResult::VICTORY || result == MovementResult::DRAW || result == MovementResult::DRAW_DEFAULT || result == MovementResult::SURRENDER); + return (result == MovementResult::OK || result == MovementResult::DIES || result == MovementResult::KILLS || result == MovementResult::BOTH_DIE || result == MovementResult::VICTORY_FLAG || result == MovementResult::VICTORY_ATTRITION || result == MovementResult::DRAW || result == MovementResult::DRAW_DEFAULT || result == MovementResult::SURRENDER); } static bool HaltResult(const MovementResult & result) { - return (result == MovementResult::VICTORY || result == MovementResult::DRAW || result == MovementResult::DRAW_DEFAULT || result == MovementResult::SURRENDER || !LegalResult(result)); + return (result == MovementResult::VICTORY_FLAG || result == MovementResult::VICTORY_ATTRITION || result == MovementResult::DRAW || result == MovementResult::DRAW_DEFAULT || result == MovementResult::SURRENDER || !LegalResult(result)); } MovementResult MovePiece(int x, int y, const Direction & direction, int multiplier=1,const Piece::Colour & colour=Piece::NONE); //Move piece from position in direction