git.ucc.asn.au
/
progcomp2012.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added check for rubbish move multipliers
[progcomp2012.git]
/
judge
/
manager
/
stratego.cpp
diff --git
a/judge/manager/stratego.cpp
b/judge/manager/stratego.cpp
index
5acfaa3
..
7894378
100644
(file)
--- a/
judge/manager/stratego.cpp
+++ b/
judge/manager/stratego.cpp
@@
-57,6
+57,27
@@
Piece::Type Piece::GetType(char fromToken)
return Piece::BOULDER;
}
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
/**
* Construct a new, empty board
* @param newWidth - the width of the board
@@
-322,6
+343,8
@@
MovementResult Board::MovePiece(int x, int y, const Direction & direction, int m
{
return MovementResult(MovementResult::IMMOBILE_UNIT);
}
{
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 (multiplier > 1 && target->type != Piece::SCOUT)
{
return MovementResult(MovementResult::INVALID_DIRECTION); //Can only move a scout multiple times.
UCC
git Repository :: git.ucc.asn.au