JjcLogic.lua 36 KB

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