| Chunk |
|---|
| Conflicting content |
|---|
}
/**
<<<<<<< HEAD
* Ensure that actions take place immediately.
*/
@Test
public void testImmediateActions() throws GameActionException {
TestMapGenerator mapGen = new TestMapGenerator(3, 1, 20);
GameMap map = mapGen.getMap("test");
TestGame game = new TestGame(map);
int oX = game.getOriginX();
int oY = game.getOriginY();
final int a = game.spawn(oX, oY, RobotType.SOLDIER, Team.A);
final int b = game.spawn(oX + 2, oY, RobotType.SOLDIER, Team.B);
game.round((id, rc) -> {
if (id != a) return;
final MapLocation start = rc.getLocation();
assertEquals(start, new MapLocation(oX, oY));
rc.move(Direction.EAST);
final MapLocation newLocation = rc.getLocation();
assertEquals(newLocation, new MapLocation(oX + 1, oY));
});
// Let delays go away
game.waitRounds(10);
game.round((id, rc) -> {
if (id != a) return;
MapLocation bLoc = new MapLocation(oX + 2, oY);
RobotInfo bInfo = rc.senseRobotAtLocation(bLoc);
assertEquals(RobotType.SOLDIER.maxHealth, bInfo.health, .00001);
rc.attackLocation(new MapLocation(oX + 2, oY));
RobotInfo bInfoNew = rc.senseRobotAtLocation(bLoc);
assertEquals(RobotType.SOLDIER.maxHealth - RobotType.SOLDIER.attackPower,
bInfoNew.health,
.00001);
});
=======
* Makes sure that parts costs are properly subtracted when building a unit.
*/
@Test
public void testPartsCost() throws GameActionException {
TestMapGenerator mapGen = new TestMapGenerator(10, 10, 100);
GameMap map = mapGen.getMap("test");
TestGame game = new TestGame(map);
int oX = game.getOriginX();
int oY = game.getOriginY();
final int archon = game.spawn(oX, oY, RobotType.ARCHON, Team.A);
assertEquals(game.getWorld().resources(Team.A), GameConstants
.PARTS_INITIAL_AMOUNT, EPSILON);
game.round((id, rc) -> {
if (id == archon) {
rc.build(Direction.SOUTH_EAST, RobotType.SOLDIER);
}
});
assertEquals(game.getWorld().resources(Team.A), GameConstants
.PARTS_INITIAL_AMOUNT - RobotType.SOLDIER.partCost +
GameConstants.ARCHON_PART_INCOME, EPSILON);
>>>>>>> f90b589f8531a140bee5bb3fc428c6294d7a3b84
}
} |
| Solution content |
|---|
}
/**
* Ensure that actions take place immediately.
*/
@Test
public void testImmediateActions() throws GameActionException {
TestMapGenerator mapGen = new TestMapGenerator(3, 1, 20);
GameMap map = mapGen.getMap("test");
TestGame game = new TestGame(map);
int oX = game.getOriginX();
int oY = game.getOriginY();
final int a = game.spawn(oX, oY, RobotType.SOLDIER, Team.A);
final int b = game.spawn(oX + 2, oY, RobotType.SOLDIER, Team.B);
game.round((id, rc) -> {
if (id != a) return;
final MapLocation start = rc.getLocation();
assertEquals(start, new MapLocation(oX, oY));
rc.move(Direction.EAST);
final MapLocation newLocation = rc.getLocation();
assertEquals(newLocation, new MapLocation(oX + 1, oY));
});
// Let delays go away
game.waitRounds(10);
game.round((id, rc) -> {
if (id != a) return;
MapLocation bLoc = new MapLocation(oX + 2, oY);
RobotInfo bInfo = rc.senseRobotAtLocation(bLoc);
assertEquals(RobotType.SOLDIER.maxHealth, bInfo.health, .00001);
rc.attackLocation(new MapLocation(oX + 2, oY));
RobotInfo bInfoNew = rc.senseRobotAtLocation(bLoc);
assertEquals(RobotType.SOLDIER.maxHealth - RobotType.SOLDIER.attackPower,
bInfoNew.health,
.00001);
});
}
/**
* Makes sure that parts costs are properly subtracted when building a unit.
*/
@Test
public void testPartsCost() throws GameActionException {
TestMapGenerator mapGen = new TestMapGenerator(10, 10, 100);
GameMap map = mapGen.getMap("test");
TestGame game = new TestGame(map);
int oX = game.getOriginX();
int oY = game.getOriginY();
final int archon = game.spawn(oX, oY, RobotType.ARCHON, Team.A);
assertEquals(game.getWorld().resources(Team.A), GameConstants
.PARTS_INITIAL_AMOUNT, EPSILON);
game.round((id, rc) -> {
if (id == archon) {
rc.build(Direction.SOUTH_EAST, RobotType.SOLDIER);
}
});
assertEquals(game.getWorld().resources(Team.A), GameConstants
.PARTS_INITIAL_AMOUNT - RobotType.SOLDIER.partCost +
GameConstants.ARCHON_PART_INCOME, EPSILON);
}
} |
| File |
|---|
| RobotControllerTest.java |
| Developer's decision |
|---|
| Concatenation |
| Kind of conflict |
|---|
| Annotation |
| Comment |
| Method signature |