import { config } from "../constants/config"



export function Utility_ConvertSecondToString(second: number) {
    var last = second
    var hour = Math.floor(last/3600)
    last = last - hour * 3600
    var minite = Math.floor(last/60)
    last = last - minite * 60
    var second = Math.floor(last)
    function format(value: number) {
        return value>=10?value.toString():("0"+value)
    }
    return `${format(hour)}:${format(minite)}:${format(second)}`
}

//计算积分
export function Utility_CalculateScore(difficulty: string, second: number): number {
    var score = 0
    var currentTime = Math.min(120, second)
    if (difficulty == config.DIFFICULTY_TYPE.Easy) {
        score = 270 - currentTime
    }
    else if (difficulty == config.DIFFICULTY_TYPE.Medium) {
        score = 420 - currentTime * 2
    }
    else if (difficulty == config.DIFFICULTY_TYPE.Hard) {
        score = 760 - currentTime * 3
    }
    else if (difficulty == config.DIFFICULTY_TYPE.Expert) {
        score = 1120 - currentTime * 3
    }
    else if (difficulty == config.DIFFICULTY_TYPE.Extreme) {
        score = 1320 - currentTime * 4
    }
    // console.log("计算积分 >>>>>", difficulty, second, score)
    return score
}