-
+#ifdef BUILD_GRAPHICS
Piece::TextureManager Piece::textures;
-
-
-
Piece::TextureManager::~TextureManager()
{
Array<Texture*>::Iterator i(*this);
}
return *(Array<Texture*>::operator[](at));
}
-
+#endif //BUILD_GRAPHICS
/**
* Gets the type of a piece, based off a character token
return Piece::BOULDER;
}
+/**
+ * Gets the opposite to the indicated colour
+ */
+Piece::Colour Piece::OppositeColour(const Colour & colour)
+{
+ switch (colour)
+ {
+ case Piece::RED:
+ return Piece::BLUE;
+ break;
+ case Piece::BLUE:
+ return Piece::RED;
+ break;
+ case Piece::BOTH:
+ return Piece::BOTH;
+ break;
+ case Piece::NONE:
+ return Piece::NONE;
+ }
+}
+
/**
* Construct a new, empty board
* @param newWidth - the width of the board
* @param stream - the stream to print information to
* @param reveal - Pieces matching this colour will have their identify revealed, other pieces will be shown as '#'
*/
-void Board::PrintPretty(FILE * stream, const Piece::Colour & reveal)
+void Board::PrintPretty(FILE * stream, const Piece::Colour & reveal, bool showRevealed)
{
for (int y=0; y < height; ++y)
{
{
fprintf(stream, ".");
}
- else if (piece->colour != Piece::NONE && (piece->colour == reveal || reveal == Piece::BOTH))
+ else if ((piece->colour != Piece::NONE && (piece->colour == reveal || reveal == Piece::BOTH))
+ || (piece->beenRevealed && showRevealed))
{
switch (piece->colour)
{
}
-
+#ifdef BUILD_GRAPHICS
/**
* Draw the board state to graphics
* @param reveal - Pieces matching this colour will be revealed. If Piece::BOTH, all pieces will be revealed
*/
void Board::Draw(const Piece::Colour & reveal, bool showRevealed)
{
+
if (!Graphics::Initialised())
{
fprintf(stderr, "ERROR - Board::Draw called whilst graphics disabled!!!\n");
}
Graphics::ClearScreen();
-
+ float scale = (float)(Piece::textures[(int)(Piece::NOTHING)].width()) / (float)(GRID_SIZE);
for (int y=0; y < height; ++y)
{
for (int x=0; x < width; ++x)
|| (piece->beenRevealed && showRevealed))
{
//Display the piece
- Piece::textures[(int)(piece->type)].DrawColour(x*32,y*32,0,1, Piece::GetGraphicsColour(piece->colour));
+
+ Piece::textures[(int)(piece->type)].DrawColour(x*GRID_SIZE*scale,y*GRID_SIZE*scale,0,scale, Piece::GetGraphicsColour(piece->colour));
}
else
switch (piece->colour)
{
case Piece::RED:
- Piece::textures[(int)(Piece::NOTHING)].DrawColour(x*32,y*32,0,1, Piece::GetGraphicsColour(piece->colour));
+ Piece::textures[(int)(Piece::NOTHING)].DrawColour(x*GRID_SIZE*scale,y*GRID_SIZE*scale,0,scale, Piece::GetGraphicsColour(piece->colour));
break;
case Piece::BLUE:
- Piece::textures[(int)(Piece::NOTHING)].DrawColour(x*32,y*32,0,1, Piece::GetGraphicsColour(piece->colour));
+ Piece::textures[(int)(Piece::NOTHING)].DrawColour(x*GRID_SIZE*scale,y*GRID_SIZE*scale,0,scale, Piece::GetGraphicsColour(piece->colour));
break;
case Piece::NONE:
- Piece::textures[(int)(Piece::BOULDER)].DrawColour(x*32,y*32,0,1, Piece::GetGraphicsColour(piece->colour));
+ Piece::textures[(int)(Piece::BOULDER)].DrawColour(x*GRID_SIZE*scale,y*GRID_SIZE*scale,0,scale, Piece::GetGraphicsColour(piece->colour));
break;
case Piece::BOTH:
- Piece::textures[(int)(Piece::BOULDER)].DrawColour(x*32,y*32,0,1, Piece::GetGraphicsColour(piece->colour));
+ Piece::textures[(int)(Piece::BOULDER)].DrawColour(x*GRID_SIZE*scale,y*GRID_SIZE*scale,0,scale, Piece::GetGraphicsColour(piece->colour));
break;
}
}
Graphics::UpdateScreen();
}
+#endif //BUILD_GRAPHICS
/**
* Adds a piece to the board
{
return MovementResult(MovementResult::IMMOBILE_UNIT);
}
+ if (multiplier < 1)
+ return MovementResult(MovementResult::INVALID_DIRECTION); //Don't allow moves that don't actually move forward
if (multiplier > 1 && target->type != Piece::SCOUT)
{
return MovementResult(MovementResult::INVALID_DIRECTION); //Can only move a scout multiple times.
if (defender->type == Piece::FLAG)
{
winner = target->colour;
- return MovementResult(MovementResult::VICTORY);
+ return MovementResult(MovementResult::VICTORY_FLAG);
}
else if (defender->type == Piece::BOMB)
{