import LabelType from "./LabelType";
import { props } from "../props";


let curScore;
export function getScore(){
    return curScore;
}
export function addScore(addCount:number){
    curScore += addCount;
    return curScore;
}
export function setScore(scoreCount:number){
    curScore = scoreCount;
}

let curLevel;
export function getCurLevel(){
    return curLevel;
}
export function setCurLevel(level){
    curLevel = level
    return curLevel;
}
//time-当前关卡时长
let levels;
export const setlevelData = () => {
    levels = {
        '1': { max: props.level_1[0], items: [[LabelType.boom, props.level_1[1]],[LabelType.coin, props.level_1[2]]],time:props.level_1[3]},
        '2': { max: props.level_2[0], items: [[LabelType.boom, props.level_2[1]], [LabelType.coin, props.level_2[2]]] ,time:props.level_2[3]},
        '3': { max: props.level_3[0], items: [[LabelType.boom, props.level_3[1]], [LabelType.coin, props.level_3[2]]] ,time:props.level_3[3]},
    }
}
export const getLevelData = () => {
    if(!levels){
        setlevelData();
    }
    return levels[getCurLevel()]
}
export const getCurrentItems = () => {
    if(!levels){
        setlevelData();
    }
    return getLevelData().items
}
export const getlevelTime = () => {
    if(!levels){
        setlevelData();
    }
    return getLevelData().time
}
//当前关卡需要的最大通关数
export const getlevelMax = () => {
    if(!levels){
        setlevelData();
    }
    return getLevelData().max
}

let touchEnabled = false;
export const getTouchEnabled = () => {
    return touchEnabled
}
export const setTouchEnabled = (b) => {
    touchEnabled = b
}