/** * Occupies the given area for the given playerId if it is not already occupied by towers of an enemy. * * @param playerId * The id of the occupying player. * @param influencingArea * The area affected by the tower. * @param groundArea * The ground area of the tower. */ public void addTowerAndOccupyArea(byte playerId, MapCircle influencingArea, FreeMapArea groundArea) { IMapArea filteredArea = new MapShapeFilter(influencingArea, width, height); PartitionOccupyingTower tower = new PartitionOccupyingTower(playerId, influencingArea.getCenter(), groundArea, filteredArea, influencingArea.getBorders(), (int) influencingArea.getRadius()); occupyAreaOfTower(tower); }
@Test public void testGetBorders() { for (int i = 1; i < 40; i++) { MapCircle circle = new MapCircle(new ShortPoint2D(100, 100), i); SRectangle borders = circle.getBorders(); for (ShortPoint2D curr : circle) { if (!borders.contains(curr)) { fail("position: " + curr + " is not in the border " + borders + " radius: " + i); } } } }