Skip to content

Commit 9a7f2b9

Browse files
committed
prevent off-map rat king formation
1 parent 001a093 commit 9a7f2b9

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,9 @@ public void assertCanBecomeRatKing() throws GameActionException {
10311031
int numAllyRats = 0;
10321032
for (Direction d : Direction.allDirections()) {
10331033
MapLocation curLoc = this.adjacentLocation(d);
1034+
if (!this.gameWorld.getGameMap().onTheMap(curLoc))
1035+
throw new GameActionException(CANT_DO_THAT,
1036+
"Not enough space on map for rat to become rat king!");
10341037
InternalRobot curRobot = this.gameWorld.getRobot(curLoc);
10351038
if (curRobot != null && curRobot.getTeam() == this.robot.getTeam() && curRobot.getType() == UnitType.BABY_RAT) {
10361039
numAllyRats += 1;

0 commit comments

Comments
 (0)