Skip to content

Commit d8b7776

Browse files
committed
changes to throwing/carrying
1 parent 81d48df commit d8b7776

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,7 @@ private void swapGrabber() {
653653
this.gameWorld.getMatchMaker().addRatNapAction(this.ID); // expand this rat
654654
this.gameWorld.getMatchMaker().addRatNapAction(grabber.ID); // shrink carrier rat
655655

656-
if (grabber.getTeam() != this.getTeam()) {
657-
grabber.remainingCarriedDuration = GameConstants.MAX_CARRY_DURATION;
658-
}
656+
grabber.remainingCarriedDuration = GameConstants.MAX_CARRY_DURATION;
659657
}
660658

661659
private void getGrabbed(InternalRobot grabber) {
@@ -669,9 +667,7 @@ private void getGrabbed(InternalRobot grabber) {
669667

670668
this.setInternalLocationOnly(grabber.getLocation());
671669

672-
if (grabber.getTeam() != this.getTeam()) {
673-
this.remainingCarriedDuration = GameConstants.MAX_CARRY_DURATION;
674-
}
670+
this.remainingCarriedDuration = GameConstants.MAX_CARRY_DURATION;
675671

676672
}
677673

@@ -689,18 +685,11 @@ private void getThrown(Direction dir) {
689685
this.thrownDir = dir;
690686
this.remainingThrowDuration = 4;
691687

692-
MapLocation nextLoc = this.getLocation().add(dir);
688+
this.setInternalLocationOnly(this.getLocation());
689+
this.gameWorld.removeRobot(this.getLocation());
693690

694-
// Cat feeding!
695-
if (this.gameWorld.getRobot(nextLoc) != null) { // there's a cat here
696-
this.addHealth(-this.getHealth()); // rat dies :(
697-
// put cat to sleep
698-
this.gameWorld.getRobot(nextLoc).sleepTimeRemaining = GameConstants.CAT_SLEEP_TIME;
699-
this.gameWorld.getMatchMaker().addCatFeedAction(this.getID());
700-
} else {
701-
this.setInternalLocationOnly(this.getLocation().add(dir));
702-
this.gameWorld.removeRobot(this.getLocation());
703-
}
691+
this.travelFlying(true);
692+
this.travelFlying(false);
704693
}
705694

706695
public void getDropped(MapLocation loc) {
@@ -1059,8 +1048,7 @@ public void processBeginningOfTurn() {
10591048
this.gameWorld.runCheeseMines();
10601049

10611050
// if rat is being carried
1062-
if (this.getType() == UnitType.BABY_RAT && this.isGrabbedByRobot()
1063-
&& this.getGrabbedByRobot().getTeam() != this.getTeam()) {
1051+
if (this.getType() == UnitType.BABY_RAT && this.isGrabbedByRobot()) {
10641052

10651053
// check if grabber has died
10661054
if (this.getGrabbedByRobot().getHealth() <= 0) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ public void assertCanCarryRat(MapLocation loc) throws GameActionException {
13281328
}
13291329

13301330
// adjacency
1331-
if (!loc.isAdjacentTo(this.getLocation())) {
1331+
if (!loc.isAdjacentTo(this.getLocation()) && !this.getLocation().equals(loc)) {
13321332
throw new GameActionException(CANT_DO_THAT, "A rat can only grab adjacent robots!");
13331333
}
13341334

0 commit comments

Comments
 (0)