JjcLogic.lua 36 KB

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