Skip to content

Commit 06bca17

Browse files
committed
add placedirt action
1 parent 299b741 commit 06bca17

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ private void assertCanActOffCenterLocation(MapLocation loc, int maxRadiusSquared
235235
}
236236

237237
private void assertCanPlaceDirt(MapLocation loc) throws GameActionException {
238+
assertIsActionReady();
238239
assertIsRobotType(this.robot.getType());
239240
// Use unit action radius as the allowed range for the action
240241
assertCanActLocation(loc, GameConstants.BUILD_DISTANCE_SQUARED);
@@ -256,6 +257,7 @@ private void assertCanPlaceDirt(MapLocation loc) throws GameActionException {
256257

257258
private void assertCanRemoveDirt(MapLocation loc) throws GameActionException {
258259
assertIsRobotType(this.robot.getType());
260+
assertIsActionReady();
259261
assertCanActLocation(loc, GameConstants.BUILD_DISTANCE_SQUARED);
260262

261263
if ((this.robot.getType().isBabyRatType()
@@ -285,6 +287,7 @@ public void placeDirt(MapLocation loc) throws GameActionException {
285287
this.robot.addCheese(-1 * GameConstants.PLACE_DIRT_CHEESE_COST);
286288

287289
this.robot.addActionCooldownTurns(GameConstants.DIG_COOLDOWN);
290+
this.gameWorld.getMatchMaker().addPlaceDirtAction(loc);
288291
}
289292

290293
@Override
@@ -309,23 +312,20 @@ private void assertCanRemoveRatTrap(MapLocation loc) throws GameActionException
309312

310313
private void assertCanPlaceTrap(MapLocation loc, TrapType trapType) throws GameActionException {
311314
assertIsRobotType(this.robot.getType());
315+
assertIsActionReady();
312316
assertCanActLocation(loc, GameConstants.BUILD_DISTANCE_SQUARED);
313-
System.out.println("LOG 1");
314317

315318
if (trapType == TrapType.CAT_TRAP && !this.gameWorld.isCooperation)
316319
throw new GameActionException(CANT_DO_THAT, "Can't place new cat traps in backstabbing mode!");
317320
if (!this.gameWorld.isPassable(loc))
318321
throw new GameActionException(CANT_DO_THAT, "Can't place trap on a wall or dirt!");
319-
System.out.println("LOG 1.1 " + this.gameWorld.getRobot(loc));
320322
if (this.gameWorld.getRobot(loc) != null)
321323
throw new GameActionException(CANT_DO_THAT, "Can't place trap on an occupied tile!");
322-
System.out.println("LOG 2");
323324
if (this.gameWorld.hasTrap(loc))
324325
throw new GameActionException(CANT_DO_THAT, "Tile already has a trap!");
325326
if (this.gameWorld.getTrapCount(trapType, this.robot.getTeam()) >= trapType.maxCount)
326327
throw new GameActionException(CANT_DO_THAT,
327328
"Team has reached maximum number of " + trapType + " traps on the map!");
328-
System.out.println("LOG 3");
329329
if (getAllCheese() < trapType.buildCost) {
330330
throw new GameActionException(CANT_DO_THAT, "Not enough cheese to build trap!");
331331
}

0 commit comments

Comments
 (0)