| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405 |
- --------------------------------
- -- 文件名 : jjcNewLadderLogic.lua
- -- 文件说明 : 天梯赛-管理器
- -- 创建时间 : 2025/05/07
- -- 创建人 : FC
- --------------------------------
- local Util = require("common.Util")
- local Lang = require("common.Lang")
- local CommonDB = require("common.CommonDB")
- local JjcExcel = require("excel.jjc")
- local MonsterExcel = require("excel.monster")
- local MailExcel = require("excel.mail")
- local Msg = require("core.Msg")
- local ObjHuman = require("core.ObjHuman")
- local RoleDBLogic = require("role.RoleDBLogic")
- local Config = require("Config")
- local ItemDefine = require("bag.ItemDefine")
- local Grid = require("bag.Grid")
- local CombatVideo = require("combat.CombatVideo")
- local RoleLogic = require("role.RoleLogic")
- local JjcNewLadderDefine = require("jjcnewladder.jjcNewLadderDefine")
- local JjcNewLadderMiddle = require("jjcnewladder.jjcNewLadderMiddle")
- local JjcNewLadderDB = require("jjcnewladder.jjcNewLadderDB")
- local BagLogic = require("bag.BagLogic")
- local MiddleCommonLogic = require("middle.MiddleCommonLogic")
- local CombatDefine = require("combat.CombatDefine")
- local Broadcast = require("broadcast.Broadcast")
- local CombatLogic = require("combat.CombatLogic")
- local WarReportLogic = require("warReport.WarReportLogic")
- local MailManager = require("mail.MailManager")
- local Timer = require("core.Timer")
- local JjcActLogic = require("jjc.JjcActLogic")
- -- 请求加入天梯赛的玩家
- local tQueryJoinPlayer = {}
- -- 请求天梯赛前三排名的数据的玩家
- local tQueryLast3Rank = {}
- local bQueryLast = false
- -- 上一轮天梯赛前三的排名玩家
- local tLast3RankPlayerInfo = nil
- -- 排行榜数据
- local tCacheRankInfo = {
- -- nNextUpdateTime -- 更新时间
- -- tRankList = {}
- }
- local bQueryRank = nil
- -- 缓存请求排行榜的玩家
- local tCacheQueryRankPlaeyer = {}
- ------------------------------------- 内部判断 ----------------------------------------------------
- -- 判断是否开启
- local function JjcNewLadderLogic_CheckIsOpen()
- local nNowTime = os.time()
- local nEndTime = CommonDB.GetJjcLadderEndTime()
- print("[JjcNewLadderLogic_CheckIsOpen] nNowTime = "..nNowTime.." nEndTime = "..nEndTime)
- if 0 >= nEndTime then
- local tDate = os.date("*t",nNowTime)
- if tDate.wday >= JjcNewLadderDefine.JJC_NEWLADDER_OPENDAY and JjcNewLadderDefine.JJC_NEWLADDER_OPENDAY <= tDate.wday then
- if JjcNewLadderDefine.JJC_NEWLADDER_OPENDAY == tDate.wday then
- if tDate.hour >= JjcNewLadderDefine.JJC_NEWLADDER_ENDTIME then
- return false
- end
- end
- return true
- end
- return false
- else
- return nNowTime > nEndTime
- end
- end
- -- 获取剩余时间
- local function JjcNewLadder_GetLeftTime()
- local nNowTime = os.time()
- local nEndTime = CommonDB.GetJjcLadderEndTime()
- if not nEndTime or nEndTime < nNowTime then
- return 0
- end
- return nEndTime - nNowTime
- end
- -- 初始化玩家DB
- local function JjcNewLadderLogic_CreatDB(human)
- human.db.JjcNewLadder =
- {
- nRefresh = os.time(), -- 免费刷新时间
- nFreeNum = 5, -- 免费挑战次数
- nPayNum = 0, -- 购买挑战次数
- bJoin = false,
- nRank = -1,
- nPoint = 0, -- 积分
- tEnemy = nil, -- 对战敌方数据
- recordList = nil, -- 对战记录
- tWorship = nil, -- 点赞记录
- nLastEndTime = CommonDB.GetJjcLadderEndTime(), -- 上一次活动结束时间
- }
- end
- -- 获取玩家上一次活动结束时间
- local function JjcNewLadder_GetHumanLastEndTime(human)
- return human.db.JjcNewLadder.nLastEndTime
- end
- -- 设置玩家上一次活动结束时间
- local function JjcNewLadder_SetHumanLastEndTime(human, nValue)
- human.db.JjcNewLadder.nLastEndTime = nValue
- end
- -- 获取玩家是否参加了天梯赛
- local function JjcNewLadder_GetHumanJoin(human)
- return human.db.JjcNewLadder.bJoin
- end
- -- 设置玩家是否参加了天梯赛
- local function JjcNewLadder_SetHumanJoin(human, nValue)
- human.db.JjcNewLadder.bJoin = nValue
- end
- -- 获取玩家敌方数据
- local function JjcNewLadder_GetHumanEnemy(human)
- return human.db.JjcNewLadder.tEnemy
- end
- -- 设置玩家敌方数据
- local function JjcNewLadder_SetHumanEnemy(human, tEnemy)
- human.db.JjcNewLadder.tEnemy = tEnemy
- end
- -- 获取玩家排名数据
- local function JjcNewLadder_GetHumanRank(human)
- return human.db.JjcNewLadder.nRank
- end
- -- 设置玩家排名数据
- local function JjcNewLadder_SetHumanRank(human, nValue)
- human.db.JjcNewLadder.nRank = nValue
- end
- -- 获取玩家积分数据
- local function JjcNewLadder_GetHumanPoint(human)
- return human.db.JjcNewLadder.nPoint
- end
- -- 设置玩家积分数据
- local function JjcNewLadder_SetHumanPoint(human, nValue)
- human.db.JjcNewLadder.nPoint = nValue
- end
- -- 获取玩家免费刷新时间
- local function JjcNewLadder_GetHumanRefreshTime(human)
- return human.db.JjcNewLadder.nRefresh
- end
- -- 设置玩家免费刷新时间
- local function JjcNewLadder_SetHumanRefreshTime(human, nValue)
- human.db.JjcNewLadder.nRefresh = nValue
- end
- -- 获取玩家免费挑战次数
- local function JjcNewLadder_GetHumanFreeNum(human)
- return human.db.JjcNewLadder.nFreeNum
- end
- -- 设置玩家免费挑战次数
- local function JjcNewLadder_SetHumanFreeNum(human, nValue)
- human.db.JjcNewLadder.nFreeNum = human.db.JjcNewLadder.nFreeNum + nValue
- end
- -- 获取玩家付费挑战次数
- local function JjcNewLadder_GetHumanPayNum(human)
- return human.db.JjcNewLadder.nPayNum
- end
- -- 设置玩家付费挑战次数
- local function JjcNewLadder_SetHumanPayNumNum(human, nValue)
- human.db.JjcNewLadder.nPayNum = human.db.JjcNewLadder.nPayNum + nValue
- end
- -- 获取玩家所有挑战次数
- local function JjcNewLadder_GetAllFightNum(human)
- return JjcNewLadder_GetHumanFreeNum(human) + JjcNewLadder_GetHumanPayNum(human)
- end
- -- 获取对战记录
- local function JjcNewLadder_GetRecordList(human)
- return human.db.JjcNewLadder.recordList
- end
- -- 设置对战记录
- local function JjcNewLadder_SetRecordList(human, videoUuid)
- if not human.db.JjcNewLadder.recordList then
- human.db.JjcNewLadder.recordList = {}
- end
- table.insert(human.db.JjcNewLadder.recordList, {videoUuid = videoUuid, time = os.time()})
- end
- -- 尝试删除对接记录的视频UID
- local function JjcNewLadder_TryDelRecordList(human)
- local tRecordList = JjcNewLadder_GetRecordList(human)
- if nil == tRecordList then
- return
- end
- local nLen = #tRecordList
- if JjcNewLadderDefine.JJC_NEWLADDER_SAVE_RECORDLIST_LEN >= nLen then
- return
- end
- local nDelLen = nLen - JjcNewLadderDefine.JJC_NEWLADDER_SAVE_RECORDLIST_LEN
- for i = nDelLen, 1, -1 do
- table.remove(tRecordList, i)
- end
- end
- -- 获取是否加入天梯赛
- local function JjcNewLadderLogic_GetJoin(human)
- return human.db.JjcNewLadder.bJoin
- end
- -- 设置是否加入天梯赛
- local function JjcNewLadderLogic_SetJoin(human, nValue)
- human.db.JjcNewLadder.bJoin = nValue
- end
- -- 获取是否点赞
- local function JjcNewLadderLogic_GetWorShip(human, uuid)
- if not human.db.JjcNewLadder.tWorship or not human.db.JjcNewLadder.tWorship[uuid] then
- return JjcNewLadderDefine.JJC_NEWLADDER_NOWORSHIP
- end
- return human.db.JjcNewLadder.tWorship[uuid]
- end
- -- 设置是否点赞
- local function JjcNewLadderLogic_SetWorShip(human, uuid, nValue)
- if not human.db.JjcNewLadder.tWorship then
- human.db.JjcNewLadder.tWorship = {}
- end
- human.db.JjcNewLadder.tWorship[uuid] = nValue
- end
- -- 获取对应uuid的一些数据
- local function JjcNewLadderLogic_GetInfoByUUID(human, uuid, nType)
- local tPlayInfo = nil
- if nType == JjcNewLadderDefine.JJC_NEWLADDER_QUERYUID_ENEMY_TYPE then
- local tEnemy = JjcNewLadder_GetHumanEnemy(human)
- if not tEnemy or nil == _G.next(tEnemy) then
- return tPlayInfo
- end
- for _, v in pairs(tEnemy) do
- if v.uuid == uuid then
- tPlayInfo = v
- return tPlayInfo
- end
- end
- else
- for i = 1, JjcNewLadderDefine.JJC_NEWLADDER_RANK_SEND_LEN, 1 do
- local tRankData = tCacheRankInfo.tRankList[i]
- if not tRankData then
- return tPlayInfo
- end
- if tRankData.uuid == uuid then
- tPlayInfo = tRankData
- return tPlayInfo
- end
- end
- end
- return tPlayInfo
- end
- -- 请求加入天梯赛
- local function JjcNewLadderLogic_JoinLadder(human)
- JjcNewLadderMiddle.JjcNewLadderMiddle_JoinLadder(human)
- end
- -- 进行匹配对手
- local function JjcNewLadderLogic_MatchRival(uuid)
- return JjcNewLadderDB.JjcNewLadderDB_MatchRival(uuid)
- end
- -- 获取对应uid的DB数据
- local function JjcNewLadderLogic_GetDataByuid(uuid)
- return JjcNewLadderDB.JjcNewLadderDB_GetDBDataByuid(uuid)
- end
- -- 组装下发的主界面数据
- local function JjcNewLadder_GetInterfaceInfo(human)
- local tMsgData = Msg.gc.GC_JJC_NEW_LADDER_QUERY
- tMsgData.ownRank = JjcNewLadder_GetHumanRank(human)
- tMsgData.ownJifen = JjcNewLadder_GetHumanPoint(human)
- tMsgData.atkZDL = human.db.zhandouli
- tMsgData.leftSec = JjcNewLadder_GetLeftTime()
- tMsgData.challengeCnt = JjcNewLadder_GetAllFightNum(human)
- tMsgData.isQuick = 0
- Grid.makeItem(tMsgData.challengeCostItem,ItemDefine.ITEM_JJC_TICKET_ID, JjcNewLadderDefine.JJC_NEWLADDER_COST_ITEM_NUM)
- -- 红点
- tMsgData.dotList[0] = 3
- tMsgData.dotList[1] = tMsgData.challengeCnt > 0 and 1 or 0
- tMsgData.dotList[2] = 0
- tMsgData.dotList[3] = 0
- -- 敌人
- local tEnemy = JjcNewLadder_GetHumanEnemy(human)
- if not tEnemy then
- tMsgData.tEnemy[0] = 0
- else
- tMsgData.tEnemy[0] = 5
- local nIndex = 0
- for _, v in pairs(tEnemy) do
- nIndex = nIndex + 1
- local tData = tMsgData.tEnemy[nIndex]
- tData.head = v.head
- tData.headFrame = v.headFrame
- tData.nPower = v.zhandouli
- tData.name = v.name
- tData.nPoint = v.point
- end
- end
- return tMsgData
- end
- -- 发送对手数据
- local function JjcNewLadder_SendEnemy(human)
- local tMsgData = Msg.gc.GC_JJC_NEW_LADDER_TARGET_FIND
- tMsgData.leftFreeCnt = JjcNewLadder_GetHumanFreeNum(human)
- local tEnemy = JjcNewLadder_GetHumanEnemy(human)
- if not tEnemy then
- tMsgData.tEnemy[0] = 0
- else
- tMsgData.tEnemy[0] = 5
- local nIndex = 0
- for _, v in pairs(tEnemy) do
- nIndex = nIndex + 1
- local tData = tMsgData.tEnemy[nIndex]
- tData.head = v.head
- tData.headFrame = v.headFrame
- tData.nPower = v.zhandouli
- tData.name = v.name
- tData.nPoint = v.point
- end
- end
- Msg.send(tMsgData, human.fd)
- end
- -- 发送上一轮前3名数据
- local function JjcNewLadder_SendLast3Rank(human)
- local tMsgData = Msg.gc.GC_JJC_NEW_LADDER_QUERY_LAST_RANK
- tMsgData.tList[0] = 0
- if tLast3RankPlayerInfo then
- local nIndex = 0
- for _, v in pairs(tLast3RankPlayerInfo) do
- nIndex = nIndex + 1
- local tData = tMsgData.tList[nIndex]
- tData.head = v.head
- tData.headFrame = v.headFrame
- tData.name = v.name
- tData.szServerName = v.szServerName
- tData.uuid = v.uuid
- tData.worshipCnt = v.worshipCnt
- tData.worshipState = JjcNewLadderLogic_GetWorShip(human, v.uuid)
- end
- end
- Msg.send(tMsgData, human.fd)
- end
- -- 发送排行榜数据
- local function JjcNewLadder_SendRankInfo(human)
- local tMsgData = Msg.gc.GC_JJC_NEW_LADDER_RANK_QUERY
- tMsgData.ownRank.nRank = JjcNewLadder_GetHumanRank(human)
- tMsgData.ownRank.head = human.db.head
- tMsgData.ownRank.headFrame = human.db.headFrame
- tMsgData.ownRank.nPower = human.db.zhandouli
- tMsgData.ownRank.name = human.db.name
- tMsgData.ownRank.szServerName = "寻宝"..Config.NEW_SVR_INDEX.."区"
- tMsgData.ownRank.uuid = human.db.uuid
- tMsgData.topList[0] = JjcNewLadderDefine.JJC_NEWLADDER_RANK_SEND_LEN
- for i = 1, JjcNewLadderDefine.JJC_NEWLADDER_RANK_SEND_LEN, 1 do
- local tRankData = tCacheRankInfo.tRankList[i]
- if tRankData then
- local tData = tMsgData.topList[i]
- tData.nRank = i
- tData.head = tRankData.head
- tData.headFrame = tRankData.headFrame or -1
- tData.nPower = tRankData.zhandouli
- tData.name = tRankData.name
- tData.uuid = tRankData.uuid
- tData.szServerName = tRankData.szServerName
- else
- print("[JjcNewLadder_SendRankInfo] 不存在对应排名对应的排行榜数据 i = "..i)
- return
- end
- end
- Msg.send(tMsgData, human.fd)
- end
- -- 保存对战录像和数据
- local function JjcNewLadder_SaveRecord(human, combatInfo)
- -- 添加录像
- local combatVideo = CombatVideo.createCombatVideo(CombatVideo.VIDEOTYPE_JJCLODDER, combatInfo, human.db._id)
- local videoUuid = combatVideo._id
- JjcNewLadder_SetRecordList(human, videoUuid)
- end
- -- 发送战败邮件(真人)
- local function JjcNewLadder_SendFailMail(uuidDes, nServerID, SrcServerName, SrcName, nNewRank)
- JjcNewLadderMiddle.JjcNewLadderMiddle_SendFailMail(uuidDes, nServerID, SrcServerName, SrcName, nNewRank)
- end
- -- 获取当前玩家对战列表缓存的uuid
- local function JjcNewLaader_GetAllEnemyUID(human)
- local tEnemy = JjcNewLadder_GetHumanEnemy(human)
- if not tEnemy then
- return nil
- end
- local tEnemyUid = {}
- for _, v in pairs(tEnemy) do
- table.insert(tEnemyUid, v.uuid)
- end
- return tEnemyUid
- end
- ---------------------------------- 内部调用 ----------------------------------------------
- -- 请求加入天梯赛(数据服)
- function JjcNewLadderLogic_JoinHuman(tData)
- local bRet = JjcNewLadderDB.JjcNewLadderDB_AddHuman(tData)
- if false == bRet then
- print("[JjcNewLadderLogic_JoinHuman] 加入DB数据失败")
- return
- end
- local nNowRank = JjcNewLadderDB.JjcNewLadderDB_GetRankByuid(tData.uuid)
- if not nNowRank then
- print("[JjcNewLadderLogic_JoinHuman] 加入DB后还是不存在对应的排名值 uuid = "..tData.uuid)
- return
- end
- local tRival = JjcNewLadderLogic_MatchRival(tData.uuid)
- if nil == tRival then
- print("[JjcNewLadderLogic_JoinHuman] 获取匹配对手的uid失败")
- return
- end
- local tRivalData = {}
- for nRank, v in pairs(tRival) do
- local tJjcData = JjcNewLadderDB.JjcNewLadderDB_GetDBDataByRank(nRank)
- if nil == tJjcData then
- print("[JjcNewLadderLogic_JoinHuman] 获取不到对应的DB数据 nRank = "..nRank)
- return
- end
- local tSendData = {
- name = tJjcData.name,
- head = tJjcData.head,
- headFrame = tJjcData.headFrame,
- uuid = tJjcData.uuid,
- nIsHuman = tJjcData.nIsHuman,
- nRank = nRank,
- zhandouli = tJjcData.zhandouli,
- point = tJjcData.point,
- nServerID = tJjcData.nServerID or Config.SVR_INDEX,
- monsterOutID = tJjcData.monsterOutID or 0
- }
- table.insert(tRivalData, tSendData)
- end
- if tData.nSrcServerID == Config.SVR_INDEX then
-
- else
- JjcNewLadderMiddle.JjcNewLadderMiddle_JoinLadder_D2C(tData.uuid, tData.nSrcServerID, nNowRank, tRivalData)
- end
- end
- -- 加入天梯赛回包(普通服)
- function JjcNewLadderLogic_JoinHumanOk(tData)
- local uuid, nRank, nPoint, tEnemy = tData.uuid, tData.nRank, tData.nPoint, tData.tEnemy
- local human = ObjHuman.onlineUuid[uuid]
- if not human then
- human = {}
- human.db = RoleDBLogic.getDb(uuid)
- human.db.JjcNewLadder.bJoin = true
- human.db.JjcNewLadder.nRank = nRank
- human.db.JjcNewLadder.tEnemy = tEnemy
- human.dn.JjcNewLadder.nPoint = nPoint
- RoleDBLogic.saveRole(human.db)
- else
- human.db.JjcNewLadder.bJoin = true
- human.db.JjcNewLadder.nRank = nRank
- human.db.JjcNewLadder.tEnemy = tEnemy
- human.dn.JjcNewLadder.nPoint = nPoint
- local tMsgData = JjcNewLadder_GetInterfaceInfo(human)
- Msg.send(tMsgData, human.fd)
- end
- end
- -- 数据服收到刷新对战列表
- function JjcNewLadderLogic_RefeshEnemy(tData)
- local tRival = JjcNewLadderLogic_MatchRival(tData.uuid)
- if nil == tRival then
- print("[JjcNewLadderLogic_JoinHuman] 获取匹配对手的uid失败")
- return
- end
-
- local tRivalData = {}
- for nRank, v in pairs(tRival) do
- local tJjcData = JjcNewLadderDB.JjcNewLadderDB_GetDBDataByRank(nRank)
- if nil == tJjcData then
- print("[JjcNewLadderLogic_JoinHuman] 获取不到对应的DB数据 nRank = "..nRank)
- return
- end
- local tSendData = {
- name = tJjcData.name,
- head = tJjcData.head,
- headFrame = tJjcData.headFrame,
- uuid = tJjcData.uuid,
- nIsHuman = tJjcData.nIsHuman,
- nRank = nRank,
- zhandouli = tJjcData.zhandouli,
- point = tJjcData.point,
- nServerID = tJjcData.nServerID or Config.SVR_INDEX,
- monsterOutID = tJjcData.monsterOutID or 0,
- lv = tJjcData.lv or 0,
- identity = tJjcData.identity or 0,
- }
- table.insert(tRivalData, tSendData)
- end
- if tData.nSrcServerID == Config.SVR_INDEX then
-
- else
- JjcNewLadderMiddle.JjcNewLadderMiddle_RefreshEnemy_D2C(tData.uuid, tData.nSrcServerID, tRivalData)
- end
-
- end
- -- 刷新对战列表回包(普通服)
- function JjcNewLadderLogic_RefeshEnemyOK(tData)
- local uuid, tEnemy = tData.uuid, tData.tEnemy
- local human = ObjHuman.onlineUuid[uuid]
- if not human then
- human = {}
- human.db = RoleDBLogic.getDb(uuid)
- human.db.JjcNewLadder.tEnemy = tEnemy
- RoleDBLogic.saveRole(human.db)
- else
- JjcNewLadder_SetHumanEnemy(human, tEnemy)
- JjcNewLadder_SendEnemy(human)
- end
- end
- -- 请求上一轮前3玩家信息(回包)
- function JjcNewLadderLogic_GetLast3RankOK(tData)
- tLast3RankPlayerInfo = tData
- for uuid, _ in pairs(tQueryLast3Rank) do
- local human = ObjHuman.onlineUuid[uuid]
- if human then
- JjcNewLadder_SendLast3Rank(human)
- end
- end
- tQueryLast3Rank = {}
- bQueryLast = false
- end
- -- 进行点赞(中心->数据(被点赞玩家所在服))
- function JjcNewLadderLogic_AddWorShip(tData)
- local uuidDes = tData.uuidDes
- local human = ObjHuman.onlineUuid[uuidDes]
- local bSave = false
- if not human then
- human = {}
- human.db = RoleDBLogic.getDb(uuidDes)
- bSave = true
- end
- if not human.db.jjcBeWorship then
- human.db.jjcBeWorship = 0
- end
- human.db.jjcBeWorship = human.db.jjcBeWorship + 1
- if true == bSave then
- RoleDBLogic.saveRole(human.db)
- end
- JjcNewLadderMiddle.JjcNewLadderMiddle_AddWorShip_D2C(tData, human.db.jjcBeWorship)
- end
- -- 点赞成功
- function JjcNewLadderLogic_AddWorShipOK(tData)
- if not tLast3RankPlayerInfo then
- print("[JjcNewLadderLogic_AddWorShipOK] 为什么点赞完不存在数据了")
- return
- end
- local uuidDes, nNowWorShip = tData.uuidDes, tData.nNowWorShip
- for _, v in pairs(tLast3RankPlayerInfo) do
- if v.uuid == uuidDes then
- v.worshipCnt = nNowWorShip
- break
- end
- end
- local human = ObjHuman.onlineUuid[tData.uuidSrc]
- local bSave = false
- if not human then
- human = {}
- human.db = RoleDBLogic.getDb(uuidDes)
- bSave = true
- end
- -- 设置已点赞
- JjcNewLadderLogic_SetWorShip(human, uuidDes, JjcNewLadderDefine.JJC_NEWLADDER_WORSHIP)
- if true == bSave then
- RoleDBLogic.saveRole(human.db)
- end
- if false == bSave then
- local tMsgData = Msg.gc.GC_JJC_NEW_LADDER_CHAMPION_WORSHIP
- tMsgData.worshipCnt = nNowWorShip
- tMsgData.dot = 0
- Msg.send(tMsgData, human.fd)
- end
- end
- -- 更新缓存的点赞数据
- function JjcNewLadderLogic_UpdateWorShip(tData)
- if not tLast3RankPlayerInfo then
- print("[JjcNewLadderLogic_UpdateWorShip] 更新缓存的点赞数据 为什么不存在数据了")
- return
- end
- for _, v in pairs(tLast3RankPlayerInfo) do
- if v.uuid == tData.uuidDes then
- v.worshipCnt = tData.nNowWorShip
- break
- end
- end
- end
- -- 请求天梯赛排行榜数据(中心->战区数据服)
- function JjcNewLadderLogic_GetRankInfo(tData)
- local tSendRankData = {}
- local nFirst = 1
- for i = 1, JjcNewLadderDefine.JJC_NEWLADDER_RANK_SEND_LEN, 1 do
- local tRank = JjcNewLadderDB.JjcNewLadderDB_GetDBDataByRank(i)
- table.insert(tSendRankData, {tRankData = tRank, nRank = i})
- local nLen = #tSendRankData
- if JjcNewLadderDefine.JJC_NEWLADDER_RANK_ONE_SEND_LEN <= nLen then
- local nFinish = i == JjcNewLadderDefine.JJC_NEWLADDER_RANK_SEND_LEN and 1 or 0
- JjcNewLadderMiddle.JjcNewLadderMiddle_QueryRankInfo_D2C(tSendRankData, nFinish, tData.nSrcServerID, nFirst)
- nFirst = 0
- end
- end
- end
- -- 获取到天梯赛排行榜数据(中心->普通)
- function JjcNewLadderLogic_GetRankInfoOK(tData)
- local nFirst, nIsEnd = tData.nFirst, tData.nIsEnd
- local tRankInfo = tData.tRankInfo
- if nFirst then
- tCacheRankInfo = {
- nNextUpdateTime = os.time() + JjcNewLadderDefine.JJC_NEWLADDER_RANK_NEXT_UPDATE_TIME + math.random(1, 30),
- tRankList = {}
- }
- end
- for _, v in ipairs(tRankInfo) do
- local nRank = v.nRank
- local tRankData = v.tRankData
- tCacheRankInfo.tRankList[nRank] = tRankData
- end
- if nIsEnd == 1 then
- for uuid, v in pairs(tCacheQueryRankPlaeyer) do
- local human = ObjHuman.onlineUuid[uuid]
- if human then
- JjcNewLadder_SendRankInfo(human)
- end
- end
- -- 清空缓存请求排行榜的玩家
- tCacheQueryRankPlaeyer = {}
- bQueryRank = nil
- end
- end
- -- 查询是否能够战斗(中心->战区数据服)
- function JjcNewLadderLogic_CheckCanFight(tData)
- local uuid, uuidDes = tData.uuid, tData.uuidDes
- local nCanFight = JjcNewLadderDefine.JJC_NEWLADDER_NO_CAN_FIGHT
- -- 检查挑战者
- local tRankData = JjcNewLadderDB.JjcNewLadderDB_GetDBDataByuid(uuid)
- if not tRankData then
- JjcNewLadderMiddle.JjcNewLadderMiddle_ReplyCheckFight(tData, nCanFight)
- return
- end
- if tRankData.nInFight == JjcNewLadderDefine.JJC_NEWLADDER_IN_FIGHT then
- -- 还在持续时间内不能战斗
- if tRankData.nLastFightTime + JjcNewLadderDefine.JJC_NEWLADDER_FIGHT_DURATION > os.time() then
- JjcNewLadderMiddle.JjcNewLadderMiddle_ReplyCheckFight(tData, nCanFight)
- return
- end
- end
- -- 检查被挑战者
- local tRankEnemyData = JjcNewLadderDB.JjcNewLadderDB_GetDBDataByuid(uuidDes)
- if not tRankEnemyData then
- JjcNewLadderMiddle.JjcNewLadderMiddle_ReplyCheckFight(tData, nCanFight)
- return
- end
- if tRankEnemyData.nInFight == JjcNewLadderDefine.JJC_NEWLADDER_IN_FIGHT then
- -- 还在持续时间内不能战斗
- if tRankEnemyData.nLastFightTime + JjcNewLadderDefine.JJC_NEWLADDER_FIGHT_DURATION > os.time() then
- JjcNewLadderMiddle.JjcNewLadderMiddle_ReplyCheckFight(tData, nCanFight)
- return
- end
- end
- -- 可以战斗
- tRankData.nInFight = JjcNewLadderDefine.JJC_NEWLADDER_IN_FIGHT
- tRankData.nLastFightTime = os.time()
- tRankEnemyData.nInFight = JjcNewLadderDefine.JJC_NEWLADDER_IN_FIGHT
- tRankEnemyData.nLastFightTime = os.time()
- nCanFight = JjcNewLadderDefine.JJC_NEWLADDER_CAN_FIGHT
- JjcNewLadderMiddle.JjcNewLadderMiddle_ReplyCheckFight(tData, nCanFight)
- end
- -- 查询是否能够战斗(中心->普通)
- function JjcNewLadderLogic_CheckCanFightOK(tData)
- local uuid, uuidDes, nIsFight = tData.uuid, tData.uuidDes, tData.nIsFight
- local human = ObjHuman.onlineUuid[uuid]
- -- 已经不在线了,直接返回
- if not human then
- return
- end
- if JjcNewLadderDefine.JJC_NEWLADDER_NO_CAN_FIGHT == nIsFight then
- return Broadcast.sendErr(human, Lang.JJCNEWLADDERNOFIGHT)
- else
- -- 开始正在的战斗流程
- JjcLadderLogic_TrueFight(human, uuidDes)
- end
- end
- -- 战斗结束(中心->战区数据服)
- function JjcNewLadderLogic_FightEnd(tData)
- local uuid, uuidDes, nResult = tData.uuid, tData.uuidDes, tData.nResult
- local tEnemyInfo = JjcNewLadderDB.JjcNewLadderDB_GetDBDataByuid(uuidDes)
- if not tEnemyInfo then
- print("[JjcNewLadderLogic_FightEnd] 不存在对战人物的DB数据 uuidDes = "..uuidDes.." nResult = "..nResult)
- return
- end
- local tPlayerInfo = JjcNewLadderDB.JjcNewLadderDB_GetDBDataByuid(uuid)
- if not tPlayerInfo then
- print("[JjcNewLadderLogic_FightEnd] 不存在玩家的DB数据 uuidDes = "..uuid.." nResult = "..nResult)
- return
- end
- -- 增加积分(会重新排序)
- JjcNewLadderDB.JjcNewLadderDB_AddPoint(uuid, 1)
- local nNewPlayerRank = JjcNewLadderDB.JjcNewLadderDB_GetRankByuid(uuid)
- local nNewEnemyRank = JjcNewLadderDB.JjcNewLadderDB_GetRankByuid(uuidDes)
- if nResult == CombatDefine.RESULT_WIN then
- -- 真人要发邮件
- if tEnemyInfo.nIsHuman == 1 then
- JjcNewLadder_SendFailMail(uuidDes, tEnemyInfo.nServerID, tPlayerInfo.szServerName, tPlayerInfo.name, nNewEnemyRank)
- end
- end
- -- 操作对战列表
- local tOldEnemyData, tChoseRank = {}, {}
- -- 防止选到已对战的角色
- tChoseRank[nNewEnemyRank] = 1
- for _, uuidEnemy in ipairs(tData.tEnemyUid) do
- if uuidEnemy ~= uuidDes then
- local tRankData = JjcNewLadderDB.JjcNewLadderDB_GetRankByuid(uuidEnemy)
- if tRankData then
- local nRank = JjcNewLadderDB_GetRankByuid(uuidEnemy)
- table.insert(tOldEnemyData, {uuid = uuidEnemy, nRank = nRank, nPoint = v.point})
- tChoseRank[nRank] = 1
- end
- end
- end
- local nNewOneRank = JjcNewLadderDB.JjcNewLadderDB_FindOneEnemy(uuid, tChoseRank)
- if -1 >= nNewOneRank then
- nNewOneRank = nNewEnemyRank
- end
- -- 组装新的对战人物数据
- local tJjcData = JjcNewLadderDB.JjcNewLadderDB_GetDBDataByRank(nNewOneRank)
- local tSendData = {
- name = tJjcData.name,
- head = tJjcData.head,
- headFrame = tJjcData.headFrame,
- uuid = tJjcData.uuid,
- nIsHuman = tJjcData.nIsHuman,
- nRank = nNewOneRank,
- zhandouli = tJjcData.zhandouli,
- point = tJjcData.point,
- nServerID = tJjcData.nServerID or Config.SVR_INDEX,
- monsterOutID = tJjcData.monsterOutID or 0
- }
- JjcNewLadderMiddle.JjcNewLadderMiddle_ReplyFightD2C(uuid, uuidDes, tData.nSrcServerID, nNewPlayerRank, tPlayerInfo.point, tOldEnemyData, tSendData)
- end
- -- 战斗结束(中心 -> 普通)
- function JjcNewLadderLogic_FightEndOK(tData)
- local uuid, nNewRank, nNewPoint = tData.uuid, tData.nNewRank, tData.nNewPoint
- local uuidDes, tNewOneEnemy, tOldEnemyData = tData.uuidDes, tData.tNewOneEnemy, tData.tOldEnemyData
- local human = ObjHuman.onlineUuid[uuid]
- local bSave = false
- if not human then
- human = {}
- human.db = RoleDBLogic.getDb(uuid)
- bSave = true
- end
- JjcNewLadder_SetHumanRank(human, nNewRank)
- JjcNewLadder_SetHumanPoint(human, nNewPoint)
- -- 更新对战列表数据
- local tEnemy = JjcNewLadder_GetHumanEnemy(human)
- local nIndex = nil
- for i, v in ipairs(tEnemy) do
- if v.uuid == uuidDes then
- nIndex = i
- else
- for _, tUpdateData in ipairs(tOldEnemyData) do
- if tUpdateData.uuid == v.uuid then
- v.point = tUpdateData.nPoint
- v.nRank = tUpdateData.nRank
- end
- end
- end
- end
- if nIndex then
- tEnemy[nIndex] = tNewOneEnemy
- else
- print("[JjcNewLadderLogic_FightEndOK] 居然找不到对应对战角色数据记录的下标")
- end
- if true == bSave then
- RoleDBLogic.saveRole(human.db)
- else
- JjcNewLadderLogic_Query(human)
- end
- end
- -- 发送战败邮件
- function JjcNewLadderLogic_SendFailMailOK(tData)
- local uuid, szServerName, szName, nNewRank = tData.uuidDes, tData.szServerName, tData.szName, tData.nNewRank
- local human = ObjHuman.onlineUuid[uuid]
- local bSave = false
- if not human then
- human = {}
- human.db = RoleDBLogic.getDb(uuid)
- bSave = true
- end
- local mailConfig = MailExcel.mail[JjcNewLadderDefine.JJC_NEWLADDER_FAIL_MAIL_ID]
- local title = mailConfig.title
- local senderName = mailConfig.senderName
- local content = Util.format(mailConfig.content, szServerName, szName, nNewRank)
- MailManager.add(MailManager.SYSTEM, human.db._id, title, content, nil, senderName)
- end
- -- 发送排名奖励(中心->普通)
- function JjcNewLadderLogic_SendPrizeMail(tData)
- local tConfig = JjcExcel.skyladderRank
- local uuid, nRank = tData.uuid, tData.nRank
- local tPrize = nil
- for _, v in ipairs(tConfig) do
- if v.nMinRank <= nRank and v.nMaxRank >= nRank then
- tPrize = v.tPrize
- break
- end
- end
- -- 发送奖励
- if tPrize then
- local mailConfig = MailExcel.mail[JjcNewLadderDefine.JJC_NEWLADDER_RANKPRIZE_MAIL_ID]
- local title = mailConfig.title
- local senderName = mailConfig.senderName
- local content = mailConfig.content
- MailManager.add(MailManager.SYSTEM, uuid,
- title, Util.format(content, nRank), tPrize, senderName)
- end
- end
- ---------------------------------- 客户端请求 ----------------------------------------------
- -- 请求天梯赛信息
- function JjcNewLadderLogic_Query(human)
- if not human.db.JjcNewLadder then
- JjcNewLadderLogic_CreatDB(human)
- end
- if false == JjcNewLadderLogic_GetJoin() then
- local uuid = human.db._id
- if not tQueryJoinPlayer[uuid] then
- tQueryJoinPlayer[uuid] = os.time()
- JjcNewLadderLogic_JoinLadder()
- else
- if tQueryJoinPlayer[uuid] + JjcNewLadderDefine.JJC_NEWLADDER_JOINTIME <= os.time() then
- tQueryJoinPlayer[uuid] = os.time()
- JjcNewLadderLogic_JoinLadder()
- else
- return
- end
- end
- else
- local tMsgData = JjcNewLadder_GetInterfaceInfo(human)
- Msg.send(tMsgData, human.fd)
- end
- end
- -- 天梯赛对战记录查询
- function JjcNewLadderLogic_RecordQuery(human)
- JjcNewLadder_TryDelRecordList(human)
- local tRecordList = JjcNewLadder_GetRecordList(human)
- local tMsgData = Msg.gc.GC_JJC_NEW_LADDER_RECORD_QUERY
- tMsgData.leftFreeCnt = JjcNewLadder_GetHumanFreeNum(human)
- tMsgData.recordList[0] = 0
- if tRecordList then
- for i, v in ipairs(tRecordList) do
- local videoUuid = v.videoUuid
- local combatVideo = CombatVideo.getCombatVideo(videoUuid)
- if combatVideo then
- tMsgData.recordList[0] = tMsgData.recordList[0] + 1
- local net = tMsgData.recordList[tMsgData.recordList[0]]
- local combatInfo = combatVideo.combatInfo
- local parms = combatInfo.endParam and Util.split(combatInfo.endParam, "|")
- net.time = combatInfo.time
- net.identity = combatVideo._id
- if combatInfo.attacker.uuid == human.db._id then
- RoleLogic.makeRoleBase(combatInfo.defender, net.roleBase)
- net.result = combatInfo.isWin and JJC_RESULT_ATK_WIN or JJC_RESULT_ATK_FAIL
- net.jifenChange = tonumber(parms and parms[3]) or 0
- else
- RoleLogic.makeRoleBase(combatInfo.attacker, net.roleBase)
- net.result = (not combatInfo.isWin) and JJC_RESULT_DEF_WIN or JJC_RESULT_DEF_FAIL
- net.jifenChange = tonumber(parms and parms[4]) or 0
- end
- end
- end
- end
- Msg.send(tMsgData, human.fd)
- end
- -- 天梯赛对手查询
- function JjcNewLadderLogic_TargetFind(human)
- JjcNewLadderMiddle.JjcNewLadderMiddle_RefreshEnemy(human)
- end
- -- 膜拜
- function JjcNewLadderLogic_Worship(human, uuid)
- if not tLast3RankPlayerInfo then
- print("[JjcNewLadderLogic_Worship] 不存在上一轮数据排名前3的数据")
- return
- end
- local nState = JjcNewLadderLogic_GetWorShip(human, uuid)
- if nState == JjcNewLadderDefine.JJC_NEWLADDER_WORSHIP then
- return
- end
- local nServerID
- for _, v in pairs(tLast3RankPlayerInfo) do
- if v.uuid == uuid then
- nServerID = v.nServerID
- break
- end
- end
- if not nServerID then
- print("[JjcNewLadderLogic_Worship] 获取对应uuid对应的服务器ID失败 name = "..human.db.name.." uuid = "..uuid)
- return
- end
- JjcNewLadderMiddle.JjcNewLadderMiddle_SendWorShip(human.db._id, uuid, nServerID)
- -- 点赞奖励
- local tItem = {}
- table.insert(tItem, {JjcNewLadderDefine.JJC_NEWLADDER_WORSHIP_GOODID, JjcNewLadderDefine.JJC_NEWLADDER_WORSHIP_GOODNUM})
- BagLogic.addItemList(human, tItem, "jjc_ladder")
- -- JjcNewLadderLogic_SetWorShip(human, uuid, JjcNewLadderDefine.JJC_NEWLADDER_WORSHIP)
- end
- -- 排行榜查询
- function JjcNewLadderLogic_RankQuery(human)
- if not tCacheRankInfo or not tCacheRankInfo.tRankList then
- local uuid = human.db._id
- if tCacheQueryRankPlaeyer[uuid] then
- return
- else
- tCacheQueryRankPlaeyer[uuid] = 1
- if not bQueryRank then
- bQueryRank = true
- JjcNewLadderMiddle.JjcNewLadderMiddle_QueryRankInfo()
- end
- return
- end
- else
- JjcNewLadder_SendRankInfo(human)
- -- 时间过期了,再次请求排行榜数据
- local nNextUpdateTime = tCacheRankInfo.nNextUpdateTime
- if nNextUpdateTime <= os.time() then
- JjcNewLadderMiddle.JjcNewLadderMiddle_QueryRankInfo()
- end
- end
- end
- -- 请求一键挑战 -- 直接获取奖励
- function JjcNewLadderLogic_OneClickChange(human)
- local tConfig = JjcExcel.skyladderFightPrize
- local nFreeNum = JjcNewLadder_GetHumanFreeNum(human)
- if 0 >= nFreeNum then
- return
- end
- local tItem = {}
- for _, v in ipairs(tConfig[1].tPrize) do
- local nGoodNum = v[2] * nFreeNum
- local nGoodID = v[1]
- table.insert(tItem, {nGoodID, nGoodNum})
- end
- if nil ~= _G.next(tItem) then
- BagLogic.addItemList(human, tItem, "jjc_ladder")
- JjcNewLadder_SetHumanFreeNum(human, -nFreeNum)
- JjcNewLadderLogic_Query(human)
- end
- end
- -- 请求天梯赛上一轮排名前三
- function JjcNewLadderLogic_LastRankQuery(human)
- if not tLast3RankPlayerInfo then
- local uuid = human.db._id
- if tQueryLast3Rank[uuid] then
- return
- end
- tQueryLast3Rank[uuid] = 1
- if bQueryLast == false then
- JjcNewLadderMiddle.JjcNewLadderMiddle_QueryLastRank()
- bQueryLast = true
- end
- else
- JjcNewLadder_SendLast3Rank(human)
- end
- end
- -- 请求排行榜奖励信息
- function JjcNewLadderLogic_RankPrizeQuery(human)
- local tMsgData = Msg.gc.GC_JJC_NEW_LADDER_QUERY_RANKPRIZE
- tMsgData.nOwnRank = JjcNewLadder_GetHumanRank(human)
- tMsgData.tOwnPrize[0] = 0
- tMsgData.tRankPrize[0] = 0
- for _, v in ipairs(JjcExcel.skyladderRank) do
- tMsgData.tRankPrize[0] = tMsgData.tRankPrize[0] + 1
- local tData = tMsgData.tRankPrize[tMsgData.tRankPrize[0]]
- tData.nMinRank = v.nMinRank
- tData.nMaxRank = v.nMaxRank
- tData.tList = #v.tPrize
- for nIndex, tItem in ipairs(v.tPrize) do
- local nGoodsID = tItem[1]
- local nGoodNum = tItem[2]
- Grid.makeItem(tData.tList[nIndex], nGoodsID, nGoodNum)
- end
- -- 个人排行榜奖励
- if tData.nMinRank <= tMsgData.nOwnRank and tData.nMaxRank >= tMsgData.nOwnRank then
- tMsgData.tOwnPrize[0] = #v.tPrize
- for nIndex, tItem in ipairs(v.tPrize) do
- local nGoodsID = tItem[1]
- local nGoodNum = tItem[2]
-
- Grid.makeItem(tMsgData.tOwnPrize[nIndex], nGoodsID, nGoodNum)
- end
- end
- end
- Msg.send(tMsgData, human.fd)
- end
- -- 请求人物所有信息
- function JjcNewLadderLogic_QueryAllInfo(human, uuid, nType)
- local tPlayInfo = JjcNewLadderLogic_GetInfoByUUID(human, uuid, nType)
- if nil == tPlayInfo then
- print("[JjcNewLadderLogic_QueryAllInfo] 获取所有数据失败 name = "..human.db.name)
- return
- end
- -- 假人不用请求了, 直接组装
- if 0 == tPlayInfo.nIsHuman then
- local msgRet = Msg.gc.GC_CHAT_PLAYER_INFO
- -- 参考 makePlayInfoByOther
- RoleLogic.makeOtherPlayInfo(msgRet, tPlayInfo)
- msgRet.vipLv = 0
- msgRet.isFriend = 0
- msgRet.unionName = ""
- msgRet.svrName = tPlayInfo.ServerName
- Msg.send(msgRet, human.fd)
- else
- local tQueryMsg =
- {
- uuid = uuid,
- nServerIndex = tPlayInfo.nServerID
- }
- MiddleCommonLogic.MiddleCommonLogic_GetChatPlayInfo_LW(human, tQueryMsg)
- end
- end
- ---------------------------------- 战斗相关 ----------------------------------------------
- -- 检测能否战斗
- function CheckCanFight(human, uuidEnemy)
- JjcNewLadderMiddle.JjcNewLadderMiddle_CheckCanFightBegin(human, uuidEnemy)
- end
- function JjcLadderLogic_TrueFight(human, uuidDes)
- local tPlayInfo = JjcNewLadderLogic_GetInfoByUUID(human, uuidDes, JjcNewLadderDefine.JJC_NEWLADDER_QUERYUID_ENEMY_TYPE)
- if not tPlayInfo then
- print("[JjcLadderLogic_TrueFight] 不存在对应的敌方数据, 上一步是如何通过的")
- return
- end
- -- 扣门票
- BagLogic.delItem(human, ItemDefine.ITEM_JJC_TICKET_ID, 3, "jjc_fight")
- local nFreeNum = JjcNewLadder_GetHumanFreeNum(human)
- if nFreeNum > 0 then
- JjcNewLadder_SetHumanFreeNum(human, -1)
- else
- local nPayNum = JjcNewLadder_GetHumanPayNum(human)
- if nPayNum > 0 then
- JjcNewLadder_SetHumanPayNumNum(human, -1)
- end
- end
- if 0 == tPlayInfo.nIsHuman then
- local args = {
- [1] = uuidDes
- }
- CombatLogic.combatBegin(human, nil, args, CombatDefine.COMBAT_TYPE29, uuidDes)
- print("[JjcLadderLogic_TrueFight] 对战的角色是人机进行对战")
- else
- local tData =
- {
- combatType = CombatDefine.COMBAT_TYPE29,
- nServerIndex = tPlayInfo.nServerID,
- param = uuidDes.."|"..human.db._id
- }
- MiddleCommonLogic.MiddleCommonLogic_CombatBegin_LW(human, tData)
- print("[JjcLadderLogic_TrueFight] 与真人开始对战 nServerID = "..tPlayInfo.nServerID)
- end
- end
- -- 调用开始战斗
- function fight(human, args, combatType)
- if CombatDefine.COMBAT_TYPE29 ~= combatType then
- return
- end
- -- 对战角色的UID
- local uuidEnemy = args[1]
- local tPlayInfo = JjcNewLadderLogic_GetInfoByUUID(human, uuidEnemy, JjcNewLadderDefine.JJC_NEWLADDER_QUERYUID_ENEMY_TYPE)
- if not tPlayInfo then
- print("[JjcNewLadderLogic_fight] 不存在对应的敌方数据")
- return
- end
- -- 检测挑战次数
- local nFreeNum = JjcNewLadder_GetHumanFreeNum(human)
- if nFreeNum <= 0 then
- local nPayNum = JjcNewLadder_GetHumanPayNum(human)
- if nPayNum <= 0 then
- print("[JjcNewLadderLogic_fight] 可用的挑战次数不足")
- return
- end
- end
- -- 去中心服查询是否能够战斗
- CheckCanFight(human, uuidEnemy)
- end
- -- 获取人物对战列表
- function getCombatObjList(human, side, args)
- if side ~= CombatDefine.ATTACK_SIDE then return end
- return CombatLogic.getHumanObjList(human, CombatDefine.COMBAT_TYPE1)
- end
- -- 获取机器人对应战斗ID
- function getCombatMonsterOutID(human, side, args)
- if side ~= CombatDefine.DEFEND_SIDE then
- return
- end
- local uuid = args[1]
- local tPlayInfo = JjcNewLadderLogic_GetInfoByUUID(human, uuid, JjcNewLadderDefine.JJC_NEWLADDER_QUERYUID_ENEMY_TYPE)
- if not tPlayInfo then
- return
- end
- if not tPlayInfo.monsterOutID then
- return
- end
- return tPlayInfo.monsterOutID, tPlayInfo.zhandouli
- end
- -- 挑战结束
- function onFightEnd(human, result, combatType, defUuid, combatInfo)
- local tPrize = result == CombatDefine.RESULT_WIN and JjcExcel.skyladderFightPrize[1] or JjcExcel.skyladderFightPrize[2]
- -- 存对战录像
- JjcNewLadder_SaveRecord(human, combatInfo)
- -- 添加战报
- local nMyRank = JjcNewLadder_GetHumanRank(human)
- local tPlayInfo = JjcNewLadderLogic_GetInfoByUUID(human, defUuid, JjcNewLadderDefine.JJC_NEWLADDER_QUERYUID_ENEMY_TYPE)
- if tPlayInfo then
- WarReportLogic.add(WarReportLogic.WAR_REPORT_3, combatInfo, nMyRank, tPlayInfo.nRank)
- else
- print("[JjcNewLadderLogic_onFightEnd] 不存在对战人物的缓存信息")
- end
- -- 获取对战列表的UID,需要刷新
- local tEnemyUuid = JjcNewLaader_GetAllEnemyUID(human)
- -- 通知中心服对战结果
- JjcNewLadderMiddle.JjcNewLadderMiddle_FightEndO2C(human.db._id, defUuid, result, tEnemyUuid)
- -- 给物品
- BagLogic.addItemList(human, tPrize.tPrize, "jjc_fight")
- end
- ---------------------------------- 刷新相关 ----------------------------------------------
- function JjcLadderLogic_LaterOperate()
- -- 清除数据
- JjcNewLadderDB.JjcNewLadderDB_OnHourOpen()
- for _, human in pairs(ObjHuman.onlineUuid) do
- JjcNewLadderLogic_CreatDB(human)
- end
- end
- -- 定时处理
- function onHour(nHour)
- if JjcNewLadderDefine.JJC_NEWLADDER_OPENTIME ~= nHour or JjcNewLadderDefine.JJC_NEWLADDER_ENDTIME ~= nHour then
- return
- end
- print("[JjcLadderLogic_onHour] 当前对应的时间为 nHour = "..nHour)
- local nNowTime = os.time()
- local tDate = os.date("*t",nNowTime)
- if JjcNewLadderDefine.JJC_NEWLADDER_OPENDAY == tDate.wday and JjcNewLadderDefine.JJC_NEWLADDER_OPENTIME == nHour then
- local nNextTime = nNowTime + 3 * 86400
- local tEndDate = os.date("*t",nNextTime)
- tEndDate.hour = 23
- tEndDate.min = 0
- tEndDate.sec = 0
- local nEndTime = os.time(tEndDate)
- CommonDB.SetJjcLadderEndTime(nEndTime)
- Timer.addLater(JjcNewLadderDefine.JJC_NEWLADDER_OPEN_LATER_TIME, JjcLadderLogic_LaterOperate)
- elseif JjcNewLadderDefine.JJC_NEWLADDER_ENDDAY == tDate.wday and JjcNewLadderDefine.JJC_NEWLADDER_ENDTIME == nHour then
- JjcNewLadderDB.JjcNewLadderDB_SendRankMail()
- else
- return
- end
- end
- -- 玩家登录处理
- function onLogin(human)
- if false == JjcNewLadderLogic_CheckIsOpen() then
- return
- end
- if not human.db.JjcNewLadder then
- JjcNewLadderLogic_CreatDB(human)
- else
- local nLastEndTime = JjcNewLadder_GetHumanLastEndTime(human)
- local nNowEndTime = CommonDB.GetJjcLadderEndTime()
- if nNowEndTime > nLastEndTime then
- JjcNewLadderLogic_CreatDB(human)
- else
- local nRefreshTime = JjcNewLadder_GetHumanRefreshTime(human)
- local nNowTime = os.time()
- if false == Util.isSameDayByTimes(nRefreshTime, nNowTime) then
- JjcNewLadder_SetHumanRefreshTime(human, nNowTime)
- JjcNewLadder_SetHumanFreeNum(human, JjcNewLadderDefine.JJC_NEWLADDER_JJC_DAY_FREE_NUM)
- end
- end
- end
- end
- -- 获取活动状态
- function getActState()
- local bRet = JjcNewLadderLogic_CheckIsOpen()
- if false == bRet then
- return JjcActLogic.STATE_NOOPEN, 0
- end
- return JjcActLogic.STATE_START, JjcNewLadder_GetLeftTime()
- end
- function isActRed(human)
- if human.db.lv < 50 then
- return false
- end
- if false == JjcNewLadderLogic_CheckIsOpen() then
- return false
- end
-
- if not human.db.JjcNewLadder then
- JjcNewLadderLogic_CreatDB(human)
- end
- local nFreeNum = JjcNewLadder_GetHumanFreeNum(human)
- if nFreeNum > 0 then
- return true
- end
- local nPayNum = JjcNewLadder_GetHumanPayNum(human)
- if nPayNum > 0 then
- return true
- end
- return false
- end
- function Init()
- print("[JjcNewLadderLogic_Init] 起服操作开始")
- -- if true == JjcNewLadderLogic_CheckIsOpen() then
- local nEndTime = CommonDB.GetJjcLadderEndTime()
- if 0 >= nEndTime then
- local nNowTime = os.time()
- local tDate = os.date("*t",nNowTime)
- tDate.wday = JjcNewLadderDefine.JJC_NEWLADDER_ENDDAY
- tDate.hour = 23
- tDate.min = 0
- tDate.sec = 0
- nEndTime = os.time(tDate)
- CommonDB.SetJjcLadderEndTime(nEndTime)
- print("[JjcNewLadderLogic_Init] 设置了结束时间 nEndTime = "..nEndTime)
- end
- JjcNewLadderDB.JjcNewLadderDB_initAfterStart()
- -- else
- -- print("[JjcNewLadderLogic_Init] 当前不在时间内直接返回 ")
- -- end
- end
|