JjcLogic.lua 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. -- 竞技场逻辑
  2. -- 开始结束赛季 给赛季奖励 ok
  3. -- 设置防守阵容 ok
  4. -- 查询基础 ok
  5. -- 战斗 ok
  6. -- 积分 ok
  7. -- 排行 根据排行给奖励 ok
  8. -- 保存战斗记录和查询战斗记录
  9. -- 门票购买 ok
  10. --[=[
  11. ------JjcDB---------
  12. jjcDB.initAfterStart()开始
  13. 如果是第一次开启
  14. 1.设定本轮活动结束时间, 即开服时间 + 7*86400 - 10800
  15. 2.jjcDB.initJJCDB()——>jjcDB.resetJJCDB()——>jjcDB.addNpc() 生成机器人,缓存到RANK_2_JJCDATA 和 ROBOT_LIST,并把机器人数据插入到数据库 db_jjc 中
  16. 非第一次开启
  17. 把竞技场玩家和npc数据读取到内存
  18. --------JjcLogin.lua-----------
  19. onHour() 定时整点函数
  20. 4点, 删除符合条件的战斗视频数据
  21. 21点, 发放当日排行奖励
  22. 如果本轮活动结束, 发放排行奖励, 重置数据(包括删除竞技场战斗视频数据), 设置新一轮活动结束时间。
  23. 每次查询或者战斗时, 检测如果玩家如果没有加入竞技场, 且设置了竞技场的防守阵容, 则会把玩家加入竞技场, 排名为现有竞技场人数(包含npc) + 1。
  24. 挑战胜利, 则更新对战双方的积分和排名。
  25. ]=]--
  26. local Util = require("common.Util")
  27. local HtmlUtil = require("common.HtmlUtil")
  28. local Lang = require("common.Lang")
  29. local CommonDB = require("common.CommonDB")
  30. local JjcExcel = require("excel.jjc")
  31. local MonsterExcel = require("excel.monster")
  32. local MailExcel = require("excel.mail")
  33. local Msg = require("core.Msg")
  34. local ObjHuman = require("core.ObjHuman")
  35. local Broadcast = require("broadcast.Broadcast")
  36. local Grid = require("bag.Grid")
  37. local BagLogic = require("bag.BagLogic")
  38. local ItemDefine = require("bag.ItemDefine")
  39. local JjcDB = require("jjc.JjcDB")
  40. local JjcActLogic = require("jjc.JjcActLogic")
  41. local RoleDBLogic = require("role.RoleDBLogic")
  42. local HeroDefine = require("hero.HeroDefine")
  43. local HeroGrid = require("hero.HeroGrid")
  44. local CombatDefine = require("combat.CombatDefine")
  45. local CombatLogic = require("combat.CombatLogic")
  46. local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
  47. local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
  48. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  49. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  50. local MailManager = require("mail.MailManager")
  51. local DailyTaskLogic = require("dailyTask.DailyTaskLogic")
  52. local MonthHzz = require("monthAct.MonthHzz")
  53. local UnionDBLogic = require("union.UnionDBLogic")
  54. local HeroExcel = require("excel.hero").hero
  55. local HeroLogic = require("hero.HeroLogic")
  56. local CombatPosLogic = require("combat.CombatPosLogic")
  57. local ChatPaoMaLogic = require("chat.ChatPaoMaLogic")
  58. local RoleDefine = require("role.RoleDefine")
  59. local RoleLogic = require("role.RoleLogic")
  60. local CombatVideo = require("combat.CombatVideo")
  61. local WarReportLogic = require("warReport.WarReportLogic")
  62. local LiLianLogic = require("dailyTask.LiLianLogic")
  63. local MailDefine = require("mail.MailIdDefine")
  64. local HeroLogLogic = require("absAct.HeroLogLogic")
  65. local HeroGrowUp = require("absAct.HeroGrowUp")
  66. local MengxinLogic = require("present.MengxinLogic")
  67. local YunYingLogic = require("yunying.YunYingLogic")
  68. local Timer = require("core.Timer")
  69. local WarOrder = require("shop.WarOrder")
  70. local TriggerDefine = require("trigger.TriggerDefine")
  71. local TriggerLogic = require("trigger.TriggerLogic")
  72. local ARENA_ORDER_TYPE = 4
  73. JJC_TARGET_CNT = 15 -- 每次找15个对手
  74. JJC_FREE_DAILY_CNT = 3 -- 每天3次免费战斗次数
  75. JJC_WORSHIP_CNT = 10 -- 每天10次膜拜次数
  76. JJC_WORSHIP_DOT_CNT = 3 -- 每天膜拜3次后红点消失
  77. JJC_WORSHIP_JINBI_CNT = 3000 -- 膜拜成功给金币数量
  78. JJC_COST_ITEM_CNT = 10 -- 竞技场挑战花费数量
  79. JJC_OPEN_QUICK = 20
  80. JJC_DOUBLE_CNT = 20 -- 双倍奖励次数
  81. JJC_COOL_TIME = 60
  82. JJC_RESULT_DEF_FAIL = 0
  83. JJC_RESULT_ATK_WIN = 1
  84. JJC_RESULT_ATK_FAIL = 2
  85. JJC_RESULT_DEF_WIN = 3
  86. local QUICK_COND_TIMES = 10 -- 跳过战斗需要战斗次数
  87. -- 检查是否加入竞技场
  88. function checkNeedJoin(human)
  89. if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1301) then
  90. return
  91. end
  92. -- 如果还没参加竞技场 并且已经设置过防守阵容 那么加入竞技场
  93. local data = JjcDB.getJjcData(human.db._id)
  94. if data then return end
  95. local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE3, nil, true)
  96. if not combatHero or not next(combatHero) then return end
  97. JjcDB.addPlayer(human)
  98. end
  99. -- 构造成员结构体
  100. function fontMemberNet(net, rank, data,worshipCnt,worshipState)
  101. net.rank = rank
  102. net.jifen = data and data.point or 0
  103. net.worshipCnt = worshipCnt
  104. net.worshipState = worshipState
  105. if data.monsterOutID then
  106. RoleLogic.makeRoleBase(data, net.roleBase)
  107. else
  108. RoleLogic.getRoleBaseByUuid(data._id, net.roleBase, CombatDefine.COMBAT_TYPE3)
  109. end
  110. end
  111. -- 竞技场查询
  112. function query(human)
  113. local flag, config = RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1301)
  114. if flag ~= true then
  115. --return Broadcast.sendErr(human, Lang.JJC_OPEN_NEED_LV)
  116. return Broadcast.sendErr(human, Util.format(Lang.COMMON_NEED_LEVEL, config.lv))
  117. end
  118. local leftSec = getLeftSec()
  119. if leftSec == nil then
  120. return Broadcast.sendErr(human, Lang.JJC_NOT_SET_OPEN_TIME)
  121. end
  122. -- 检查是否加入到竞技场
  123. checkNeedJoin(human)
  124. local seasonBox = JjcDB.getJjcSeasonBox(human.db._id)
  125. local totalFight = JjcDB.getJjcTotalFight(human.db._id)
  126. local totalFightCnt = JjcDB.getTotalFightCnt(human.db._id)
  127. local msgRet = Msg.gc.GC_JJC_QUERY
  128. msgRet.leftSec = leftSec
  129. msgRet.ownRank = JjcDB.getRank(human.db._id)
  130. msgRet.ownJifen = JjcDB.getJjcPoint(human.db._id)
  131. msgRet.defZDL = CombatPosLogic.getCombatHeroZDL(human, CombatDefine.COMBAT_TYPE3)
  132. msgRet.atkZDL = CombatPosLogic.getCombatHeroZDL(human, CombatDefine.COMBAT_TYPE1)
  133. msgRet.dotList[0] = 3
  134. msgRet.dotList[1] = championChallengeDot(human)
  135. msgRet.dotList[2] = championBillboardDot(human)
  136. msgRet.dotList[3] = championRecordDot(human)
  137. msgRet.challengeCnt = totalFight
  138. Grid.makeItem(msgRet.challengeCostItem,ItemDefine.ITEM_JJC_TICKET_ID,JJC_COST_ITEM_CNT)
  139. msgRet.isQuick = human.db.combatQuick[CombatDefine.COMBAT_TYPE2] or 0
  140. if human.db.combatQuick[CombatDefine.COMBAT_TYPE2] == nil then
  141. if totalFightCnt >= QUICK_COND_TIMES then
  142. human.db.combatQuick[CombatDefine.COMBAT_TYPE2] = 0
  143. else
  144. msgRet.isQuick = -1
  145. end
  146. end
  147. local boxExcel = JjcExcel.seasonBox
  148. local boxLen = #boxExcel
  149. for i = 1,boxLen do
  150. local v = boxExcel[i]
  151. local net = msgRet.jjcBox[i]
  152. net.reachCnt = v.reachCnt
  153. if seasonBox == nil or seasonBox[i] == nil then
  154. -- 未领取
  155. if totalFight >= v.reachCnt then
  156. -- 已达标
  157. net.state = 1
  158. else
  159. net.state = 0
  160. end
  161. else
  162. -- 已领取
  163. net.state = 2
  164. end
  165. local itemLen = #v.item
  166. for j = 1,itemLen do
  167. Grid.makeItem(net.item[j],v.item[j][1],v.item[j][2])
  168. end
  169. net.item[0] = itemLen
  170. end
  171. msgRet.jjcBox[0] = boxLen
  172. Msg.send(msgRet, human.fd)
  173. local nowRank = JjcDB.getRank(human.db._id)
  174. if nowRank > 0 and ((human.db.jjcBestRank or 0) <= 0 or nowRank < (human.db.jjcBestRank or 0)) then
  175. human.db.jjcBestRank = nowRank
  176. end
  177. end
  178. function getQuick(human, combatType)
  179. local totalFight = JjcDB.getJjcTotalFight(human.db._id)
  180. if totalFight > JJC_OPEN_QUICK then
  181. return 1
  182. end
  183. return 0
  184. end
  185. -- 挑战记录查询
  186. function recordQuery(human)
  187. local msgRet = Msg.gc.GC_JJC_RECORD_QUERY
  188. local recordList = JjcDB.getJjcRecordList(human.db._id)
  189. local nowFightCnt = human.db.jjcDailyFight or 0
  190. msgRet.leftFreeCnt = math.max(JJC_FREE_DAILY_CNT - nowFightCnt, 0)
  191. msgRet.recordList[0] = 0
  192. if not recordList then
  193. Msg.send(msgRet, human.fd)
  194. return
  195. end
  196. for i = 1, #recordList do
  197. local videoUuid = recordList[i]
  198. local combatVideo = CombatVideo.getCombatVideo(videoUuid)
  199. if combatVideo then
  200. msgRet.recordList[0] = msgRet.recordList[0] + 1
  201. local net = msgRet.recordList[msgRet.recordList[0]]
  202. local combatInfo = combatVideo.combatInfo
  203. local parms = combatInfo.endParam and Util.split(combatInfo.endParam, "|")
  204. net.time = combatInfo.time
  205. net.identity = combatVideo._id
  206. if combatInfo.attacker.uuid == human.db._id then
  207. RoleLogic.makeRoleBase(combatInfo.defender, net.roleBase)
  208. net.result = combatInfo.isWin and JJC_RESULT_ATK_WIN or JJC_RESULT_ATK_FAIL
  209. net.jifenChange = tonumber(parms and parms[3]) or 0
  210. else
  211. RoleLogic.makeRoleBase(combatInfo.attacker, net.roleBase)
  212. net.result = (not combatInfo.isWin) and JJC_RESULT_DEF_WIN or JJC_RESULT_DEF_FAIL
  213. net.jifenChange = tonumber(parms and parms[4]) or 0
  214. end
  215. end
  216. end
  217. Msg.send(msgRet, human.fd)
  218. -- 记录点开战斗记录时间
  219. human.db.jjcNewestRecord = os.time()
  220. RoleSystemLogic.onDot(human,RoleSystemDefine.ROLE_SYS_ID_1300)
  221. end
  222. --[[-- 计算分数
  223. function calcPoint(comBatResult, atkPoint, defPoint)
  224. -- 赢 加积分 扣对方积分
  225. local addPoint = 0
  226. local delPoint = 0
  227. if comBatResult == CombatDefine.RESULT_WIN then
  228. if defPoint > 0 then
  229. if atkPoint >= defPoint then
  230. local tp1 = (defPoint/atkPoint)^2 * (1250/atkPoint) * 25
  231. local tp2 = 1 + math.floor((defPoint-atkPoint)/50 + 0.5) / 10
  232. addPoint = math.ceil (tp1 * tp2)
  233. delPoint = math.ceil(addPoint * (atkPoint/defPoint))
  234. else
  235. --我方积分较低的胜场
  236. addPoint = math.ceil((defPoint/atkPoint)^2 * (1250/atkPoint)*25)
  237. delPoint = math.ceil(addPoint * (atkPoint/defPoint))
  238. end
  239. end
  240. if addPoint <= 0 or delPoint <= 0 then
  241. addPoint = 0
  242. delPoint = 0
  243. else
  244. addPoint = addPoint > 100 and 100 or addPoint
  245. delPoint = delPoint > 100 and 100 or delPoint
  246. end
  247. atkPoint = atkPoint + addPoint --我方积分
  248. defPoint = defPoint - delPoint --防守方积分
  249. else
  250. -- 输 减积分 加对方积分
  251. local scal = 15
  252. if atkPoint >= defPoint then
  253. scal = 25
  254. end
  255. if defPoint > 0 then
  256. addPoint = math.ceil((atkPoint / defPoint) * scal)
  257. delPoint = math.ceil(addPoint * (atkPoint/defPoint))
  258. end
  259. if addPoint <= 0 or delPoint <= 0 then
  260. addPoint = 0
  261. delPoint = 0
  262. else
  263. addPoint = addPoint > 100 and 100 or addPoint
  264. delPoint = delPoint > 100 and 100 or delPoint
  265. end
  266. atkPoint = atkPoint - addPoint
  267. defPoint = defPoint + delPoint
  268. end
  269. if atkPoint < 0 then
  270. atkPoint = 1
  271. end
  272. if defPoint < 0 then
  273. defPoint = 1
  274. end
  275. return atkPoint, defPoint
  276. end]]
  277. -- 计算分数
  278. function calcPoint(comBatResult, atkPoint, defPoint)
  279. -- 赢 加积分 扣对方积分
  280. local addPoint = 0
  281. local delPoint = 0
  282. addPoint = math.ceil(22/(atkPoint/defPoint)^2)
  283. delPoint = math.ceil(22/(atkPoint/defPoint)^2 - 5)
  284. if addPoint <= 1 then
  285. addPoint = 1
  286. end
  287. if defPoint <= 1 then
  288. defPoint = 1
  289. end
  290. if comBatResult == CombatDefine.RESULT_WIN then
  291. atkPoint = atkPoint + addPoint --我方积分
  292. defPoint = defPoint - delPoint --防守方积分
  293. end
  294. if atkPoint < 0 then
  295. atkPoint = 1
  296. end
  297. if defPoint < 0 then
  298. defPoint = 1
  299. end
  300. return atkPoint, defPoint
  301. end
  302. function rewardQuery(human, type)
  303. if type ~= 1 and type ~= 2 then
  304. return
  305. end
  306. local msgRet = Msg.gc.GC_JJC_DAY_REWARD_QUERY
  307. msgRet.type = type
  308. msgRet.rank = JjcDB.getRank(human.db._id)
  309. msgRet.canGet[0] = 0
  310. if type == 1 then
  311. -- 每日奖励
  312. for i = 1, #JjcExcel.dayReward do
  313. local configTemp = JjcExcel.dayReward[i]
  314. msgRet.list[i].maxRank = configTemp.rankMax
  315. msgRet.list[i].minRank = configTemp.rankMin
  316. local len = #configTemp.reward
  317. msgRet.list[i].items[0] = len
  318. for j = 1, len do
  319. local itemID = configTemp.reward[j][1]
  320. local itemCnt = configTemp.reward[j][2]
  321. Grid.makeItem(msgRet.list[i].items[j], itemID, itemCnt)
  322. end
  323. if msgRet.rank >= configTemp.rankMin and msgRet.rank <= configTemp.rankMax then
  324. for j = 1, len do
  325. local itemID = configTemp.reward[j][1]
  326. local itemCnt = configTemp.reward[j][2]
  327. Grid.makeItem(msgRet.canGet[j], itemID, itemCnt)
  328. end
  329. msgRet.canGet[0] = len
  330. end
  331. end
  332. msgRet.list[0] = #JjcExcel.dayReward
  333. local now = os.time()
  334. local ts1 = Util.getDayHourTime(now, 21)
  335. if now >= ts1 then
  336. msgRet.leftSec = ts1 + 24 * 3600 - now
  337. else
  338. msgRet.leftSec = ts1 - now
  339. end
  340. else
  341. -- 赛季奖励
  342. for i = 1, #JjcExcel.seasonReward do
  343. local configTemp = JjcExcel.seasonReward[i]
  344. msgRet.list[i].maxRank = configTemp.rankMax
  345. msgRet.list[i].minRank = configTemp.rankMin
  346. local len = #configTemp.reward
  347. msgRet.list[i].items[0] = len
  348. for j = 1, len do
  349. local itemID = configTemp.reward[j][1]
  350. local itemCnt = configTemp.reward[j][2]
  351. Grid.makeItem(msgRet.list[i].items[j], itemID, itemCnt)
  352. end
  353. if msgRet.rank >= configTemp.rankMin and msgRet.rank <= configTemp.rankMax then
  354. for j = 1, len do
  355. local itemID = configTemp.reward[j][1]
  356. local itemCnt = configTemp.reward[j][2]
  357. Grid.makeItem(msgRet.canGet[j], itemID, itemCnt)
  358. end
  359. msgRet.canGet[0] = len
  360. end
  361. end
  362. msgRet.list[0] = #JjcExcel.seasonReward
  363. msgRet.leftSec = 0
  364. end
  365. Msg.send(msgRet, human.fd)
  366. end
  367. --[[
  368. -- 查找对手
  369. function targetFind(human)
  370. ObjHuman.updateDaily(human)
  371. local rank = 0
  372. local len = 0
  373. local tempRank = {}
  374. local targetIndexs = {}
  375. local nowFightCnt = human.db.jjcDailyFight or 0
  376. local leftFreeCnt = 0
  377. if JJC_FREE_DAILY_CNT > nowFightCnt then
  378. leftFreeCnt = JJC_FREE_DAILY_CNT - nowFightCnt
  379. end
  380. local msgRet = Msg.gc.GC_JJC_TARGET_FIND
  381. msgRet.leftFreeCnt = leftFreeCnt
  382. --没有加入队列
  383. local humanRank = JjcDB.getRank(human.db._id)
  384. if humanRank < 1 then
  385. --随机取机器人
  386. local randomCount = #JjcDB.ROBOT_LIST - 30
  387. local randomIndex = math.random(1, randomCount)
  388. local randomEnd = randomIndex + 30
  389. for i = randomIndex, randomEnd do
  390. local dataTemp = JjcDB.ROBOT_LIST[i]
  391. if dataTemp ~= nil then
  392. if len >= 30 then
  393. break
  394. end
  395. len = len + 1
  396. fontMemberNet(msgRet.targetList[len], rank, dataTemp,0,0)
  397. end
  398. end
  399. msgRet.targetList[0] = len
  400. Msg.send(msgRet, human.fd)
  401. return
  402. end
  403. local leftCnt = 8 -- 往前取8个
  404. local rightCnt = JJC_TARGET_CNT - leftCnt -- 往后取7个
  405. if humanRank <= leftCnt then
  406. leftCnt = humanRank - 1
  407. rightCnt = JJC_TARGET_CNT - leftCnt
  408. end
  409. if humanRank >= #JjcDB.RANK_2_JJCDATA - rightCnt then
  410. rightCnt = #JjcDB.RANK_2_JJCDATA - humanRank
  411. leftCnt = JJC_TARGET_CNT - rightCnt
  412. end
  413. if leftCnt > 0 then
  414. for i = humanRank - leftCnt, humanRank - 1 do
  415. table.insert(targetIndexs, i)
  416. end
  417. end
  418. if rightCnt > 0 then
  419. for i = humanRank + 1, humanRank + rightCnt do
  420. table.insert(targetIndexs, i)
  421. end
  422. end
  423. for i = 1, JJC_TARGET_CNT do
  424. rank = targetIndexs[i]
  425. if rank > 0 then
  426. tempRank[rank] = rank
  427. end
  428. end
  429. -- 自己的前20位 再随机 取5个
  430. local rankMin= humanRank - 20
  431. local rankMax = humanRank - 1
  432. if rankMin > 0 and rankMax > 0 then
  433. local randIndex = math.random(rankMin, rankMax)
  434. local endRank = randIndex + 5
  435. for i = randIndex, endRank do
  436. if tempRank[i] == nil and i ~= humanRank and JjcDB.RANK_2_JJCDATA[i] ~= nil then
  437. tempRank[i] = i
  438. end
  439. end
  440. end
  441. -- 自己的后100位 再随机 取10个
  442. rankMin = humanRank + 1
  443. rankMax = humanRank + 300
  444. if rankMin > 0 and rankMax > 0 then
  445. local randIndex = math.random(rankMin, rankMax)
  446. local endRank = randIndex + 10
  447. for i = randIndex, endRank do
  448. if tempRank[i] == nil and i ~= humanRank and JjcDB.RANK_2_JJCDATA[i] ~= nil then
  449. tempRank[i] = i
  450. end
  451. end
  452. end
  453. local unionUuid = ""
  454. for k, rank in pairs(tempRank) do
  455. local dataTemp = JjcDB.RANK_2_JJCDATA[rank]
  456. if dataTemp ~= nil and rank ~= humanRank then
  457. if len >= 30 then
  458. break
  459. end
  460. len = len + 1
  461. local db = RoleDBLogic.getDb(dataTemp._id)
  462. if db == nil then
  463. fontMemberNet(msgRet.targetList[len], rank, dataTemp,0,0)
  464. else
  465. local worshipCnt = db.jjcBeWorship and db.jjcBeWorship or 0
  466. local worshipState = 0
  467. if db._id ~= human.db._id and (human.db.jjcWorship == nil or human.db.jjcWorship[dataTemp._id] == nil) then
  468. worshipState = 1
  469. end
  470. fontMemberNet(msgRet.targetList[len], rank, dataTemp,worshipCnt,worshipState)
  471. end
  472. end
  473. end
  474. msgRet.targetList[0] = len
  475. Msg.send(msgRet, human.fd)
  476. end
  477. ]]
  478. -- 查找对手
  479. function targetFind(human,type)
  480. ObjHuman.updateDaily(human)
  481. local rank = 0
  482. local len = 0
  483. local targetIndexs = {}
  484. local nowFightCnt = human.db.jjcDailyFight or 0
  485. local leftFreeCnt = 0
  486. if JJC_FREE_DAILY_CNT > nowFightCnt then
  487. leftFreeCnt = JJC_FREE_DAILY_CNT - nowFightCnt
  488. end
  489. local msgRet = Msg.gc.GC_JJC_TARGET_FIND
  490. msgRet.leftFreeCnt = leftFreeCnt
  491. --没有加入队列
  492. local humanPoint = JjcDB.getJjcPoint(human.db._id)
  493. local areaList = {}
  494. local choseUuid = {}
  495. local count = 0
  496. local jjcRival = JjcDB.getJjcRival(human.db._id)
  497. if jjcRival ~= nil and #jjcRival ~= 0 and type == 0 then
  498. for k,v in pairs(jjcRival) do
  499. local rank = JjcDB.getRank(v)
  500. local jjcData = JjcDB.RANK_2_JJCDATA[rank]
  501. len = len + 1
  502. local db = RoleDBLogic.getDb(v)
  503. if db == nil then
  504. fontMemberNet(msgRet.targetList[len], rank, jjcData,0,0)
  505. else
  506. local worshipCnt = db.jjcBeWorship and db.jjcBeWorship or 0
  507. local worshipState = 0
  508. if db._id ~= human.db._id and (human.db.jjcWorship == nil or human.db.jjcWorship[v] == nil) then
  509. worshipState = 1
  510. end
  511. fontMemberNet(msgRet.targetList[len], rank, jjcData,worshipCnt,worshipState)
  512. end
  513. if len >= 3 then
  514. break
  515. end
  516. end
  517. else
  518. local minRate = 95
  519. local maxRate = 110
  520. while true do
  521. local minPoint = math.floor(humanPoint*minRate/100)
  522. local maxPoint = math.floor(humanPoint*maxRate/100)
  523. for k,v in pairs(JjcDB.RANK_2_JJCDATA) do
  524. if v.point > minPoint and v.point < maxPoint and v._id ~= human.db._id and choseUuid[v._id] == nil then
  525. count = count + 1
  526. areaList[count] = v._id
  527. choseUuid[v._id] = 1
  528. end
  529. end
  530. if count < 10 then
  531. minRate = minRate - 10
  532. maxRate = maxRate + 10
  533. else
  534. break
  535. end
  536. end
  537. for i = 1,3 do
  538. local index = 0
  539. while true do
  540. index = math.random(1,count)
  541. if areaList[index] ~= nil then
  542. break
  543. end
  544. end
  545. local uuid = areaList[index]
  546. areaList[index] = nil
  547. local rank = JjcDB.getRank(uuid)
  548. local v = JjcDB.RANK_2_JJCDATA[rank]
  549. local db = RoleDBLogic.getDb(uuid)
  550. if db == nil then
  551. fontMemberNet(msgRet.targetList[i], rank, v,0,0)
  552. else
  553. local worshipCnt = db.jjcBeWorship and db.jjcBeWorship or 0
  554. local worshipState = 0
  555. if db._id ~= human.db._id and (human.db.jjcWorship == nil or human.db.jjcWorship[v._id] == nil) then
  556. worshipState = 1
  557. end
  558. fontMemberNet(msgRet.targetList[i], rank, v,worshipCnt,worshipState)
  559. end
  560. JjcDB.updateRival(human.db._id,i,v._id)
  561. end
  562. end
  563. msgRet.targetList[0] = 3
  564. Msg.send(msgRet, human.fd)
  565. end
  566. -- 获取竞技场箱子奖励
  567. function getChampionBoxReward(human,index)
  568. local leftSec = getLeftSec()
  569. -- 竞技场未开,返回
  570. if leftSec == nil then
  571. return
  572. end
  573. local seasonBox = JjcDB.getJjcSeasonBox(human.db._id)
  574. local totalFight = JjcDB.getJjcTotalFight(human.db._id)
  575. -- 奖励已被领取
  576. if seasonBox and seasonBox[index] ~= nil then
  577. return
  578. end
  579. -- 参数错误
  580. local v = JjcExcel.seasonBox[index]
  581. if v == nil then
  582. return
  583. end
  584. -- 奖励未达成
  585. if totalFight < v.reachCnt then
  586. return
  587. end
  588. -- 写DB
  589. JjcDB.updateSeasonBox(human.db._id,index)
  590. -- 给物品
  591. BagLogic.addItemList(human, v.item, "jjc_season_box")
  592. RoleSystemLogic.onDot(human,RoleSystemDefine.ROLE_SYS_ID_1300)
  593. query(human)
  594. end
  595. function championWorship(human,uuid)
  596. -- 不能膜拜自己
  597. if uuid == human.db._id then
  598. return
  599. end
  600. -- 初始化膜拜数据
  601. human.db.jjcWorship = human.db.jjcWorship or {}
  602. human.db.jjcWorship.count = human.db.jjcWorship.count or 0
  603. -- 每日膜拜已达上限
  604. if human.db.jjcWorship.count >= JJC_WORSHIP_CNT then
  605. return Broadcast.sendErr(human, Lang.GODWAR_MOBAI_ERR)
  606. end
  607. -- 已膜拜过此玩家
  608. if human.db.jjcWorship[uuid] ~= nil then
  609. return Broadcast.sendErr(human, Lang.GODWAR_MOBAI_HAD)
  610. end
  611. -- 写数据库
  612. human.db.jjcWorship[uuid] = 1
  613. human.db.jjcWorship.count = human.db.jjcWorship.count + 1
  614. -- 写被膜拜玩家数据库
  615. local worshipCnt = 0
  616. local db = RoleDBLogic.getDb(uuid)
  617. if db == nil then
  618. JjcDB.updateWorshipCnt(uuid)
  619. worshipCnt = JjcDB.getWorshipCnt(uuid)
  620. else
  621. db.jjcBeWorship = db.jjcBeWorship or 0
  622. db.jjcBeWorship = db.jjcBeWorship + 1
  623. RoleDBLogic.saveRole(db)
  624. worshipCnt = db.jjcBeWorship
  625. end
  626. -- 给奖励
  627. BagLogic.addItem(human, ItemDefine.ITEM_JINBI_ID, JJC_WORSHIP_JINBI_CNT, "jjc_worship")
  628. Broadcast.sendErr(human, Util.format(Lang.JJC_WORSHIP_GOOD, JJC_WORSHIP_JINBI_CNT))
  629. local msgRet = Msg.gc.GC_JJC_CHAMPION_WORSHIP
  630. msgRet.worshipCnt = worshipCnt
  631. msgRet.dot = 1
  632. if human.db.jjcWorship.count >= 3 or human.db.lv < 9 then
  633. msgRet.dot = 0
  634. end
  635. Msg.send(msgRet,human.fd)
  636. end
  637. function championBillboardQuery(human)
  638. local flag = RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1301)
  639. if flag ~= true then
  640. return Broadcast.sendErr(human, Lang.JJC_OPEN_NEED_LV)
  641. end
  642. local leftSec = getLeftSec()
  643. if leftSec == nil then
  644. return Broadcast.sendErr(human, Lang.JJC_NOT_SET_OPEN_TIME)
  645. end
  646. local seasonBox = JjcDB.getJjcSeasonBox(human.db._id)
  647. local totalFight = JjcDB.getJjcTotalFight(human.db._id)
  648. local msgRet = Msg.gc.GC_JJC_CHAMPION_BILLBOARD_QUERY
  649. msgRet.leftSec = leftSec
  650. msgRet.topList[0] = 0
  651. for i = 1, #JjcDB.RANK_2_JJCDATA do
  652. if i > 100 then
  653. break
  654. end
  655. msgRet.topList[0] = msgRet.topList[0] + 1
  656. local dataTemp = JjcDB.RANK_2_JJCDATA[i]
  657. local db = RoleDBLogic.getDb(dataTemp._id)
  658. if db == nil then
  659. local worshipCnt = dataTemp.worshipCnt or 0
  660. local worshipState = 0
  661. if dataTemp._id ~= human.db._id and (human.db.jjcWorship == nil or human.db.jjcWorship[dataTemp._id] == nil) then
  662. worshipState = 1
  663. end
  664. fontMemberNet(msgRet.topList[msgRet.topList[0]], i, dataTemp,worshipCnt,worshipState)
  665. else
  666. local worshipCnt = db.jjcBeWorship or 0
  667. local worshipState = 0
  668. if db._id ~= human.db._id and (human.db.jjcWorship == nil or human.db.jjcWorship[dataTemp._id] == nil) then
  669. worshipState = 1
  670. end
  671. fontMemberNet(msgRet.topList[msgRet.topList[0]], i, dataTemp,worshipCnt,worshipState)
  672. end
  673. end
  674. local rank = JjcDB.UUID_2_RANK[human.db._id]
  675. local jjcData = JjcDB.RANK_2_JJCDATA[rank] or {}
  676. local worshipCnt = human.db.jjcBeWorship and human.db.jjcBeWorship or 0
  677. fontMemberNet(msgRet.ownRank, rank, jjcData,worshipCnt,0)
  678. msgRet.dotList[0] = 3
  679. msgRet.dotList[1] = championChallengeDot(human)
  680. msgRet.dotList[2] = championBillboardDot(human)
  681. msgRet.dotList[3] = championRecordDot(human)
  682. Msg.send(msgRet, human.fd)
  683. if rank > 0 and ((human.db.jjcBestRank or 0) <= 0 or rank < (human.db.jjcBestRank or 0)) then
  684. human.db.jjcBestRank = rank
  685. end
  686. end
  687. function onHour(hour)
  688. -- 判断是赛季结束还是每日结束
  689. if _G.is_middle == true then
  690. return
  691. end
  692. if hour == 4 then -- 错开整点一些处理
  693. Timer.addLater(11, JjcDB.cleanOldVideos)
  694. return
  695. end
  696. local openDay = CommonDB.getServerOpenDay()
  697. if openDay == nil then return end
  698. if hour == 21 then
  699. -- 发每日奖励
  700. local mailConfig = MailExcel.mail[MailDefine.MAIL_ID_JJC_DAY]
  701. local title = mailConfig.title
  702. local senderName = mailConfig.senderName
  703. local nowDateStr = HtmlUtil.getDataStr(os.time())
  704. -- 发每日奖励
  705. for i = 1, #JjcExcel.dayReward do
  706. local config = JjcExcel.dayReward[i]
  707. for j = config.rankMin, config.rankMax do
  708. local data = JjcDB.RANK_2_JJCDATA[j]
  709. if data == nil then
  710. break
  711. end
  712. if data.monsterOutID == nil then
  713. local content = Util.format(mailConfig.content, nowDateStr, j)
  714. MailManager.add(MailManager.SYSTEM, data._id, title, content, config.reward, senderName)
  715. end
  716. end
  717. end
  718. if openDay % JjcDB.SEASON_KEEP_DAY == 0 then
  719. -- 赛季结束结算
  720. Msg.sendWorld(Msg.gc.GC_JJC_SEASON_END)
  721. local mailConfig = MailExcel.mail[MailDefine.MAIL_ID_JJC_SEASON]
  722. local title = mailConfig.title
  723. local senderName = mailConfig.senderName
  724. -- 发每日奖励
  725. for i = 1, #JjcExcel.seasonReward do
  726. local config = JjcExcel.seasonReward[i]
  727. for j = config.rankMin, config.rankMax do
  728. local data = JjcDB.RANK_2_JJCDATA[j]
  729. if data == nil then
  730. break
  731. end
  732. if data.monsterOutID == nil then
  733. local content = Util.format(mailConfig.content, j)
  734. MailManager.add(MailManager.SYSTEM, data._id, title, content, config.reward, senderName)
  735. end
  736. end
  737. end
  738. -- reset数据
  739. JjcDB.resetJJCDB()
  740. -- 开启新赛季
  741. JjcDB.setSeasonEndTime()
  742. end
  743. return
  744. end
  745. end
  746. -- 获取剩余时间
  747. function getLeftSec()
  748. local endTime = JjcDB.getSeasonEndTime()
  749. if not endTime then return end
  750. return endTime - os.time()
  751. end
  752. function getHeroShareMonster(uuid, heroIndex)
  753. local jjcData = JjcDB.getJjcData(uuid)
  754. if not jjcData then return end
  755. if not jjcData.monsterOutID then return end
  756. local monsterOutConfig = MonsterExcel.monsterOut[jjcData.monsterOutID]
  757. if not monsterOutConfig then return end
  758. local mcf = monsterOutConfig.member[heroIndex]
  759. if not mcf then return end
  760. local monsterID = mcf[1]
  761. if not monsterID or monsterID < 1 then return end
  762. return monsterID, jjcData.lv
  763. end
  764. --------------- 以下内容是竞技场列表显示要用到的 start ---------------------------
  765. -- 额外参数设置
  766. function fontActArgs(args, human)
  767. args[0] = 2
  768. local rank,score = getActRank(human)
  769. args[1] = rank
  770. args[2] = score
  771. end
  772. function getActRank(human)
  773. local rank = JjcDB.getRank(human.db._id)
  774. local score = JjcDB.getJjcPoint(human.db._id)
  775. return math.max(rank, 0), math.max(score, 0) -- 0表示未上榜
  776. end
  777. function getActZhandouli(human)
  778. return CombatPosLogic.getCombatHeroZDL(human, CombatDefine.COMBAT_TYPE3, true)
  779. end
  780. -- 赛季开始时间段
  781. function getActDesc(desc)
  782. local endTime, startTime = JjcDB.getSeasonEndTime()
  783. if not endTime or not startTime then
  784. return Lang.COMMON_SYSTEM_NEED_OPENTIME
  785. end
  786. local d1 = os.date("*t", startTime)
  787. local d2 = os.date("*t", endTime)
  788. return Util.format(desc, d1.month .. "月" .. d1.day.."日", d2.month .. "月" .. d2.day.."日")
  789. end
  790. -- 活动状态
  791. function getActState()
  792. local endTime = JjcDB.getSeasonEndTime()
  793. if not endTime then
  794. return JjcActLogic.STATE_NOOPEN, 0
  795. end
  796. return JjcActLogic.STATE_START, endTime - os.time()
  797. end
  798. -- 红点
  799. function isActRed(human)
  800. if human.db.lv < 9 then
  801. return false
  802. end
  803. if championChallengeDot(human) == 1 then
  804. return true
  805. end
  806. if championBillboardDot(human) == 1 then
  807. return true
  808. end
  809. if championRecordDot(human) == 1 then
  810. return true
  811. end
  812. end
  813. function getCombatObjList(human, side, args)
  814. if side ~= CombatDefine.DEFEND_SIDE then return end
  815. local uuid = args[1]
  816. local jjcData = JjcDB.getJjcData(uuid)
  817. if not jjcData then return end
  818. if jjcData.monsterOutID then return end
  819. local target = CombatLogic.createCombatFakeHuman(uuid)
  820. if not target then return end
  821. return CombatLogic.getHumanObjList(target, CombatDefine.COMBAT_TYPE3)
  822. end
  823. function getCombatMonsterOutID(human, side, args)
  824. if side ~= CombatDefine.DEFEND_SIDE then return end
  825. local uuid = args[1]
  826. local jjcData = JjcDB.getJjcData(uuid)
  827. if not jjcData then return end
  828. if not jjcData.monsterOutID then return end
  829. return jjcData.monsterOutID, jjcData.zhandouli
  830. end
  831. function checkCombatPos(human, args, combatType)
  832. if combatType == CombatDefine.COMBAT_TYPE3 then
  833. return true
  834. end
  835. local uuid = args[1]
  836. local leftSec = getLeftSec()
  837. if leftSec == nil then
  838. return Broadcast.sendErr(human, Lang.JJC_NOT_SET_OPEN_TIME)
  839. end
  840. local jjcData = JjcDB.getJjcData(uuid)
  841. if not jjcData then return end
  842. -- 判断是否免费
  843. ObjHuman.updateDaily(human)
  844. local nowFightCnt = human.db.jjcDailyFight or 0
  845. if JJC_FREE_DAILY_CNT <= nowFightCnt then
  846. -- 判断是否有门票
  847. if BagLogic.getItemCnt(human, ItemDefine.ITEM_JJC_TICKET_ID) < 1 then
  848. return Broadcast.sendErr(human, Lang.JJC_ERR_FIGHT_NO_ITEM)
  849. end
  850. end
  851. return true, uuid
  852. end
  853. function fight(human, args, combatType)
  854. if combatType ~= CombatDefine.COMBAT_TYPE2 then return end
  855. local isok, uuid = checkCombatPos(human, args, combatType)
  856. if not isok then return end
  857. local nowFightCnt = human.db.jjcDailyFight or 0
  858. if JJC_FREE_DAILY_CNT <= nowFightCnt then
  859. -- 扣门票
  860. BagLogic.delItem(human, ItemDefine.ITEM_JJC_TICKET_ID, 1, "jjc_fight")
  861. end
  862. human.db.jjcDailyFight = (human.db.jjcDailyFight or 0) + 1
  863. JjcDB.updateTotalFight(human.db._id)
  864. JjcDB.updateTotalFightCnt(human.db._id)
  865. local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE2, nil, true)
  866. if not combatHero or not next(combatHero) then
  867. CombatPosLogic.copyCombatHeros(human, CombatDefine.COMBAT_TYPE1, CombatDefine.COMBAT_TYPE2)
  868. end
  869. checkNeedJoin(human)
  870. CombatLogic.combatBegin(human, nil, args, CombatDefine.COMBAT_TYPE2, uuid)
  871. DailyTaskLogic.recordDailyTaskFinishCnt(human, DailyTaskLogic.DAILY_TASK_ID_4, 1)
  872. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_5,1)
  873. MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_3,1)
  874. HeroLogLogic.finishTaskCB(human,HeroLogLogic.HERO_LOG_TYPE_2,1)
  875. YunYingLogic.onCallBack(human, "onJjcFight",1)
  876. TriggerLogic.PublishEvent(TriggerDefine.EVENT_TYPE_CHAMPIONSNUM, human.db._id, 1)
  877. end
  878. -- 挑战结束
  879. function onFightEnd(human, result, combatType, defUuid, combatInfo)
  880. local defData = JjcDB.getJjcData(defUuid)
  881. local atkPoint = JjcDB.getJjcPoint(human.db._id)
  882. local defPoint = JjcDB.getJjcPoint(defUuid)
  883. local oldAtkPoint = atkPoint
  884. local oldDefPoint = defPoint
  885. local defHuman = ObjHuman.onlineUuid[defUuid]
  886. if result == CombatDefine.RESULT_WIN then
  887. if defHuman ~= nil then
  888. defHuman.jjcWinCount = nil
  889. end
  890. human.jjcWinCount = (human.jjcWinCount or 0) + 1
  891. JjcDB.cleanRival(human.db._id)
  892. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE8, human.jjcWinCount)
  893. LiLianLogic.onCallbackByCombat(human,combatInfo)
  894. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_15,1)
  895. HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE7, 1)
  896. HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE11, combatInfo)
  897. WarOrder.trigger(human,ARENA_ORDER_TYPE)
  898. else
  899. human.jjcWinCount = nil
  900. end
  901. MonthHzz.addJjcFight(human, result)
  902. atkPoint, defPoint = calcPoint(result, atkPoint, defPoint)
  903. -- 重置名字和头像
  904. if defData.monsterOutID then
  905. combatInfo.defender.head = defData.head
  906. combatInfo.defender.name = defData.name
  907. combatInfo.defender.lv = defData.lv
  908. combatInfo.defender.zhandouli = defData.zhandouli
  909. combatInfo.defender.uuid = defData._id
  910. end
  911. combatInfo.endParam = atkPoint .. "|" .. defPoint .. "|" .. (atkPoint - oldAtkPoint) .. "|" .. (defPoint - oldDefPoint)
  912. JjcDB.updatePlayerPoint(human.db._id, atkPoint, true)
  913. JjcDB.updatePlayerPoint(defUuid, defPoint, nil)
  914. -- 保存战斗记录
  915. JjcDB.addJjcRecord(human.db._id, defUuid, combatInfo)
  916. -- 保存战报 名次前20次
  917. local rank = JjcDB.getRank(human.db._id)
  918. if rank <= WarReportLogic.WAR_JJC_RANK then
  919. local defRank = JjcDB.getRank(defUuid)
  920. WarReportLogic.add(WarReportLogic.WAR_REPORT_1, combatInfo, rank, defRank)
  921. end
  922. -- 给奖励
  923. local totalWeight = 0
  924. for i = 1, #JjcExcel.fightReward do
  925. totalWeight = totalWeight + JjcExcel.fightReward[i].weight
  926. end
  927. local msgRet = Msg.gc.GC_JJC_AFTER_FIGHT
  928. msgRet.atkPoint = atkPoint
  929. msgRet.atkPointChange = atkPoint - oldAtkPoint
  930. msgRet.defPoint = defPoint
  931. msgRet.defPointChange = defPoint - oldDefPoint
  932. RoleLogic.makeRoleBase(combatInfo.defender,msgRet.defRole)
  933. RoleLogic.makeRoleBase(combatInfo.attacker,msgRet.atkRole)
  934. msgRet.items[0] = 1
  935. local randNum = math.random(1, totalWeight)
  936. local indexTemp = 1
  937. for i = 1, #JjcExcel.fightReward do
  938. if randNum <= JjcExcel.fightReward[i].weight then
  939. indexTemp = i
  940. break
  941. end
  942. randNum = randNum - JjcExcel.fightReward[i].weight
  943. end
  944. local itemID = JjcExcel.fightReward[indexTemp].itemID
  945. local itemCntMin = JjcExcel.fightReward[indexTemp].itemCnt1
  946. local itemCntMax = JjcExcel.fightReward[indexTemp].itemCnt2
  947. local itemCnt = math.random(itemCntMin, itemCntMax)
  948. -- 双倍结算
  949. local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1301)
  950. local isDouble
  951. if double and (not human.db.jjcDailyFight or human.db.jjcDailyFight <= JJC_DOUBLE_CNT) then
  952. itemCnt = itemCnt * 2
  953. isDouble = true
  954. end
  955. BagLogic.addItem(human, itemID, itemCnt, "jjc_fight")
  956. Grid.makeItem(msgRet.items[1], itemID, itemCnt)
  957. msgRet.double = isDouble and 1 or 0
  958. msgRet.result = result
  959. Msg.send(msgRet, human.fd)
  960. human.db.jjcNewestRecord = os.time()
  961. -- 当被挑战玩家在线时,向被挑战玩家发送协议告知玩家被挑战
  962. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1300)
  963. if defHuman ~= nil then
  964. local msg = Msg.gc.GC_JJC_CHAMPION_BE_CHALLENGE
  965. Msg.send(msg, defHuman.fd)
  966. RoleSystemLogic.onDot(defHuman, RoleSystemDefine.ROLE_SYS_ID_1300)
  967. end
  968. end
  969. -- 获取 竞技场 剩余双倍次数
  970. function getJJCDoubleCnt(human)
  971. local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1301)
  972. if double then
  973. if human.db.jjcDailyFight then
  974. local cnt = JJC_DOUBLE_CNT - human.db.jjcDailyFight
  975. return cnt > 0 and cnt or 0
  976. end
  977. return JJC_DOUBLE_CNT
  978. end
  979. return 0
  980. end
  981. --------------------- about dot -------------------------------------
  982. -- 冠军联赛挑战记录红点
  983. function championRecordDot(human)
  984. if human.db.lv < 9 then
  985. return 0
  986. end
  987. -- 没有战斗记录,红点不亮
  988. local recordList = JjcDB.getJjcRecordList(human.db._id)
  989. if not recordList then
  990. return 0
  991. end
  992. -- 有战斗记录,玩家没点开过战斗记录,红点亮
  993. if human.db.jjcNewestRecord == nil then
  994. return 1
  995. end
  996. local videoUuid = recordList[1]
  997. local combatInfo = CombatVideo.getCombatVideo(videoUuid)
  998. -- 最新一条战斗记录时间比上次点开战斗记录时间大,红点亮
  999. if combatInfo and combatInfo.combatInfo.time > human.db.jjcNewestRecord then
  1000. return 1
  1001. end
  1002. -- 否则不亮
  1003. return 0
  1004. end
  1005. -- 冠军联赛挑战红点
  1006. function championChallengeDot(human)
  1007. if human.db.lv < 9 then
  1008. return 0
  1009. end
  1010. -- 今日挑战次数小于免费次数,红点亮
  1011. if human.db.jjcDailyFight == nil or human.db.jjcDailyFight < JJC_FREE_DAILY_CNT then
  1012. return 1
  1013. end
  1014. return boxRewardDot(human)
  1015. end
  1016. -- 冠军联赛排行榜红点
  1017. function championBillboardDot(human)
  1018. if human.db.lv < 9 then
  1019. return 0
  1020. end
  1021. -- 今日膜拜次数小于3次,红点亮
  1022. if human.db.jjcWorship == nil or human.db.jjcWorship.count < JJC_WORSHIP_DOT_CNT then
  1023. return 1
  1024. end
  1025. return 0
  1026. end
  1027. function boxRewardDot(human)
  1028. if human.db.lv < 9 then
  1029. return 0
  1030. end
  1031. local seasonBox = JjcDB.getJjcSeasonBox(human.db._id)
  1032. local totalFight = JjcDB.getJjcTotalFight(human.db._id)
  1033. local len = #JjcExcel.seasonBox
  1034. for i = 1,len do
  1035. if not seasonBox or not seasonBox[i] then
  1036. if totalFight >= JjcExcel.seasonBox[i].reachCnt then
  1037. return 1
  1038. end
  1039. end
  1040. end
  1041. return 0
  1042. end