{"size": 1185, "ext": "js", "max_stars_repo_path": "node_modules/phaser3-rex-plugins/templates/bejeweled/board/chess/RandomSymobl.js", "max_stars_repo_name": "SamueleDelMoro/ACTAM.Project2122-TraningGame", "max_stars_repo_stars_event_min_datetime": "2018-03-29T05:11:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T14:02:58.000Z", "max_issues_repo_path": "node_modules/phaser3-rex-plugins/templates/bejeweled/board/chess/RandomSymobl.js", "max_issues_repo_name": "SamueleDelMoro/ACTAM.Project2122-TraningGame", "max_issues_repo_issues_event_min_datetime": "2018-07-20T07:39:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T23:08:01.000Z", "max_forks_repo_path": "node_modules/phaser3-rex-plugins/templates/bejeweled/board/chess/RandomSymobl.js", "max_forks_repo_name": "SamueleDelMoro/ACTAM.Project2122-TraningGame", "max_forks_repo_forks_event_min_datetime": "2018-05-17T06:45:48.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T11:48:52.000Z"}
{"max_stars_count": 888, "max_issues_count": 194, "max_forks_count": 262, "avg_line_length": 31.1842105263, "max_line_length": 78, "alphanum_fraction": 0.5316455696}
const GetRandom = Phaser.Utils.Array.GetRandom;

var RandomSymbol = function (board, tileX, tileY, callback, scope, excluded) {
    var symbol;
    if (Array.isArray(callback)) {
        // pick random symbol from symbol array
        var symbols = callback;
        // excluded: undefined or a symbol array
        if (excluded !== undefined) {
            for (var i = 0, cnt = symbols.length; i < cnt; i++) {
                symbol = symbols[i];
                if (excluded.indexOf(symbol) !== -1) {
                    continue;
                }
                tmpSymbolArray.push(symbol);
            }
            symbol = GetRandom(tmpSymbolArray);
            tmpSymbolArray.length = 0;
        } else {
            symbol = GetRandom(symbols);
        }

    } else if (typeof (obj) === 'function') {
        // symbols from return of callback
        if (scope) {
            symbol = callback.call(scope, board, tileX, tileY, excluded);
        } else {
            symbol = callback(board, tileX, tileY, excluded);
        }
    } else {
        // symbol value
        symbol = callback;
    }
    return symbol;
}

var tmpSymbolArray = [];
export default RandomSymbol;