15 * Contains classes for a game of Stratego
20 * Class for a game piece
25 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
28 typedef enum {RED=0, BLUE=1, NONE=2, BOTH=3} Colour; //Used for the allegiance of the pieces - terrain counts as NONE.
30 Piece(const Type & newType, const Colour & newColour) : type(newType), colour(newColour) {}
34 //Operators compare the strength of two pieces
35 bool operator==(const Piece & equ) const {return type == equ.type;}
36 bool operator<(const Piece & equ) const {return type < equ.type;}
37 bool operator>(const Piece & equ) const {return type > equ.type;}
39 bool operator!=(const Piece & equ) const {return !operator==(equ);}
40 bool operator<=(const Piece & equ) const {return (operator<(equ) || operator==(equ));}
41 bool operator>=(const Piece & equ) const {return (operator>(equ) || operator==(equ));}
43 //Contains the characters used to identify piece types when the board is printed to a stream
45 static int maxUnits[];
47 static Type GetType(char fromToken);
50 //Attributes of the piece
56 class TextureManager : public Graphics::TextureManager<LUint>, private Array<Texture*>
59 TextureManager() : Graphics::TextureManager<LUint>(), Array<Texture*>() {}
60 virtual ~TextureManager();
62 virtual Texture & operator[](const LUint & at);
64 static TextureManager textures;
66 static Graphics::Colour GetGraphicsColour(const Piece::Colour & colour)
71 return Graphics::Colour(1,0,0);
74 return Graphics::Colour(0,0,1);
77 return Graphics::Colour(0.5,0.5,0.5);
80 return Graphics::Colour(1,0,1);
91 #include "movementresult.h"
99 Board(int newWidth, int newHeight); //Constructor
101 virtual ~Board(); //Destructor
103 void Print(FILE * stream, const Piece::Colour & reveal=Piece::BOTH); //Print board
105 void Draw(const Piece::Colour & reveal=Piece::BOTH); //Draw board
108 bool AddPiece(int x, int y, const Piece::Type & newType, const Piece::Colour & newColour); //Add piece to board
111 Piece * GetPiece(int x, int y); //Retrieve piece from a location on the board
114 typedef enum {UP, DOWN, LEFT, RIGHT} Direction;
118 static bool LegalResult(const MovementResult & result)
120 return (result == MovementResult::OK || result == MovementResult::DIES || result == MovementResult::KILLS || result == MovementResult::BOTH_DIE);
123 MovementResult MovePiece(int x, int y, const Direction & direction, int multiplier=1,const Piece::Colour & colour=Piece::NONE); //Move piece from position in direction
126 Piece::Colour winner;
128 int Width() const {return width;}
129 int Height() const {return height;}