Skip to content

Commit 5a8deb6

Browse files
committed
Only allow attacking adjacent locations for rats
1 parent 97db510 commit 5a8deb6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

engine/src/main/battlecode/world/RobotControllerImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,10 @@ private void assertCanAttackRat(MapLocation loc, int cheeseConsumed) throws Game
950950
assertIsActionReady();
951951
// Attack is limited to vision radius
952952
assertCanActLocation(loc, this.getType().getVisionRadiusSquared());
953+
if (!this.getLocation().isAdjacentTo(loc)) {
954+
throw new GameActionException(CANT_DO_THAT, "Rats can only attack adjacent squares!");
955+
}
956+
953957
if (!this.gameWorld.isPassable(loc))
954958
throw new GameActionException(CANT_DO_THAT, "Rats cannot attack squares with walls or dirt on them!");
955959

0 commit comments

Comments
 (0)