local tItemSortData ={}
	tItemSortData[123] = 1--头盔类
	tItemSortData[205] = 20--双人骑宠外套
	tItemSortData[200] = 20--骑宠外套
	tItemSortData[201] = 12--法宝-凌霄扇
	tItemSortData[202] = 12--法宝-混元塔
	tItemSortData[203] = 21--马鞭
	tItemSortData[204] = 22--风雷翅
	tItemSortData[300] = 14--马匹
	tItemSortData[350] = 16--长武器外套
	tItemSortData[360] = 15--短武器外套
	tItemSortData[370] = 17--弓外套
	tItemSortData[380] = 18--盾外套
	tItemSortData[601] = 4--单手武器
	
	tItemSortData[1] = {}
	tItemSortData[1][11] = 1 --头盔
	tItemSortData[1][14] = 1 --头盔
	tItemSortData[1][17] = 1 --头盔
	tItemSortData[1][18] = 11 --外套
	tItemSortData[1][19] = 11 --外套
	tItemSortData[1][12] = 2 --项链
	tItemSortData[1][10] = 3 --盔甲
	tItemSortData[1][13] = 3 --盔甲
	tItemSortData[1][15] = 7 --戒指
	tItemSortData[1][16] = 8 --鞋子
	tItemSortData[4] = 4 --单手武器
	tItemSortData[6] = 4 --单手武器
	tItemSortData[5] = 5 --双手武器
	tItemSortData[7] = 9 --其他, 不能直接使用
	tItemSortData[9] = 6 --盾牌
	tItemSortData[10] = 0 --易耗品
	tItemSortData[20] = 10 --法宝
	tItemSortData[21] = 10 -- 法宝
	tItemSortData[22] = 10 --法宝
	tItemSortData[23] = 10 --法宝
	tItemSortData[24] = 10 --法宝
	tItemSortData[25] = 10 --法宝
	tItemSortData[26] = 10 --法宝
	tItemSortData[27] = 10 --法宝
	tItemSortData[28] = 10 --法宝
	tItemSortData[29] = 10 --法宝
	tItemSortData[39] = 26 --勾玉
	tItemSortData[40] = 23 --符文
	tItemSortData[41] = 24 --玄宝
	tItemSortData[42] = 25 --器灵
	

local function GetItemSort(nItemId)
	--勾玉物品特殊处理
	if nItemId >= 3330028 and nItemId <= 3330062 then
		return 26
	end
	
	--秘术精华
	if nItemId == 3329979 then
		return 26
	end
	
	--藏品物品特殊处理
	if (nItemId >= 4300000 and nItemId <= 4330000) then
		return 27
	end
	
	if (nItemId >= 4330000 and nItemId <= 4339999) then
		return 27
	end
	
	--元神
	if (nItemId >= 10020101 and nItemId <= 10100110) then
		return 28
	end
	
	local nType = -1
	local nHead = math.floor(nItemId / 1000)
	
	if tItemSortData[nHead] ~= nil then
		if nHead ~= 300 then
			nType = tItemSortData[nHead]
		elseif nItemId % 10 == 0 then
			nType = tItemSortData[nHead]
		end
	end
	
	if nType ~= -1 then
		return nType
	end
	
	nHead = math.floor(nItemId / 100000)
	local nSubData = math.floor((nItemId % 1000000) / 10000)
	
	if tItemSortData[nHead] ~= nil then
		if type(tItemSortData[nHead]) == "number" then
			nType = tItemSortData[nHead]
		elseif type(tItemSortData[nHead]) == "table" and tItemSortData[nHead][nSubData] ~= nil then
			nType = tItemSortData[nHead][nSubData]
		end
	end
	
	return nType
end

-- 是否是符文
local function IsRune(nItemId)
	local sort = math.floor(nItemId / 10000)
	
	if (sort == 401 or sort==402 or sort == 403) then
		-- 神纹配置去掉等级
		return true
	end
	
	return false
end

-- 主要是用于解决塔的sort在客户端是12，在服务端却是13的问题，让40713BBC能给塔使用，主要是添加了GetSpecialEffectSort这个函数
local function GetSpecialEffectSort(nItemId)
	if math.floor(nItemId / 1000) == 202 then
		return 13
	end
	
	return GetItemSort(nItemId)
end

--藏品相关id
local tCollectItem = {}
	tCollectItem[1] = 3326046
	tCollectItem[2] = 3326259
	tCollectItem[3] = 3326260
	tCollectItem[4] = 3326261
	tCollectItem[5] = 3326262
	tCollectItem[6] = 3326263
	tCollectItem[7] = 4300000
	tCollectItem[8] = 4300001
	tCollectItem[9] = 4300002
	tCollectItem[10] = 4300003
	tCollectItem[11] = 4300004
	tCollectItem[12] = 3336144
	tCollectItem[13] = 3336145
	tCollectItem[14] = 3336146
	tCollectItem[15] = 4310000
	tCollectItem[16] = 4310001
	tCollectItem[17] = 4310002
	tCollectItem[18] = 3336737
	tCollectItem[19] = 4320000
	tCollectItem[20] = 4320001
	tCollectItem[21] = 3341899
	tCollectItem[22] = 3341900
	tCollectItem[23] = 3341901
	tCollectItem[24] = 4330000
	tCollectItem[25] = 3342835
	tCollectItem[26] = 3342836
	tCollectItem[27] = 3344551
	tCollectItem[28] = 4320002
	tCollectItem[29] = 3346022
	tCollectItem[30] = 3346027
	tCollectItem[31] = 4331000
	tCollectItem[32] = 4330001
	tCollectItem[33] = 3347144
	tCollectItem[34] = 4330002
	tCollectItem[35] = 3348179
	tCollectItem[36] = 4332000
	tCollectItem[37] = 3349734
	tCollectItem[38] = 3349735
	
function IsCollect(nItemId)
	for k,v in pairs(tCollectItem) do
		if nItemId == v then
			return true
		end
	end
	
	return false
end

local ITEMSORT_RING					=	7 --戒指
local SpecialQuenchInfo = {
	--这个值是GetItemSort获得的
	[ITEMSORT_RING] = {
		[1] =  3348998,
		[2] =  3348999,
		[3] =  3349000,
		[4] =  3349001,
		[5] =  3349002,
	},
}

--返回装备能被什么特殊淬炼材料进行特殊淬炼
local function GetSpecialQuenchInfo(key,index,itemtype)
	print("GetSpecialQuenchInfo")
	index = index + 1
	local quenchType = GetItemSort(itemtype)
	if SpecialQuenchInfo[quenchType] == nil then
		return nil
	end

	if key == "amount"then
		return #SpecialQuenchInfo[quenchType]
	elseif SpecialQuenchInfo[quenchType][index] ~= nil then
		return SpecialQuenchInfo[quenchType][index]
	end

	return nil
end

--返回这个装备部位能否被特殊淬炼
local function IsCanSpecialQuench(nsort)
	print("IsCanSpecialQuench")
	if nsort == ITEMSORT_RING then
		return true
	end

	return false
end

--特殊淬炼材料列表
local SpecialQuenchItem = {
	--score:实力评分,  type1：1是属性2是技能, detail_type1: 属性类型或者技能type, detail_value1:属性值或者技能等级
	[3348998] = {score = 100,  type1 = 1, detail_type1 = 3, detail_value1 = 100, type2 = 1, detail_type2 = 5, detail_value2 = 100, type3 = 1, detail_type3 = 28, detail_value3 =  30, type4 = 1, detail_type4 = 29, detail_value4 = 30, type5 = 2, detail_type5 = 24940, detail_value5 = 1,  },
	[3348999] = {score = 200,  type1 = 1, detail_type1 = 3, detail_value1 = 200, type2 = 1, detail_type2 = 5, detail_value2 = 200, type3 = 1, detail_type3 = 28, detail_value3 =  60, type4 = 1, detail_type4 = 29, detail_value4 = 60, type5 = 2, detail_type5 = 24940, detail_value5 = 2,  },
	[3349000] = {score = 400,  type1 = 1, detail_type1 = 3, detail_value1 = 400, type2 = 1, detail_type2 = 5, detail_value2 = 400, type3 = 1, detail_type3 = 28, detail_value3 =  120, type4 = 1, detail_type4 = 29, detail_value4 = 120, type5 = 2, detail_type5 = 24940, detail_value5 = 3,  },
	[3349001] = {score = 700,  type1 = 1, detail_type1 = 3, detail_value1 = 700, type2 = 1, detail_type2 = 5, detail_value2 = 700, type3 = 1, detail_type3 = 28, detail_value3 =  210 ,type4 = 1, detail_type4 = 29, detail_value4 = 210,type5 = 2, detail_type5 = 24940, detail_value5 = 4,  },
	[3349002] = {score = 1000,  type1 = 1, detail_type1 = 3, detail_value1 =1000, type2 = 1, detail_type2 = 5, detail_value2 =1000, type3 = 1, detail_type3 = 28, detail_value3 = 300,type4 = 1, detail_type4 = 29, detail_value4 = 300,type5 = 2, detail_type5 = 24940, detail_value5 = 5,  },
	
}

--这边请判断物品是不是特殊淬炼材料
local function IsSpecialQuenchItem(itemtype)
	print("IsSpecialQuenchItem")
	if SpecialQuenchItem[itemtype] ~= nil then
		return true
	end

	return false
end

--根据不同的加成类型返回不同的值
local function GetValueStr(key, value)
	if key >= 1 and key <= 9 then
		return value
	else
		return string.format("%.2f", value / 100)
	end
end

--获得淬炼材料属性信息
local function GetSpecialQuenchItemInfo(itemtype, key, index)
	print("GetSpecialQuenchItemInfo")
	if SpecialQuenchItem[itemtype] == nil then
		return nil
	elseif key == "score" then
		return SpecialQuenchItem[itemtype]["score"]
	else
		local realKey = key..math.ceil(index + 1)
		local typeIndex = "type"..math.ceil(index + 1)
		if key == "type" then
			--返回是属性还是技能
			return SpecialQuenchItem[itemtype][typeIndex]
		elseif key == "detail_type" then
			--是属性
			if SpecialQuenchItem[itemtype][typeIndex] == 1 then
				return "STR_QUENCH_SPECIAL_ATTR_"..SpecialQuenchItem[itemtype][realKey].."_TIP"
			else
				return SpecialQuenchItem[itemtype][realKey]
			end
		elseif key == "detail_value" then
			if SpecialQuenchItem[itemtype][typeIndex] == 1 then
				local attrType = "detail_type"..math.ceil(index + 1)
				return GetValueStr(SpecialQuenchItem[itemtype][attrType], SpecialQuenchItem[itemtype][realKey])
			else
				return SpecialQuenchItem[itemtype][realKey]
			end
		end
	end
	
	return nil
end


--特殊淬炼材料加成最多的条数
local function GetSpecialQuenchItemAttrAmount(itemtype)
	return 5
end

local function GetQuenchSpecialSysMsg(itemtype)
	return "STR_QUENCH_SPECIAL_SUC_TIP"
end

local function Unload()
	tItemSortData = nil
	SpecialQuenchInfo = nil
	SpecialQuenchItem = nil
	tCollectItem = nil
end

local ItemSort = {
	GetQuenchSpecialSysMsg = GetQuenchSpecialSysMsg,
	GetSpecialQuenchItemInfo = GetSpecialQuenchItemInfo,
	GetSpecialQuenchItemAttrAmount = GetSpecialQuenchItemAttrAmount,
	IsCanSpecialQuench = IsCanSpecialQuench,
	GetValueStr = GetValueStr,
	GetSpecialQuenchInfo = GetSpecialQuenchInfo,
	IsSpecialQuenchItem = IsSpecialQuenchItem,
	GetSpecialEffectSort = GetSpecialEffectSort,
	GetItemSort = GetItemSort,
	IsRune = IsRune,
	IsCollect = IsCollect,
}

ItemSort_GetQuenchSpecialSysMsg = ItemSort.GetQuenchSpecialSysMsg
ItemSort_GetSpecialQuenchItemInfo = ItemSort.GetSpecialQuenchItemInfo
ItemSort_GetSpecialQuenchItemAttrAmount = ItemSort.GetSpecialQuenchItemAttrAmount
ItemSort_IsCanSpecialQuench = ItemSort.IsCanSpecialQuench
ItemSort_GetValueStr = ItemSort.GetValueStr
ItemSort_ClassifySubtype = ItemSort.ClassifySubtype
ItemSort_GetSellType = ItemSort.GetSellType
ItemSort_GetSpecialQuenchInfo = ItemSort.GetSpecialQuenchInfo
ItemSort_IsSpecialQuenchItem = ItemSort.IsSpecialQuenchItem
ItemSort_GetSpecialEffectSort = ItemSort.GetSpecialEffectSort
ItemSort_GetSort = ItemSort.GetItemSort
ItemSort_IsRune = ItemSort.IsRune
ItemSort_IsCollect = ItemSort.IsCollect

return ItemSort