local JinLiLotteryActivityTime = {
	-- ["OpenDay"] = 活动开始开服时间, 
	["OpenDay"] = 0, 
	-- ["EndDay"] = 活动结束开服时间, 
	["EndDay"] = 57, 
	-- ["LotteryTime"] = 抽奖时间, 
	["LotteryTime"] = 8, 
	-- ["EndLotteryTime"] = 抽奖结束时间, 
	["EndLotteryTime"] = 22, 
	-- ["OpenResult"] = 开奖时间, 
	["OpenResult"] = 22,
	["ServerType"] = 512, 
	-- ["MaxPool0"] = 金币最大奖池, 
	["MaxPool0"] = 1300000000, 
	-- ["MaxPool1"] = 天石最大奖池,
	["MaxPool1"] = 31250, 
	-- ["Cost0"] = 金币抽奖花费道具, 
	["Cost0"] = 3350222, 
	-- ["Cost1"] = 天石抽奖花费道具,
	["Cost1"] = 3350223,
}

local function GetJinLiLotteryActivityTime(key)
	if JinLiLotteryActivityTime == nil then
		return nil
	end

	if JinLiLotteryActivityTime[key] == nil then
		return nil
	end

	return JinLiLotteryActivityTime[key]
end

--奖励预览
-- 当["RewardXType"]为2表示固定值时，要配置["RewardXValue2"]来表示固定值的人数
local JinLiLotteryReward =  {
	--金币
	[0] = {
		--特等
		--Type:1为百分比 2为固定值
		["Reward1Type"] = 1,
		["Reward1Value"] = 10,
		--一等奖
		["Reward2Type"] = 1,
		["Reward2Value"] = 5,
		--二等奖
		["Reward3Type"] = 1,
		["Reward3Value"] = 4,
		--三等奖
		["Reward4Type"] = 1,
		["Reward4Value"] = 2,
		--参与奖
		["ItemType1"] = 730003,
		["Monopoly1"] = 1,
		["Amount1"] = 2,
		-- 秒
		["DelTime1"] = 432000,
		
		["ItemType2"] = 3003126,
		["Monopoly2"] = 1,
		["Amount2"] = 3,
		["DelTime2"] = 0,
	},

	--天石
	[1] = {
		--特等
		--Type:1为百分比 2为固定值
		["Reward1Type"] = 1,
		["Reward1Value"] = 35,
		--一等奖
		["Reward2Type"] = 1,
		["Reward2Value"] = 10,
		--二等奖
		["Reward3Type"] = 1,
		["Reward3Value"] = 6,
		--三等奖
		["Reward4Type"] = 2,
		["Reward4Value"] = 270,
		["Reward4Value2"] = 10,
		--参与
		["ItemType1"] = 730005,
		["Monopoly1"] = 1,
		["Amount1"] = 1,
		["DelTime1"] = 432000,
		
		["ItemType2"] = 3322762,
		["Monopoly2"] = 1,
		["Amount2"] = 3,
		["DelTime2"] = 604800,
	},
}

-- 界面金币天石分页分别展示哪几期抽奖,对应值为
-- 顺序请按开服天数排列，不能1期是开服4天，2期是开服3天，然后1期排在2期前面
local JinLiLotteryDlgInfo=  {
	--金币
	[0] = {
		[1] = 1,
		[2] = 2,
		[3] = 3,
		[4] = 4,
		[5] = 5,
		[6] = 7,
		[7] = 8,
		[8] = 9,
		[9] = 10,
		[10] = 11,
		[11] = 12,
		[12] = 14,
		[13] = 15,
		[14] = 16,
		[15] = 17,
		[16] = 18,
		[17] = 19,
	},

	--天石
	[1] = {
		[1] = 6,
		[2] = 13,
		[3] = 20,
	},
}

local JinLiLotterInfo = {
	--期号/OpenDay:开服几天开始抽奖，0为开服第一天/CloseDay 开服几天终止抽奖同时当天20点开奖/ LotteryTime 抽奖时间 /EndLotteryTime开奖时间/Type类别：0金币，1天石
	[1] =  {["OpenDay"] = 35,   ["CloseDay"] = 35,   ["Type"] = 0, 	["Lev"] = 100, },
	[2] =  {["OpenDay"] = 36,   ["CloseDay"] = 36,   ["Type"] = 0, 	["Lev"] = 100, },
	[3] =  {["OpenDay"] = 37,   ["CloseDay"] = 37,   ["Type"] = 0, 	["Lev"] = 100, },
	[4] =  {["OpenDay"] = 38,   ["CloseDay"] = 38,   ["Type"] = 0, 	["Lev"] = 100, },
	[5] =  {["OpenDay"] = 39,   ["CloseDay"] = 39,   ["Type"] = 0, 	["Lev"] = 100, },
	[6] =  {["OpenDay"] = 35,   ["CloseDay"] = 40,   ["Type"] = 1, 	["Lev"] = 100, },
	[7] =  {["OpenDay"] = 40,   ["CloseDay"] = 41,   ["Type"] = 0, 	["Lev"] = 100, },
	[8] =  {["OpenDay"] = 42,   ["CloseDay"] = 42,   ["Type"] = 0, 	["Lev"] = 100, },
	[9] =  {["OpenDay"] = 43,   ["CloseDay"] = 43,   ["Type"] = 0, 	["Lev"] = 100, },
	[10] = {["OpenDay"] = 44,   ["CloseDay"] = 44,   ["Type"] = 0, 	["Lev"] = 100, },
	[11] = {["OpenDay"] = 45,   ["CloseDay"] = 45,   ["Type"] = 0, 	["Lev"] = 100, },
	[12] = {["OpenDay"] = 46,   ["CloseDay"] = 46,   ["Type"] = 0, 	["Lev"] = 100, },
	[13] = {["OpenDay"] = 41,   ["CloseDay"] = 47,   ["Type"] = 1, 	["Lev"] = 100, },
	[14] = {["OpenDay"] = 47,   ["CloseDay"] = 48,   ["Type"] = 0, 	["Lev"] = 100, },
	[15] = {["OpenDay"] = 49,   ["CloseDay"] = 49,   ["Type"] = 0, 	["Lev"] = 100, },
	[16] = {["OpenDay"] = 50,   ["CloseDay"] = 50,   ["Type"] = 0, 	["Lev"] = 100, },
	[17] = {["OpenDay"] = 51,   ["CloseDay"] = 51,   ["Type"] = 0, 	["Lev"] = 100, },
	[18] = {["OpenDay"] = 52,   ["CloseDay"] = 52,   ["Type"] = 0, 	["Lev"] = 100, },
	[19] = {["OpenDay"] = 53,   ["CloseDay"] = 53,   ["Type"] = 0, 	["Lev"] = 100, },
	[20] = {["OpenDay"] = 48,   ["CloseDay"] = 54,   ["Type"] = 1, 	["Lev"] = 100, },
}

-- 累计参与次数奖励
local JinLiRewardJoinTimesInfo = {
	[1] = {
		["Num"] = 1,
		["ItemType1"] = 730003,  ["Amount1"] = 1, ["Monopoly1"] = 1, ["DelTime1"] = 432000,
		["ItemType2"] = 3322760, ["Amount2"] = 2, ["Monopoly2"] = 1, ["DelTime2"] = 604800,
	},
	[2] = {
		["Num"] = 3,
		["ItemType1"] = 730003,  ["Amount1"] = 2, ["Monopoly1"] = 1, ["DelTime1"] = 432000,
		["ItemType2"] = 3322760, ["Amount2"] = 2, ["Monopoly2"] = 1, ["DelTime2"] = 604800,
	},
	
	[3] = {
		["Num"] = 7,
		["ItemType1"] = 730004,  ["Amount1"] = 1, ["Monopoly1"] = 1, ["DelTime1"] = 432000,
		["ItemType2"] = 3322762, ["Amount2"] = 1, ["Monopoly2"] = 1, ["DelTime2"] = 604800,
	},
	
	[4] = {
		["Num"] = 12,
		["ItemType1"] = 730004,  ["Amount1"] = 2, ["Monopoly1"] = 1, ["DelTime1"] = 432000,
		["ItemType2"] = 3322762, ["Amount2"] = 1, ["Monopoly2"] = 1, ["DelTime2"] = 604800,
	},
	
	[5] = {
		["Num"] = 20,
		["ItemType1"] = 730004,  ["Amount1"] = 2, ["Monopoly1"] = 1, ["DelTime1"] = 432000,
		["ItemType2"] = 3322762, ["Amount2"] = 2, ["Monopoly2"] = 1, ["DelTime2"] = 604800,
	},
	
	[6] = {
		["Num"] = 30,
		["ItemType1"] = 730005,  ["Amount1"] = 1, ["Monopoly1"] = 1, ["DelTime1"] = 432000,
		["ItemType2"] = 3314553, ["Amount2"] = 3, ["Monopoly2"] = 1, ["DelTime2"] = 0,
	},
	
	[7] = {
		["Num"] = 50,
		["ItemType1"] = 730005,  ["Amount1"] = 2, ["Monopoly1"] = 1, ["DelTime1"] = 432000,
		["ItemType2"] = 3314553, ["Amount2"] = 6, ["Monopoly2"] = 1, ["DelTime2"] = 0,
	},
	
	[8] = {
		["Num"] = 100,
		["ItemType1"] = 730006,  ["Amount1"] = 1, ["Monopoly1"] = 1, ["DelTime1"] = 432000,
		["ItemType2"] = 723694,  ["Amount2"] = 1, ["Monopoly2"] = 1, ["DelTime2"] = 0,
	},
}

-- 弹幕界面信息
local JinLiBarrageInfo = {
	["CloseDelay"] = 3,	--关闭时间
	["BarrageMinSpeed"] = 50,  --弹幕最小速度
	["BarrageMaxSpeed"] = 200,  --弹幕最大速度
	["BarrageLeft"] = -600, --弹幕左侧消失位置
	["BarrageRight"] = 1600, --弹幕右侧起始位置
	["BarrageRight1"] = 1800, --弹幕右侧起始位置 最远
	["BarrageTop"] = 100, --弹幕上侧位置
	["BarrageBottom"] = 720, --弹幕下侧位置
}

local POOL_STATUS_NONE = 0				--空
local POOL_STATUS_PART1 = 1				--1/3
local POOL_STATUS_PART2 = 2				--2/3
local POOL_STATUS_FULL = 3				--3/3

-- 根据当前窗口类型和奖池数量获得奖池光效
local function GetProgressEffectByDlgTypeAndPool(type, value)
	local MaxValue = 0;
	if type == 0 then
		--金币
		MaxValue = JinLiLotteryActivityTime["MaxPool0"];
	else
		--天石
		MaxValue = JinLiLotteryActivityTime["MaxPool1"];
	end

	if MaxValue == 0 then
		MaxValue = 100;
	end

	local Status = POOL_STATUS_NONE;
	local Progress = value / MaxValue;
	if Progress == 0 then
		-- 0的时候为空
		Status = POOL_STATUS_NONE
	elseif Progress > 0 and Progress <= (1 / 3) then
		-- 大于0小于1/3 显示1/3
		Status = POOL_STATUS_PART1;
	elseif Progress > (1 / 3) and Progress < 1 then
		-- 超过1/3没满 显示2/3
		Status = POOL_STATUS_PART2;
	elseif Progress >= 1 then
		-- 超过最大值 显示3/3
		Status = POOL_STATUS_FULL;
	end
	
	if Status == POOL_STATUS_NONE then
		return "kaifujinli5";
	end

	if Status == POOL_STATUS_PART1 then
		return "kaifujinli1";
	end

	if Status == POOL_STATUS_PART2 then
		return "kaifujinli2";
	end

	return "kaifujinli3";
end

local function GetJinLiBarrageInfo(index)
	if JinLiBarrageInfo == nil then
		return nil
	end

	if JinLiBarrageInfo[index] == nil then
		return nil
	end

	return JinLiBarrageInfo[index]
end

local function GetJinLiRewardJoinTimesInfo(index, key)
	if JinLiRewardJoinTimesInfo == nil then
		return nil
	end
	
	if index == "Amount" then
		return #JinLiRewardJoinTimesInfo
	end

	if JinLiRewardJoinTimesInfo[index] == nil then
		return nil
	end

	if JinLiRewardJoinTimesInfo[index][key] == nil then
		return nil
	end

	return JinLiRewardJoinTimesInfo[index][key]
end

-- 开奖页面开奖后自动关闭时间(单位秒)
local function GetResultEndTime()
	return 13
end

-- 抽象花费的道具ItemType
local function GetJinLiLotteryCostItem(index)
	if index == 0 then
		return JinLiLotteryActivityTime["Cost0"] 
	end

	if index == 1 then
		return JinLiLotteryActivityTime["Cost1"] 
	end
end

-- 抽奖时间
local function GetJinLiLotteryTime(data, index)
	if index == "LotteryTime" then
		return JinLiLotteryActivityTime["LotteryTime"]
	end

	if index == "EndLotteryTime" then
		return JinLiLotteryActivityTime["EndLotteryTime"]
	end
end


local function GetJinLiLotteryDlgInfo(index, key)
	if JinLiLotteryDlgInfo[index] == nil then
		return nil
	end

	if key == "Amount" then
		return #JinLiLotteryDlgInfo[index]
	end

	if JinLiLotteryDlgInfo[index][key] == nil then
		return nil
	end

	return JinLiLotteryDlgInfo[index][key]
end

local function GetJinLiLotterInfo(index, key)
	if JinLiLotterInfo[index] == nil then
		return nil
	end

	if JinLiLotterInfo[index][key] == nil then
		return nil
	end

	return JinLiLotterInfo[index][key]
end

local function GetJinLiLotteryReward(index, key)
	if JinLiLotteryReward[index] == nil then
		return nil
	end

	if JinLiLotteryReward[index][key] == nil then
		return nil
	end

	return JinLiLotteryReward[index][key]
end

-- 消耗物的获取方式
local CostItemGetWayInfo = {
	[3350222] = {
		[1] = {			
			--Type:1 npc寻路 2脚本命令:KoiCarpLottery_GetItemWay
			["Type"] = 2,
		},
		[2] = {
			--Type:1 npc寻路 2脚本命令:KoiCarpLottery_GetItemWay
			["Type"] = 2,
		},
		[3] = {
			--Type:1 npc寻路 2脚本命令:KoiCarpLottery_GetItemWay
			["Type"] = 2,
		},
	},

	[3350223] = {
		[1] = {
			--Type:1 npc寻路 2脚本命令:KoiCarpLottery_GetItemWay
			["Type"] = 1,
			-- 仅当type为1时使用
			["Npc"] = 7879,
			["Map"] = 10364,
			["MapX"] = 301,
			["MapY"] = 141,
		},
		[2] = {
			--Type:1 npc寻路 2脚本命令:KoiCarpLottery_GetItemWay
			["Type"] = 2,
		},
	},
}

-- 获取消耗物的获取方式
local function GetCostItemGetWayInfo(idItemType, index, key)
	if CostItemGetWayInfo == nil then
		return nil
	end

	if CostItemGetWayInfo[idItemType] == nil then
		return nil
	end

	if index == "Amount" then
		return #CostItemGetWayInfo[idItemType]
	end

	if CostItemGetWayInfo[idItemType][index] == nil then
		return nil
	end

	if CostItemGetWayInfo[idItemType][index][key] == nil then
		return nil
	end

	return CostItemGetWayInfo[idItemType][index][key]
end


-- 清理变量释放内存
local function Unload()
	JinLiLotteryReward = nil
end

-- 通过require传给其他Lua脚本使用
local JinLiLottery = {
	GetProgressEffectByDlgTypeAndPool = GetProgressEffectByDlgTypeAndPool,
	GetResultEndTime = GetResultEndTime,
	GetJinLiLotteryReward = GetJinLiLotteryReward,
	GetJinLiLotterInfo = GetJinLiLotterInfo,
	GetJinLiLotteryDlgInfo = GetJinLiLotteryDlgInfo,
	GetJinLiLotteryCostItem = GetJinLiLotteryCostItem,
	GetJinLiLotteryTime = GetJinLiLotteryTime,
	GetJinLiRewardJoinTimesInfo = GetJinLiRewardJoinTimesInfo,
	GetJinLiBarrageInfo = GetJinLiBarrageInfo,
	GetJinLiLotteryActivityTime = GetJinLiLotteryActivityTime,
	GetCostItemGetWayInfo = GetCostItemGetWayInfo,
	Unload = Unload,
}

-- C++程序使用的global函数名
JinLiLottery_GetCostItemGetWayInfo = JinLiLottery.GetCostItemGetWayInfo
JinLiLottery_GetProgressEffectByDlgTypeAndPool = JinLiLottery.GetProgressEffectByDlgTypeAndPool
JinLiLottery_GetJinLiBarrageInfo = JinLiLottery.GetJinLiBarrageInfo
JinLiLottery_GetResultEndTime = JinLiLottery.GetResultEndTime
JinLiLottery_GetJinLiLotteryTime = JinLiLottery.GetJinLiLotteryTime
JinLiLottery_GetJinLiLotterInfo = JinLiLottery.GetJinLiLotterInfo
JinLiLottery_GetJinLiLotteryDlgInfo = JinLiLottery.GetJinLiLotteryDlgInfo
JinLiLottery_GetJinLiLotteryReward = JinLiLottery.GetJinLiLotteryReward
JinLiLottery_GetJinLiLotteryCostItem = JinLiLottery.GetJinLiLotteryCostItem
JinLiLottery_GetJinLiRewardJoinTimesInfo = JinLiLottery.GetJinLiRewardJoinTimesInfo
JinLiLottery_GetJinLiLotteryActivityTime = JinLiLottery.GetJinLiLotteryActivityTime
JinLiLottery_Unload = JinLiLottery.Unload

-- require返回值
return JinLiLottery

