From 2f41b58b425e8b8d6f3b53ade9f2109aef375e83 Mon Sep 17 00:00:00 2001 From: Elizabeth Zou Date: Sat, 1 Jan 2022 14:22:27 -0600 Subject: [PATCH] send change health action for prototype initialization --- engine/src/main/battlecode/world/InternalRobot.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/engine/src/main/battlecode/world/InternalRobot.java b/engine/src/main/battlecode/world/InternalRobot.java index 50d12f37..b2fcf2fb 100644 --- a/engine/src/main/battlecode/world/InternalRobot.java +++ b/engine/src/main/battlecode/world/InternalRobot.java @@ -59,6 +59,7 @@ 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()) { @@ -66,7 +67,13 @@ public InternalRobot(GameWorld gw, int id, RobotType type, MapLocation loc, Team } 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;