public/js-roguelike-skeleton/src/valid-targets.js
function(game, targets, settings){
        this.game = game;

        settings = settings || {};
        this.typeSortPriority = settings.typeSortPriority || [].concat(this.typeSortPriority);

        var width = settings.mapWidth || this.game.map.width;
        var height = settings.mapWidth || this.game.map.width;

        this.map = new RL.MultiObjectManager(this.game, null, width, height);
        this.setTargets(targets);
        if(!settings.skipSort){
            this.sort();
        }
    }
function(game, targets, settings){
        this.game = game;

        settings = settings || {};
        this.typeSortPriority = settings.typeSortPriority || [].concat(this.typeSortPriority);

        var width = settings.mapWidth || this.game.map.width;
        var height = settings.mapWidth || this.game.map.width;

        this.map = new RL.MultiObjectManager(this.game, null, width, height);
        this.setTargets(targets);
        if(!settings.skipSort){
            this.sort();
        }
    }
function ( game , targets , settings ) { this . game = game ; settings = settings || { } ; this . typeSortPriority = settings . typeSortPriority || [ ] . concat ( this . typeSortPriority ) ; var width = settings . mapWidth || this . game . map . width ; var height = settings . mapWidth || this . game . map . width ; this . map = new RL . MultiObjectManager ( this . game , null , width , height ) ; this . setTargets ( targets ) ; if ( ! settings . skipSort ) { this . sort ( ) ; } }
Manages a list of valid targets and which is currently selected.
@class ValidTargets
@constructor
@param {Game} game - Game instance this obj is attached to.
@param {Array} [targets=Array] An Array of valid target objects to select from (intended to be in the format `validTargetsFinder.getValidTargets()` returns).
@param {Object} settings
@param {Array} [settings.typeSortPriority=this.typeSortPriority] - Array of types in order of their sort priority.
@param {Bool} [settings.mapWidth=game.map.width] - Width of `this.map`.
@param {Bool} [settings.mapHeight=game.map.height] - Height of `this.map`.
@param {Bool} [settings.skipSort=false] - If true initial sort is skipped.
Manages a list of valid targets and which is currently selected .