X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=manager%2Fstratego.h;fp=manager%2Fstratego.h;h=929f8702dd9dd4dd71ef78ba08a893111191bf98;hp=39e887310d6e43f23f858eb3f4f580afd601166f;hb=2120cc40abf9e3fd763c84a1e09b61064bb40be6;hpb=fe470c015d73d07c44f0e951a2bb205d95763f22 diff --git a/manager/stratego.h b/manager/stratego.h index 39e8873..929f870 100644 --- a/manager/stratego.h +++ b/manager/stratego.h @@ -10,6 +10,7 @@ #include "graphics.h" #include "array.h" +#include /** * Contains classes for a game of Stratego @@ -25,9 +26,10 @@ class Piece typedef enum {ERROR=14,BOMB=13,MARSHAL=12, GENERAL=11, COLONEL=10, MAJOR=9, CAPTAIN=8, LIEUTENANT=7, SERGEANT=6, MINER=5, SCOUT=4, SPY=3, FLAG=2,BOULDER=1, NOTHING=0} Type; //Type basically defines how strong the piece is + typedef enum {RED=0, BLUE=1, NONE=2, BOTH=3} Colour; //Used for the allegiance of the pieces - terrain counts as NONE. - Piece(const Type & newType, const Colour & newColour) : type(newType), colour(newColour) {} + Piece(const Type & newType, const Colour & newColour) : type(newType), colour(newColour), beenRevealed(false) {} virtual ~Piece() {} @@ -46,11 +48,14 @@ class Piece static Type GetType(char fromToken); + int PieceValue() const {if (type == BOMB || type == FLAG) {return 0;} return (int)(type) - (int)(SPY) + 1;} //Attributes of the piece const Type type; const Colour colour; + bool beenRevealed; + public: class TextureManager : public Graphics::TextureManager, private Array @@ -118,8 +123,13 @@ 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); - } + 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); + } + + static bool HaltResult(const MovementResult & result) + { + return (result == MovementResult::VICTORY || 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 @@ -128,10 +138,15 @@ class Board int Width() const {return width;} int Height() const {return height;} + + int MobilePieces(const Piece::Colour & colour) const; + int TotalPieceValue(const Piece::Colour & colour) const; + bool RemovePiece(Piece * piece); private: int width; int height; Piece ** * board; + std::vector pieces; }; #endif //STRATEGO_H