import Data from "../script/defaultData";
interface Item {
    id: number;
    text: string;
    pic: string;
    type: string;
    right: string;
}
export default class Game {
    private static ins: Game;
    public static getIns(): Game {
        if (!Game.ins) Game.ins = new Game();
        return Game.ins;
    }
    private lists: Array<any>
    private nowStem: any;
    public pause: boolean;
    public isRobot: boolean;
    public playerScore: number;
    public robotScore: number;
    public robotLevel: number;
    constructor() {
        //
    }
    reset() {
        this.lists = JSON.parse(JSON.stringify(Data.list));
        this.pause = false;
        this.isRobot = false;
        this.playerScore = 0;
        this.robotScore = 0;
        let rand = Math.random();
        if (rand < 0.3) {
            this.robotLevel = 0;//0 1 2 三个级别 0 最高
        } else if (rand < 0.6) {
            this.robotLevel = 1;//0 1 2 三个级别 0 最高
        } else {
            this.robotLevel = 2;//0 1 2 三个级别 0 最高
        }
    }
    addScore() {
        if (this.isRobot) {
            this.robotScore++;
        } else {
            this.playerScore++;
        }
        this.nowStem.stem.times--;
        this.nowStem = null;
    }
    get nowList() {
        if (this.nowStem) {
            return this.nowStem.list;
        }
        //每一个企鹅是什么应该在这边获取。
        let items: any = this.lists.filter(li => {
            return li.stem.times > 0;
        });
        let item = items[Math.floor(Math.random() * items.length)]
        this.nowStem = item;
        return item.list;
    }
    get isOver() {
        let times = 0;
        this.lists.forEach((li) => {
            times += li.stem.times;
        })
        return times == 0;
    }
    get penguin() {
        let item = this.nowList[Math.floor(Math.random() * this.nowList.length)];
        return item;
    }
}