/** * Adds on-board HexTargets within the MAX_ARTILLERY_BLAST_RADIUS of the given coordinates * to the given HexTarget set. * @param coords Center coordinates * @param targetList List of target hexes * @param game game pointer */ private void addHexDonuts(Coords coords, Set<Targetable> targetList, IGame game) { // while we're here, consider shooting at hexes within "MAX_BLAST_RADIUS" // of the designated coordinates for(int radius = 1; radius <= MAX_ARTILLERY_BLAST_RADIUS; radius++) { for(Coords donutHex : BotGeometry.getHexDonut(coords, radius)) { // don't bother adding off-board donuts. if(game.getBoard().contains(donutHex)) { targetList.add(new HexTarget(donutHex, game.getBoard(), Targetable.TYPE_HEX_ARTILLERY)); } } } }
BotGeometry.debugSelfTest(this); } finally { methodEnd(getClass(), METHOD_NAME);
/** * Debugging method that renders a hex donut around the given coordinates, with the given radius. * @param g Graphics object on which to draw. */ private void renderDonut(Graphics2D g, Coords coords, int radius) { Set<Coords> donut = BotGeometry.getHexDonut(coords, radius); for(Coords donutCoords : donut) { Point p = getCentreHexLocation(donutCoords.getX(), donutCoords.getY(), true); p.translate(HEX_W / 2, HEX_H / 2); drawHexBorder(g, p, Color.PINK, 0, 6); } } /**
for(Coords currentCoords : BotGeometry.getHexDonut(coords, distanceFromCenter)) { totalDamage += calculateDamageValueForHex(currentDamage, currentCoords, shooter, game, owner);
Coords testCoords = new Coords(0, 0); Set<Coords> resultingCoords = BotGeometry.getHexDonut(testCoords, 0); Assert.assertEquals(1, resultingCoords.size()); Assert.assertEquals(true, resultingCoords.contains(testCoords)); resultingCoords = BotGeometry.getHexDonut(testCoords, 1); resultingCoords = BotGeometry.getHexDonut(testCoords, 2);