local ForestDance = {};

ForestDance.MONEY = 0;
ForestDance.EMONEY = 1;
ForestDance.MACHINE = {
	[5] = { money_type = ForestDance.MONEY, },
	[6] = { money_type = ForestDance.EMONEY, },
}

ForestDance.MachineId = {
    [ForestDance.MONEY] = 5,
    [ForestDance.EMONEY] = 6,
}

ForestDance.COLOR = {
    E_COLOR_NORMAL = 0,
    E_COLOR_RED = 1,
    E_COLOR_YELLOW = 2,
    E_COLOR_BLUE = 3,
}

ForestDance.TXT_COLOR = {
    E_COLOR_NORMAL = 0xfffff3bb,
    E_COLOR_RED = 0xffffdfc0,
    E_COLOR_YELLOW = 0xfffff3bb,
    E_COLOR_BLUE = 0xffbbf6ff,
}

-- 下注盘
ForestDance.BetViewBoard = {
    -- nRow
    {
        {
            ["color"] = ForestDance.COLOR.E_COLOR_NORMAL,
            ["Icon"] = "slwhmain_iconhouzi",
            ["IconBg"] = "slwhmain_liebiaocheng",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_NORMAL,
            ["rate"] = "1:2.4",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_NORMAL,
            ["Icon"] = "slwhmain_icontuzi",
            ["IconBg"] = "slwhmain_liebiaocheng",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_NORMAL,
            ["rate"] = "1:3.2",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_NORMAL,
            ["Icon"] = "slwhmain_iconxiongmao",
            ["IconBg"] = "slwhmain_liebiaocheng",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_NORMAL,
            ["rate"] = "1:4.8",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_NORMAL,
            ["Icon"] = "slwhmain_iconshizi",
            ["IconBg"] = "slwhmain_liebiaocheng",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_NORMAL,
            ["rate"] = "1:9.7",
        },
    },
    {
        {
            ["color"] = ForestDance.COLOR.E_COLOR_RED,
            ["Icon"] = "slwhmain_iconred",
            ["IconBg"] = "slwhmain_liebiaohong",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_RED,
            ["rate"] = "1:1.9",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_RED,
            ["Icon"] = "slwhmain_iconhouzi",
            ["IconBg"] = "slwhmain_liebiaohong",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_RED,
            ["rate"] = "1:4.8",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_RED,
            ["Icon"] = "slwhmain_icontuzi",
            ["IconBg"] = "slwhmain_liebiaohong",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_RED,
            ["rate"] = "1:6.5",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_RED,
            ["Icon"] = "slwhmain_iconxiongmao",
            ["IconBg"] = "slwhmain_liebiaohong",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_RED,
            ["rate"] = "1:9.7",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_RED,
            ["Icon"] = "slwhmain_iconshizi",
            ["IconBg"] = "slwhmain_liebiaohong",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_RED,
            ["rate"] = "1:19",
        },
    },
    {
        {
            ["color"] = ForestDance.COLOR.E_COLOR_YELLOW,
            ["Icon"] = "slwhmain_iconyellow",
            ["IconBg"] = "slwhmain_liebiaohuang",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_YELLOW,
            ["rate"] = "1:2.9",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_YELLOW,
            ["Icon"] = "slwhmain_iconhouzi",
            ["IconBg"] = "slwhmain_liebiaohuang",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_YELLOW,
            ["rate"] = "1:7.2",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_YELLOW,
            ["Icon"] = "slwhmain_icontuzi",
            ["IconBg"] = "slwhmain_liebiaohuang",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_YELLOW,
            ["rate"] = "1:9.7",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_YELLOW,
            ["Icon"] = "slwhmain_iconxiongmao",
            ["IconBg"] = "slwhmain_liebiaohuang",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_YELLOW,
            ["rate"] = "1:14.5",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_YELLOW,
            ["Icon"] = "slwhmain_iconshizi",
            ["IconBg"] = "slwhmain_liebiaohuang",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_YELLOW,
            ["rate"] = "1:29",
        },
    },
    {
        {
            ["color"] = ForestDance.COLOR.E_COLOR_BLUE,
            ["Icon"] = "slwhmain_iconblue",
            ["IconBg"] = "slwhmain_liebiaolan",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_BLUE,
            ["rate"] = "1:5.8",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_BLUE,
            ["Icon"] = "slwhmain_iconhouzi",
            ["IconBg"] = "slwhmain_liebiaolan",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_BLUE,
            ["rate"] = "1:14.5",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_BLUE,
            ["Icon"] = "slwhmain_icontuzi",
            ["IconBg"] = "slwhmain_liebiaolan",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_BLUE,
            ["rate"] = "1:19",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_BLUE,
            ["Icon"] = "slwhmain_iconxiongmao",
            ["IconBg"] = "slwhmain_liebiaolan",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_BLUE,
            ["rate"] = "1:29",
        },
        {
            ["color"] = ForestDance.COLOR.E_COLOR_BLUE,
            ["Icon"] = "slwhmain_iconshizi",
            ["IconBg"] = "slwhmain_liebiaolan",
            ["txtcolor"] = ForestDance.TXT_COLOR.E_COLOR_BLUE,
            ["rate"] = "1:58",
        },
    },
}

ForestDance.RaffleIcon = {
    {
        ["icon"] = "slwhmain_iconshizi",
        ["rate"] = "1",
    },
    {
        ["icon"] = "slwhmain_iconhouzi",
        ["rate"] = "2",
    },
    {
        ["icon"] = "slwhmain_icontuzi",
        ["rate"] = "3",
    },
    {
        ["icon"] = "slwhmain_iconxiongmao",
        ["rate"] = "4",
    },
    {
        ["icon"] = "slwhmain_iconhouzi",
        ["rate"] = "5",
    },
    {
        ["icon"] = "slwhmain_icontuzi",
        ["rate"] = "6",
    },
    {
        ["icon"] = "slwhmain_iconhouzi",
        ["rate"] = "7",
    },
    {
        ["icon"] = "slwhmain_iconxiongmao",
        ["rate"] = "8",
    },
    {
        ["icon"] = "slwhmain_icontuzi",
        ["rate"] = "9",
    },
    {
        ["icon"] = "slwhmain_iconhouzi",
        ["rate"] = "10",
    },
}


ForestDance.GetForestBetData = function (nRow, nCol, strkey)
    if not ForestDance.BetViewBoard[nRow] then
        return nil;
    end

    local tbViewData = ForestDance.BetViewBoard[nRow][nCol];
    if not tbViewData then
        return nil;
    end

    if tbViewData[strkey] then
        return tbViewData[strkey];
    end

    return nil;
end

ForestDance.GetForestBetDataRowCount = function ()
    return #ForestDance.BetViewBoard;
end

ForestDance.GetForestBetDataColCount = function (nRow)
    if not ForestDance.BetViewBoard[nRow] then
        return 0;
    end

    return #ForestDance.BetViewBoard[nRow];
end

ForestDance.BetMaxChip = {
    [ForestDance.MachineId[ForestDance.MONEY]] = 100000000000,
    [ForestDance.MachineId[ForestDance.EMONEY]] = 1000000,
}

ForestDance.GetForestBetChipMax = function (idMachine)
    return ForestDance.BetMaxChip[idMachine];
end

--按钮特效
ForestDance.Transition = {
	[1] = "act_kapaichouma10k",
	[2] = "act_kapaichouma100k",
	[3] = "act_kapaichouma1M",
	[4] = "act_kapaichouma10M",
	[5] = "act_kapaichouma100M",
}

--下注筹码动效
ForestDance.GetChipTransition = function(Money)
	if ForestDance.Transition[Money] == nil then
		return ""
	end
	
    return ForestDance.Transition[Money]
end

ForestDance.CHIP = {
	CHIP_RATE_1 = 1, -- 倍率1
	CHIP_RATE_2 = 2, -- 倍率2
	CHIP_RATE_3 = 3, -- 倍率3
	CHIP_RATE_4 = 4, -- 倍率4
	CHIP_RATE_5 = 5, -- 倍率4
	CHIP_RATE_END = 6,
};

ForestDance.BetRate = {
    [ForestDance.MONEY] = {
        10000, 100000, 1000000, 10000000, 100000000
    },
    [ForestDance.EMONEY] = {
        10, 30, 100, 300, 1000
    }
}

--下注筹码筹码
ForestDance.GetForestDanceBetChip = function(idMachine, ChipRate)
	local nMoneyType = ForestDance.GetMoneyType(idMachine);
	if ForestDance.BetRate[nMoneyType] == nil or ForestDance.BetRate[nMoneyType][ChipRate] == nil then
		return 0
	end
	
    return ForestDance.BetRate[nMoneyType][ChipRate]
end

-- 获取推荐下注等级
ForestDance.GetForestDanceRate = function (idMachine, i64UserMoney)
    local nRate = nil;
    local nMoneyType = ForestDance.GetMoneyType(idMachine);
    if nMoneyType == ForestDance.MONEY then
        if i64UserMoney <= 10000000 then
            return 1;
        elseif i64UserMoney <= 100000000 then
            return 2;
        elseif i64UserMoney <= 1000000000 then
            return 3;
        elseif i64UserMoney <= 10000000000 then
            return 4;
        else
            return 5;
        end
    elseif nMoneyType == ForestDance.EMONEY then
        if i64UserMoney <= 1000 then
            return 1;
        elseif i64UserMoney <= 5000 then
            return 2;
        elseif i64UserMoney <= 10000 then
            return 3;
        elseif i64UserMoney <= 50000 then
            return 4;
        else
            return 5;
        end
    end

    return nRate;
end

--筹码Icon
ForestDance.ForestDanceBetIcon = {
	[ForestDance.MONEY] = {
		[10000] = "tbmain_iconcm1",
		[100000] = "tbmain_iconcm2",
		[1000000] = "tbmain_iconcm3",
		[10000000] = "tbmain_iconcm4",
		[100000000] = "tbmain_iconcm5",
	},

	[ForestDance.EMONEY] = {
		[10] = "tbmain_iconcm1",
		[30] = "tbmain_iconcm2",
		[100] = "tbmain_iconcm3",
		[300] = "tbmain_iconcm4",
		[1000] = "tbmain_iconcm5",
	},
}

--下注筹码筹码icon
ForestDance.GetChipIcon = function(idMachine, Money)
	local nMoneyType = ForestDance.GetMoneyType(idMachine);
	if ForestDance.ForestDanceBetIcon[nMoneyType] == nil or ForestDance.ForestDanceBetIcon[nMoneyType][Money] == nil then
		return ""
	end
	
    return ForestDance.ForestDanceBetIcon[nMoneyType][Money]
end

--Money类型
ForestDance.GetMoneyType = function(idMachine)
	if ForestDance.MACHINE[idMachine] == nil then
		return ForestDance.MONEY
	end
	
    return ForestDance.MACHINE[idMachine]["money_type"]
end

ForestDance.BET_FORESTDANCE_ANIMAL_TYPE_MONKEY = 1 -- 猴子
ForestDance.BET_FORESTDANCE_ANIMAL_TYPE_RABBIT = 2 -- 兔子
ForestDance.BET_FORESTDANCE_ANIMAL_TYPE_PANDA = 3 -- 熊猫
ForestDance.BET_FORESTDANCE_ANIMAL_TYPE_LION = 4 -- 狮子

ForestDance.BET_FORESTDANCE_COLOR_TYPE_READ = 1 -- 红
ForestDance.BET_FORESTDANCE_COLOR_TYPE_YELLOW = 2 -- 黄
ForestDance.BET_FORESTDANCE_COLOR_TYPE_BLUE = 3 -- 蓝

ForestDance.RouteInfo = {
    ["color1"] = {
        [ForestDance.BET_FORESTDANCE_COLOR_TYPE_READ] = "slwhld_ludanhong1",
        [ForestDance.BET_FORESTDANCE_COLOR_TYPE_YELLOW] = "slwhld_ludanhuang1",
        [ForestDance.BET_FORESTDANCE_COLOR_TYPE_BLUE] = "slwhld_ludanlan1",
    },
    ["color2"] = {
        [ForestDance.BET_FORESTDANCE_COLOR_TYPE_READ] = "slwhld_ludanhong2",
        [ForestDance.BET_FORESTDANCE_COLOR_TYPE_YELLOW] = "slwhld_ludanhuang2",
        [ForestDance.BET_FORESTDANCE_COLOR_TYPE_BLUE] = "slwhld_ludanlan2",
    },
    ["animal"] = {
        [ForestDance.BET_FORESTDANCE_ANIMAL_TYPE_MONKEY] = "slwhmain_iconhouzi",
        [ForestDance.BET_FORESTDANCE_ANIMAL_TYPE_RABBIT] = "slwhmain_icontuzi",
        [ForestDance.BET_FORESTDANCE_ANIMAL_TYPE_PANDA] = "slwhmain_iconxiongmao",
        [ForestDance.BET_FORESTDANCE_ANIMAL_TYPE_LION] = "slwhmain_iconshizi",
    },
    BoardPageMaxShow = 12,
}

ForestDance.DrawTimeInfo = {
    -- 外圈转盘
    ["OutSide"] = 9,
    -- 内圈转盘
    ["InSide"] = 11,
    -- 球
    ["ball"] = 10,
    -- 结算总时间
    ["settle"] = 5,
    -- 转盘总时间
    ["drawtotal"] = 12,
    -- 结算停留时间
    ["SettleStay"] = 1,
    -- 下注倒计时声音播放条件，剩余多少时间播放
    ["TimeDownLeft"] = 5;
}

ForestDance.GetRouteInfo = function(strType, nType, bRoutePage)
    if strType == "color" then
        if bRoutePage then
            strType = strType .. 1;
        else
            strType = strType .. 2;
        end
    end
    if ForestDance.RouteInfo[strType] == nil then
        return nil;
    end

    local tbData = ForestDance.RouteInfo[strType];
    if tbData[nType] == nil then
        return nil;
    end

    return tbData[nType];
end

return ForestDance;