@@ -239,6 +239,7 @@ private void assertCanPlaceDirt(MapLocation loc) throws GameActionException {
239239 assertIsRobotType (this .robot .getType ());
240240 // Use unit action radius as the allowed range for the action
241241 assertCanActLocation (loc , GameConstants .BUILD_DISTANCE_SQUARED );
242+ assertIsActionReady ();
242243
243244 // state checks :
244245 if (this .gameWorld .getTeamInfo ().getDirt (this .robot .getTeam ()) <= 0 )
@@ -259,6 +260,7 @@ private void assertCanRemoveDirt(MapLocation loc) throws GameActionException {
259260 assertIsRobotType (this .robot .getType ());
260261 assertIsActionReady ();
261262 assertCanActLocation (loc , GameConstants .BUILD_DISTANCE_SQUARED );
263+ assertIsActionReady ();
262264
263265 if ((this .robot .getType ().isBabyRatType ()
264266 || this .robot .getType ().isRatKingType ()) && (this .getAllCheese () < GameConstants .DIG_DIRT_CHEESE_COST ))
@@ -314,6 +316,7 @@ private void assertCanPlaceTrap(MapLocation loc, TrapType trapType) throws GameA
314316 assertIsRobotType (this .robot .getType ());
315317 assertIsActionReady ();
316318 assertCanActLocation (loc , GameConstants .BUILD_DISTANCE_SQUARED );
319+ assertIsActionReady ();
317320
318321 if (trapType == TrapType .CAT_TRAP && !this .gameWorld .isCooperation )
319322 throw new GameActionException (CANT_DO_THAT , "Can't place new cat traps in backstabbing mode!" );
@@ -875,9 +878,11 @@ private void assertCanBuildRat(MapLocation loc) throws GameActionException {
875878 assertNotNull (loc );
876879 assertCanActLocation (loc , GameConstants .BUILD_ROBOT_RADIUS_SQUARED );
877880 assertIsActionReady ();
881+
878882 if (!this .robot .getType ().isRatKingType ()) {
879883 throw new GameActionException (CANT_DO_THAT , "Only rat kings can spawn other rats!" );
880884 }
885+
881886 int cost = getCurrentRatCost ();
882887
883888 if (this .gameWorld .getTeamInfo ().getCheese (this .robot .getTeam ()) < cost ) {
@@ -906,11 +911,11 @@ public boolean canBuildRat(MapLocation loc) {
906911 @ Override
907912 public void buildRat (MapLocation loc ) throws GameActionException {
908913 assertCanBuildRat (loc );
914+ int cost = getCurrentRatCost ();
915+ this .robot .addCheese (-cost );
909916 this .robot .addActionCooldownTurns (GameConstants .BUILD_ROBOT_COOLDOWN );
910917 this .gameWorld .spawnRobot (UnitType .BABY_RAT , loc , this .getDirection (), this .robot .getChirality (),
911918 this .robot .getTeam ());
912- int cost = getCurrentRatCost ();
913- this .robot .addCheese (-cost );
914919 InternalRobot robotSpawned = this .gameWorld .getRobot (loc );
915920 this .gameWorld .getMatchMaker ().addSpawnAction (robotSpawned .getID (), loc , this .robot .getDirection (),
916921 this .robot .getChirality (), getTeam (), UnitType .BABY_RAT );
0 commit comments