Skip to content

Commit 439f957

Browse files
author
Ian Gonzalez Hermosillo
committed
completing tower patterns costs chips
1 parent 1837805 commit 439f957

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

engine/src/main/battlecode/common/UnitType.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ public enum UnitType {
55
SPLASHER(300, 400, 50, 150, -1, 300, 50, 8, -1, 50, 0, 0),
66
MOPPER(100, 300, 0, 50, -1, 100, 30, 2, -1, -1, 0, 0),
77

8-
LEVEL_ONE_PAINT_TOWER(0, 25, 0, 1000, 1, 1000, 10, 9, 20, 10, 5, 0),
8+
LEVEL_ONE_PAINT_TOWER(0, 100, 0, 1000, 1, 1000, 10, 9, 20, 10, 5, 0),
99
LEVEL_TWO_PAINT_TOWER(0, 250, 0, 1500, 2, 1000, 10, 9, 20, 10, 10, 0),
1010
LEVEL_THREE_PAINT_TOWER(0, 500, 0, 2000, 3, 1000, 10, 9, 20, 10, 15, 0),
1111

12-
LEVEL_ONE_MONEY_TOWER(0, 25, 0, 1000, 1, 1000, 10, 9, 20, 10, 0, 10),
12+
LEVEL_ONE_MONEY_TOWER(0, 100, 0, 1000, 1, 1000, 10, 9, 20, 10, 0, 10),
1313
LEVEL_TWO_MONEY_TOWER(0, 250, 0, 1500, 2, 1000, 10, 9, 20, 10, 0, 15),
1414
LEVEL_THREE_MONEY_TOWER(0, 500, 0, 2000, 3, 1000, 10, 9, 20, 10, 0, 20),
1515

16-
LEVEL_ONE_DEFENSE_TOWER(0, 25, 0, 2500, 1, 1000, 10, 20, 60, 30, 0, 0),
16+
LEVEL_ONE_DEFENSE_TOWER(0, 100, 0, 2500, 1, 1000, 10, 20, 60, 30, 0, 0),
1717
LEVEL_TWO_DEFENSE_TOWER(0, 250, 0, 3000, 2, 1000, 10, 20, 65, 35, 0, 0),
1818
LEVEL_THREE_DEFENSE_TOWER(0, 500, 0, 3500, 3, 1000, 10, 20, 70, 40, 0, 0);
1919

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,20 @@ public void markResourcePattern(MapLocation loc, int rotationAngle, boolean refl
708708
this.gameWorld.markResourcePattern(getTeam(), loc, rotationAngle, reflect);
709709
}
710710

711+
private UnitType getBaseUnitType(UnitType type){
712+
UnitType baseType;
713+
switch (type){
714+
case LEVEL_TWO_DEFENSE_TOWER: baseType = UnitType.LEVEL_ONE_DEFENSE_TOWER; break;
715+
case LEVEL_THREE_DEFENSE_TOWER: baseType = UnitType.LEVEL_ONE_DEFENSE_TOWER; break;
716+
case LEVEL_TWO_MONEY_TOWER: baseType = UnitType.LEVEL_ONE_MONEY_TOWER; break;
717+
case LEVEL_THREE_MONEY_TOWER: baseType = UnitType.LEVEL_ONE_MONEY_TOWER; break;
718+
case LEVEL_TWO_PAINT_TOWER: baseType = UnitType.LEVEL_ONE_PAINT_TOWER; break;
719+
case LEVEL_THREE_PAINT_TOWER: baseType = UnitType.LEVEL_ONE_PAINT_TOWER; break;
720+
default: baseType = type;
721+
}
722+
return baseType;
723+
}
724+
711725
private void assertCanCompleteTowerPattern(UnitType type, MapLocation loc) throws GameActionException {
712726
assertIsRobotType(this.robot.getType());
713727
assertIsTowerType(type);
@@ -725,6 +739,12 @@ private void assertCanCompleteTowerPattern(UnitType type, MapLocation loc) throw
725739
+ ") because the center is not a ruin");
726740
}
727741

742+
if (getMoney() < getBaseUnitType(type).moneyCost){
743+
throw new GameActionException(CANT_DO_THAT,
744+
"Cannot complete tower pattern centered at (" + loc.x + ", " + loc.y
745+
+ ") because the team does not have enough money!");
746+
}
747+
728748
if (!this.gameWorld.isValidPatternCenter(loc)) {
729749
throw new GameActionException(CANT_DO_THAT,
730750
"Cannot complete tower pattern centered at (" + loc.x + ", " + loc.y
@@ -768,6 +788,7 @@ public void completeTowerPattern(UnitType type, MapLocation loc) throws GameActi
768788
assertCanCompleteTowerPattern(type, loc);
769789
this.gameWorld.completeTowerPattern(getTeam(), type, loc);
770790
InternalRobot tower = this.gameWorld.getRobot(loc);
791+
this.gameWorld.getTeamInfo().addMoney(getTeam(), -getBaseUnitType(type).moneyCost);
771792
this.gameWorld.getMatchMaker().addSpawnAction(tower.getID(), loc, tower.getTeam(), type);
772793
this.gameWorld.getMatchMaker().addBuildAction(tower.getID());
773794
}

0 commit comments

Comments
 (0)