From: Sam Moore Date: Thu, 2 Feb 2012 10:29:52 +0000 (+0800) Subject: Added check for rubbish move multipliers X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=commitdiff_plain;h=037a4b52ab76fe90955d671604238e02f3e4f5a2;hp=69aa3e180883a3042446f4be3bfd6f727b0c8022 Added check for rubbish move multipliers --- diff --git a/judge/manager/stratego.cpp b/judge/manager/stratego.cpp index e142a4b..7894378 100644 --- a/judge/manager/stratego.cpp +++ b/judge/manager/stratego.cpp @@ -343,6 +343,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.