@@ -797,6 +797,7 @@ public void processTrapsAtLocation(MapLocation loc) {
797797 if (trap .getTeam () == this .robot .getTeam () || wrongTrapType ) {
798798 continue ;
799799 }
800+
800801 this .gameWorld .triggerTrap (trap , robot );
801802
802803 }
@@ -820,7 +821,7 @@ public void move(Direction d) throws GameActionException {
820821 processTrapsAtLocation (newLoc );
821822 }
822823
823- this .robot .setLocation (d .dx , d .dy );
824+ this .robot .translateLocation (d .dx , d .dy );
824825 this .robot .addMovementCooldownTurns (d );
825826
826827 }
@@ -934,11 +935,11 @@ private void assertCanAttackRat(MapLocation loc, int cheeseConsumed) throws Game
934935 throw new GameActionException (CANT_DO_THAT , "Rats cannot attack squares with walls or dirt on them!" );
935936
936937 if (this .gameWorld .getTeamInfo ().getCheese (this .getTeam ()) + this .getAllCheese () < cheeseConsumed ) {
937- throw new RuntimeException ( "Not enough cheese to bite!" );
938+ throw new GameActionException ( CANT_DO_THAT , "Not enough cheese to bite!" );
938939 }
939940
940941 if (this .getType () == UnitType .CAT ) {
941- throw new RuntimeException ( "Unit must be a baby rat or rat king to bite!" );
942+ throw new GameActionException ( CANT_DO_THAT , "Unit must be a baby rat or rat king to bite!" );
942943 }
943944 }
944945
@@ -980,7 +981,7 @@ public boolean canAttack(MapLocation loc) {
980981 @ Override
981982 public boolean canAttack (MapLocation loc , int cheeseConsumed ) {
982983 try {
983- assertCanAttack (loc , 0 );
984+ assertCanAttack (loc , cheeseConsumed );
984985 return true ;
985986 } catch (GameActionException e ) {
986987 return false ;
@@ -1203,10 +1204,10 @@ public void assertCanThrowRat(Direction dir) throws GameActionException {
12031204 if (!this .robot .isCarryingRobot ())
12041205 throw new GameActionException (CANT_DO_THAT , "This rat is not carrying any rat!" );
12051206 if (!this .gameWorld .getGameMap ().onTheMap (nextLoc )) {
1206- throw new RuntimeException ( "Cannot throw outside of map!" );
1207+ throw new GameActionException ( CANT_DO_THAT , "Cannot throw outside of map!" );
12071208 }
12081209 if (!this .gameWorld .isPassable (nextLoc ) || (this .gameWorld .getRobot (nextLoc ) != null )) {
1209- throw new RuntimeException ( "There must be at least 1 empty space in front the throwing rat!" );
1210+ throw new GameActionException ( CANT_DO_THAT , "There must be at least 1 empty space in front the throwing rat!" );
12101211 }
12111212 }
12121213
@@ -1219,10 +1220,10 @@ public void assertCanDropRat(Direction dir) throws GameActionException {
12191220 if (!this .robot .isCarryingRobot ())
12201221 throw new GameActionException (CANT_DO_THAT , "This rat is not carrying any rat!" );
12211222 if (!this .gameWorld .getGameMap ().onTheMap (nextLoc )) {
1222- throw new RuntimeException ( "Cannot drop outside of map!" );
1223+ throw new GameActionException ( CANT_DO_THAT , "Cannot drop outside of map!" );
12231224 }
12241225 if (!this .gameWorld .isPassable (nextLoc ) || (this .gameWorld .getRobot (nextLoc ) != null )) {
1225- throw new RuntimeException ( "Can only drop rats into empty spaces!" );
1226+ throw new GameActionException ( CANT_DO_THAT , "Can only drop rats into empty spaces!" );
12261227 }
12271228 }
12281229
@@ -1263,9 +1264,9 @@ public void assertCanCarryRat(MapLocation loc) throws GameActionException {
12631264 assertIsActionReady ();
12641265
12651266 if (!this .robot .getType ().isThrowingType ()) {
1266- throw new RuntimeException ( "Unit must be a rat to grab other rats" );
1267+ throw new GameActionException ( CANT_DO_THAT , "Unit must be a rat to grab other rats" );
12671268 } else if (this .robot .isCarryingRobot ()) {
1268- throw new RuntimeException ( "Already carrying a rat" );
1269+ throw new GameActionException ( CANT_DO_THAT , "Already carrying a rat" );
12691270 }
12701271 // Must be a rat-type
12711272 if (!this .robot .getType ().isBabyRatType ()) {
0 commit comments