// export class Option {
//     type;
//     txt;
//     picUrl;
//     audioUrl;
//     public data;
//     public id: number;
//     public count: number;
//     constructor(data, id) {
//         this.id = id;
//         this.data = data;
//         this.type = data.type;
//         this.txt = data.text;
//         this.picUrl = data.image;
//         this.audioUrl = data.optionAudio;
//     }
// }
export class Item {
    public page;
    public audio;
    public image;
    public text;
    public type;
    public recordScore;
    public recordAudio;
    constructor(data, page) {
        this.audio = data.audio;
        this.image = data.image;
        this.text = data.text;
        this.type = data.type;
        this.recordScore = -1;
        this.page = page;
    }
}
export default class Game {
    private static ins: Game;
    public static getIns(): Game {
        if (!Game.ins) Game.ins = new Game();
        return Game.ins;
    }
    private data: any;
    public lists: Array<Item>
    public isRead: boolean;//record 录音模式   read 阅读模式
    constructor() {
        //
        this.start = false;
        this.lists = [];
    }
    get len() {
        return this.lists.length;
    }
    public init(data) {
        this.start = false;
        this.lists = [];
        this.data = data.questions;
        this.isRead = data.questionType == "read";
    }
    public start: boolean;
    public page: number;
    reset() {
        this.page = 1;
        this.start = true;
        this.lists = [];
        for (let i = 0; i < this.data.length; i++) {
            let data = this.data[i];
            this.lists.push(new Item(data, i));
        }
    }
    getDataByPage(page): Item {
        return this.lists.filter(li => li.page == page)[0]
    }
    getCurrentPage(): Item {
        let page = this.page;
        return this.lists.filter(li => li.page == page)[0]
    }
    getTotalPageNum() {
        return this.lists.length;
    }
    getCurrentPageNum() {
        return this.page;
    }
    addPage() {
        if (this.page >= this.lists.length) {
            return false;
        } else {
            this.page += 1;
            return true
        }
    }
    subPage() {
        if (this.page <= 1) {
            return false;
        } else {
            this.page -= 1;
            return true
        }
    }
    get isOver() {
        return this.page > this.lists.length;
    }
}

let win: any = window;
win.Game = Game;