Skip to content

Commit 5ea1de0

Browse files
committed
fix python docs and fix carrying rat king bug
1 parent 64ec98e commit 5ea1de0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

engine/src/crossplay_python/python_docs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def is_adjacent_to(loc1: MapLocation, loc2: MapLocation) -> bool:
4444
def is_within_distance_squared(loc1: MapLocation, loc2: MapLocation, distance_squared: int, theta: float = 360, use_bottom_left: bool = False) -> bool:
4545
pass
4646

47-
def get_all_type_locations(unit_type: UnitType, center: MapLocation) -> list[MapLocation]
47+
def get_all_type_locations(unit_type: UnitType, center: MapLocation) -> list[MapLocation]:
4848
pass
4949

5050
# use the alias "rc" for conciseness in your bot.py file when using RobotController methods

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,12 +1139,26 @@ public void becomeRatKing() throws GameActionException {
11391139
this.gameWorld.getTeamInfo().addCheese(this.getTeam(), currentRobot.getCheese());
11401140
currentRobot.addCheese(-currentRobot.getCheese());
11411141

1142+
if (currentRobot.isCarryingRobot()) {
1143+
// you steal the cheese of the robot they are carrying if it's an enemy,
1144+
// or just add it to your global cheese if it's an ally
1145+
InternalRobot robotBeingCarried = currentRobot.getRobotBeingCarried();
1146+
this.gameWorld.getTeamInfo().addCheese(this.getTeam(), robotBeingCarried.getCheese());
1147+
robotBeingCarried.addCheese(-robotBeingCarried.getCheese());
1148+
robotBeingCarried.addHealth(-robotBeingCarried.getHealth());
1149+
}
1150+
11421151
// all robots in the 3x3 including enemies die
11431152
currentRobot.addHealth(-currentRobot.getHealth());
11441153
}
11451154
this.gameWorld.addRobot(this.adjacentLocation(d), this.robot);
11461155
}
11471156

1157+
if (this.robot.isCarryingRobot()) {
1158+
InternalRobot robotBeingCarried = this.robot.getRobotBeingCarried();
1159+
robotBeingCarried.addHealth(-robotBeingCarried.getHealth());
1160+
}
1161+
11481162
this.gameWorld.getTeamInfo().addCheese(this.getTeam(), -GameConstants.RAT_KING_UPGRADE_CHEESE_COST);
11491163
health = Math.min(health, UnitType.RAT_KING.health);
11501164

0 commit comments

Comments
 (0)