Minor rule changes
[progcomp2012.git] / judge / manager / stratego.cpp
index e7cf60a..c9716cf 100644 (file)
@@ -57,6 +57,27 @@ Piece::Type Piece::GetType(char fromToken)
        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
@@ -136,7 +157,7 @@ void Board::Print(FILE * stream, const Piece::Colour & reveal)
  * @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)
        {
@@ -147,7 +168,8 @@ void Board::PrintPretty(FILE * stream, const Piece::Colour & reveal)
                        {
                                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)  
                                {
@@ -322,6 +344,8 @@ MovementResult Board::MovePiece(int x, int y, const Direction & direction, int m
        {
                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.
@@ -375,7 +399,7 @@ MovementResult Board::MovePiece(int x, int y, const Direction & direction, int m
                if (defender->type == Piece::FLAG)
                {
                        winner = target->colour;
-                       return MovementResult(MovementResult::VICTORY);
+                       return MovementResult(MovementResult::VICTORY_FLAG);
                }
                else if (defender->type == Piece::BOMB)
                {

UCC git Repository :: git.ucc.asn.au