Skip to content

Commit 1d35d0e

Browse files
committed
make cats trigger traps when pouncing
1 parent f775e07 commit 1d35d0e

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,10 +940,12 @@ public void pounce(int[] delta) {
940940
int dy = delta[1];
941941

942942
MapLocation[] oldLocs = this.getAllPartLocations();
943+
943944
for (MapLocation partLoc : oldLocs) {
944945
// shift location by dx, dy
945946
MapLocation translatedLoc = partLoc.translate(dx, dy);
946947
InternalRobot crushedRobot = this.gameWorld.getRobot(translatedLoc);
948+
947949
if (crushedRobot != null && (crushedRobot.getID() != this.ID)) {
948950
// destroy robot
949951
crushedRobot.addHealth(-crushedRobot.getHealth());
@@ -953,10 +955,15 @@ public void pounce(int[] delta) {
953955
// actually translate the cat
954956
this.translateLocation(dx, dy);
955957

958+
MapLocation[] newLocs = this.getAllPartLocations();
959+
960+
for (MapLocation partLoc : newLocs) {
961+
this.controller.processTrapsAtLocation(partLoc);
962+
}
963+
956964
// incur double the movement cooldown
957965
this.addMovementCooldownTurns(this.dir);
958966
this.addMovementCooldownTurns(this.dir);
959-
960967
}
961968

962969
public MapLocation getCatCornerByChirality(){

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

0 commit comments

Comments
 (0)