Skip to content

Commit

Permalink
Merge pull request #29 from battlecode/engine-fixes
Browse files Browse the repository at this point in the history
send change health action for prototype initialization
  • Loading branch information
wflms20110333 authored Jan 1, 2022
2 parents 5a7ce61 + 2f41b58 commit fa1d1fd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion engine/src/main/battlecode/world/InternalRobot.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,21 @@ public InternalRobot(GameWorld gw, int id, RobotType type, MapLocation loc, Team
this.type = type;
this.location = loc;
this.level = 1;

if (this.type == RobotType.ARCHON) {
this.mode = RobotMode.TURRET;
} else if (this.type.isBuilding()) {
this.mode = RobotMode.PROTOTYPE;
} else {
this.mode = RobotMode.DROID;
}
this.health = (int) ((this.mode == RobotMode.PROTOTYPE ? GameConstants.PROTOTYPE_HP_PERCENTAGE : 1) * this.type.getMaxHealth(this.level));

this.health = this.type.getMaxHealth(this.level);
if (this.mode == RobotMode.PROTOTYPE) {
int newHealth = (int) (GameConstants.PROTOTYPE_HP_PERCENTAGE * this.health);
this.gameWorld.getMatchMaker().addAction(getID(), Action.CHANGE_HEALTH, newHealth - this.health);
this.health = newHealth;
}

this.controlBits = 0;
this.currentBytecodeLimit = type.bytecodeLimit;
Expand Down

0 comments on commit fa1d1fd

Please sign in to comment.