Skip to content

Commit 84fa007

Browse files
committed
thrown robot collision damage change, remove flying robot that hit cat, destroy flying robots that died, don't allow flying robots to pick up cheese
1 parent 3bc783b commit 84fa007

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@ public void destroyRobot(int id, boolean fromException, boolean fromDamage) {
11371137

11381138
for (MapLocation robotLoc : robot.getAllPartLocations()) {
11391139
removeRobot(robotLoc);
1140+
removeFlyingRobot(robotLoc);
11401141
}
11411142

11421143
if (robot.isCarryingRobot()) {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,8 @@ private void getThrown(Direction dir) {
724724

725725
this.setInternalLocationOnly(this.getLocation());
726726

727-
this.travelFlying(true);
728727
this.travelFlying(false);
728+
this.travelFlying(true);
729729
}
730730

731731
public void getDropped(MapLocation loc) {
@@ -786,6 +786,10 @@ public void hitTarget(boolean isSecondMove) {
786786
InternalRobot robot = this.gameWorld.getRobot(this.getLocation().add(this.thrownDir));
787787
robot.addHealth(-damage);
788788
}
789+
else if (this.gameWorld.getFlyingRobot(this.getLocation().add(this.thrownDir)) != null){
790+
InternalRobot robot = this.gameWorld.getFlyingRobot(this.getLocation().add(this.thrownDir));
791+
robot.remainingThrowDuration = 1; // force other robot to drop to ground as well on next turn
792+
}
789793
this.thrownDir = null;
790794
this.remainingThrowDuration = 0;
791795

@@ -821,6 +825,7 @@ public void travelFlying(boolean isSecondMove) {
821825
} else if (this.gameWorld.getRobot(newLoc) != null
822826
&& this.gameWorld.getRobot(newLoc).getType() == UnitType.CAT) {
823827
// cat feeding!
828+
this.gameWorld.removeFlyingRobot(this.location);
824829
this.addHealth(-this.getHealth()); // rat dies :(
825830
// put cat to sleep
826831
this.gameWorld.getRobot(newLoc).sleepTimeRemaining = GameConstants.CAT_SLEEP_TIME;

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,10 @@ private void assertCanPickUpCheese(MapLocation loc) throws GameActionException {
469469
if (myType != UnitType.BABY_RAT && myType != UnitType.RAT_KING) {
470470
throw new GameActionException(CANT_DO_THAT, "Only rats can pick up cheese");
471471
}
472+
473+
if (this.robot.isBeingThrown()){
474+
throw new GameActionException(CANT_DO_THAT, "Flying rats cannot pick up cheese");
475+
}
472476
}
473477

474478
@Override
@@ -551,7 +555,8 @@ public RobotInfo senseRobotAtLocation(MapLocation loc) throws GameActionExceptio
551555
@Override
552556
public boolean canSenseRobot(int id) {
553557
InternalRobot sensedRobot = getRobotByID(id);
554-
return sensedRobot != null && canSenseLocation(sensedRobot.getLocation());
558+
Boolean isFlying = sensedRobot.isBeingThrown();
559+
return sensedRobot != null && isFlying && canSenseLocation(sensedRobot.getLocation());
555560
}
556561

557562
@Override

0 commit comments

Comments
 (0)