-- 历练 --
local Lang = require("common.Lang")
local Util = require("common.Util")
local Msg = require("core.Msg")
local ObjHuman = require("core.ObjHuman")
local LiLianExcel = require("excel.liLian")
local LiLianTaskExcel = require("excel.liLian").group
local BagLogic = require("bag.BagLogic")
local Grid = require("bag.Grid")
local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
local CombatDefine = require("combat.CombatDefine")
local HeroExcel = require("excel.hero")
local YjTreasureLogic = require("yjTreasure.YjTreasureLogic")
local ChatHandler = require("chat.Handler")
local Broadcast = require("broadcast.Broadcast")
local ChatLogic = require("chat.ChatLogic")
local RoleDBLogic = require("role.RoleDBLogic")
local Timer = require("core.Timer")
LILIAN_TASK_TYPE1 = 1 --竞技历练
LILIAN_TASK_TYPE2 = 2 --战斗历练
LILIAN_TASK_TYPE3 = 3 --终极历练
LILIAN_TASK_TYPE4 = 4 --达标奖励

LILIAN_TASK1 = 1 	--皇冠联赛中，6回合内战胜高战力对手，累计{1}次 o
LILIAN_TASK2 = 2 	--皇冠联赛中，4回合内战胜高战力对手，累计{1}次 o
LILIAN_TASK3 = 3	--众神之战累计进入{1}次32强 o
LILIAN_TASK4 = 4 	--众神之战累计进入{1}次8强 o
LILIAN_TASK5 = 5 	--获得{1}次众神之战冠军 o
LILIAN_TASK6 = 6 	--天梯争霸赛季结算时获得前{1}名 o
LILIAN_TASK7 = 7 	--天梯争霸累计挑战胜利{1}次 o
LILIAN_TASK8 = 8 	--巅峰段位赛累计获胜{1}场 x
LILIAN_TASK9 = 9 	--巅峰段位赛结算时达到铂金及以上段位 x
LILIAN_TASK10 = 10 	--巅峰段位赛结算时达到钻石及以上段位 x
LILIAN_TASK11 = 11 	--巅峰段位赛赛季结算时获得前{1}名 x
LILIAN_TASK12 = 12 	--通关通天塔{1}层 o
LILIAN_TASK13 = 13 	--挑战公会boss，当场累计造成{1}伤害 o
LILIAN_TASK14 = 14 	--公会战中累计获得{1}次个人胜利 o
LILIAN_TASK15 = 15 	--通关{1}次圣树试炼普通难度 o
LILIAN_TASK16 = 16 	--通关{1}次圣树试炼精英难度 o
LILIAN_TASK17 = 17 	--通关{1}次圣树试炼噩梦难度 o
LILIAN_TASK18 = 18 	--进入遗迹探宝{1}层 o
LILIAN_TASK19 = 19 	--遗迹探宝中累计击败{1}守卫 o
LILIAN_TASK20 = 20 	--单场公会boss累计造成{1}中毒伤害 o
LILIAN_TASK21 = 21 	--单场通天塔累计造成{1}流血伤害 o
LILIAN_TASK22 = 22 	--单场公会战累计造成{1}燃烧伤害 o
LILIAN_TASK23 = 23 	--通关无尽之路{1}关 x
LILIAN_TASK24 = 24 	--通关任意圣殿第{1}关 x
LILIAN_TASK25 = 25 	--本周内通关每个圣殿第{1}关 x
LILIAN_TASK26 = 26 	--守望圣殿排行榜结算时累计获得{1}次前10 x
LILIAN_TASK27 = 27 	--守望圣殿排行榜结算时累计获得{1}次前3 x
LILIAN_TASK28 = 28 	--完美通关神之领域前{1}章 x
LILIAN_TASK29 = 29 	--最高战力达到{1}万 o
LILIAN_TASK30 = 30 	--当前拥有{1}个10星英雄 o
LILIAN_TASK31 = 31 	--当前拥有{1}个11星英雄 o
LILIAN_TASK32 = 32 	--使{1}个恶魔英雄达到10星 1 o
LILIAN_TASK33 = 33 	--使{1}个恶魔英雄达到11星   o
LILIAN_TASK34 = 34 	--使{1}个不死英雄达到10星 2 o
LILIAN_TASK35 = 35 	--使{1}个不死英雄达到11星   o
LILIAN_TASK36 = 36 	--使{1}个圣堂英雄达到10星 3 o
LILIAN_TASK37 = 37 	--使{1}个圣堂英雄达到11星   o
LILIAN_TASK38 = 38 	--使{1}个神谕英雄达到10星 4 o
LILIAN_TASK39 = 39 	--使{1}个神谕英雄达到11星   o
LILIAN_TASK40 = 40 	--使{1}个混沌英雄达到10星 5 o
LILIAN_TASK41 = 41 	--使{1}个混沌英雄达到11星   o
LILIAN_TASK42 = 42 	--任意一场众神之战中{1}次竞猜全部正确 o
LILIAN_TASK43 = 43 	--普通招募累计活动{1}个5星英雄 o
LILIAN_TASK44 = 44 	--友情招募累计获得{1}个5星英雄 o
LILIAN_TASK45 = 45 	--累计获得{1}个神话符文 o
LILIAN_TASK46 = 46 	--累计获得{1}个传说符文 o
LILIAN_TASK47 = 47 	--累计领悟{1}本初级兵书 o
LILIAN_TASK48 = 48 	--累计领悟{1}本中级兵书 o
LILIAN_TASK49 = 49 	--累计充值{1}钻石 o
LILIAN_TASK50 = 50 	--公会建设中累计花费{1}钻石 o
LILIAN_TASK51 = 51 	--获得{1}次公会红包的手气最佳 o
LILIAN_TASK52 = 52 	--发放的红包累计超过{1}钻石 o
LILIAN_TASK53 = 53 	--累计完成{1}个历练任务 o

LILIAN_OUTID1 = 1 --皇冠联赛中，x回合内战胜高战力对手，累计{1}次
LILIAN_OUTID2 = 2 --众神之战累计进入{1}次x强
LILIAN_OUTID3 = 3 --天梯争霸赛季结算时获得前{1}名
LILIAN_OUTID4 = 4 --天梯争霸累计挑战胜利{1}次
LILIAN_OUTID5 = 5 --巅峰段位赛累计获胜{1}场
LILIAN_OUTID6 = 6 --巅峰段位赛结算时达到x及以上段位
LILIAN_OUTID7 = 7 --巅峰段位赛赛季结算时获得前{1}名
LILIAN_OUTID8 = 8 --通关通天塔{1}层
LILIAN_OUTID9 = 9 --挑战公会boss，当场累计造成{1}伤害
LILIAN_OUTID10 = 10 --公会战中累计获得{1}次个人胜利
LILIAN_OUTID11 = 11 --通关{1}次圣树试炼x难度
LILIAN_OUTID12 = 12 --进入遗迹探宝{1}层
LILIAN_OUTID13 = 13 --遗迹探宝中累计击败{1}守卫
LILIAN_OUTID14 = 14 --单场公会boss累计造成{1}中毒伤害
LILIAN_OUTID15 = 15 --单场通天塔累计造成{1}流血伤害
LILIAN_OUTID16 = 16 --单场公会战累计造成{1}燃烧伤害
LILIAN_OUTID17 = 17 --通关无尽之路{1}关
LILIAN_OUTID18 = 18 --通关任意圣殿第{1}关
LILIAN_OUTID19 = 19 --本周内通关每个圣殿第{1}关
LILIAN_OUTID20 = 20 --守望圣殿排行榜结算时累计获得{1}次前x
LILIAN_OUTID21 = 21 --完美通关神之领域前{1}章
LILIAN_OUTID22 = 22 --最高战力达到{1}
LILIAN_OUTID23 = 23 --当前拥有{1}个x星英雄
LILIAN_OUTID24 = 24 --使{1}个x英雄达到x星
LILIAN_OUTID25 = 25 --任意一场众神之战中{1}次竞猜全部正确
LILIAN_OUTID26 = 26 --普通招募累计活动{1}个x星英雄
LILIAN_OUTID27 = 27 --友情招募累计获得{1}个x星英雄
LILIAN_OUTID28 = 28 --累计获得{1}个x符文
LILIAN_OUTID29 = 29 --累计充值{1}钻石
LILIAN_OUTID30 = 30 --公会建设中累计花费{1}钻石
LILIAN_OUTID31 = 31 --获得{1}次公会红包的手气最佳
LILIAN_OUTID32 = 32 --发放的红包累计超过{1}钻石
LILIAN_OUTID33 = 33 --累计完成{1}个历练任务

LILIAN_OUT2TASK = {
	[LILIAN_OUTID1] = {LILIAN_TASK1,LILIAN_TASK2},
	[LILIAN_OUTID2] = {LILIAN_TASK3,LILIAN_TASK4,LILIAN_TASK5},
	[LILIAN_OUTID3] = {LILIAN_TASK6},
	[LILIAN_OUTID4] = {LILIAN_TASK7},
	[LILIAN_OUTID5] = {LILIAN_TASK8},
	[LILIAN_OUTID6] = {LILIAN_TASK9,LILIAN_TASK10},
	[LILIAN_OUTID7] = {LILIAN_TASK11},
	[LILIAN_OUTID8] = {LILIAN_TASK12},
	[LILIAN_OUTID9] = {LILIAN_TASK13},
	[LILIAN_OUTID10] = {LILIAN_TASK14},
	[LILIAN_OUTID11] = {LILIAN_TASK15,LILIAN_TASK16,LILIAN_TASK17},
	[LILIAN_OUTID12] = {LILIAN_TASK18},
	[LILIAN_OUTID13] = {LILIAN_TASK19},
	[LILIAN_OUTID14] = {LILIAN_TASK20},
	[LILIAN_OUTID15] = {LILIAN_TASK21},
	[LILIAN_OUTID16] = {LILIAN_TASK22},
	[LILIAN_OUTID17] = {LILIAN_TASK23},
	[LILIAN_OUTID18] = {LILIAN_TASK24},
	[LILIAN_OUTID19] = {LILIAN_TASK25},
	[LILIAN_OUTID20] = {LILIAN_TASK26,LILIAN_TASK27},
	[LILIAN_OUTID21] = {LILIAN_TASK28},
	[LILIAN_OUTID22] = {LILIAN_TASK29},
	[LILIAN_OUTID23] = {LILIAN_TASK30,LILIAN_TASK31},
	[LILIAN_OUTID24] = {LILIAN_TASK32,LILIAN_TASK33,LILIAN_TASK34,LILIAN_TASK35,LILIAN_TASK36,LILIAN_TASK37,LILIAN_TASK38,LILIAN_TASK39,LILIAN_TASK40,LILIAN_TASK41},
	[LILIAN_OUTID25] = {LILIAN_TASK42},
	[LILIAN_OUTID26] = {LILIAN_TASK43},
	[LILIAN_OUTID27] = {LILIAN_TASK44},
	[LILIAN_OUTID28] = {LILIAN_TASK45,LILIAN_TASK46,LILIAN_TASK47,LILIAN_TASK48},
	[LILIAN_OUTID29] = {LILIAN_TASK49},
	[LILIAN_OUTID30] = {LILIAN_TASK50},
	[LILIAN_OUTID31] = {LILIAN_TASK51},
	[LILIAN_OUTID32] = {LILIAN_TASK52},
	[LILIAN_OUTID33] = {LILIAN_TASK53},
}

LILIAN_STATE_NOT = 0            -- 未完成
LILIAN_STATE_CAN = 1            -- 可获取
LILIAN_STATE_HAD = 2            -- 已获取

-- 根据历练类型获取配表
local function getConfigByType(lilianType)
	if lilianType == LILIAN_TASK_TYPE1 then
		return LiLianExcel.jjcLiLian
	elseif lilianType == LILIAN_TASK_TYPE2 then
		return LiLianExcel.combatLiLian
	elseif lilianType == LILIAN_TASK_TYPE3 then
		return LiLianExcel.finalLiLian
	elseif lilianType == LILIAN_TASK_TYPE4 then
		return LiLianExcel.dabiaoReward
	end
end

-- 获取历练组id详细历练配置
-- config 历练类型配表
-- groupID 历练任务组
function getLiLianConf(human,config,groupID)
    -- 初始化历练db
    human.db.liLianGroup = human.db.liLianGroup or {}
	human.db.liLianGroup[groupID] = human.db.liLianGroup[groupID] or {0,1}

	local liLianDB = human.db.liLianGroup[groupID]
	local groupConfig = LiLianTaskExcel[groupID]

	if groupConfig == nil then
		return
	end
	
	local liLianID = groupConfig.sub[liLianDB[2]]
	return config[liLianID],groupConfig,liLianID
end

-- 获取背包中传入星级英雄个数
local function getStarHeroCnt(human,starTarget)
	local cnt = 0 
	for index, heroGrid in pairs(human.db.heroBag) do
		if index ~= 0 then
			local id = heroGrid and (heroGrid.id or heroGrid.heroID) 
			local config = id and HeroExcel.hero[id]
			local star = config and config.star or 0
			if star == starTarget then
				cnt = cnt + 1
			end
		end
	end
	return cnt
end

-- 获取任务组完成次数
local function getFinishCntByTask(human,groupID)
	--通天塔
	if groupID == LILIAN_TASK12 then
		return human.db.tower and human.db.tower.lv or 0 
	--遗迹探宝
	elseif groupID == LILIAN_TASK18 then
		return YjTreasureLogic.getLayerMax(human)
	-- --无尽之路
	-- elseif task == LILIAN_TASK23 then
	-- 	return
	-- --任意圣殿x关
	-- elseif task == LILIAN_TASK24 then
	-- 	return
	-- --每个圣殿x关
	-- elseif task == LILIAN_TASK25 then
	-- 	return
	-- --神之领域x章
	-- elseif task == LILIAN_TASK28 then
	-- 	return
	--x个10星英雄
	elseif groupID == LILIAN_TASK30 then
		return getStarHeroCnt(human,10)
	--x个11星英雄
	elseif groupID == LILIAN_TASK31 then
		return getStarHeroCnt(human,11)
	--累充
	elseif groupID == LILIAN_TASK49 then
		return human.db.topupAcountDaily or 0
	end

	return human.db.liLian and human.db.liLian.taskRecord and human.db.liLian.taskRecord[groupID] or 0
end

-- 根据历练类型及历练id获取历练状态
local function getStateByLiLianID(human,taskType,id)
	local config = getConfigByType(taskType)

	if not config or not config[id] then
        return LILIAN_STATE_NOT 
    end

	if human.db.liLian 
        and human.db.liLian[taskType]
		and human.db.liLian[taskType].getList 
		and human.db.liLian[taskType].getList[id] then
		return LILIAN_STATE_HAD
	end

	local need = config[id].param
	local now = getFinishCntByTask(human,config[id].task)
	local taskConfig = LiLianExcel.tasks[config[id].task]
	if taskConfig.compareType ~= 0 then
		if now <= need and now ~= 0 then return LILIAN_STATE_CAN end
	else
		if now >= need then return LILIAN_STATE_CAN end
	end

	return LILIAN_STATE_NOT
end

-- 构造历练任务结构体
local function makeLiLianTask(human,net,config,taskType,id)
	net.id = id
	net.taskName = config.taskName
	net.taskDesc = config.desc
	net.finishCnt = getFinishCntByTask(human,config.task)	
	net.needCnt = config.param
	net.state = getStateByLiLianID(human,taskType,id)
	net.panelID = config.panelID

	net.items[0] = #config.reward
	for i=1,#config.reward do
		Grid.makeItem(net.items[i],config.reward[i][1],config.reward[i][2])
	end
end

-- 获取一个类型所有任务完成数量
local function getAllFinishCnt(human,taskType)
	local getList = nil
	if human.db.liLian
		and human.db.liLian[taskType]
		and human.db.liLian[taskType]
		and human.db.liLian[taskType].getList then
		getList = human.db.liLian[taskType].getList
	end
	
	local cnt = 0
	if getList then
		for _,_ in pairs(getList) do
			cnt = cnt + 1
		end
	end

	local config = getConfigByType(taskType)
	return cnt,#config
end

-- 红点检查
local function isRedByTaskType(human,taskType)
	local config = getConfigByType(taskType)
	for i=1,#config do
		local state = getStateByLiLianID(human,taskType,i)
		if state == LILIAN_STATE_CAN then
			return true
		end
	end
end

-- 
local function makeLiLianTaskState(human,net,taskType)
	net[0] = 4

	local index = 0
	for i=1,4 do
		index = index + 1
		net[index].taskType = i

		local finishCnt,needCnt = getAllFinishCnt(human,i)
		net[index].finishCnt = finishCnt
		net[index].needCnt = needCnt
		net[index].isRed = isRedByTaskType(human,i) and 1 or 0
	end
end

-- 查询历练
function lilianQuery(human,taskType)
	local config = getConfigByType(taskType)
	if not config then return end

	local msgRet = Msg.gc.GC_LILIAN_QUERY
	msgRet.taskType = taskType
	
    local len = #LiLianTaskExcel
    local count = 0
	for i=1,len do
        if LiLianTaskExcel[i].taskType == taskType then
            local lilianConfig,groupConfig,id = getLiLianConf(human,config,i)
            if lilianConfig ~= nil then
                count = count + 1
		        makeLiLianTask(human,msgRet.lists[count],lilianConfig,taskType,id)
            end
        end
	end
    
	msgRet.lists[0] = count
	makeLiLianTaskState(human,msgRet.taskState,taskType)
	--Msg.trace(msgRet)
	Msg.send(msgRet,human.fd)
end

function lilianGet(human,taskType,liLianID)
	local config = getConfigByType(taskType)

	if not config or not config[liLianID] then
        return 
    end

	local state = getStateByLiLianID(human,taskType,liLianID)
	if state ~= LILIAN_STATE_CAN then 
        return
    end

	human.db.liLian = human.db.liLian or {}
	human.db.liLian[taskType] = human.db.liLian[taskType] or {}
	human.db.liLian[taskType].getList = human.db.liLian[taskType].getList or {}
	human.db.liLian[taskType].getList[liLianID] = liLianID
    
    human.db.liLianGroup = human.db.liLianGroup or {}
	human.db.liLianGroup[config[liLianID].task] = human.db.liLianGroup[config[liLianID].task] or {0,1}
	human.db.liLianGroup[config[liLianID].task][2] = human.db.liLianGroup[config[liLianID].task][2] + 1 

    BagLogic.addItemList(human, config[liLianID].reward, "li_lian")
    lilianQuery(human,taskType)
	onCallback(human,LILIAN_OUTID33,1,nil,nil,true)
end

-- 
function setCnt(human,task,param1,noAdd)
	if noAdd then
		human.db.liLian = human.db.liLian or {}
		human.db.liLian.taskRecord = human.db.liLian.taskRecord or {}
		human.db.liLian.taskRecord[task] = param1
	else
		human.db.liLian = human.db.liLian or {}
		human.db.liLian.taskRecord = human.db.liLian.taskRecord or {}
		human.db.liLian.taskRecord[task] = (human.db.liLian.taskRecord[task] or 0 ) + param1
	end

--	print("human.db.liLian.taskRecord[task]",human.db.liLian.taskRecord[task])
end

-- 触发回调
function onCallback(human,outID,param1,param2,param3,noAdd)
	if not LILIAN_OUT2TASK[outID] then return end
	for i=1,#LILIAN_OUT2TASK[outID] do
		local task = LILIAN_OUT2TASK[outID][i]
		local taskConfig = LiLianExcel.tasks[task]
		local set = true
		local paramCnf = taskConfig.param
		if #paramCnf > 0 then
			local paramCnf1 = paramCnf[1]
			local paramCnf2 = paramCnf[2] or 0
			if param2 ~= paramCnf1 then
				set = nil
			end

			if paramCnf2 ~= 0 then
				if param3 ~= paramCnf2 then
					set = nil
				end
			end

			if outID == LILIAN_OUTID1 or outID == LILIAN_OUTID2 or outID == LILIAN_OUTID20 then
				if param2 <= paramCnf1 then
					set = true
				end
			end
		else
			local nowCnt = getFinishCntByTask(human,task)
			if nowCnt ~= 0 then
				if taskConfig.compareType ~= 0 then
					if nowCnt <= param1 then
						set = nil
					end
				else
					if nowCnt >= param1 then
						set = nil
					end
				end
			end
		end

		if set then
			setCnt(human,task,param1,noAdd)
		end
	end
end


function onCallbackByUuid(uuid,task,param1,param2,param3,noAdd)
	do return end

	local target = ObjHuman.onlineUuid[uuid]
	if target and target.fd then
		onCallback(target,task,param1,param2,param3,noAdd)
	else
		local fakeDB = RoleDBLogic.getDb(uuid,{liLian = 1})
		if fakeDB then
			local fakeHuman = {}
			fakeHuman.db = fakeDB
			onCallback(fakeHuman,task,param1,param2,param3,noAdd)
			ObjHuman.save(fakeHuman)
		end
	end	
end

function onCallbackByCombat(human,combatInfo)
	do return end

	if not combatInfo then return end
	
	local attacker = combatInfo.attacker
	local defender = combatInfo.defender
	local combatType = combatInfo.type

	if combatType ~= CombatDefine.COMBAT_TYPE2 or --皇冠联赛/冠军联赛（进攻）
		combatType ~= CombatDefine.COMBAT_TYPE11 or --公会boss
		combatType ~= CombatDefine.COMBAT_TYPE12 or --公会战（进攻）
		combatType ~= CombatDefine.COMBAT_TYPE6 then --通天塔/恶魔之塔
		return
	end

	if attacker.uuid ~= human.db._id then return end
	
	if attacker.zhandouli < defender.zhandouli and combatType == CombatDefine.COMBAT_TYPE2 then
		onCallback(human,LILIAN_OUTID1,1,combatInfo.result.round)
	end
	
	local totalzhongdu = nil
	local totalliuxue = nil
	local totalranshao = nil
	local totalhurt = nil
	for pos = 1, CombatDefine.COMBAT_HERO_CNT do
		local obj = objList and objList[pos]
		if obj then
			local extraCombatRecord = obj.extraCombatRecord
			local zhongdu = extraCombatRecord and extraCombatRecord.zhongdu or 0
			local liuxue = extraCombatRecord and extraCombatRecord.liuxue or 0
			local ranshao = extraCombatRecord and extraCombatRecord.ranshao or 0
			local hurt = obj.result and obj.result[1] or 0

			if zhongdu > 0 and combatType == CombatDefine.COMBAT_TYPE11 then
				totalzhongdu = (totalzhongdu or 0) + zhongdu
			end

			if liuxue > 0 and combatType == CombatDefine.COMBAT_TYPE6 then
				totalliuxue = (totalliuxue or 0) + liuxue
			end

			if ranshao > 0 and combatType == CombatDefine.COMBAT_TYPE12 then
				totalranshao = (totalranshao or 0) + ranshao
			end

			if hurt > 0 and combatType == CombatDefine.COMBAT_TYPE11 then
				totalhurt = (totalhurt or 0) + hurt
			end
		end 
	end

	if totalzhongdu then
		onCallback(human,LILIAN_OUTID14,totalzhongdu)
	end

	if totalliuxue then
		onCallback(human,LILIAN_OUTID15,totalliuxue)
	end

	if totalranshao then
		onCallback(human,LILIAN_OUTID16,totalliuxue)
	end

	if totalhurt then
		onCallback(human,LILIAN_OUTID9,totalhurt)
	end
end

-- 历练分享
function lilianShare(human,taskType,id,shareType)
	local state = getStateByLiLianID(human,taskType,id)
	if state ~= LILIAN_STATE_HAD then return end

	if shareType ~= ChatHandler.CHAT_TYPE_WORLD and shareType ~= ChatHandler.CHAT_TYPE_UNION and shareType ~= ChatHandler.CHAT_TYPE_MIDDLE then
		return
	end
	
	-- 如果是分享在世界上检测是否在聊天CD 中
	if shareType == ChatHandler.CHAT_TYPE_WORLD and human.worldChatTime and human.worldChatTime + CHAT_CD > Timer.now then
		local cdLeftSec = math.ceil((CHAT_CD - (Timer.now - human.worldChatTime))/1000)
		Broadcast.sendDown(human, Util.format(Lang.CHAT_TIME_SHORT, cdLeftSec))
		return
	end

	if shareType == ChatHandler.CHAT_TYPE_UNION and human.db.unionUuid == nil then
		return Broadcast.sendErr(human, Lang.UNION_PLAYER_IN_NO)
	end
	
	local shareConf = LiLianExcel.share[taskType]
	if not shareConf then return end

	local config = getConfigByType(taskType)
	if not config then return end

	local name = shareConf.name
	local desc = shareConf.desc
	local taskName = config[id].taskName

	local content = Util.format(desc,name,taskName)

    local msgNet = {}
    msgNet.msgType = shareType
    msgNet.msg = content

	local flag = ChatLogic.chat(human, msgNet)
    if flag == true then
        Broadcast.sendErr(human, Lang.SHARE_SUCCESS)
    else
        Broadcast.sendErr(human, Lang.SHARE_ERROR)
    end
end


function isDot(human)
   for i = 1, 4 do
   	  if isRedByTaskType(human,i) then
         return true
      end
   end
   return false
end