import { ChapterData } from "../interface/ChapterData";
import { Chapters1 } from "./Chapter1";
import { Chapters2 } from "./Chapter2";
import { Chapters3 } from "./Chapter3";
import { Chapters4 } from "./Chapter4";
import { Chapters5 } from "./Chapter5";
import { Chapters6 } from "./Chapter6";
import { Chapters7 } from "./Chapter7";
import { Chapters8 } from "./Chapter8";
import { Chapters9 } from "./Chapter9";
import { Chapters10 } from "./Chapter10";
import { Chapters11 } from "./Chapter11";
import { PassTargetData } from "../interface/PassTargetData";
import { PassType } from "../enum/PassType";
// import { submitTran } from "../enum/ElementType";
import { Chapters12 } from "./Chapter12";

//所有的关卡
const chapters: ChapterData[] = [].concat(
    Chapters1,
    Chapters2,
    Chapters3,
    Chapters4,
    Chapters5,
    Chapters6,
    // Chapters7,
    // Chapters8,
    // Chapters9,
    // Chapters10,
    // Chapters11,
    // Chapters12,
)
/**
 * 获取关卡数据，返回关卡数据
 * 以后每添加20关，添加一个文件，上面concat一个文件
 * @param index 关数 从1开始
 */
export function getChapterData(index: number): ChapterData {
    //没有数据就返回第一关数据
    return chapters[index] || chapters[1];
}

var a = {
    "lev": 102,
    "tar": [
        { "type": 5, "num": 40 }
    ],
    "one": 6000,
    "two": 15000,
    "three": 32000
};
//取数据格式用，一般情况注释
// (function exportFile(chapters: ChapterData[]) {
//     var obj = []
//     for (var i = 1; i < chapters.length; i++) {
//         var chapter: ChapterData = chapters[i]
//         var target: PassTargetData = chapter.passTarget
//         var a: any = {};
//         a["lev"] = i;
//         a["tar"] = [];
//         if (target.type == PassType.SCORE_TARGET) {
//             a["tar"].push({ "type": 1, "num": target.score })
//         } else {
//             for (var j = 0; j < target.elements.length; j++) {
//                 var element = target.elements[j];
//                 a["tar"].push({ "type": submitTran[element.type], "num": element.count })
//             }
//         }

//         a["one"] = chapter.starScores[0];
//         a["two"] = chapter.starScores[1];
//         a["three"] = chapter.starScores[2];

//         obj.push(a)
//     }
//     var file = new File([JSON.stringify(obj)], "cfg.json", { type: "text/plain;charset=utf-8" });
//     window["saveAs"](file);
// })(chapters)