Skip to content

Commit 1963217

Browse files
Start initial towers at level 2
1 parent 2b9bdb2 commit 1963217

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,20 @@ public GameWorld(LiveMap gm, RobotControlProvider cp, GameMaker.MatchMaker match
130130
towersByLoc[i] = Team.NEUTRAL;
131131
}
132132
for (int i = 0; i < initialBodies.length; i++) {
133-
RobotInfo robot = initialBodies[i];
134-
MapLocation newLocation = robot.location.translate(gm.getOrigin().x, gm.getOrigin().y);
135-
spawnRobot(robot.ID, robot.type, newLocation, robot.team);
133+
RobotInfo robotInfo = initialBodies[i];
134+
MapLocation newLocation = robotInfo.location.translate(gm.getOrigin().x, gm.getOrigin().y);
135+
spawnRobot(robotInfo.ID, robotInfo.type, newLocation, robotInfo.team);
136136
this.towerLocations.add(newLocation);
137-
towersByLoc[locationToIndex(newLocation)] = robot.team;
137+
towersByLoc[locationToIndex(newLocation)] = robotInfo.team;
138138
this.allRuinsByLoc[locationToIndex(newLocation)] = true;
139139
this.allRuins.add(newLocation);
140+
141+
// Start initial towers at level 2. Defer upgrade action until the tower's first
142+
// turn since client only supports actions this way
143+
InternalRobot robot = getRobot(newLocation);
144+
UnitType newType = robot.getType().getNextLevel();
145+
robot.upgradeTower(newType);
146+
upgradeTower(newType, robot.getTeam());
140147
}
141148
}
142149

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,12 @@ public void processBeginningOfRound() {
596596
addPaint(this.type.paintPerTurn + this.gameWorld.extraResourcesFromPatterns(this.team));
597597
if (this.type.moneyPerTurn != 0)
598598
this.gameWorld.getTeamInfo().addMoney(this.team, this.type.moneyPerTurn+this.gameWorld.extraResourcesFromPatterns(this.team));
599+
600+
// Add upgrade action for initially upgraded starting towers
601+
if (this.type.isTowerType() && this.gameWorld.getCurrentRound() == 1 && this.type.level == 2) {
602+
this.getGameWorld().getMatchMaker().addUpgradeAction(getID(), getHealth(),
603+
getType().health, getPaint(), getType().paintCapacity);
604+
}
599605
}
600606

601607
public void processBeginningOfTurn() {

0 commit comments

Comments
 (0)