JjcLogic.lua 36 KB

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