-- 四个气门默认图标和底板光效
local DefaultIcon = {
    [0] = "NewRefBreath_qinglongPic",
    [1] = "NewRefBreath_zhuquePic",
    [2] = "NewRefBreath_baihuPic",
    [3] = "NewRefBreath_xuanwuPic",
    bgeffect = "NewRefBreathBG",
}

local function GetDefaultIcon(index, default)
    local res = DefaultIcon[index]
    
    if (res ~= nil) then
        return res
    end
    
    return default
end

-- 光效坐标,0-3表示青龙至玄武
local EffectPos = {
    background = { x = 515, y = 400, },
    box = { x = 500, y = 400, },
    [0] = { x= 520, y = 400,},
    [1] = { x= 500, y = 400,},
    [2] = { x= 500, y = 400,},
    [3] = { x= 500, y = 400,},
}

local function GetEffectPos(index, xory, default)
    local t = EffectPos[index]
    
    if (t ~= nil) then
        local res = t[xory]
        
        if (res ~= nil) then
            return res
        end
    end
    
    return default
end

-- 切换光效气门分数梯度
local TVScoreGrade = {
    num = 3,
    [0] = 200,
    [1] = 300,
    [2] = 360,
}

local function GetTVScoreGrade(index, default)
    local res = TVScoreGrade[index]
    
    if (res ~= nil) then
        return res
    end
    
    return default
end

-- 4个气门,和各分数梯度对应光效
local TVEffect = {
    [0] = { "shenshou1_2", "shenshou2_2", "shenshou3_2",},
    [1] = { "shenshou1_3", "shenshou2_3", "shenshou3_3",},
    [2] = { "shenshou1_4", "shenshou2_4", "shenshou3_4",},
    [3] = { "shenshou1_1", "shenshou2_1", "shenshou3_1",},
}

local function GetTVEffect(lParam, rParam, default)
    local t = TVEffect[lParam]
    
    if (t ~= nil) then
        local res = t[rParam]
        
        if (res ~= nil) then
            return res
        end
    end
    
    return default
end

-- 外框光效练气经验梯度
local TVLevelGrade = {
    num = 3,
    [0] = 100,
    [1] = 200,
    [2] = 300,
}

local function GetTVLevelGrade(index, default)
    local res = TVLevelGrade[index]
    
    if (res ~= nil) then
        return res
    end
    
    return default
end

-- 外框光效
local TVBoxEffect = {
    [0] = "rf_title",
    [1] = "rf_title",
    [2] = "rf_title",
}

local function GetTVBoxEffect(index, default)
    local res = TVBoxEffect[index]
    
    if (res ~= nil) then
        return res
    end
    
    return default
end

-- 练气界面对比光效
local TVContrastEffect = {
    activateeffect = "rf_jihuo",
    contrasteffect = "rf_gaofen",
    x = 250,
    y = 180,
    Spacex = 450,
}

local function GetTVContrastEffect(index, default)
    local res = TVContrastEffect[index]
    
    if (res ~= nil) then
        return res
    end
    
    return default
end

local DlgInfo = {
-- 激活按钮偏移(开启保护前后) 保护后为续时按钮
	ActiveBtnX = 120,
	ActiveBtnY = 70,
-- 
}

-- 练气开放配置
-- 可直接新增服务器类型扩充
local OpenLimit = {
-- 普通服
[0] = {
    [0] = { 1, 0, 0, },
    [1] = { 1, 110, 300, },
    [2] = { 1, 110, 300, },
    [3] = { 2, 110, 300, },
    [4] = { 2, 110, 300, },
    },
-- 新服
[8] = {
    [0] = { 1, 0, 0, },
    [1] = { 1, 110, 300, },
    [2] = { 1, 110, 300, },
    [3] = { 2, 110, 300, },
    [4] = { 2, 110, 300, },
    },
-- 激情服
[16] = {
    [0] = { 1, 110, 0, },
    [1] = { 1, 110, 300, },
    [2] = { 1, 110, 300, },
    [3] = { 2, 110, 300, },
    [4] = { 2, 110, 300, },
    },
-- 老兵服
[256] = {
    [0] = { 1, 110, 0, },
    [1] = { 1, 110, 300, },
    [2] = { 1, 110, 300, },
    [3] = { 2, 110, 300, },
    [4] = { 2, 110, 300, },
    },
-- 老兵服新服
[264] = {
    [0] = { 1, 110, 0, },
    [1] = { 1, 110, 300, },
    [2] = { 1, 110, 300, },
    [3] = { 2, 110, 300, },
    [4] = { 2, 110, 300, },
    },
-- 掉钱服
[512] = {
    [0] = { 1, 110, 0, },
    [1] = { 1, 110, 300, },
    [2] = { 1, 110, 300, },
    [3] = { 2, 110, 300, },
    [4] = { 2, 110, 300, },
    },
-- 掉钱服新服
[520] = {
    [0] = { 2, 0, 0, },
    [1] = { 2, 110, 300, },
    [2] = { 2, 110, 300, },
    [3] = { 2, 110, 300, },
    [4] = { 2, 110, 300, },
    },
}

local function GetOpenLimit(nServerType, nSlotIndex, nIndex, default)
    local t = OpenLimit[nServerType]
    if (t == nil) then
        return default
    end
    
    local k = t[nSlotIndex]
    if (k == nil) then
        return default
    end
    
    local res = k[nIndex]
    if (res == nil) then
        return default
    end

    return res
end

local function GetDlgInfo(index, default)
    local res = DlgInfo[index]
    
    if (res ~= nil) then
        return res
    end
    
    return default
end

local function Unload()
    DefaultIcon = nil
    TVScoreGrade = nil
    TVEffect = nil
    TVLevelGrade = nil
    TVBoxEffect = nil
    GetEffectPos = nil
    TVContrastEffect = nil
    GetDlgInfo = nil
    OpenLimit = nil
end

local TrainVitalityCfg = {
    GetDlgInfo = GetDlgInfo,
    GetDefaultIcon = GetDefaultIcon,
    GetTVScoreGrade = GetTVScoreGrade,
    GetTVEffect = GetTVEffect,
    GetTVLevelGrade = GetTVLevelGrade,
    GetTVBoxEffect = GetTVBoxEffect,
    GetEffectPos = GetEffectPos,
    GetTVContrastEffect = GetTVContrastEffect,
    GetOpenLimit = GetOpenLimit,
    Unload = Unload,
}


-- global
TrainVitalityCfg_GetDlgInfo = TrainVitalityCfg.GetDlgInfo
TrainVitalityCfg_GetDefaultIcon = TrainVitalityCfg.GetDefaultIcon
TrainVitalityCfg_GetTVScoreGrade = TrainVitalityCfg.GetTVScoreGrade
TrainVitalityCfg_GetTVEffect = TrainVitalityCfg.GetTVEffect
TrainVitalityCfg_GetTVLevelGrade = TrainVitalityCfg.GetTVLevelGrade
TrainVitalityCfg_GetTVBoxEffect = TrainVitalityCfg.GetTVBoxEffect
TrainVitalityCfg_GetEffectPos = TrainVitalityCfg.GetEffectPos
TrainVitalityCfg_GetTVContrastEffect = TrainVitalityCfg.GetTVContrastEffect
TrainVitalityCfg_Unload = TrainVitalityCfg.Unload
TrainVitalityCfg_GetOpenLimit = TrainVitalityCfg.GetOpenLimit
TrainVitalityCfg_Unload = TrainVitalityCfg.Unload

return TrainVitalityCfg
