Skip to content

Commit 7b86c66

Browse files
committed
Merge branch 'engine-bugfix-2' of github.com:battlecode/battlecode26 into trap_changes
2 parents 06bca17 + 0dd2d36 commit 7b86c66

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

engine/src/main/battlecode/common/RobotController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public interface RobotController {
130130
*
131131
* @battlecode.doc.costlymethod
132132
*/
133-
public int getGlobalCheese();
133+
int getGlobalCheese();
134134

135135
/**
136136
* Returns the amount of cheese the robot has access to.
@@ -139,7 +139,7 @@ public interface RobotController {
139139
*
140140
* @battlecode.doc.costlymethod
141141
*/
142-
public int getAllCheese();
142+
int getAllCheese();
143143

144144
/**
145145
* Returns the amount of dirt that this robot's team has.
@@ -1035,4 +1035,4 @@ void setIndicatorLine(MapLocation startLoc, MapLocation endLoc, int red, int gre
10351035
void setTimelineMarker(String label, int red, int green, int blue);
10361036
}
10371037
// TODO: update bytecode costs, particularly for new methods + methods that got
1038-
// renamed from last year
1038+
// renamed from last year

engine/src/main/battlecode/common/UnitType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public MapLocation[] getAllTypeLocations(MapLocation center) {
7474
return locs;
7575
}
7676

77-
UnitType(int health, int size, int visionConeRadius, int visionConeAngle, int actionCooldown,
77+
UnitType(int health, int size, int visionConeRadiusSquared, int visionConeAngle, int actionCooldown,
7878
int movementCooldown, int bytecodeLimit) {
7979
this.health = health;
8080
this.size = size;
81-
this.visionConeRadiusSquared = visionConeRadius;
81+
this.visionConeRadiusSquared = visionConeRadiusSquared;
8282
this.visionConeAngle = visionConeAngle;
8383
this.actionCooldown = actionCooldown;
8484
this.movementCooldown = movementCooldown;

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)