public/js-roguelike-skeleton/src/valid-targets-finder.js
function(){
            var tiles = [];
            if(this.limitToFov){
                var fovTiles = this.limitToFov.visibleTiles;
                for (var i = 0; i < fovTiles.length; i++) {
                    var fovTile = fovTiles[i];
                    // if no max range, if there is a max range check it
                    if(!this.range || fovTile.range <= this.range){

                        // if including tile objects in result but not preparing them
                        if(this.includeTiles && !this.prepareValidTargets){
                            fovTile = fovTile.value;
                        }
                        tiles.push(fovTile);
                    }
                }
            } else {
                var x = this.x,
                    y = this.y;

                if(this.range === 1){
                    if(this.limitToNonDiagonalAdjacent){
                        tiles = this.game.map.getAdjacent(x, y, {withDiagonals: false});
                    }
                    else{
                        tiles = this.game.map.getAdjacent(x, y);
                    }
                } else {
                    tiles = this.game.map.getWithinSquareRadius(x, y, {radius: this.range});
                }

                // if including tile objects, prepare them
                if(this.includeTiles && this.prepareValidTargets){
                    var _this = this;
                    tiles = tiles.map(function(tile){
                        return _this.prepareTargetObject(tile);
                    });
                }
            }
            return tiles;
        }
function(){
            var tiles = [];
            if(this.limitToFov){
                var fovTiles = this.limitToFov.visibleTiles;
                for (var i = 0; i < fovTiles.length; i++) {
                    var fovTile = fovTiles[i];
                    // if no max range, if there is a max range check it
                    if(!this.range || fovTile.range <= this.range){

                        // if including tile objects in result but not preparing them
                        if(this.includeTiles && !this.prepareValidTargets){
                            fovTile = fovTile.value;
                        }
                        tiles.push(fovTile);
                    }
                }
            } else {
                var x = this.x,
                    y = this.y;

                if(this.range === 1){
                    if(this.limitToNonDiagonalAdjacent){
                        tiles = this.game.map.getAdjacent(x, y, {withDiagonals: false});
                    }
                    else{
                        tiles = this.game.map.getAdjacent(x, y);
                    }
                } else {
                    tiles = this.game.map.getWithinSquareRadius(x, y, {radius: this.range});
                }

                // if including tile objects, prepare them
                if(this.includeTiles && this.prepareValidTargets){
                    var _this = this;
                    tiles = tiles.map(function(tile){
                        return _this.prepareTargetObject(tile);
                    });
                }
            }
            return tiles;
        }
function ( ) { var tiles = [ ] ; if ( this . limitToFov ) { var fovTiles = this . limitToFov . visibleTiles ; for ( var i = 0 ; i < fovTiles . length ; i ++ ) { var fovTile = fovTiles [ i ] ; // if no max range, if there is a max range check it if ( ! this . range || fovTile . range <= this . range ) { // if including tile objects in result but not preparing them if ( this . includeTiles && ! this . prepareValidTargets ) { fovTile = fovTile . value ; } tiles . push ( fovTile ) ; } } } else { var x = this . x , y = this . y ; if ( this . range === 1 ) { if ( this . limitToNonDiagonalAdjacent ) { tiles = this . game . map . getAdjacent ( x , y , { withDiagonals : false } ) ; } else { tiles = this . game . map . getAdjacent ( x , y ) ; } } else { tiles = this . game . map . getWithinSquareRadius ( x , y , { radius : this . range } ) ; } // if including tile objects, prepare them if ( this . includeTiles && this . prepareValidTargets ) { var _this = this ; tiles = tiles . map ( function ( tile ) { return _this . prepareTargetObject ( tile ) ; } ) ; } } return tiles ; }
Get tile coords a valid target may be on. Only checking range and fov, not objects on the tile.
@method getValidTargetTiles
@return {Array} of Tile objects
Get tile coords a valid target may be on . Only checking range and fov not objects on the tile .