File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
engine/src/main/battlecode/world Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -577,11 +577,23 @@ public int getTowerPattern(UnitType towerType) {
577577 }
578578
579579 public boolean isValidPatternCenter (MapLocation loc ) {
580- return !(loc .x < GameConstants .PATTERN_SIZE / 2
580+ return ( !(loc .x < GameConstants .PATTERN_SIZE / 2
581581 || loc .y < GameConstants .PATTERN_SIZE / 2
582582 || loc .x >= gameMap .getWidth () - (GameConstants .PATTERN_SIZE - 1 ) / 2
583583 || loc .y >= gameMap .getHeight () - (GameConstants .PATTERN_SIZE - 1 ) / 2
584- );
584+ )) && areaIsPaintable (loc ) ;
585+ }
586+
587+ // checks that location has no walls/ruins in the surrounding 5x5 area
588+ public boolean areaIsPaintable (MapLocation loc ){
589+ for (int dx = -GameConstants .PATTERN_SIZE / 2 ; dx < (GameConstants .PATTERN_SIZE + 1 ) / 2 ; dx ++) {
590+ for (int dy = -GameConstants .PATTERN_SIZE / 2 ; dy < (GameConstants .PATTERN_SIZE + 1 ) / 2 ; dy ++) {
591+ MapLocation newLoc = loc .translate (dx , dy );
592+ if (!isPaintable (newLoc ))
593+ return false ;
594+ }
595+ }
596+ return true ;
585597 }
586598
587599 public boolean isPassable (MapLocation loc ) {
You can’t perform that action at this time.
0 commit comments