瀏覽代碼

提交阵容推荐

SCFC 1 年之前
父節點
當前提交
12d95cb1bf

+ 378 - 364
script/common/CommonDB.lua

@@ -1,365 +1,379 @@
-local DB = require("common.DB")
-local LuaMongo = _G.lua_mongo
-local Config = require("Config")
-local Util = require("common.Util")
-local ObjHuman = require("core.ObjHuman")
-local YunYingLogic = require("yunying.YunYingLogic")
-local OpenAct = require("present.OpenAct")
-
-local DBUpdate = {_id=nil}								-- 更新	
-local DBUpdateField = {}								-- 更新域
-
-
-KEY_SERVER_START_TIME = "serverStartTime"				-- 开服时间
-KEY_IDENTITY_MAX = "identityMax"						-- 自增的最大的数字 从1开始
-KEY_UNION_IDENTITY_MAX = "unionIdentityMax"				-- 自增的最大的数字 从1开始
-KEY_REWARD_INDEX = "rewardIndex"						-- 好友排行榜奖励索引rewardIndex
-KEY_BAN_IP = "banIp"									-- 被禁IP
-KEY_CHONGJI_ACT = "chongJiAct"							-- 全服冲级活动 领取情况
-KEY_ACT_MONTH = "actMonth"								-- 当前计算的真实月份
-KEY_UNION_WAR = "unionWar"								-- 公会战
-KEY_ACT_MONTH_LIST = "actMonthList"						-- 现实活动
-KEY_RESET_TIME = "resetTime"
-KEY_DRILL = "drill"										-- 过关斩将信息(本期开始时间等)
-KEY_SHARE_PLATFORM_BOARD = "sharePlatformBoard"			-- 分享排行
-KEY_BILLBOARD_AIM = "billboardAim"						-- 排行榜达标记录
-KEY_JJC_LADDER = "jjcLadder"							-- 天梯争霸信息
-KEY_VALLEY = "valley"									-- 荣耀峡谷信息
-KEY_LIANYU = "lianyu" 									-- 绝望深渊信息
-KEY_MIDDLE_INFO = "middleInfo"							-- 跨服链接信息
-KEY_CHAMPION_END_TIME = "championEndTime"				-- 冠军竞技场本赛季结束时间
-KEY_DRAGON_NEST_CITIAO = "dragonNestCiTiao"             -- 冰龙巢穴词条
-KEY_WORK_MAN = "workMan"                                -- 打工人活动
-KEY_OPEN_SERVER_TOPUP_TOP = "openServerTopupTop"		-- 开服充值排名活动
-KEY_CIYUAN_MOZHU = "ciyuanMoZhu"                        -- 次元魔蛛
-KEY_YJ_TIME = "yjTreasureTime"                          -- 遗迹探险时间
-KEY_CDK_BATCH = "cdkBatchIdx"                           -- CDK批次序号
-KEY_WEEKLOOP_CARD_BATCH = "weekLoopCardBatch"			-- 周活动-抽卡批次
-
-db = db or {
-	serverStartTime = nil,								-- 开服时间
-	zhuanpanRecord = nil,								-- 转盘中奖记录
-	identityMax = nil,									-- 自增的最大的数字 从1开始
-    rewardIndex = nil,                                  -- 好友排行榜奖励索引rewardIndex
-    unionIdentityMax = nil,                             -- 自增的最大的数字 从1开始
-    mergeSvrIndex = nil,								-- 合服之后对应的服务器索引 比如如果10001,10003,100004合服了 这里的数据结构是{10001,10003,10004}
-    banIp = {},                                         -- 被禁IP
-	chongJiAct  = {},                                   -- 全服冲级活动 领取情况
-	actMonth = nil,                                     -- 当前计算的真实月份
-	unionWarState = nil,                                -- 当前工会战状态
-	actMonthList = nil,                                 -- 现实活动
-	resetTime = nil,                                    -- 确认是否重置数据
-	middleInfo = {},									-- 跨服链接信息
-	championEndTime = nil,							    -- 冠军竞技场本赛季结束时间
-	dragonNestCiTiao = {},                              -- 冰龙巢穴词条
-	workMan = {},                                       -- 打工人活动
-	ciyuanMoZhu = nil,                                  -- 次元魔蛛 
-    yjTreasureTime = nil,                               -- 遗迹探险时间
-	cdkBatchIdx = nil,									-- CDK批次序号
-	weekLoopCardBatch = nil,							-- 周活动-抽卡批次
-}
-
-function init()
-	LuaMongo.find(DB.db_common)
-	if not LuaMongo.next(db) then
-		LuaMongo.insert(DB.db_common, db)
-	end
-end
-
--- 修改db单个字段
-function updateValue(key, value)
-	if not key then return end	
-	if not db then return end
-	if value then
-		DBUpdateField["$set"] = {[key]=value}
-		DBUpdateField["$unset"] = nil
-	else
-		DBUpdateField["$set"] = nil
-		DBUpdateField["$unset"] = {[key]=1}
-	end
-	DBUpdate._id = db._id
-	db[key] = value
-	LuaMongo.update(DB.db_common, DBUpdate, DBUpdateField)
-end
-
-function getCDKBatch()
-	if not db  then 
-		return
-	end
-	return db[KEY_CDK_BATCH] or 0
-end
-
-function setCDKBatch(idx)
-	idx = idx + 1
-	updateValue(KEY_CDK_BATCH,idx)
-end
-
-function getValueByKey(key)
-	if not db then return end
-	return db[key]
-end
-
--- 同步db内容
-function reset()
-	LuaMongo.find(DB.db_common)
-	
-	if not LuaMongo.next(db) then
-		db = {banIp = {},}
-	end
-	print("db.serverStartTime:",db.serverStartTime)
-end
-
--- 设置开服时间
-function setServerOpenTime(time)
-	db.serverStartTime = time
-	updateValue(KEY_SERVER_START_TIME, time)
-	
-    YunYingLogic.onServerOpenTime()
-	OpenAct.onServerOpenTime()
-end
-
-function getServerOpenTime()
-	if not db.serverStartTime then 
-		local t = Util.getDayStartTime()
-		setServerOpenTime(t)
-	end
-	return db.serverStartTime
-end
-
--- 获得当前是开服第几天(如果是开服第一天返回1)
-function getServerOpenDay()
-	local openTime = getServerOpenTime()
-	if openTime == 0 then
-		return
-	end
-	
-	local startTime = Util.getDayStartTime(openTime)
-	
-	local now = os.time()
-	return math.ceil((now - startTime + 1) / 24 / 3600)
-end
-
-function getIdentityMax()
-	if db.identityMax == nil then
-		db.identityMax = math.random(10001, 20000)	
-		setIdentityMax(db.identityMax)
-	elseif db.identityMax < 10001 then
-		db.identityMax = math.random(10001, 20000) -- 兼容老规则下数据
-		setIdentityMax(db.identityMax)
-	end
-	
-	return db.identityMax
-end
-
--- 虚拟ID,假的
-function getFakeIdentityMax()
-	return math.random(1, 9999)
-end
-
-function setIdentityMax(idMax)
-	updateValue(KEY_IDENTITY_MAX, idMax)
-end
-
-function getUnionIdentityMax()
-	if db.unionIdentityMax == nil then
-		db.unionIdentityMax = math.random(10001, 20000)	
-		setUnionIdentityMax(db.unionIdentityMax)
-	elseif db.unionIdentityMax < 10001 then
-		db.unionIdentityMax = math.random(10001, 20000) -- 兼容老规则下数据
-		setUnionIdentityMax(db.unionIdentityMax)
-	end
-	
-	return db.unionIdentityMax
-end
-
-function setUnionIdentityMax(idMax)
-	updateValue(KEY_UNION_IDENTITY_MAX, idMax)
-end
-
-function getRewardIndex()
-	return db.rewardIndex or 0
-end
-
-function setRewardIndex(rewardIndex)
-	updateValue(KEY_REWARD_INDEX, rewardIndex)
-end
-
-function getMergeSvrIndex()
-	return db.mergeSvrIndex
-end
-
-cnt = 1
-function setBanIp(ip,time)
-    db.banIp[cnt] =db.banIp[cnt] or {}
-    db.banIp[cnt].ip = ip
-    db.banIp[cnt].time = time
-    cnt = cnt + 1
-	
-	updateValue(KEY_BAN_IP, db.banIp)
-end
-
-function getBanIp(ip)
-    for k,v in pairs(db.banIp) do
-        if v.ip == ip then
-            return v.ip,v.time
-        end
-    end
-    return 
-end
-
-function delBanIp(ip)
-    for k,v in pairs(db.banIp) do
-        if v.ip == ip then
-            db.banIp[k] = nil
-        end
-    end
-
-    updateValue(KEY_BAN_IP, db.banIp)
-end
-
--- 全服创号 冲级活动
-function getSvrChongJiGet(id)
-	local num = 0 
-	if not db.chongJiAct then
-		return num
-	end
-
-	if db.chongJiAct[id] then
-		num = db.chongJiAct[id] or 0
-	end
-
-	return num
-end
-
-function addSvrChongJiGet(id)
-	db.chongJiAct = db.chongJiAct or {}
-    db.chongJiAct[id] = db.chongJiAct[id] or 0
-    db.chongJiAct[id] = db.chongJiAct[id] + 1
-
-	updateValue(KEY_CHONGJI_ACT, db.chongJiAct)	
-end
-
-function getActMonth()
-    return db.actMonth or 0
-end
-
-function setActMonth(month)
-	updateValue(KEY_ACT_MONTH, month)	
-end
-
-function getActMonthList(id)
-	local act = nil 
-	if not db.actMonthList then
-		return act
-	end
-
-	if db.actMonthList[id] then
-		act = db.actMonthList[id] or 0
-	end
-
-	return act
-end
-
-function setActMonthList(id, endTime, month)
-	db.actMonthList = db.actMonthList or {}
-    db.actMonthList[id] = db.actMonthList[id] or {}
-    db.actMonthList[id].endTime = endTime
-	db.actMonthList[id].month = month
-	updateValue(KEY_ACT_MONTH_LIST, db.actMonthList)
-end
-
-function getResetTime()
-	return db.resetTime or 0
-end
-
-function setResetTime(time)
-	updateValue(KEY_RESET_TIME, time)
-end
-
-function getMiddleInfo()
-	return db.middleInfo
-end
-
-function setMiddleInfo(ip, port, host)
-	db.middleInfo.ip = ip
-	db.middleInfo.port = port
-	db.middleInfo.host = host
-	updateValue(KEY_MIDDLE_INFO, db.middleInfo)
-end
-
-function getChampionEndTime()
-	return db.championEndTime or 0
-end
-
-function setChampionEndTime(time)
-	updateValue(KEY_CHAMPION_END_TIME, time)
-end
-
-function getDragonNestCitiao()
-	return db.dragonNestCiTiao
-end
-
-function setDragonNestCitiao(list, time)
-	db.dragonNestCiTiao.citiao = Util.copyTable(list)
-	db.dragonNestCiTiao.time = time
-	updateValue(KEY_DRAGON_NEST_CITIAO, db.dragonNestCiTiao)
-end
-
-function setWorkManState(state)
-    db.workMan.state = state
-    updateValue(KEY_WORK_MAN, db.workMan)
-end
-
-function setWorkManGroup(group)
-    db.workMan.group = group
-    updateValue(KEY_WORK_MAN, db.workMan)
-end
-
-function setWorkManTs(ts)
-    db.workMan.time = ts
-    updateValue(KEY_WORK_MAN, db.workMan)
-end
-
-function getWorkMan()
-	return db.workMan
-end
-
--- 获取合服时间
-function getMergeServerTime()
-	return db.mergeServerTime or 0
-end
-
-
--- 获得当前是合服第几天(如果是合服第一天返回1)
-function getServerMergeDay()
-	local mergeTime = getMergeServerTime()
-	if mergeTime == 0 then
-		return
-	end
-	
-	local startTime = Util.getDayStartTime(mergeTime)
-	
-	local now = os.time()
-	return math.ceil((now - startTime + 1) / 24 / 3600)
-end
-
-function setMergeTime(ts)
-    db.mergeServerTime = ts
-    updateValue("mergeServerTime", db.mergeServerTime)
-end
-
-function getYjTreasureEndTime()
-	return db.yjTreasureTime or 0
-end
-
-function setYjTreasureEndTime(time)
-	updateValue(KEY_YJ_TIME, time)
-end
-
-function getWeekCardBatch()
-	return db.weekLoopCardBatch or 0
-end
-
-function setWeekCardBatch(nValue)
-	updateValue(KEY_WEEKLOOP_CARD_BATCH, nValue)
+local DB = require("common.DB")
+local LuaMongo = _G.lua_mongo
+local Config = require("Config")
+local Util = require("common.Util")
+local ObjHuman = require("core.ObjHuman")
+local YunYingLogic = require("yunying.YunYingLogic")
+local OpenAct = require("present.OpenAct")
+
+local DBUpdate = {_id=nil}								-- 更新	
+local DBUpdateField = {}								-- 更新域
+
+
+KEY_SERVER_START_TIME = "serverStartTime"				-- 开服时间
+KEY_IDENTITY_MAX = "identityMax"						-- 自增的最大的数字 从1开始
+KEY_UNION_IDENTITY_MAX = "unionIdentityMax"				-- 自增的最大的数字 从1开始
+KEY_REWARD_INDEX = "rewardIndex"						-- 好友排行榜奖励索引rewardIndex
+KEY_BAN_IP = "banIp"									-- 被禁IP
+KEY_CHONGJI_ACT = "chongJiAct"							-- 全服冲级活动 领取情况
+KEY_ACT_MONTH = "actMonth"								-- 当前计算的真实月份
+KEY_UNION_WAR = "unionWar"								-- 公会战
+KEY_ACT_MONTH_LIST = "actMonthList"						-- 现实活动
+KEY_RESET_TIME = "resetTime"
+KEY_DRILL = "drill"										-- 过关斩将信息(本期开始时间等)
+KEY_SHARE_PLATFORM_BOARD = "sharePlatformBoard"			-- 分享排行
+KEY_BILLBOARD_AIM = "billboardAim"						-- 排行榜达标记录
+KEY_JJC_LADDER = "jjcLadder"							-- 天梯争霸信息
+KEY_VALLEY = "valley"									-- 荣耀峡谷信息
+KEY_LIANYU = "lianyu" 									-- 绝望深渊信息
+KEY_MIDDLE_INFO = "middleInfo"							-- 跨服链接信息
+KEY_CHAMPION_END_TIME = "championEndTime"				-- 冠军竞技场本赛季结束时间
+KEY_DRAGON_NEST_CITIAO = "dragonNestCiTiao"             -- 冰龙巢穴词条
+KEY_WORK_MAN = "workMan"                                -- 打工人活动
+KEY_OPEN_SERVER_TOPUP_TOP = "openServerTopupTop"		-- 开服充值排名活动
+KEY_CIYUAN_MOZHU = "ciyuanMoZhu"                        -- 次元魔蛛
+KEY_YJ_TIME = "yjTreasureTime"                          -- 遗迹探险时间
+KEY_CDK_BATCH = "cdkBatchIdx"                           -- CDK批次序号
+KEY_WEEKLOOP_CARD_BATCH = "weekLoopCardBatch"			-- 周活动-抽卡批次
+kEY_RECOMMENDLINEUP = "recommendlineup"					-- 推荐阵容
+
+db = db or {
+	serverStartTime = nil,								-- 开服时间
+	zhuanpanRecord = nil,								-- 转盘中奖记录
+	identityMax = nil,									-- 自增的最大的数字 从1开始
+    rewardIndex = nil,                                  -- 好友排行榜奖励索引rewardIndex
+    unionIdentityMax = nil,                             -- 自增的最大的数字 从1开始
+    mergeSvrIndex = nil,								-- 合服之后对应的服务器索引 比如如果10001,10003,100004合服了 这里的数据结构是{10001,10003,10004}
+    banIp = {},                                         -- 被禁IP
+	chongJiAct  = {},                                   -- 全服冲级活动 领取情况
+	actMonth = nil,                                     -- 当前计算的真实月份
+	unionWarState = nil,                                -- 当前工会战状态
+	actMonthList = nil,                                 -- 现实活动
+	resetTime = nil,                                    -- 确认是否重置数据
+	middleInfo = {},									-- 跨服链接信息
+	championEndTime = nil,							    -- 冠军竞技场本赛季结束时间
+	dragonNestCiTiao = {},                              -- 冰龙巢穴词条
+	workMan = {},                                       -- 打工人活动
+	ciyuanMoZhu = nil,                                  -- 次元魔蛛 
+    yjTreasureTime = nil,                               -- 遗迹探险时间
+	cdkBatchIdx = nil,									-- CDK批次序号
+	weekLoopCardBatch = nil,							-- 周活动-抽卡批次
+	recommendlineup = {},								-- 推荐阵容
+}
+
+function init()
+	LuaMongo.find(DB.db_common)
+	if not LuaMongo.next(db) then
+		LuaMongo.insert(DB.db_common, db)
+	end
+end
+
+-- 修改db单个字段
+function updateValue(key, value)
+	if not key then return end	
+	if not db then return end
+	if value then
+		DBUpdateField["$set"] = {[key]=value}
+		DBUpdateField["$unset"] = nil
+	else
+		DBUpdateField["$set"] = nil
+		DBUpdateField["$unset"] = {[key]=1}
+	end
+	DBUpdate._id = db._id
+	db[key] = value
+	LuaMongo.update(DB.db_common, DBUpdate, DBUpdateField)
+end
+
+function getCDKBatch()
+	if not db  then 
+		return
+	end
+	return db[KEY_CDK_BATCH] or 0
+end
+
+function setCDKBatch(idx)
+	idx = idx + 1
+	updateValue(KEY_CDK_BATCH,idx)
+end
+
+function getValueByKey(key)
+	if not db then return end
+	return db[key]
+end
+
+-- 同步db内容
+function reset()
+	LuaMongo.find(DB.db_common)
+	
+	if not LuaMongo.next(db) then
+		db = {banIp = {},}
+	end
+	print("db.serverStartTime:",db.serverStartTime)
+end
+
+-- 设置开服时间
+function setServerOpenTime(time)
+	db.serverStartTime = time
+	updateValue(KEY_SERVER_START_TIME, time)
+	
+    YunYingLogic.onServerOpenTime()
+	OpenAct.onServerOpenTime()
+end
+
+function getServerOpenTime()
+	if not db.serverStartTime then 
+		local t = Util.getDayStartTime()
+		setServerOpenTime(t)
+	end
+	return db.serverStartTime
+end
+
+-- 获得当前是开服第几天(如果是开服第一天返回1)
+function getServerOpenDay()
+	local openTime = getServerOpenTime()
+	if openTime == 0 then
+		return
+	end
+	
+	local startTime = Util.getDayStartTime(openTime)
+	
+	local now = os.time()
+	return math.ceil((now - startTime + 1) / 24 / 3600)
+end
+
+function getIdentityMax()
+	if db.identityMax == nil then
+		db.identityMax = math.random(10001, 20000)	
+		setIdentityMax(db.identityMax)
+	elseif db.identityMax < 10001 then
+		db.identityMax = math.random(10001, 20000) -- 兼容老规则下数据
+		setIdentityMax(db.identityMax)
+	end
+	
+	return db.identityMax
+end
+
+-- 虚拟ID,假的
+function getFakeIdentityMax()
+	return math.random(1, 9999)
+end
+
+function setIdentityMax(idMax)
+	updateValue(KEY_IDENTITY_MAX, idMax)
+end
+
+function getUnionIdentityMax()
+	if db.unionIdentityMax == nil then
+		db.unionIdentityMax = math.random(10001, 20000)	
+		setUnionIdentityMax(db.unionIdentityMax)
+	elseif db.unionIdentityMax < 10001 then
+		db.unionIdentityMax = math.random(10001, 20000) -- 兼容老规则下数据
+		setUnionIdentityMax(db.unionIdentityMax)
+	end
+	
+	return db.unionIdentityMax
+end
+
+function setUnionIdentityMax(idMax)
+	updateValue(KEY_UNION_IDENTITY_MAX, idMax)
+end
+
+function getRewardIndex()
+	return db.rewardIndex or 0
+end
+
+function setRewardIndex(rewardIndex)
+	updateValue(KEY_REWARD_INDEX, rewardIndex)
+end
+
+function getMergeSvrIndex()
+	return db.mergeSvrIndex
+end
+
+cnt = 1
+function setBanIp(ip,time)
+    db.banIp[cnt] =db.banIp[cnt] or {}
+    db.banIp[cnt].ip = ip
+    db.banIp[cnt].time = time
+    cnt = cnt + 1
+	
+	updateValue(KEY_BAN_IP, db.banIp)
+end
+
+function getBanIp(ip)
+    for k,v in pairs(db.banIp) do
+        if v.ip == ip then
+            return v.ip,v.time
+        end
+    end
+    return 
+end
+
+function delBanIp(ip)
+    for k,v in pairs(db.banIp) do
+        if v.ip == ip then
+            db.banIp[k] = nil
+        end
+    end
+
+    updateValue(KEY_BAN_IP, db.banIp)
+end
+
+-- 全服创号 冲级活动
+function getSvrChongJiGet(id)
+	local num = 0 
+	if not db.chongJiAct then
+		return num
+	end
+
+	if db.chongJiAct[id] then
+		num = db.chongJiAct[id] or 0
+	end
+
+	return num
+end
+
+function addSvrChongJiGet(id)
+	db.chongJiAct = db.chongJiAct or {}
+    db.chongJiAct[id] = db.chongJiAct[id] or 0
+    db.chongJiAct[id] = db.chongJiAct[id] + 1
+
+	updateValue(KEY_CHONGJI_ACT, db.chongJiAct)	
+end
+
+function getActMonth()
+    return db.actMonth or 0
+end
+
+function setActMonth(month)
+	updateValue(KEY_ACT_MONTH, month)	
+end
+
+function getActMonthList(id)
+	local act = nil 
+	if not db.actMonthList then
+		return act
+	end
+
+	if db.actMonthList[id] then
+		act = db.actMonthList[id] or 0
+	end
+
+	return act
+end
+
+function setActMonthList(id, endTime, month)
+	db.actMonthList = db.actMonthList or {}
+    db.actMonthList[id] = db.actMonthList[id] or {}
+    db.actMonthList[id].endTime = endTime
+	db.actMonthList[id].month = month
+	updateValue(KEY_ACT_MONTH_LIST, db.actMonthList)
+end
+
+function getResetTime()
+	return db.resetTime or 0
+end
+
+function setResetTime(time)
+	updateValue(KEY_RESET_TIME, time)
+end
+
+function getMiddleInfo()
+	return db.middleInfo
+end
+
+function setMiddleInfo(ip, port, host)
+	db.middleInfo.ip = ip
+	db.middleInfo.port = port
+	db.middleInfo.host = host
+	updateValue(KEY_MIDDLE_INFO, db.middleInfo)
+end
+
+function getChampionEndTime()
+	return db.championEndTime or 0
+end
+
+function setChampionEndTime(time)
+	updateValue(KEY_CHAMPION_END_TIME, time)
+end
+
+function getDragonNestCitiao()
+	return db.dragonNestCiTiao
+end
+
+function setDragonNestCitiao(list, time)
+	db.dragonNestCiTiao.citiao = Util.copyTable(list)
+	db.dragonNestCiTiao.time = time
+	updateValue(KEY_DRAGON_NEST_CITIAO, db.dragonNestCiTiao)
+end
+
+function setWorkManState(state)
+    db.workMan.state = state
+    updateValue(KEY_WORK_MAN, db.workMan)
+end
+
+function setWorkManGroup(group)
+    db.workMan.group = group
+    updateValue(KEY_WORK_MAN, db.workMan)
+end
+
+function setWorkManTs(ts)
+    db.workMan.time = ts
+    updateValue(KEY_WORK_MAN, db.workMan)
+end
+
+function getWorkMan()
+	return db.workMan
+end
+
+-- 获取合服时间
+function getMergeServerTime()
+	return db.mergeServerTime or 0
+end
+
+
+-- 获得当前是合服第几天(如果是合服第一天返回1)
+function getServerMergeDay()
+	local mergeTime = getMergeServerTime()
+	if mergeTime == 0 then
+		return
+	end
+	
+	local startTime = Util.getDayStartTime(mergeTime)
+	
+	local now = os.time()
+	return math.ceil((now - startTime + 1) / 24 / 3600)
+end
+
+function setMergeTime(ts)
+    db.mergeServerTime = ts
+    updateValue("mergeServerTime", db.mergeServerTime)
+end
+
+function getYjTreasureEndTime()
+	return db.yjTreasureTime or 0
+end
+
+function setYjTreasureEndTime(time)
+	updateValue(KEY_YJ_TIME, time)
+end
+
+function getWeekCardBatch()
+	return db.weekLoopCardBatch or 0
+end
+
+function setWeekCardBatch(nValue)
+	updateValue(KEY_WEEKLOOP_CARD_BATCH, nValue)
+end
+
+-- 获取阵容数据
+function getRecommendLineUp()
+	return db.recommendlineup
+end
+
+-- 修改阵容数据
+function SetRecommendLineUp(tData)
+	db.recommendlineup = tData
+
+	updateValue(kEY_RECOMMENDLINEUP, db.recommendlineup)
 end

+ 3 - 1
script/common/ProtoID.lua

@@ -1316,4 +1316,6 @@ _ENV[1349]="GC_DBQB_RESET"
 _ENV[1350]="CG_DBQB_START_GAME"
 _ENV[1351]="GC_DBQB_START_GAME"
 _ENV[1352]="CG_DBQB_TIPS"
-_ENV[1353]="GC_DBQB_TIPS"
+_ENV[1353]="GC_DBQB_TIPS"
+_ENV[1354]="CG_DRAWCARD_GET_RECOMMEND_LINEUP"
+_ENV[1355]="GC_DRAWCARD_GET_RECOMMEND_LINEUP"

+ 2 - 0
script/module/combat/CombatPosLogic.lua

@@ -45,6 +45,7 @@ local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
 local SkillExcel = require("excel.skill")
 local RoleAttr = require("role.RoleAttr")
 local LostTempleCombatLogic = require("lostTemple.lostTempleCombatLogic")
+local RecommendLineup = require("drawCard.RecommendLineup")
 
 -- 根据战斗类型获取出战队伍类型
 function getTeamType(combatType)
@@ -175,6 +176,7 @@ function onUpdatePos(human, teamType)
     			ObjHuman.doCalc(human)
 	            local heroListZDL = getCombatHeroZDL(human, CombatDefine.COMBAT_TYPE1)
                 ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_8,heroListZDL)
+				RecommendLineup.RecommendLineup_UpDate(human)
     		end
     	end
     end

+ 6 - 0
script/module/drawCard/Handler.lua

@@ -1,4 +1,6 @@
 local DrawCardLogic = require("drawCard.DrawCardLogic")
+local RecommendLineup = require("drawCard.RecommendLineup")
+
 function CG_DRAWCARD_QUERY(human,msg)
 	DrawCardLogic.query(human)
 end
@@ -9,4 +11,8 @@ end
 
 function CG_DRAWCARD_SKIP_SET(human, msg)
 	DrawCardLogic.setSkip(human, nil, msg.skip)
+end
+
+function CG_DRAWCARD_GET_RECOMMEND_LINEUP(human, msg)
+	RecommendLineup.GetRecommendLineUp(human)
 end

+ 16 - 0
script/module/drawCard/Proto.lua

@@ -1,5 +1,6 @@
 local ItemData = require("bag.Proto").ItemData
 local HeroNiceNet = require("hero.Proto").HeroNiceNet
+local HeroSimple = require("hero.Proto").HeroSimple
 
 CG_DRAWCARD_QUERY = {}
 DrawCardNet = {
@@ -49,4 +50,19 @@ GC_DRAWCARD_OP = {
 
 CG_DRAWCARD_SKIP_SET = {
 	{"skip",		    1,		"byte"},   -- 是否跳过
+}
+
+RecommendLineup = 
+{
+	{"data", 	7, 	HeroSimple},
+	{"nPower", 	1, 	"int"},
+}
+
+-- 请求推荐阵容
+CG_DRAWCARD_GET_RECOMMEND_LINEUP = {}
+
+-- 请求推荐阵容回报
+GC_DRAWCARD_GET_RECOMMEND_LINEUP = {
+	{"bIsEnd",   1,		"byte"},		
+	{"list",  35, RecommendLineup}
 }

+ 273 - 0
script/module/drawCard/RecommendLineup.lua

@@ -0,0 +1,273 @@
+--------------------------------
+-- 文件名       :  RecommendLineup.lua
+-- 文件说明     :  推荐阵容
+-- 创建时间     :   2025/1/15
+-- 创建人       :   FC
+--------------------------------
+
+local HeroLogic = require("hero.HeroLogic")
+local BagLogic = require("bag.BagLogic")
+local HeroGrid = require("hero.HeroGrid")
+local CommonDB = require("common.CommonDB")
+local Msg = require("core.Msg")
+local CombatPosLogic = require("combat.CombatPosLogic")
+local CombatDefine = require("combat.CombatDefine")
+local HeroExcel = require("excel.hero")
+
+
+local nRecommendLineupLen = 30		 -- 阵容记录推荐数量
+local tRecommendLineupData = nil
+local nSendLen = 15                     -- 一次性发送数据长度
+
+---------------------------------------- 内部函数 ------------------------------------
+local function RecommendLineup_GetData()
+    if not tRecommendLineupData then
+        tRecommendLineupData = CommonDB.getRecommendLineUp()
+        table.sort(tRecommendLineupData, function (l, r)
+            return l.nPower > r.nPower
+        end
+        )
+    end
+
+    return tRecommendLineupData
+end
+
+local function RecommendLineup_SetData(tData)
+    table.sort(tData, function (l, r)
+        return l.nPower > r.nPower
+    end
+    )
+    tRecommendLineupData = tData
+    CommonDB.SetRecommendLineUp(tRecommendLineupData)
+end
+
+-- 获取小于该战力的下表
+local function RecommendLineup_GetIndex(nNewPower, human)
+    local nIndex = -1
+    local tDBData = RecommendLineup_GetData()
+    local nKey = human.db._id
+
+    if nil == _G.next(tDBData) then
+        nIndex = 1
+        return nIndex
+    end
+
+    local nNowLen = #tDBData
+    if nNowLen < nRecommendLineupLen then
+        for i, value in ipairs(tDBData) do
+            -- 更新阵容
+            if value.key and value.key == nKey then
+                -- 大于等于才更新
+                if nNewPower >= value.nPower then
+                    print("[RecommendLineup_GetIndex] 已存在 nIndex = "..i)
+                    nIndex = i
+                end
+                
+                -- 直接返回
+                return nIndex
+            end
+        end
+
+        if -1 == nIndex then
+            nIndex = nNowLen + 1
+            return nIndex
+        end
+    end
+
+    for i, value in ipairs(tDBData) do
+        local nPower = value.nPower
+        if nNewPower > nPower then
+            nIndex = i
+            break
+        end
+    end
+
+    return nIndex
+end
+
+-- 插入最新的表
+local function RecommendLineup_UpDateData(human, nIndex, tHeroData)
+    local tOldData = RecommendLineup_GetData()
+    local nOldLen = #tOldData
+    local tNewData = {}
+
+    if nil == _G.next(tOldData) then
+        table.insert(tNewData, tHeroData)
+        RecommendLineup_SetData(tNewData)
+        return
+    end
+
+    -- 已经存在
+    if nIndex <= nOldLen then
+        tNewData = tOldData
+        tNewData[nIndex] = tHeroData
+        RecommendLineup_SetData(tNewData)
+        return
+    end
+
+    -- 长度还不够
+    if nOldLen < nRecommendLineupLen then
+        tNewData = tOldData
+        table.insert(tNewData, tHeroData)
+        RecommendLineup_SetData(tNewData)
+        return
+    end
+    
+    -- 只有30个直接遍历
+    local nLen = 0
+    local tLastData = nil
+    for i, value in ipairs(tOldData) do
+        if nLen >= nRecommendLineupLen then
+            break
+        end
+
+        if i == nIndex then
+            table.insert(tNewData, tHeroData)
+            tLastData = value
+        elseif i < nIndex then
+            table.insert(tNewData, value)
+        elseif i > nIndex then
+            table.insert(tNewData, tLastData)
+            tLastData = value
+        end
+        
+        nLen = nLen + 1
+    end
+
+    RecommendLineup_SetData(tNewData)
+end
+
+-- 封装信息
+local function RecommendLineup_MakeSimpleData(net, tSaveData)
+    local cf = HeroExcel.hero[tSaveData.id]
+    if not cf then
+        print("[RecommendLineup_MakeSimpleData] 不存在对应英雄配置 nHeroID = "..tSaveData.id)
+        return
+    end
+    net.id = tSaveData.id
+	net.index = tSaveData.index or 0
+    net.uuid = tSaveData.uuid or ""
+	net.gl = tSaveData.gl or 0
+	net.camp = tSaveData.camp or 0
+	net.job = tSaveData.job or 0
+	net.star = tSaveData.star or 0 --cf and cf.star or 0 星级调整 dxzeng  
+	net.icon = tSaveData.head or (cf.head or 0)
+	net.body = tSaveData.body or 0
+	net.up =  tSaveData.up or 0 --是否能够升星
+
+	net.lv = tSaveData.lv or 1
+	net.xLv = tSaveData.xLv or 0
+	net.zhandouli = tSaveData.zhandouli or 0
+	net.quality = tSaveData.quality or 0
+	net.isLock = tSaveData.isLock and 1 or 0
+	net.hp = tSaveData.hp or 0		
+	net.hpMax = tSaveData.hpMax or 0	
+	net.cnt = tSaveData.cnt or 1
+	net.isget = tSaveData.isget  or 0
+	net.weightLv = tSaveData.grade or 0
+	net.name = tSaveData.name or ""
+	net.grade = tSaveData.grade or 0
+	net.jobDesc = tSaveData.desc or ""
+    net.label = tSaveData.label or ""
+    net.order = tSaveData.order or 0
+    net.isGongMing = tSaveData.isGongMing or 0
+    
+    
+    --是否发送图鉴信息
+    net.general = tSaveData.general
+
+	--宝石
+	net.gemData = tSaveData.gemData
+end
+
+---------------------------------------- 客户端请求 ------------------------------------
+function GetRecommendLineUp(human)
+    local tData = RecommendLineup_GetData()
+
+    local tMsgData = Msg.gc.GC_DRAWCARD_GET_RECOMMEND_LINEUP
+    tMsgData.list[0] = 0 
+    tMsgData.bIsEnd = 0
+
+    for i, value in ipairs(tData) do
+        tMsgData.list[0] = tMsgData.list[0] + 1
+        local tHeroData = tMsgData.list[tMsgData.list[0]]
+        tHeroData.data[0] = 0
+        tHeroData.nPower = value.nPower
+        print("[GetRecommendLineUp] nPower = "..value.nPower.." i = "..i)
+        for _, v in pairs(value.data) do
+            
+            tHeroData.data[0] = tHeroData.data[0] + 1
+            RecommendLineup_MakeSimpleData(tHeroData.data[tHeroData.data[0]], v)
+        end
+        
+        if i >= nSendLen then
+            Msg.send(tMsgData, human.fd)
+            tMsgData.list[0] = 0
+        end
+    end
+	
+    tMsgData.bIsEnd = 1
+    Msg.send(tMsgData, human.fd)
+	print("[GetRecommendLineUp] 发送成功 ")
+end
+
+
+function RecommendLineup_UpDate(human)
+    if 5 >= human.db.lv then
+        return
+    end
+
+    local combatHero,helpList = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE1)
+    if not combatHero then
+        return
+    end
+
+    local nNewPower = CombatPosLogic.getCombatHeroZDL(human, CombatDefine.COMBAT_TYPE1, true)
+
+    local nIndex = RecommendLineup_GetIndex(nNewPower, human)
+    if -1 >= nIndex then
+        return
+    end
+
+    print("[RecommendLineup_UpDate] 获取到的下表 nIndex = "..nIndex)
+
+    local tHeroData = {
+        key = human.db._id,
+        nPower = nNewPower,
+        data = {},
+    }
+
+    local nLen = 1
+    for _, v in pairs(combatHero) do
+        local heroGrid = HeroLogic.getHeroGridByUuid(human, v)
+        if heroGrid then
+              tHeroData.data[nLen] = {
+                general = {},
+                gemData = {},
+            }
+            HeroGrid.makeHeroSimple(tHeroData.data[nLen], heroGrid, heroGrid.bagIndex, human)
+            nLen = nLen + 1
+        end
+    end
+    
+    for _,v in pairs(helpList) do
+        local heroGrid = HeroLogic.getHeroGridByUuid(human, v)
+        if heroGrid then
+            tHeroData.data[nLen] = {
+                general = {},
+                gemData = {},
+            }
+            HeroGrid.makeHeroSimple(tHeroData.data[nLen], heroGrid, heroGrid.bagIndex, human)
+            nLen = nLen + 1
+        end
+    end
+
+    RecommendLineup_UpDateData(human, nIndex, tHeroData)
+end
+
+function RecommendLineup_GMClear()
+    local tData = {}
+    tRecommendLineupData = tData
+    CommonDB.SetRecommendLineUp(tRecommendLineupData)
+    print("[RecommendLineup_GMClear] 重置成功")
+end

+ 3 - 0
script/module/zhanbu/ZhanbuLogic.lua

@@ -19,6 +19,7 @@ local MengxinLogic = require("present.MengxinLogic")
 local AbsZhanbuLunpanLogic = require("absAct.AbsZhanbuLunpanLogic")
 local YunYingLogic = require("yunying.YunYingLogic")
 local TalismanLogic = require("talisman.TalismanLogic")
+local RecommendLineup = require("drawCard.RecommendLineup")
 --[[
     pool ����
     hand ����
@@ -578,6 +579,8 @@ function onLogin(human)
             human.db.zhanbu.ts = os.time()
         end
     end
+
+    RecommendLineup.RecommendLineup_UpDate(human)
 end