{"size": 1362, "ext": "js", "max_stars_repo_path": "node_modules/phaser3-rex-plugins/plugins/gameobjects/dynamictext/textplayer/parser/sprites/OnParseChainAnimationTag.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/plugins/gameobjects/dynamictext/textplayer/parser/sprites/OnParseChainAnimationTag.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/plugins/gameobjects/dynamictext/textplayer/parser/sprites/OnParseChainAnimationTag.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": 30.2666666667, "max_line_length": 80, "alphanum_fraction": 0.533773862}
import AppendCommandBase from '../../../dynamictext/methods/AppendCommand.js';

const GetValue = Phaser.Utils.Objects.GetValue;

var IsChainAnimationTag = function (tags, prefix) {
    // sprite.name.chain 
    return (tags.length === 3) && (tags[0] === prefix) && (tags[2] === 'chain');
}

var OnParseChainAnimationTag = function (textPlayer, parser, config) {
    var prefix = GetValue(config, 'sprite', 'sprite');
    if (!prefix) {
        return;
    }
    parser
        .on('+', function (tag) {
            if (parser.skipEventFlag) {  // Has been processed before
                return;
            }

            // [sprite.name.chain=key]
            var tags = tag.split('.');
            var name;
            if (IsChainAnimationTag(tags, prefix)) {
                name = tags[1];
            } else {
                return;
            }
            var keys = Array.prototype.slice.call(arguments, 1);
            AppendCommandBase.call(textPlayer,
                'sprite.chain',   // name
                ChainAnimation,   // callback
                [name, keys],     // params
                textPlayer,       // scope
            );
            parser.skipEvent();
        })
}

var ChainAnimation = function (params) {
    // this: textPlayer
    this.spriteManager.chainAnimation(...params);
}

export default OnParseChainAnimationTag;