瀏覽代碼

提交战区聊天和修复战力冲刺bug

SCFC 1 年之前
父節點
當前提交
985f4eaa9c

+ 2 - 1
script/common/InnerProto.lua

@@ -31,7 +31,8 @@ WL_HEARTBEAT = {}
 
 LW_MIDDLE_CHAT = 
 {
-  {"tChatMsg",               "table"}
+  {"svrIndex",               "int"},
+  {"tChatMsg",               "table"},
 }
 
 WL_MIDDLE_CHAT = 

+ 3 - 1
script/common/Lang.lua

@@ -67,7 +67,9 @@ CHAT_TIME_DUPLICATE = [[你不能重复发言]]
 CHAT_BAN = [[禁言中]]
 CHAT_NEED_JOIN_UNION = [[尚未加入公会]]
 CHAT_NEED_LV_ARGS = [[等级达到{1}级开放此聊天]]
-CHAT_MIDDLE_NEED_LV_ARGS = [[等级达到{1}级且开服达到7天才可在此频道发言]]
+CHAT_MIDDLE_NEED_LV_ARGS = [[等级达到{1}级且开服达到15天才可在此频道发言]]
+CHAT_WARZONE_NEED_LV_ARGS = [[等级达到{1}级且开服达到7天才可在此频道发言]]
+
 
 BATTLE_HANG_GET_ITEM_ERR_NONE = [[没有新的战利品]]
 BATTLE_HANG_GET_EXP_ERR_NONE = [[没有产生新的经验]]

+ 79 - 30
script/module/chat/ChatLogic.lua

@@ -21,6 +21,41 @@ local ObjHuman = require("core.ObjHuman")
 local InnerMsg = require("core.InnerMsg")
 local CommonDB = require("common.CommonDB")
 
+local CHAT_SENDDOWN_RESON_LV = 1
+local CHAT_SENDDOWN_RESON_DAY = 2
+
+local function ChatLogic_GetLimit(nChatType)
+    local nLimitLv, nLimitOpenDay = 0, 0
+    if ChatHandler.CHAT_TYPE_MIDDLE == nChatType then
+        nLimitLv = ChatHandler.CHAT_LV_NEED_MIDDLE
+        nLimitOpenDay = ChatHandler.CHAT_OPEN_DAY_MIDDLE
+
+    elseif ChatHandler.CHAT_TYPE_WARZONE == nChatType then
+        nLimitLv = ChatHandler.CHAT_LV_NEED_WARZONE
+        nLimitOpenDay = ChatHandler.CHAT_OPEN_DAY_WARZONE
+    elseif ChatHandler.CHAT_TYPE_WORLD == nChatType then
+        nLimitLv = ChatHandler.CHAT_LV_NEED_WORLD
+    elseif ChatHandler.CHAT_TYPE_FRIEND == nChatType then
+        nLimitLv = ChatHandler.CHAT_LV_NEED_FRIEND
+    end
+
+    return nLimitLv, nLimitOpenDay
+end
+
+local function ChatLogic_SendDown(human, nChatType, nReson)
+    local str
+    if ChatHandler.CHAT_TYPE_MIDDLE == nChatType then
+        str = Util.format(Lang.CHAT_MIDDLE_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_MIDDLE)
+    elseif ChatHandler.CHAT_TYPE_WARZONE == nChatType then
+        str = Util.format(Lang.CHAT_WARZONE_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_WARZONE)
+    elseif ChatHandler.CHAT_TYPE_WORLD == nChatType then
+        str = Util.format(Lang.CHAT_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_WORLD)
+    elseif ChatHandler.CHAT_TYPE_FRIEND == nChatType then
+        str = Util.format(Lang.CHAT_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_FRIEND)
+    end
+
+    Broadcast.sendDown(human, str)
+end
 
 function chat(human, recvMsg, isJson)
 	if Gm.checkGm(human, recvMsg.msg) then
@@ -29,40 +64,51 @@ function chat(human, recvMsg, isJson)
 
     isJson = isJson or ChatHandler.CHAT_NORMAL
     
-	--世界聊天限制等级
-    if recvMsg.msgType == ChatHandler.CHAT_TYPE_WORLD then 
-		if human.db.lv < ChatHandler.CHAT_LV_NEED_WORLD and VipLogic.getVipLv(human) == 0 then
-            local str = Util.format(Lang.CHAT_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_WORLD)
-			Broadcast.sendDown(human, str)
-			return 
-		end
+    local nOpenServerDay = CommonDB.getServerOpenDay()
+    local nLimitLv, nLimitOpenDay = ChatLogic_GetLimit(recvMsg.msgType)
+    if human.db.lv < nLimitLv and VipLogic.getVipLv(human) == 0 then
+        ChatLogic_SendDown(human, recvMsg.msgType, CHAT_SENDDOWN_RESON_LV)
+        return
     end
 
-    -- 跨服聊天限制等级
-    if recvMsg.msgType == ChatHandler.CHAT_TYPE_MIDDLE then 
-        local nOpenServerDay = CommonDB.getServerOpenDay()
-        if nOpenServerDay < 7 then
-            local str = Util.format(Lang.CHAT_MIDDLE_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_MIDDLE)
-			Broadcast.sendDown(human, str)
-            return
-        end
-
-		if human.db.lv < ChatHandler.CHAT_LV_NEED_MIDDLE and VipLogic.getVipLv(human) == 0 then
-			local str = Util.format(Lang.CHAT_MIDDLE_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_MIDDLE)
-			Broadcast.sendDown(human, str)
-			return 
-		end
+    if nOpenServerDay < nLimitOpenDay then
+        ChatLogic_SendDown(human, recvMsg.msgType, CHAT_SENDDOWN_RESON_DAY)
+        return
     end
 
+	--世界聊天限制等级
+    -- if recvMsg.msgType == ChatHandler.CHAT_TYPE_WORLD then 
+	-- 	if human.db.lv < ChatHandler.CHAT_LV_NEED_WORLD and VipLogic.getVipLv(human) == 0 then
+    --         local str = Util.format(Lang.CHAT_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_WORLD)
+	-- 		Broadcast.sendDown(human, str)
+	-- 		return 
+	-- 	end
+    -- end
+
+    -- 跨服聊天限制等级
+    -- if recvMsg.msgType == ChatHandler.CHAT_TYPE_MIDDLE then 
+    --     local nOpenServerDay = CommonDB.getServerOpenDay()
+    --     if nOpenServerDay < 15 then
+    --         local str = Util.format(Lang.CHAT_MIDDLE_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_MIDDLE)
+	-- 		Broadcast.sendDown(human, str)
+    --         return
+    --     end
+
+	-- 	if human.db.lv < ChatHandler.CHAT_LV_NEED_MIDDLE and VipLogic.getVipLv(human) == 0 then
+	-- 		local str = Util.format(Lang.CHAT_MIDDLE_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_MIDDLE)
+	-- 		Broadcast.sendDown(human, str)
+	-- 		return 
+	-- 	end
+    -- end
 
     -- 好友私聊
     if recvMsg.msgType == ChatHandler.CHAT_TYPE_FRIEND then 
 		-- 聊天权限判断
-        if human.db.lv < ChatHandler.CHAT_LV_NEED_FRIEND and VipLogic.getVipLv(human) == 0 then
-			local str = Util.format(Lang.CHAT_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_FRIEND)
-			Broadcast.sendDown(human, str)
-			return 
-		end
+        -- if human.db.lv < ChatHandler.CHAT_LV_NEED_FRIEND and VipLogic.getVipLv(human) == 0 then
+		-- 	local str = Util.format(Lang.CHAT_NEED_LV_ARGS, ChatHandler.CHAT_LV_NEED_FRIEND)
+		-- 	Broadcast.sendDown(human, str)
+		-- 	return 
+		-- end
 
         -- 是否互为好友
         local isFriend = FriendDBLogic.isFriend(human.db._id, recvMsg.fUuid)
@@ -126,8 +172,9 @@ function chat(human, recvMsg, isJson)
     human.chatTime = human.chatTime or {}
     local chatTime = human.chatTime[recvMsg.msgType] or 0
 
-    if recvMsg.msgType == ChatHandler.CHAT_TYPE_WORLD or
-       recvMsg.msgType == ChatHandler.CHAT_TYPE_MIDDLE then --世界聊天
+    if recvMsg.msgType == ChatHandler.CHAT_TYPE_WORLD or    --世界聊天
+       recvMsg.msgType == ChatHandler.CHAT_TYPE_MIDDLE or   -- 全服
+       ChatHandler.CHAT_TYPE_WARZONE == recvMsg.msgType then    -- 战区
         --世界聊天
         -- 判断上次发言时间
         if chatTime and chatTime + ChatHandler.CHAT_CD > Timer.now then
@@ -150,9 +197,11 @@ function chat(human, recvMsg, isJson)
         human.chatTime[recvMsg.msgType] = Timer.now
 
         -- 跨服
-        if  recvMsg.msgType == ChatHandler.CHAT_TYPE_MIDDLE then
+        if  recvMsg.msgType == ChatHandler.CHAT_TYPE_MIDDLE 
+            or ChatHandler.CHAT_TYPE_WARZONE == recvMsg.msgType then
             -- 发送数据到中心服
             local lwMsgRet = InnerMsg.lw.LW_MIDDLE_CHAT
+            lwMsgRet.svrIndex = Config.SVR_INDEX
             lwMsgRet.tChatMsg = msgRet
             InnerMsg.sendMsg(0, lwMsgRet)
             print("[chat] 发送跨服消息开始")
@@ -223,5 +272,5 @@ end
 -- 跨服消息到达
 function WL_MIDDLE_CHAT(fd, msg)
     Msg.sendWorld(msg.tChatMsg)
-    ChatRecord.addMiddleRecord(msg.tChatMsg.item, ChatHandler.CHAT_TYPE_MIDDLE)
+    ChatRecord.addMiddleRecord(msg.tChatMsg.item, msg.tChatMsg.item.msgType)
 end

+ 20 - 8
script/module/chat/ChatRecord.lua

@@ -34,10 +34,19 @@ local function fontRecord(human,net,msgType)
             cnt = cnt + 1
 		    net[cnt].msgType = record.msgType
 			local fields = {}
-            
-            RoleLogic.makeRoleBase(record.roleBase,net[cnt].roleBase)
+           
+            -- 跨服直接赋值
+            if ChatHandler.CHAT_TYPE_MIDDLE == msgType or ChatHandler.CHAT_TYPE_WARZONE == msgType then
+                net[cnt].roleBase = record.roleBase
+            else
+                RoleLogic.makeRoleBase(record.roleBase,net[cnt].roleBase)
+            end
 			RoleLogic.makeRoleBaseFields(fields)
 			local db = RoleDBLogic.getDb(record.roleBase.uuid,fields)
+
+            -- if msgType == ChatHandler.CHAT_TYPE_MIDDLE then
+            --     table.print_lua_table(net[cnt].roleBase)
+            -- end
             if db then
                 RoleLogic.makeRoleBase(db,net[cnt].roleBase)
             end
@@ -194,6 +203,11 @@ function addRecord(human,chatItem, msgType,fUuid)
            CHAT_RECORD[msgType] = {}   
         end
         record = CHAT_RECORD[msgType]
+    elseif msgType == ChatHandler.CHAT_TYPE_WARZONE then
+        if CHAT_RECORD[msgType] == nil then
+            CHAT_RECORD[msgType] = {}   
+         end
+         record = CHAT_RECORD[msgType]
     elseif msgType == ChatHandler.CHAT_TYPE_UNION then
         -- 公会聊天
         if CHAT_RECORD_UNION[unionUuid] == nil then
@@ -230,7 +244,8 @@ end
 
 -- 添加跨服聊天记录
 function addMiddleRecord(chatItem, msgType)
-    if msgType ~= ChatHandler.CHAT_TYPE_MIDDLE then
+    if msgType ~= ChatHandler.CHAT_TYPE_MIDDLE and msgType ~= ChatHandler.CHAT_TYPE_WARZONE then
+        print("[addMiddleRecord] 此处返回了?msgType = "..msgType)
         return
     end
 
@@ -250,9 +265,6 @@ function addMiddleRecord(chatItem, msgType)
 
     local newTb = Util.copyTable(chatItem)
     table.insert(record, newTb)
-    if #record > CHAT_RECORD_CNT then
-        table.remove(record, 1)
-    end
 end
 
 -- 根据玩家Uuid 删除聊天记录
@@ -334,7 +346,7 @@ function getChatRecord(human,type)
             end
         else
             if CHAT_RECORD[i] ~= nil then
-                if i ~= ChatHandler.CHAT_TYPE_MIDDLE then
+                if i ~= ChatHandler.CHAT_TYPE_MIDDLE and i ~= ChatHandler.CHAT_TYPE_WARZONE then
                     local len = CHAT_RECORD_JINDU[i]
                     human.db.chatRead[i] = human.db.chatRead[i] or 0
     
@@ -495,7 +507,7 @@ function sendAllNotRead(human)
             end
         else
             if CHAT_RECORD[i] ~= nil then
-                if i ~= ChatHandler.CHAT_TYPE_MIDDLE then
+                if i ~= ChatHandler.CHAT_TYPE_MIDDLE and i~= ChatHandler.CHAT_TYPE_WARZONE then
                     local len = CHAT_RECORD_JINDU[i]
                     human.db.chatRead[i] = human.db.chatRead[i] or 0
     

+ 180 - 176
script/module/chat/Handler.lua

@@ -1,176 +1,180 @@
-local Log = require("common.Log")
-local Lang = require("common.Lang")
-local Json = require("common.Json")
-local Msg = require("core.Msg")
-local Timer = require("core.Timer")
-local Util = require("common.Util")
-local ChatBan = require("chat.ChatBan")
-local ChatRecord = require("chat.ChatRecord")
-local Broadcast = require("broadcast.Broadcast")
-local ChatLogic = require("chat.ChatLogic")
-local CombatVideo = require("combat.CombatVideo")
-local Define = require("platform.Define")
-local HeroExcel = require("excel.hero")
-local RoleLogic = require("role.RoleLogic")
-local CharRecord = require("chat.ChatRecord")
-
--- 聊天频道
-CHAT_TYPE_WORLD         = 1	    --世界
-CHAT_TYPE_SYSTEM        = 2 	--系统
-CHAT_TYPE_UNION	        = 3 	--工会
-CHAT_TYPE_FRIEND        = 4 	--好友私聊
-CHAT_TYPE_MIDDLE        = 5 	--跨服
-
-CHAT_TYPE_CNT = 5           --聊天频道数
-
--- isJson值
-CHAT_NORMAL         = 0         -- 普通聊天 
-CHAT_UNION_FIGHT    = 1         -- 公会战
-CHAT_UNION_ECTYPE   = 2         -- 公会副本
-CHAT_UNION_RED_BAG  = 3         -- 公会红包
-CHAT_UNION_ZHAOMU   = 4         -- 公会招募
-CHAT_HERO_SHARE     = 5         -- 英雄聊天分享
-CHAT_FIGHT_SHARE    = 6         -- 战斗记录聊天分享
-CHAT_ITEM_SHARE     = 7         -- 道具聊天分享
-                      
-CHAT_SHARE_TYPE     = 1         -- 战报分享
-CHAT_LV_NEED_WORLD        = 20	    -- 开放聊天等级
-CHAT_LV_NEED_MIDDLE        = 50	    -- 开放聊天等级
-CHAT_LV_NEED_FRIEND        = 30	    -- 开放聊天等级
-CHAT_CD             = 10000		-- 聊天cd时间
-CHAT_MSG_LEN        = 90
-
-CHATLIMITMONEY = 10000		--所有聊天频道发言需要累充的金额
-
-
-function chatReport(human, content)
-	s2aParam = {}
-
-    s2aParam.role_name = human.db.name
-    s2aParam.account_name = human.db.account
-    s2aParam.content = content or ""
-    s2aParam.ip = human.db.ip
-    
-	_G.thread_http.send(Define.CHAT_REPORT,Json.Encode(s2aParam))
-    Log.write(Log.LOGID_DEBUG, "chatReportSuccrss"..Define.CHAT_REPORT) 
-end
-
-function CG_CHAT_REPORT(human, msg)
-    chatReport(human, msg.content)
-end
-
-function CG_CHAT(human, msg)
-    local strLen = string.len(msg.msg)
-    -- 普通聊天限制字数
-    if CHAT_MSG_LEN < strLen and msg.isJson == CHAT_NORMAL then
-        return Broadcast.sendErr(human, Lang.CHAT_MSG_LEN_ERR)	
-    end
-    ChatLogic.chat(human, msg, msg.isJson)
-end
-
-function onLogin(human)
-    ChatRecord.initHumanChatRead(human)
-	ChatBan.sendBanList(human)
-end
-
-function CG_CHAT_BAN(human, msg)
-	ChatBan.setBan(human, msg.uuid, msg.op)
-end
-
-function CG_CHAT_PLAYER_INFO(human, msg)
-	local msgRet = Msg.gc.GC_CHAT_PLAYER_INFO
-	if not RoleLogic.makePlayInfo(msgRet.data, msg.uuid) then
-		return
-	end
-	Msg.send(msgRet, human.fd)
-end
-
-function CG_CHAT_HERO_SHARE(human,msg)
-	local bagIndex = msg.bagIndex
-	local heroGrid = human.db.heroBag[bagIndex]
-	if not heroGrid then
-		return
-	end
-	
-	local heroConfig = HeroExcel.hero[heroGrid.id]
-    if 	heroConfig == nil then
-        return 		
-	end
-    msg.videoUuid = ""
-	ChatLogic.chat(human, msg,CHAT_HERO_SHARE)
-end
-
---战斗界面 战斗记录分享
-function CG_CHAT_COMBAT_SHARE(human, msg)
-	if msg.msgType ~= CHAT_TYPE_WORLD and msg.msgType ~= CHAT_TYPE_UNION and msg.msgType ~= CHAT_TYPE_MIDDLE then
-		return
-	end
-	
-	-- 如果是分享在世界上检测是否在聊天CD 中
-	if msg.msgType == 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 msg.msgType == CHAT_TYPE_UNION and human.db.unionUuid == nil then
-		return Broadcast.sendErr(human, Lang.UNION_PLAYER_IN_NO)
-	end
-    local content = {}
-    content.msg = msg.msg
-    content.msgType = msg.msgType
-    if msg.shareType ~= CHAT_SHARE_TYPE then
-        local combatInfo = Util.copyTable(human.combat)	
-	    if combatInfo == nil then
-	    	return
-	    end	 
-    
-
-	    local videoUuid = human.combat.videoUuid
-	    if not videoUuid then
-	    	videoUuid = CombatVideo.saveCombatVideo(human, true)		
-	    end	
-
-	    if not videoUuid then 
-	    	return Broadcast.sendErr(human, Lang.SHARE_ERROR)
-	    end
-        
-        content.videoUuid = videoUuid
-    end
-	local flag = ChatLogic.chat(human,content,CHAT_FIGHT_SHARE)
-    if flag == true then
-        Broadcast.sendErr(human, Lang.SHARE_SUCCESS)
-    else
-        Broadcast.sendErr(human, Lang.SHARE_ERROR)
-    end
-end
-
-function CG_CHAT_COMPLAIN_PLAYER(human,msg) 
-    ChatBan.jubaoChat(human,msg)
-end
-
--- 获取聊天记录
-function CG_CHAT_RECORD_QUERY(human,msg)
-    CharRecord.getChatRecord(human,msg.msgType)
-end
-
--- 获取私聊列表
-function CG_CHAT_FRIEND_RECORD_QUERY(human)
-    CharRecord.getChatFriendList(human)
-end
-
---根据uuid获取私聊记录
-function CG_CHAT_FRIEND_RECORD_BY_FRIEND(human,msg)
-    CharRecord.getChatFriendRecord(human,msg.uuid)
-end
-
--- 新增私聊
-function CG_CHAT_FRIEND_RECORD_ADD(human,msg)
-    CharRecord.addFriendChat(human,msg.uuid)
-end
-
--- 删除玩家私聊数据
-function CG_CHAT_FRIEND_RECORD_DEL(human,msg)
-    CharRecord.delFriendChatRecord(human,msg.uuid)
-end
-
+local Log = require("common.Log")
+local Lang = require("common.Lang")
+local Json = require("common.Json")
+local Msg = require("core.Msg")
+local Timer = require("core.Timer")
+local Util = require("common.Util")
+local ChatBan = require("chat.ChatBan")
+local ChatRecord = require("chat.ChatRecord")
+local Broadcast = require("broadcast.Broadcast")
+local ChatLogic = require("chat.ChatLogic")
+local CombatVideo = require("combat.CombatVideo")
+local Define = require("platform.Define")
+local HeroExcel = require("excel.hero")
+local RoleLogic = require("role.RoleLogic")
+local CharRecord = require("chat.ChatRecord")
+
+-- 聊天频道
+CHAT_TYPE_WORLD         = 1	    --世界
+CHAT_TYPE_SYSTEM        = 2 	--系统
+CHAT_TYPE_UNION	        = 3 	--工会
+CHAT_TYPE_FRIEND        = 4 	--好友私聊
+CHAT_TYPE_MIDDLE        = 5 	--跨服
+CHAT_TYPE_WARZONE		= 6		--战区
+
+CHAT_TYPE_CNT = 6           --聊天频道数
+
+-- isJson值
+CHAT_NORMAL         = 0         -- 普通聊天 
+CHAT_UNION_FIGHT    = 1         -- 公会战
+CHAT_UNION_ECTYPE   = 2         -- 公会副本
+CHAT_UNION_RED_BAG  = 3         -- 公会红包
+CHAT_UNION_ZHAOMU   = 4         -- 公会招募
+CHAT_HERO_SHARE     = 5         -- 英雄聊天分享
+CHAT_FIGHT_SHARE    = 6         -- 战斗记录聊天分享
+CHAT_ITEM_SHARE     = 7         -- 道具聊天分享
+                      
+CHAT_SHARE_TYPE     = 1         -- 战报分享
+CHAT_LV_NEED_WORLD        = 20	    -- 开放聊天等级
+CHAT_LV_NEED_MIDDLE        = 70	    -- 开放聊天等级
+CHAT_LV_NEED_FRIEND        = 30	    -- 开放聊天等级
+CHAT_LV_NEED_WARZONE 	   	= 50	-- 开放聊天等级-战区
+CHAT_OPEN_DAY_WARZONE		= 7		-- 开放聊天服务器天数-战区
+CHAT_OPEN_DAY_MIDDLE		= 15	-- 开放聊天服务器天数-跨服
+CHAT_CD             = 10000		-- 聊天cd时间
+CHAT_MSG_LEN        = 90
+
+CHATLIMITMONEY = 10000		--所有聊天频道发言需要累充的金额
+
+
+function chatReport(human, content)
+	s2aParam = {}
+
+    s2aParam.role_name = human.db.name
+    s2aParam.account_name = human.db.account
+    s2aParam.content = content or ""
+    s2aParam.ip = human.db.ip
+    
+	_G.thread_http.send(Define.CHAT_REPORT,Json.Encode(s2aParam))
+    Log.write(Log.LOGID_DEBUG, "chatReportSuccrss"..Define.CHAT_REPORT) 
+end
+
+function CG_CHAT_REPORT(human, msg)
+    chatReport(human, msg.content)
+end
+
+function CG_CHAT(human, msg)
+    local strLen = string.len(msg.msg)
+    -- 普通聊天限制字数
+    if CHAT_MSG_LEN < strLen and msg.isJson == CHAT_NORMAL then
+        return Broadcast.sendErr(human, Lang.CHAT_MSG_LEN_ERR)	
+    end
+    ChatLogic.chat(human, msg, msg.isJson)
+end
+
+function onLogin(human)
+    ChatRecord.initHumanChatRead(human)
+	ChatBan.sendBanList(human)
+end
+
+function CG_CHAT_BAN(human, msg)
+	ChatBan.setBan(human, msg.uuid, msg.op)
+end
+
+function CG_CHAT_PLAYER_INFO(human, msg)
+	local msgRet = Msg.gc.GC_CHAT_PLAYER_INFO
+	if not RoleLogic.makePlayInfo(msgRet.data, msg.uuid) then
+		return
+	end
+	Msg.send(msgRet, human.fd)
+end
+
+function CG_CHAT_HERO_SHARE(human,msg)
+	local bagIndex = msg.bagIndex
+	local heroGrid = human.db.heroBag[bagIndex]
+	if not heroGrid then
+		return
+	end
+	
+	local heroConfig = HeroExcel.hero[heroGrid.id]
+    if 	heroConfig == nil then
+        return 		
+	end
+    msg.videoUuid = ""
+	ChatLogic.chat(human, msg,CHAT_HERO_SHARE)
+end
+
+--战斗界面 战斗记录分享
+function CG_CHAT_COMBAT_SHARE(human, msg)
+	if msg.msgType ~= CHAT_TYPE_WORLD and msg.msgType ~= CHAT_TYPE_UNION and msg.msgType ~= CHAT_TYPE_MIDDLE then
+		return
+	end
+	
+	-- 如果是分享在世界上检测是否在聊天CD 中
+	if msg.msgType == 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 msg.msgType == CHAT_TYPE_UNION and human.db.unionUuid == nil then
+		return Broadcast.sendErr(human, Lang.UNION_PLAYER_IN_NO)
+	end
+    local content = {}
+    content.msg = msg.msg
+    content.msgType = msg.msgType
+    if msg.shareType ~= CHAT_SHARE_TYPE then
+        local combatInfo = Util.copyTable(human.combat)	
+	    if combatInfo == nil then
+	    	return
+	    end	 
+    
+
+	    local videoUuid = human.combat.videoUuid
+	    if not videoUuid then
+	    	videoUuid = CombatVideo.saveCombatVideo(human, true)		
+	    end	
+
+	    if not videoUuid then 
+	    	return Broadcast.sendErr(human, Lang.SHARE_ERROR)
+	    end
+        
+        content.videoUuid = videoUuid
+    end
+	local flag = ChatLogic.chat(human,content,CHAT_FIGHT_SHARE)
+    if flag == true then
+        Broadcast.sendErr(human, Lang.SHARE_SUCCESS)
+    else
+        Broadcast.sendErr(human, Lang.SHARE_ERROR)
+    end
+end
+
+function CG_CHAT_COMPLAIN_PLAYER(human,msg) 
+    ChatBan.jubaoChat(human,msg)
+end
+
+-- 获取聊天记录
+function CG_CHAT_RECORD_QUERY(human,msg)
+    CharRecord.getChatRecord(human,msg.msgType)
+end
+
+-- 获取私聊列表
+function CG_CHAT_FRIEND_RECORD_QUERY(human)
+    CharRecord.getChatFriendList(human)
+end
+
+--根据uuid获取私聊记录
+function CG_CHAT_FRIEND_RECORD_BY_FRIEND(human,msg)
+    CharRecord.getChatFriendRecord(human,msg.uuid)
+end
+
+-- 新增私聊
+function CG_CHAT_FRIEND_RECORD_ADD(human,msg)
+    CharRecord.addFriendChat(human,msg.uuid)
+end
+
+-- 删除玩家私聊数据
+function CG_CHAT_FRIEND_RECORD_DEL(human,msg)
+    CharRecord.delFriendChatRecord(human,msg.uuid)
+end
+

+ 51 - 7
script/module/middle/MiddleConnect.lua

@@ -9,9 +9,12 @@ local MiddleHeartBeat = require("middle.MiddleHeartBeat")
 local Define = require("platform.Define")
 local Json = require("common.Json")
 local JjcLadderMiddle = require("jjcLadder.JjcLadderMiddle")
+local WarZoneConf = require("excel.WarZone")    --- 战区配置
+local ChatHandler = require("chat.Handler")
 
 IS_MIDDLE_CONNECT = IS_MIDDLE_CONNECT or nil -- 是否連上跨服 收到WLhello才認為連上了
 
+local nServerOffSet = 810538  -- 配置中服务器ID偏移量
 YY_ACT_FLAG = nil
 
 -- 请求middleInfo
@@ -22,6 +25,21 @@ local function questMiddleInfo()
     _G.thread_http.send(Define.MIDDLE_INFO_URL, Json.Encode(s2aParam))
 end
 
+-- 获取战区最小和最大服务器ID
+local function MiddleConnect_GetWarZoneServer(nSeverID)
+    local tWarZoneConf = WarZoneConf.group
+    if not tWarZoneConf then
+        return 0, 0
+    end
+
+    for _, v in pairs(tWarZoneConf) do
+        if v.nMinServerID <= nSeverID and v.nMaxServerID >= nSeverID then
+            return v.nMinServerID, v.nMaxServerID
+        end
+    end
+
+    return 0, 0
+end
 
 function setMiddleInfo(ip, port, host)
 	if _G.is_middle == true then return end
@@ -155,10 +173,10 @@ function WL_HELLO(fd, msg)
 
         local openTime = CommonDB.getServerOpenTime()
         if openTime ~= 0 then
-            local msg = InnerMsg.lw.LW_SET
-            msg.openTime = openTime or 0
-            msg.svrIndex = Config.SVR_INDEX
-            InnerMsg.sendMsg(fd, msg)
+            -- local msg = InnerMsg.lw.LW_SET
+            -- msg.openTime = openTime or 0
+            -- msg.svrIndex = Config.SVR_INDEX
+            -- InnerMsg.sendMsg(fd, msg)
         end
     end
 end
@@ -195,10 +213,36 @@ function LW_MIDDLE_CHAT(fd, msg)
 
     local szMsgData = InnerMsg.wl.WL_MIDDLE_CHAT
     szMsgData.tChatMsg = msg.tChatMsg
+    
+    local nMsgType = szMsgData.tChatMsg.item.msgType
+    if ChatHandler.CHAT_TYPE_MIDDLE ==  nMsgType then
+        for _, nFD in pairs(tAllConnectFD) do
+            InnerMsg.sendMsg(nFD, szMsgData)
+        end
+        
+        print("[LW_MIDDLE_CHAT] 全服发送消息结束")
+    elseif ChatHandler.CHAT_TYPE_WARZONE ==  nMsgType then
+        local nSendServerID = msg.svrIndex
+        local nConfServerID = nSendServerID - nServerOffSet + 1
+        local nMinServerID, nMaxServerID = MiddleConnect_GetWarZoneServer(nConfServerID)
+        if 0 >= nMinServerID or 0 >= nMaxServerID then
+            print("[LW_MIDDLE_CHAT 获取不到配置 nSendServerID = "..nSendServerID.." nConfServerID = "..nConfServerID)
+            return
+        end
 
-    for _, nFD in pairs(tAllConnectFD) do
-        InnerMsg.sendMsg(nFD, szMsgData)
+        local nServeL, nServerR = nMinServerID + nServerOffSet - 1, nMaxServerID + nServerOffSet - 1
+        for i = nServeL, nServerR, 1 do
+            local nFD = MiddleManager.getFDBySvrIndex(i)
+            if nFD then
+                InnerMsg.sendMsg(nFD, szMsgData)
+            else
+                print("[LW_MIDDLE_CHAT] 不存在对应的fd i = "..i)
+            end
+        end
+
+        print("[LW_MIDDLE_CHAT] 战区发送消息结束")
+    else
+        print("[LW_MIDDLE_CHAT] 未处理的发送消息结束")
     end
 
-    print("[LW_MIDDLE_CHAT] 发送消息结束")
 end

+ 411 - 403
script/module/present/OpenServerActPowerUp.lua

@@ -1,404 +1,412 @@
---------------------------------
--- 文件名       :  OpenServerActPowerUp.lua
--- 文件说明     :  开服7天活动 - 战力冲刺
--- 创建时间     :   2024/11/14
--- 创建人       :   FC
---------------------------------
-
-local Util = require("common.Util")
-local Lang = require("common.Lang")
-local Broadcast = require("broadcast.Broadcast")
-local OpenAct = require("present.OpenAct")
-local PresentExcel = require("excel.present")
-local OpenActExcel = require("excel.openAct")
-local MailExcel = require("excel.mail")
-local Msg = require("core.Msg")
-local ObjHuman = require("core.ObjHuman")
-local MailManager = require("mail.MailManager")
-local BagLogic = require("bag.BagLogic")
-local Grid = require("bag.Grid")
-local KingWorldLogic = require("present.KingWorldLogic")
-local YunYingLogic = require("yunying.YunYingLogic")
-local PanelDefine = require("broadcast.PanelDefine")
-local SevenDayGiftLogic = require("present.SevenDayGiftLogic")
-local CommonDB = require("common.CommonDB")
-local BuyLogic = require("topup.BuyLogic")
-local GuideLogic = require("guide.GuideLogic")
-local Log = require("common.Log")
-
-local tPrizeByID = nil
-
-POWERGIFT_STATE_NONE    =   0       -- 不可领取
-POWERGIFT_STATE_CANGET  =   1       -- 可领取
-POWERGIFT_STATE_FINISH  =   2       -- 已领取
-
------------------------------------------ DB数据操作 -------------------------------------
-
--- 初始化DB数据
-local function ActPowerUp_InitDB(human)
-    if not human then
-        return false
-    end
-
-    human.db.PowerGift = {}
-    return true
-end
-
--- 获取DB数据
-local function ActPowerUp_GetDB(human)
-    if not human or not human.db.PowerGift then
-        return nil
-    end
-    
-    return human.db.PowerGift
-end
-
--- 删除DB数据 
-local function ActPowerUp_DelDB(human)
-    if not human or not human.db.PowerGift then
-        return
-    end
-    
-    human.db.PowerGift = nil
-end
-
--- 创建DB数据
-local function ActPowerUp_CreateDB(human)
-    if not human then
-        return false
-    end
-
-    if not human.db.PowerGift then
-        local bRet = ActPowerUp_InitDB(human)
-        if false == bRet then
-            print("[ActPowerUp_CreateDB] 初始化BD数据失败")
-            return false
-        end
-
-        if tPrizeByID then
-            for nID, value in pairs(tPrizeByID) do
-                human.db.PowerGift[nID] = POWERGIFT_STATE_NONE
-            end
-        else
-            print("[ActPowerUp_CreateDB] 不存在对应的ID对应配置")
-            return false
-        end
-    end
-
-    return true
-end
-
--- 获取某个数据状态
-local function ActPowerUp_GetDBIDState(human, nID)
-    if not human or 0 >= nID then
-        return POWERGIFT_STATE_NONE
-    end
-
-    local tDBPrize = ActPowerUp_GetDB(human)
-    if nil == tDBPrize then
-        return POWERGIFT_STATE_NONE
-    end
-
-    return tDBPrize[nID]
-end
-
--- 设置某个数据状态
-local function ActPowerUp_SetDBIDState(human, nID, nState)
-    if not human or 0 >= nID then
-        return false
-    end
-
-    local tDBPrize = ActPowerUp_GetDB(human)
-    if nil == tDBPrize then
-        return false
-    end
-
-    tDBPrize[nID] = nState
-    return true
-end
------------------------------------------ 内部函数判断 -------------------------------------
--- 获取配置
-local function ActPowerUp_GetConfig()
-    return OpenActExcel.PowerUp
-end
-
--- 日志写入
-local function ActPowerUp_WriteLog(szText)
-    Log.write(Log.LOGID_OSS_OPENSERVER_ACT, szText)
-end
-
--- 报错打印
-local function ActPowerUp_PrintInfo(szFuncName,szText)
-    print(szFuncName.." "..szText)
-end
-
--- 客户端回包
-local function ActPowerUp_SendClient(fd, data)
-    Msg.send(data, fd)
-    ActPowerUp_PrintInfo("[ActPowerUp_SendClient]", "发送给客户端结束")
-end
-
--- 活动是否开启
-local function ActPowerUp_IsOpen(human)
-    local szFuncName = "ActPowerUp_IsOpen"
-    local szText = ""
-    if not human then
-        szText = "参数不正确 "
-        ActPowerUp_PrintInfo(szFuncName, szText)
-        return false
-    end
-
-    local nOpenLv = YunYingLogic.getOpenLvByPanelID(PanelDefine.PANEL_ID_3609)
-    if human.db.lv < nOpenLv then
-        return false
-    end
-
-    local flag = OpenAct.getOpenActTime(OpenAct.OPEN_ACT_SERVER_GIFT)
-    if not flag then
-		return false
-	end
-
-    return true
-end
-
--- 活动剩余时间
-local function ActPowerUp_GetLeftTime()
-    local openDay = CommonDB.getServerOpenDay()
-    if openDay == nil then
-        return 0
-    end
-
-    local OpenActConfig = OpenActExcel.openAct[1]
-    if not OpenActConfig then return 0 end
-
-    local sDay = OpenActConfig.sDay
-    local eDay = OpenActConfig.eDay
-
-    if openDay >= sDay and openDay <= eDay then
-        local time = os.time()
-        local openTime = CommonDB.getServerOpenTime()
-        if openTime == 0 then
-            return 0
-        end
-
-        local endTime = Util.getDayStartTime(openTime) + eDay * 86400
-        return endTime - time
-    end
-
-    return 0
-end
-
--- 红点
-local function ActPowerUp_CheckRed(human)
-    local szFuncName = "ActPowerUp_CheckRed"
-    local szText = ""
-    if not human then
-        szText = "参数不正确"
-        ActPowerUp_PrintInfo(szFuncName, szText)
-        return false
-    end
-
-    ActPowerUp_CreateDB(human)
-
-    local tDBData = ActPowerUp_GetDB(human)
-    if not tDBData then
-        szText = "获取玩家DB奖励数据状态表失败"
-        ActPowerUp_PrintInfo(szFuncName, szText)
-        return false
-    end
-
-    for k, v in pairs(tDBData) do
-        if POWERGIFT_STATE_CANGET == v then
-            return true
-        end
-    end
-
-    return false
-end
-
------------------------------------------ 活动模板调用 -------------------------------------
--- 是否开启
-function isOpen(human, YYInfo, funcConfig)
-    print("[ActPowerUp_isOpen] 进入了判断")
-    return ActPowerUp_IsOpen(human)
-end
-
--- 活动剩余时间
-function getLeftTime()
-    print("[ActPowerUp_getLeftTime] 获取剩余时间")
-
-    return ActPowerUp_GetLeftTime()
-end
-
--- 是否存在红点
-function isRed(human)
-    print("[ActPowerUp_isRed] 获取红点")
-    return ActPowerUp_CheckRed(human)
-end
-
------------------------------------------ 客户端协议请求 -------------------------------------
--- 请求活动协议
-function ActPowerUp_Query(human)
-    if not human then
-        return
-    end
-
-    local nCreatRet = ActPowerUp_CreateDB(human)
-    if false == nCreatRet then
-        ActPowerUp_PrintInfo("[ActPowerUp_Query]", "初始化DB数据失败")
-        return
-    end
-
-    local tPrize = ActPowerUp_GetConfig()
-    if not tPrize then
-        return
-    end
-
-    local tMsgData = Msg.gc.GC_PRESENT_OPEN_POWERUP_QUERY
-    tMsgData.nNowPower = human.db.zhandouli
-    tMsgData.list[0] = 0
-
-    for nID, v in pairs(tPrize) do
-        tMsgData.list[0] = tMsgData.list[0] + 1
- 
-        local tPrizeData = tMsgData.list[tMsgData.list[0]]
-        tPrizeData.nID = nID
-        tPrizeData.nNeedPower = v.nPower
-        tPrizeData.nState = ActPowerUp_GetDBIDState(human, nID)
-        
-        local nPrizeLne = #v.tPrize
-        tPrizeData.item[0] = nPrizeLne
-        
-        -- ActPowerUp_PrintInfo("[ActPowerUp_Query]", "遍历的奖励信息 nID = "
-        --         .. nID .." nPower = "..v.nPower .. " nState = ".. tPrizeData.nState.." nPrizeLne = "..nPrizeLne)
-
-        for j = 1, nPrizeLne do
-            local nGoodsID = v.tPrize[j][1]
-            local nGoodsNum = v.tPrize[j][2]
-            ActPowerUp_PrintInfo("[ActPowerUp_Query]", "物品信息 nGoodsID = "..nGoodsID .. " nGoodsNum = "..nGoodsNum)
-
-            Grid.makeItem(tPrizeData.item[j], nGoodsID, nGoodsNum)
-        end
-    end
-
-    -- local tPrintTable = Util.printTable(tMsgData)
-
-    Msg.send(tMsgData, human.fd)
-    ActPowerUp_PrintInfo("[ActPowerUp_Query]", "获取到的奖励长度为 nIndex = "..tMsgData.list[0])
-end
-
-
--- 请求领取奖励
-function ActPowerUp_GetPrize(human, nID)
-    if not human or 0 >= nID then
-        return
-    end
-
-    if not tPrizeByID or not tPrizeByID[nID] then
-        return
-    end
-
-    local nNowPower = human.db.zhandouli
-    local tMsgData = Msg.gc.GC_PRESENT_OPEN_POWERUP_GETPRIZE
-    tMsgData.nID = nID
-    local nNowState = ActPowerUp_GetDBIDState(human, nID)
-    if POWERGIFT_STATE_CANGET ~= nNowState then
-        ActPowerUp_PrintInfo("ActPowerUp_GetPrize", "请求领取的奖励状态不正确 nID = "..nID)
-        tMsgData.nState = 0
-
-        ActPowerUp_SendClient(human.fd, tMsgData)
-        return
-    end
-
-    local tGoodsInfo = tPrizeByID[nID].tPrize
-    -- if nNowPower < tGoodsInfo.nPower then
-    --     ActPowerUp_PrintInfo("ActPowerUp_GetPrize", "战斗力不足不应该领取 nID = "..nID)
-    --     return
-    -- end
-
-    tMsgData.nState = 1
-
-    -- 设置状态
-    if false == ActPowerUp_SetDBIDState(human, nID, POWERGIFT_STATE_FINISH) then
-        ActPowerUp_PrintInfo("ActPowerUp_GetPrize", "设置数据状态失败 nID = "..nID)
-        tMsgData.nState = 0
-
-        ActPowerUp_SendClient(human.fd, tMsgData)
-        return
-    end
-
-    -- 发奖励
-    for i = 1, #tGoodsInfo do
-        local nGoodsID = tGoodsInfo[i][1]
-        local nGoodsNum = tGoodsInfo[i][2]
-
-        BagLogic.addItem(human, nGoodsID, nGoodsNum,"open_server_PowerUpPrize")
-    end
-
-	BagLogic.sendItemGetList(human, tGoodsInfo, "open_server_PowerUpPrize")
-
-	for k, v in pairs(funcID) do
-	    YunYingLogic.updateIcon(YYInfo[k], human)
-	    YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_3605)
-        break
-    end
-    
-    ActPowerUp_Query(human)
-end
-
-
------------------------------------------ 其他模块调用 -------------------------------------
--- 用于起服时映射奖励ID对应配置
-function Init()
-    local tPrize = ActPowerUp_GetConfig()
-    if not tPrize then
-        ActPowerUp_PrintInfo("Init", "起服获取不到配置")
-        return
-    end
-    
-    tPrizeByID = {}
-   -- Util.printTable(tPrize)
-
-    for nID, v in pairs(tPrize) do
-        if tPrizeByID[nID] then
-            ActPowerUp_PrintInfo("Init", "配置了重复的奖励ID")
-            return
-        end
-
-        tPrizeByID[nID] = v
-    end
-end
-
--- 战力改变回调
-function ActPowerUp_PowerChange(human, nNewPower)
-    -- 活动未开启
-    if false == ActPowerUp_IsOpen(human) then
-        return
-    end
-
-    if not human or 0 >= nNewPower then
-        return
-    end
-
-    local tPrizeConfig = ActPowerUp_GetConfig()
-    if not tPrizeConfig then
-        return
-    end
-
-    local nSendClient = false
-    for nID, v in pairs(tPrizeConfig) do
-        local nState = ActPowerUp_GetDBIDState(human, nID)
-        if POWERGIFT_STATE_NONE == nState then
-            if nNewPower >= v.nPower then
-                ActPowerUp_SetDBIDState(human, nID, POWERGIFT_STATE_CANGET)
-                nSendClient = true
-            end
-        end
-    end
-
-    if true == nSendClient then
-        ActPowerUp_Query(human)
-    end
-
-    return true
+--------------------------------
+-- 文件名       :  OpenServerActPowerUp.lua
+-- 文件说明     :  开服7天活动 - 战力冲刺
+-- 创建时间     :   2024/11/14
+-- 创建人       :   FC
+--------------------------------
+
+local Util = require("common.Util")
+local Lang = require("common.Lang")
+local Broadcast = require("broadcast.Broadcast")
+local OpenAct = require("present.OpenAct")
+local PresentExcel = require("excel.present")
+local OpenActExcel = require("excel.openAct")
+local MailExcel = require("excel.mail")
+local Msg = require("core.Msg")
+local ObjHuman = require("core.ObjHuman")
+local MailManager = require("mail.MailManager")
+local BagLogic = require("bag.BagLogic")
+local Grid = require("bag.Grid")
+local KingWorldLogic = require("present.KingWorldLogic")
+local YunYingLogic = require("yunying.YunYingLogic")
+local PanelDefine = require("broadcast.PanelDefine")
+local SevenDayGiftLogic = require("present.SevenDayGiftLogic")
+local CommonDB = require("common.CommonDB")
+local BuyLogic = require("topup.BuyLogic")
+local GuideLogic = require("guide.GuideLogic")
+local Log = require("common.Log")
+
+local tPrizeByID = nil
+
+POWERGIFT_STATE_NONE    =   0       -- 不可领取
+POWERGIFT_STATE_CANGET  =   1       -- 可领取
+POWERGIFT_STATE_FINISH  =   2       -- 已领取
+
+----------------------------------------- DB数据操作 -------------------------------------
+
+-- 初始化DB数据
+local function ActPowerUp_InitDB(human)
+    if not human then
+        return false
+    end
+
+    human.db.PowerGift = {}
+    return true
+end
+
+-- 获取DB数据
+local function ActPowerUp_GetDB(human)
+    if not human or not human.db.PowerGift then
+        return nil
+    end
+    
+    return human.db.PowerGift
+end
+
+-- 删除DB数据 
+local function ActPowerUp_DelDB(human)
+    if not human or not human.db.PowerGift then
+        return
+    end
+    
+    human.db.PowerGift = nil
+end
+
+-- 创建DB数据
+local function ActPowerUp_CreateDB(human)
+    if not human then
+        return false
+    end
+
+    if not human.db.PowerGift then
+        local bRet = ActPowerUp_InitDB(human)
+        if false == bRet then
+            print("[ActPowerUp_CreateDB] 初始化BD数据失败")
+            return false
+        end
+
+        if tPrizeByID then
+            for nID, value in pairs(tPrizeByID) do
+                human.db.PowerGift[nID] = POWERGIFT_STATE_NONE
+            end
+        else
+            print("[ActPowerUp_CreateDB] 不存在对应的ID对应配置")
+            return false
+        end
+    end
+
+    return true
+end
+
+-- 获取某个数据状态
+local function ActPowerUp_GetDBIDState(human, nID)
+    if not human or 0 >= nID then
+        return POWERGIFT_STATE_NONE
+    end
+
+    local tDBPrize = ActPowerUp_GetDB(human)
+    if nil == tDBPrize then
+        return POWERGIFT_STATE_NONE
+    end
+
+    return tDBPrize[nID]
+end
+
+-- 设置某个数据状态
+local function ActPowerUp_SetDBIDState(human, nID, nState)
+    if not human or 0 >= nID then
+        return false
+    end
+
+    local tDBPrize = ActPowerUp_GetDB(human)
+    if nil == tDBPrize then
+        return false
+    end
+
+    tDBPrize[nID] = nState
+    return true
+end
+----------------------------------------- 内部函数判断 -------------------------------------
+-- 获取配置
+local function ActPowerUp_GetConfig()
+    return OpenActExcel.PowerUp
+end
+
+-- 日志写入
+local function ActPowerUp_WriteLog(szText)
+    Log.write(Log.LOGID_OSS_OPENSERVER_ACT, szText)
+end
+
+-- 报错打印
+local function ActPowerUp_PrintInfo(szFuncName,szText)
+    print(szFuncName.." "..szText)
+end
+
+-- 客户端回包
+local function ActPowerUp_SendClient(fd, data)
+    Msg.send(data, fd)
+    ActPowerUp_PrintInfo("[ActPowerUp_SendClient]", "发送给客户端结束")
+end
+
+-- 活动是否开启
+local function ActPowerUp_IsOpen(human)
+    local szFuncName = "ActPowerUp_IsOpen"
+    local szText = ""
+    if not human then
+        szText = "参数不正确 "
+        ActPowerUp_PrintInfo(szFuncName, szText)
+        return false
+    end
+
+    local nOpenLv = YunYingLogic.getOpenLvByPanelID(PanelDefine.PANEL_ID_3609)
+    if human.db.lv < nOpenLv then
+        return false
+    end
+
+    local flag = OpenAct.getOpenActTime(OpenAct.OPEN_ACT_SERVER_GIFT)
+    if not flag then
+		return false
+	end
+
+    return true
+end
+
+-- 活动剩余时间
+local function ActPowerUp_GetLeftTime()
+    local openDay = CommonDB.getServerOpenDay()
+    if openDay == nil then
+        return 0
+    end
+
+    local OpenActConfig = OpenActExcel.openAct[1]
+    if not OpenActConfig then return 0 end
+
+    local sDay = OpenActConfig.sDay
+    local eDay = OpenActConfig.eDay
+
+    if openDay >= sDay and openDay <= eDay then
+        local time = os.time()
+        local openTime = CommonDB.getServerOpenTime()
+        if openTime == 0 then
+            return 0
+        end
+
+        local endTime = Util.getDayStartTime(openTime) + eDay * 86400
+        return endTime - time
+    end
+
+    return 0
+end
+
+-- 红点
+local function ActPowerUp_CheckRed(human)
+    local szFuncName = "ActPowerUp_CheckRed"
+    local szText = ""
+    if not human then
+        szText = "参数不正确"
+        ActPowerUp_PrintInfo(szFuncName, szText)
+        return false
+    end
+
+    ActPowerUp_CreateDB(human)
+
+    local tDBData = ActPowerUp_GetDB(human)
+    if not tDBData then
+        szText = "获取玩家DB奖励数据状态表失败"
+        ActPowerUp_PrintInfo(szFuncName, szText)
+        return false
+    end
+
+    for k, v in pairs(tDBData) do
+        if POWERGIFT_STATE_CANGET == v then
+            return true
+        end
+    end
+
+    return false
+end
+
+----------------------------------------- 活动模板调用 -------------------------------------
+-- 是否开启
+function isOpen(human, YYInfo, funcConfig)
+    print("[ActPowerUp_isOpen] 进入了判断")
+    return ActPowerUp_IsOpen(human)
+end
+
+-- 活动剩余时间
+function getLeftTime()
+    print("[ActPowerUp_getLeftTime] 获取剩余时间")
+
+    return ActPowerUp_GetLeftTime()
+end
+
+-- 是否存在红点
+function isRed(human)
+    print("[ActPowerUp_isRed] 获取红点")
+    return ActPowerUp_CheckRed(human)
+end
+
+----------------------------------------- 客户端协议请求 -------------------------------------
+-- 请求活动协议
+function ActPowerUp_Query(human)
+    if not human then
+        return
+    end
+
+    local nCreatRet = ActPowerUp_CreateDB(human)
+    if false == nCreatRet then
+        ActPowerUp_PrintInfo("[ActPowerUp_Query]", "初始化DB数据失败")
+        return
+    end
+
+    local tPrize = ActPowerUp_GetConfig()
+    if not tPrize then
+        return
+    end
+
+    local tMsgData = Msg.gc.GC_PRESENT_OPEN_POWERUP_QUERY
+    tMsgData.nNowPower = human.db.zhandouli
+    tMsgData.list[0] = 0
+
+    for nID, v in pairs(tPrize) do
+        tMsgData.list[0] = tMsgData.list[0] + 1
+ 
+        local tPrizeData = tMsgData.list[tMsgData.list[0]]
+        tPrizeData.nID = nID
+        tPrizeData.nNeedPower = v.nPower
+        tPrizeData.nState = ActPowerUp_GetDBIDState(human, nID)
+        
+        local nPrizeLne = #v.tPrize
+        tPrizeData.item[0] = nPrizeLne
+        
+        -- ActPowerUp_PrintInfo("[ActPowerUp_Query]", "遍历的奖励信息 nID = "
+        --         .. nID .." nPower = "..v.nPower .. " nState = ".. tPrizeData.nState.." nPrizeLne = "..nPrizeLne)
+
+        for j = 1, nPrizeLne do
+            local nGoodsID = v.tPrize[j][1]
+            local nGoodsNum = v.tPrize[j][2]
+            ActPowerUp_PrintInfo("[ActPowerUp_Query]", "物品信息 nGoodsID = "..nGoodsID .. " nGoodsNum = "..nGoodsNum)
+            
+            Grid.makeItem(tPrizeData.item[j], nGoodsID, nGoodsNum)
+            if v.tPrize[j][3] then
+                tPrizeData.item[j].rare = v.tPrize[j][3]
+            end
+        end
+    end
+
+    -- local tPrintTable = Util.printTable(tMsgData)
+
+    Msg.send(tMsgData, human.fd)
+    ActPowerUp_PrintInfo("[ActPowerUp_Query]", "获取到的奖励长度为 nIndex = "..tMsgData.list[0])
+end
+
+
+-- 请求领取奖励
+function ActPowerUp_GetPrize(human, nID)
+    if not human or 0 >= nID then
+        return
+    end
+
+    if not tPrizeByID or not tPrizeByID[nID] then
+        return
+    end
+
+    local nNowPower = human.db.zhandouli
+    local tMsgData = Msg.gc.GC_PRESENT_OPEN_POWERUP_GETPRIZE
+    tMsgData.nID = nID
+    local nNowState = ActPowerUp_GetDBIDState(human, nID)
+    if POWERGIFT_STATE_CANGET ~= nNowState then
+        ActPowerUp_PrintInfo("ActPowerUp_GetPrize", "请求领取的奖励状态不正确 nID = "..nID)
+        tMsgData.nState = 0
+
+        ActPowerUp_SendClient(human.fd, tMsgData)
+        return
+    end
+
+    local tGoodsInfo = tPrizeByID[nID].tPrize
+    -- if nNowPower < tGoodsInfo.nPower then
+    --     ActPowerUp_PrintInfo("ActPowerUp_GetPrize", "战斗力不足不应该领取 nID = "..nID)
+    --     return
+    -- end
+
+    tMsgData.nState = 1
+
+    -- 设置状态
+    if false == ActPowerUp_SetDBIDState(human, nID, POWERGIFT_STATE_FINISH) then
+        ActPowerUp_PrintInfo("ActPowerUp_GetPrize", "设置数据状态失败 nID = "..nID)
+        tMsgData.nState = 0
+
+        ActPowerUp_SendClient(human.fd, tMsgData)
+        return
+    end
+
+    -- 发奖励
+    for i = 1, #tGoodsInfo do
+        local nGoodsID = tGoodsInfo[i][1]
+        local nGoodsNum = tGoodsInfo[i][2]
+
+        BagLogic.addItem(human, nGoodsID, nGoodsNum,"open_server_PowerUpPrize")
+    end
+
+	BagLogic.sendItemGetList(human, tGoodsInfo, "open_server_PowerUpPrize")
+
+	for k, v in pairs(funcID) do
+	    YunYingLogic.updateIcon(YYInfo[k], human)
+	    YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_3605)
+        break
+    end
+    
+    ActPowerUp_Query(human)
+end
+
+
+----------------------------------------- 其他模块调用 -------------------------------------
+-- 用于起服时映射奖励ID对应配置
+function Init()
+    local tPrize = ActPowerUp_GetConfig()
+    if not tPrize then
+        ActPowerUp_PrintInfo("Init", "起服获取不到配置")
+        return
+    end
+    
+    tPrizeByID = {}
+   -- Util.printTable(tPrize)
+
+    for nID, v in pairs(tPrize) do
+        if tPrizeByID[nID] then
+            ActPowerUp_PrintInfo("Init", "配置了重复的奖励ID")
+            return
+        end
+
+        tPrizeByID[nID] = v
+    end
+end
+
+-- 战力改变回调
+function ActPowerUp_PowerChange(human, nNewPower)
+    -- 活动未开启
+    if false == ActPowerUp_IsOpen(human) then
+        return
+    end
+
+    if not human or 0 >= nNewPower then
+        return
+    end
+
+    local tPrizeConfig = ActPowerUp_GetConfig()
+    if not tPrizeConfig then
+        return
+    end
+
+    local nSendClient = false
+    for nID, v in pairs(tPrizeConfig) do
+        local nState = ActPowerUp_GetDBIDState(human, nID)
+        if POWERGIFT_STATE_NONE == nState then
+            if nNewPower >= v.nPower then
+                ActPowerUp_SetDBIDState(human, nID, POWERGIFT_STATE_CANGET)
+                nSendClient = true
+            end
+        end
+    end
+
+    if true == nSendClient then
+        ActPowerUp_Query(human)
+    end
+
+    return true
+end
+
+function ActPowerUp_GMClear(human)
+    ActPowerUp_DelDB(human)
+    print("[ActPowerUp_GMClear] 战力冲刺数据清空结束")
 end

+ 1 - 24
script/module/present/Proto.lua

@@ -185,33 +185,12 @@ DailyLeichongNet = {
     {"max",         1, "int"},      --需要进度
     {"reward",      10, ItemData},  --奖励道具
     {"desc",        1, "string"},   --奖励道具
-    {"state",       1, "byte"},      --状态, 0-未达成,1-达成且已领取
 }
 GC_DAILY_LEICHONG_QUERY = {
     {"sec", 1, "int"},            --剩余时间
     {"weekPay", 15, DailyLeichongNet},   --兑换列表
-    {"titledesc",        1, "string"},   --描述
 }
 
-
---好评礼包
-CG_ESTEEMGIFT_QUERY = {}
-
-GC_ESTEEMGIFT_QUERY = {
-    {"desc",         1, "string"},      --描述
-    {"reward",      10, ItemData},  --奖励道具
-}
-
---单日大额
-CG_HUGERECHARGE_QUERY = {}
-
-GC_HUGERECHARGE_QUERY = {
-    {"desc",         1, "string"},      --描述
-    {"reward",      10, ItemData},  --奖励道具
-}
-
-
-
 -- 通用特殊礼包
 SpecificNet = {
     {"id",          1,      "byte"},        -- 子id
@@ -955,7 +934,7 @@ CG_PRESENT_OPEN_POWERUP_QUERY = {}
 -- 请求开服活动-战力冲刺信息 回包
 GC_PRESENT_OPEN_POWERUP_QUERY = {
     {"nNowPower",   1,  "int"},
-    {"list",        8,  PowerPrize},
+    {"list",        15,  PowerPrize},
 }
 
 -- 请求领取战力冲刺奖励
@@ -991,8 +970,6 @@ GC_PRESEN_OPEN_ADDUP_CHARGE_QUERY =
 CG_PRESENT_OPEN_ADDUP_CHARGE_GETPRIZE = {
     {"nID",             1,      "int"},         -- 领取奖励ID
 }
-
-
 ---------------------------在线奖励-------------------------
 SINGLE_AWARD_INFO = {
     {"itemInfo",       1,  ItemData},