JjcLogic.lua 38 KB

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