-- 参数
-- 	Axis	坐标轴，为"x"或"y"
-- 	Index	显示图标序号，从0开始
-- 返回值
--	距离角色屏幕基点的坐标偏移值，单位像素


local first_recharge_256 = {
	[1] = {
		day = 1,
		server_type = 256,
		itemtype = 201009,
		monopoly = 1,
		num = 1,
	},
	[2] = {
		day = 1,
		server_type = 256,
		itemtype = 3312766,
		monopoly = 1,
		num = 1,
	},
	[3] = {
		day = 1,
		server_type = 256,
		itemtype = 3312767,
		monopoly = 1,
		num = 1,
	},
	[4] = {
		day = 1,
		server_type = 256,
		itemtype = 1088001,
		monopoly = 1,
		num = 1000,
	},
	[5] = {
		day = 1,
		server_type = 256,
		itemtype = 730004,
		monopoly = 1,
		num = 3,
		deltime = 432000
	},
	[6] = {
		day = 2,
		server_type = 256,
		itemtype = 200654,
		monopoly = 1,
		num = 1,
		reducedmg=1,
	},
	[7] = {
		day = 2,
		server_type = 256,
		itemtype = 3312767,
		monopoly = 1,
		num = 1,
	},
	[8] = {
		day = 2,
		server_type = 256,
		itemtype = 730004,
		monopoly = 1,
		num = 4,
		deltime = 432000
	},
	[9] = {
		day = 2,
		server_type = 256,
		itemtype = 1088000,
		monopoly = 1,
		num = 5,
	},
	[10] = {
		day = 3,
		server_type = 256,
		itemtype = 196185,
		monopoly = 1,
		num = 1,
		reducedmg=1,
	},
	[11] = {
		day = 3,
		server_type = 256,
		itemtype = 722840,
		monopoly = 1,
		num = 1,
	},
	[12] = {
		day = 3,
		server_type = 256,
		itemtype = 3312767,
		monopoly = 1,
		num = 1,
	},
	[13] = {
		day = 3,
		server_type = 256,
		itemtype = 3314225,
		monopoly = 1,
		num = 5,
	},
}

local first_recharge_512 = {
	[1] = {
		day = 1,
		server_type = 512,
		itemtype = 201009,
		monopoly = 1,
		num = 1,
	},
	[2] = {
		day = 1,
		server_type = 512,
		itemtype = 3312766,
		monopoly = 1,
		num = 1,
	},
	[3] = {
		day = 1,
		server_type = 512,
		itemtype = 3312767,
		monopoly = 1,
		num = 1,
	},
	[4] = {
		day = 1,
		server_type = 512,
		itemtype = 1088001,
		monopoly = 1,
		num = 1000,
	},
	[5] = {
		day = 1,
		server_type = 512,
		itemtype = 730004,
		monopoly = 1,
		num = 3,
		deltime = 432000
	},
	[6] = {
		day = 2,
		server_type = 512,
		itemtype = 200654,
		monopoly = 1,
		num = 1,
		reducedmg=1,
	},
	[7] = {
		day = 2,
		server_type = 512,
		itemtype = 3312767,
		monopoly = 1,
		num = 1,
	},
	[8] = {
		day = 2,
		server_type = 512,
		itemtype = 730004,
		monopoly = 1,
		num = 4,
		deltime = 432000
	},
	[9] = {
		day = 2,
		server_type = 512,
		itemtype = 1088000,
		monopoly = 1,
		num = 5,
	},
	[10] = {
		day = 3,
		server_type = 512,
		itemtype = 196185,
		monopoly = 1,
		num = 1,
		reducedmg=1,
	},
	[11] = {
		day = 3,
		server_type = 512,
		itemtype = 722840,
		monopoly = 1,
		num = 1,
	},
	[12] = {
		day = 3,
		server_type = 512,
		itemtype = 3312767,
		monopoly = 1,
		num = 1,
	},
	[13] = {
		day = 3,
		server_type = 512,
		itemtype = 3314225,
		monopoly = 1,
		num = 5,
	},
}

local first_recharge = {
	[1] = {
		day = 1,
		server_type = 0,
		itemtype = 201009,
		monopoly = 1,
		num = 1,
	},
	[2] = {
		day = 1,
		server_type = 0,
		itemtype = 3312766,
		monopoly = 1,
		num = 1,
	},
	[3] = {
		day = 1,
		server_type = 0,
		itemtype = 3312767,
		monopoly = 1,
		num = 1,
	},
	[4] = {
		day = 1,
		server_type = 0,
		itemtype = 1088001,
		monopoly = 1,
		num = 1000,
	},
	[5] = {
		day = 1,
		server_type = 0,
		itemtype = 730004,
		monopoly = 1,
		num = 3,
		deltime = 432000
	},
	[6] = {
		day = 2,
		server_type = 0,
		itemtype = 200654,
		monopoly = 1,
		num = 1,
		reducedmg=1,
	},
	[7] = {
		day = 2,
		server_type = 0,
		itemtype = 3312767,
		monopoly = 1,
		num = 1,
	},
	[8] = {
		day = 2,
		server_type = 0,
		itemtype = 730004,
		monopoly = 1,
		num = 4,
		deltime = 432000
	},
	[9] = {
		day = 2,
		server_type = 0,
		itemtype = 1088000,
		monopoly = 1,
		num = 5,
	},
	[10] = {
		day = 3,
		server_type = 0,
		itemtype = 196185,
		monopoly = 1,
		num = 1,
		reducedmg=1,
	},
	[11] = {
		day = 3,
		server_type = 0,
		itemtype = 722840,
		monopoly = 1,
		num = 1,
	},
	[12] = {
		day = 3,
		server_type = 0,
		itemtype = 3312767,
		monopoly = 1,
		num = 1,
	},
	[13] = {
		day = 3,
		server_type = 0,
		itemtype = 3314225,
		monopoly = 1,
		num = 5,
	},
}

-- 首充奖励预览
local first_recharge_preview = {
	--服务器类型
	[512] = {
		-- 第一天
		[1] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 0,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 0,
			-- type = 1 和 2 时，配置模型大小
			scale = 100,
			-- type = 0 时，配置光效title
			title = "fp_Fan",
		},

		-- 第二天
		[2] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 2,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 200654,
			-- type = 1 和 2 时，配置模型大小
			scale = 150,
			-- type = 0 时，配置光效title
			title = "",
		},

		-- 第三天
		[3] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 1,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 196185,
			-- type = 1 和 2 时，配置模型大小
			scale = 200,
			-- type = 0 时，配置光效title
			title = "",
		},
	},
	
	[520] = {
		-- 第一天
		[1] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 0,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 0,
			-- type = 1 和 2 时，配置模型大小
			scale = 100,
			-- type = 0 时，配置光效title
			title = "fp_Fan",
		},

		-- 第二天
		[2] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 2,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 200654,
			-- type = 1 和 2 时，配置模型大小
			scale = 150,
			-- type = 0 时，配置光效title
			title = "",
		},

		-- 第三天
		[3] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 1,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 196185,
			-- type = 1 和 2 时，配置模型大小
			scale = 200,
			-- type = 0 时，配置光效title
			title = "",
		},
	},

	[0] = {
		-- 第一天
		[1] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 0,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 0,
			-- type = 1 和 2 时，配置模型大小
			scale = 100,
			-- type = 0 时，配置光效title
			title = "fp_Fan",
		},

		-- 第二天
		[2] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 2,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 200654,
			-- type = 1 和 2 时，配置模型大小
			scale = 150,
			-- type = 0 时，配置光效title
			title = "",
		},

		-- 第三天
		[3] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 1,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 196185,
			-- type = 1 和 2 时，配置模型大小
			scale = 200,
			-- type = 0 时，配置光效title
			title = "",
		},
	},
	[256] = {
		-- 第一天
		[1] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 0,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 0,
			-- type = 1 和 2 时，配置模型大小
			scale = 100,
			-- type = 0 时，配置光效title
			title = "fp_Fan",
		},

		-- 第二天
		[2] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 2,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 200654,
			-- type = 1 和 2 时，配置模型大小
			scale = 150,
			-- type = 0 时，配置光效title
			title = "",
		},

		-- 第三天
		[3] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 1,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 196185,
			-- type = 1 和 2 时，配置模型大小
			scale = 200,
			-- type = 0 时，配置光效title
			title = "",
		},
	},
	[264] = {
		-- 第一天
		[1] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 0,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 0,
			-- type = 1 和 2 时，配置模型大小
			scale = 100,
			-- type = 0 时，配置光效title
			title = "fp_Fan",
		},

		-- 第二天
		[2] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 2,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 200654,
			-- type = 1 和 2 时，配置模型大小
			scale = 150,
			-- type = 0 时，配置光效title
			title = "",
		},

		-- 第三天
		[3] = {
			-- type:0特效、1人物外套模型、2人物坐骑模型
			type = 1,
			-- type = 1 和 2 时，配置外套或者坐骑外套
			value = 196185,
			-- type = 1 和 2 时，配置模型大小
			scale = 200,
			-- type = 0 时，配置光效title
			title = "",
		},
	},

}
local function GetPreviewFirstRecharge(servertype, day, key)
	local infoTable = {};
	if first_recharge_preview[servertype] == nil then

		-- 如果没对应服务器配置，读取下列默认值
		infoTable = {
			-- 第一天
			[1] = {
				-- type:0特效、1人物外套模型、2人物坐骑模型
				type = 0,
				-- type = 1 和 2 时，配置外套或者坐骑外套
				value = 0,
				-- type = 1 和 2 时，配置模型大小
				scale = 100,
				-- type = 0 时，配置光效title
				title = "fp_Fan",
			},

			-- 第二天
			[2] = {
				-- type:0特效、1人物外套模型、2人物坐骑模型
				type = 2,
				-- type = 1 和 2 时，配置外套或者坐骑外套
				value = 200654,
				-- type = 1 和 2 时，配置模型大小
				scale = 150,
				-- type = 0 时，配置光效title
				title = "",
			},

			-- 第三天
			[3] = {
				-- type:0特效、1人物外套模型、2人物坐骑模型
				type = 1,
				-- type = 1 和 2 时，配置外套或者坐骑外套
				value = 196185,
				-- type = 1 和 2 时，配置模型大小
				scale = 200,
				-- type = 0 时，配置光效title
				title = "",
			},
		};
	else
		infoTable = first_recharge_preview[servertype];
	end

	if infoTable[day] == nil then
		return nil;
	end

	if infoTable[day][key] == nil then
		return nil;
	end

	return infoTable[day][key];
end
local function GetStatusIconOffset(Axis, Index)
	local l = 70
	local t = 70
	local icon_w = 30
	local icon_h = 30
	if (Axis == "x") then return icon_w * Index - l; end
	if (Axis == "y") then return - icon_h - t; end
	return 0
end

local function GetWingOffsetY(i)
	if (i == 5) then
		return 25
	elseif (i == 6) then
		return 25
	elseif (i == 7 or i == 8) then
		return 25
	end
end

local function GetWingOffsetZ(i)
	if (i == 5) then
		return -32
	elseif (i == 6) then
		return -32
	elseif (i == 7 or i == 8) then
		return -32
	end
end

local NameOffset = {
[110] = { y = 25 },
[115] = { y = 25 },
}

local SynflagInfo = {
	--相对于第一条血量的偏移
	["OffsetX"] = -70,
	["OffsetY"] = -170,
	--字体大小
	["FontSize"] = 20,
	--字体宽度
	["FontWidth"] = 11,
	--总血量颜色
	["MaxLifeColor"] = 0xff00ff00,
	--“/”分隔符颜色
	["SignColor"] = 0xffFAF706,
	["ColorNum"] = 3,
	--大于Percent1百分的数字血量
	[0] = {
	["Percent"] = 40,
	["NumColor"] = 0xFF00FF00,
	},  
	--大于Percent2百分的数字血量
	[1] = {
	["Percent"] = 20,
	["NumColor"] = 0xffffff00,
	},  
	[2] = {
	["Percent"] = -1,
	["NumColor"] = 0xffff0000,
	},  
}

local SynflagColorInfo = {
	--血条颜色数量（5条一个单位）
	--如BarLimit0为，当血量大于80000000时候，血条显示BarColor0的颜色
	["BarColorNum"] = 6,
	[0] = {
	["BarLimit"] = 100000001,
	["BarColor"] = 0xFF00FF00,
	},
	[1] = {
	["BarLimit"] = 80000001,
	["BarColor"] = 0xFFFBB803,
	},
	[2] = {
	["BarLimit"] = 60000001,
	["BarColor"] = 0xFF95FC03,
	},
	[3] = {
	["BarLimit"] = 40000001,
	["BarColor"] = 0xFF03F9FC,
	},
	[4] = {
	["BarLimit"] = 20000001,
	["BarColor"] = 0xFFFFDE00,
	},
	[5] = {
	["BarLimit"] = 0,
	["BarColor"] = 0xFFFF0000,
	},
}

local function GetTraceMosterOffset(i)
    if (i == "x") then
        return 20
    elseif (i == "y") then
        return -10
    end
end

-- 参数
-- 	NpcType	npc类型，对应数据库npc表的`type`字段
-- 	Axis	坐标轴，为"x"或"y"
-- 返回值
--	角色名的偏移值，y>0，则名字往上移
local function GetNameOffset(NpcType, Axis)
	local npc = NameOffset[NpcType]
	local offset = nil

	if (npc ~= nil) then
		offset = npc[Axis]
	end
	
	if (offset ~= nil) then
		return offset
	end
	
	return 0
end

local T_Immortal_Armor = {
[1] = 189915,
[2] = 189915,
[3] = 189915,
[4] = 189925,
[5] = 189925,
[6] = 189925,
[7] = 189935,
[8] = 189935,
[9] = 189935,
[10] = 189935,
}

-- 获取仙人模式等级对应衣服
local function GetImmortalModeArmor(immortalMode, armor)
	local ret = T_Immortal_Armor[immortalMode]

	if not ret then
		return 189885
	end
	return ret
end

-- 清理变量释放内存
local function Unload()
	T_Immortal_Armor = nil
	Player_GetStatusIconOffset = nil
        Player_GetNameOffset = nil
        Player_GetBarColorInfo = nil
	Player_GetSynflagInfo =  nil
	Player_GetTextColorInfo = nil
	Player_Unload = nil
	Player_unload = nil
end

local function GetSynflagInfo(key)
	local value = SynflagInfo[key]

	if (value) then
		return value
	end
	
	return 0
end

local function GetBarColorInfo(key)
	for i = 0,SynflagColorInfo["BarColorNum"],1 do
		if (key > SynflagColorInfo[i]["BarLimit"]) then
			return SynflagColorInfo[i]["BarColor"]
		end
	end
	
	return 0xFF00FF00
end

local function GetTextColorInfo(key)
	for i = 0,SynflagInfo["ColorNum"],1 do
		if (key > SynflagInfo[i]["Percent"]) then
			return SynflagInfo[i]["NumColor"]
		end
	end
	
	return 0xffff0000
end

--道士技能-枯木咒，根据易伤层数，修改光效
local function GetVulnerableEff(num)
	if num < 2 then
		return "hdjx_mu1lv1"
	elseif num < 3 then 
		return "hdjx_mu1lv2"
	else
		return "hdjx_mu1lv3"
	end
end

local function GetFirstRecharge(nIndex, key)
	if nIndex == "KuangEffect" then
		return "fp_kuang"
	end

	local tbReward = first_recharge;

	if UserData_IsOldSoldierServer() == true then
		tbReward = first_recharge_256;
	elseif UserData_IsCoinsServer() == true then
		tbReward = first_recharge_512
	end

	if tbReward == nil then
		return nil
	end

	if nIndex == "Amount" then
		return #tbReward
	end

	if tbReward[nIndex] == nil then
		return nil
	end

	if tbReward[nIndex][key] == nil then
		return nil
	end

	return tbReward[nIndex][key]
end

-- 通过require传给其他Lua脚本使用
local Player = {
	GetImmortalModeArmor = GetImmortalModeArmor,
	GetStatusIconOffset = GetStatusIconOffset,
	GetNameOffset = GetNameOffset,
	GetWingOffsetY = GetWingOffsetY,
	GetWingOffsetZ = GetWingOffsetZ,
    GetSynflagInfo = GetSynflagInfo,
	GetBarColorInfo = GetBarColorInfo,
	GetTextColorInfo = GetTextColorInfo,
	GetTraceMosterOffset = GetTraceMosterOffset,
	GetVulnerableEff = GetVulnerableEff,
	GetFirstRecharge = GetFirstRecharge,
	Unload = Unload,
	GetPreviewFirstRecharge = GetPreviewFirstRecharge,
	Unload = Unload,

}

-- C++程序使用的global函数名
Player_GetImmortalModeArmor = Player.GetImmortalModeArmor
Player_GetStatusIconOffset = Player.GetStatusIconOffset
Player_GetNameOffset = Player.GetNameOffset
Player_GetWingOffsetY = Player.GetWingOffsetY
Player_GetWingOffsetZ = Player.GetWingOffsetZ
Player_GetBarColorInfo = Player.GetBarColorInfo
Player_GetSynflagInfo = Player.GetSynflagInfo
Player_GetTextColorInfo = Player.GetTextColorInfo
Player_GetTraceMosterOffset = Player.GetTraceMosterOffset
Player_GetVulnerableEff = Player.GetVulnerableEff
Player_GetFirstRecharge = Player.GetFirstRecharge
Player_Unload = Player.Unload
Player_GetPreviewFirstRecharge = Player.GetPreviewFirstRecharge
Player_GetFirstRecharge = Player.GetFirstRecharge
Player_GetImmortalModeArmor = Player.GetImmortalModeArmor
Player_GetStatusIconOffset = Player.GetStatusIconOffset
-- require返回值
return Player

