module JD {

    export function loadScript(gameType) {
        var scr = document.createElement("script");
        scr.src = "Games/Elements/" + GameTypes[gameType] + "/" + GameTypes[gameType] + ".js";
        document.getElementsByTagName('head')[0].appendChild(scr);
    }
    
    function initGame(alias, attrs, game, x, y) {
      return new GameGroups.StartingGroup(game, attrs[0], x, y, attrs[1]);
    }

    export function decode(arr, json, game) {
        var ret = [];
        var len = json.length;
        for (var i = 0; i < len; i++) {
            ret.push(initGame(json[i].GameType, json[i].attrs, game,(i + 1) * Global.Main.dims.x, 0));
        }
        ret = arr.concat(ret);
        return ret;
    }
}

