UIOpenServerInfo.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. ---@class UIOpenServerInfo
  2. UIOpenServerInfo = class()
  3. local this = UIOpenServerInfo
  4. function this:ctor()
  5. end
  6. function this:Reset()
  7. --self.isFirst=false
  8. --self.purchasedIds={}
  9. end
  10. function this:Init()
  11. --self.multiplierInfo={} --经验倍率信息
  12. --self.vipCfg = nil
  13. self:InitData()
  14. self:RegistMessages()
  15. end
  16. function this:InitData()
  17. end
  18. function this:RegistMessages()
  19. SL:RegisterLuaNetMsg(LuaMessageIdToClient.OPEN_SERVER_ACT_REWARD_CHANGE, self.ResUpdateRankingInfo)
  20. SL:RegisterLuaNetMsg(LuaMessageIdToClient.OPEN_SERVER_ACT_TYPE_RANK_INFO, self.ResUpdateOPENRankInfo)
  21. SL:RegisterLuaNetMsg(LuaMessageIdToClient.OPEN_SERVER_ACT_RANK_CHANGE, self.ResUpdatePersonalRankInfo)
  22. --self.messageContainer:Regist(MessageDef.ResEfficiencyMagnificationMessage, self.ResEfficiencyMagnificationMessage, self)
  23. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_OPEN_SERVER_FIRST_KILL_INFO, self.ResFirstkillInfo)
  24. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_GLOBAL_FIRST_KILL_CHANGE, self.ResBosskillChange)
  25. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_PERSONAL_FIRST_KILL_CHANGE, self.ResPalerBosskillInfo)
  26. end
  27. ---追加强化排行榜
  28. function this.ResUpdateOPENRankInfo(id,data)
  29. this.rankInfo = data
  30. end
  31. --排行奖励
  32. function this.ResUpdateRankingInfo(id,data)
  33. local myrid = SL:GetMetaValue(EMetaVarGetKey.MAIN_ACTOR_ID)
  34. if this.rankInfo and data.rankType == this.rankInfo.rank_type then
  35. local changedata = data.awardData
  36. local rankinfo = nil
  37. if changedata.award_type == 0 then
  38. this:ResUpdateRankingAndPersonalInfo(data)
  39. else
  40. if changedata.award_type == 1 and this.rankInfo.rank_list and this.rankInfo.rank_list.award_rank then
  41. rankinfo = this.rankInfo.rank_list.award_rank
  42. end
  43. if changedata.award_type == 2 and this.rankInfo.rank_list and this.rankInfo.rank_list.personal_rank then
  44. rankinfo = this.rankInfo.rank_list.personal_rank
  45. end
  46. if changedata and table.count(changedata) > 0 and rankinfo and table.count(rankinfo) > 0 then
  47. if table.getValue(rankinfo,tostring(data.goalValue)) then
  48. local taskTypeData = table.getValue(rankinfo,tostring(data.goalValue))
  49. if changedata.data and changedata.data.status then
  50. if taskTypeData and table.count(taskTypeData) > 0 then
  51. if changedata.award_type == 1 then
  52. for k, j in pairs(taskTypeData) do
  53. if j.rank_no == changedata.data.rank_no then
  54. j.status = changedata.data.status
  55. end
  56. end
  57. end
  58. if changedata.award_type == 2 then
  59. if taskTypeData.my_info.rank == changedata.data.rank then
  60. taskTypeData.my_info.status = changedata.data.status
  61. end
  62. end
  63. end
  64. end
  65. end
  66. end
  67. end
  68. end
  69. end
  70. ---竞技领取排行和个人,刷新数据
  71. function this:ResUpdateRankingAndPersonalInfo(data)
  72. local changedata = data.awardData
  73. local rankinfo = nil
  74. local Personalinfo = nil
  75. if this.rankInfo.rank_list and this.rankInfo.rank_list.award_rank then
  76. rankinfo = this.rankInfo.rank_list.award_rank
  77. end
  78. if this.rankInfo.rank_list and this.rankInfo.rank_list.personal_rank then
  79. Personalinfo = this.rankInfo.rank_list.personal_rank
  80. end
  81. if changedata and table.count(changedata) > 0 and rankinfo and table.count(rankinfo) > 0 then
  82. if table.getValue(rankinfo,tostring(data.goalValue)) then
  83. local taskTypeData = table.getValue(rankinfo,tostring(data.goalValue))
  84. local updatedata = nil
  85. if changedata.data and changedata.data.rank then
  86. updatedata = changedata.data.rank
  87. end
  88. if updatedata and updatedata.status then
  89. if taskTypeData and table.count(taskTypeData) > 0 then
  90. for k, j in pairs(taskTypeData) do
  91. if j.rank_no == updatedata.rank_no then
  92. j.status = updatedata.status
  93. end
  94. end
  95. end
  96. end
  97. end
  98. end
  99. if changedata and table.count(changedata) > 0 and Personalinfo and table.count(Personalinfo) > 0 then
  100. if table.getValue(Personalinfo,tostring(data.goalValue)) then
  101. local taskTypeData = table.getValue(Personalinfo,tostring(data.goalValue))
  102. local updatedata = nil
  103. if changedata.data and changedata.data.personal then
  104. updatedata = changedata.data.personal
  105. end
  106. if updatedata and updatedata.status then
  107. if taskTypeData and table.count(taskTypeData) > 0 then
  108. if taskTypeData.my_info.rank == updatedata.rank then
  109. taskTypeData.my_info.status = updatedata.status
  110. end
  111. end
  112. end
  113. end
  114. end
  115. end
  116. --个人奖励
  117. function this.ResUpdatePersonalRankInfo(id,data)
  118. local rankinfo = nil
  119. local myrid = SL:GetMetaValue(EMetaVarGetKey.MAIN_ACTOR_ID)
  120. --if this.rankInfo and data.rankType == this.rankInfo.rank_type then
  121. -- local changedata = data.goalChange.personal_rank_record
  122. -- if this.rankInfo.rank_list and this.rankInfo.rank_list.personal_rank then
  123. -- rankinfo = this.rankInfo.rank_list.personal_rank
  124. -- end
  125. -- if changedata and table.count(changedata) > 0 and rankinfo and table.count(rankinfo) > 0 then
  126. -- for k, v in pairs(rankinfo) do
  127. -- local personalData = table.getValue(changedata,tostring(k))
  128. -- if personalData then
  129. -- v.my_info = personalData.goal_info
  130. -- v.rank_size = personalData.rank_size
  131. -- end
  132. --
  133. -- end
  134. -- end
  135. --end
  136. end
  137. ---------------------------------------装备首曝-----------------------------------------------
  138. ---获取对应的状态和数量
  139. function this:GetRankAndNumByType(taskType,allnum)
  140. local myrid = SL:GetMetaValue(EMetaVarGetKey.MAIN_ACTOR_ID)
  141. local dataLv = nil
  142. local my_rank = 0
  143. local my_state = 0 ---个人奖励状态
  144. local usecount = 0 ---使用数量
  145. if this.rankInfo and this.rankInfo.rank_list and this.rankInfo.rank_list.personal_rank then
  146. local ranklist = this.rankInfo.rank_list.personal_rank
  147. if ranklist and taskType then
  148. dataLv = table.getValue(ranklist,tostring(taskType))
  149. end
  150. --local name,serstate,rid = this:GetRankNameBySort(taskType,1)
  151. if dataLv and table.count(dataLv) > 0 then
  152. usecount = dataLv.rank_size
  153. if dataLv.my_info then
  154. my_state = dataLv.my_info.status
  155. my_rank = dataLv.my_info.rank
  156. --if myrid == tostring(rid) then
  157. -- my_state = dataLv.my_info.status
  158. -- my_rank = dataLv.my_info.rank
  159. --else
  160. -- if dataLv.my_info.status >= 1 then
  161. -- my_state = 2
  162. -- end
  163. -- my_rank = dataLv.my_info.rank
  164. --end
  165. else
  166. if usecount >= allnum then
  167. my_state = 2
  168. end
  169. end
  170. end
  171. end
  172. return my_state,usecount,my_rank
  173. end
  174. --------------------------------------竞技排行----------------------------------------------------------
  175. ---等级竞技排行获取对应排行名称和状态
  176. --类型1 只获取自己的状态
  177. function this:GetRankNameBySort(taskType,sort,type)
  178. local myrid = SL:GetMetaValue(EMetaVarGetKey.MAIN_ACTOR_ID)
  179. local rankinfo = nil
  180. local name = "无"
  181. local state = 0
  182. local rid = nil
  183. if this.rankInfo and this.rankInfo.rank_list and this.rankInfo.rank_list.award_rank then
  184. local award_rank = this.rankInfo.rank_list.award_rank
  185. if award_rank and taskType then
  186. rankinfo = table.getValue(award_rank,tostring(taskType))
  187. end
  188. if rankinfo and table.count(rankinfo) > 0 then
  189. for i, v in pairs(rankinfo) do
  190. if v.rank_no == sort then
  191. name = v.name
  192. rid = v.rid
  193. if type == 1 then
  194. if myrid == tostring(v.rid) then
  195. state = v.status
  196. end
  197. else
  198. if myrid == tostring(v.rid) then
  199. state = v.status
  200. else
  201. if v.status >= 1 then
  202. state = 2
  203. end
  204. end
  205. end
  206. end
  207. end
  208. end
  209. end
  210. return name,state,rid
  211. end
  212. ---竞技叠加数据根据taskType 获取最新排名数据
  213. --function this:GetAthleticsUnGetMinSortData(data_list,data_type,minTasktype)
  214. -- local curnextType = nil
  215. -- local retdata = {} ---对应类型 ,排序
  216. -- ---初始默认排序数据
  217. -- if data_list and table.count(data_list) > 0 then
  218. -- for i, v in pairs(data_list) do
  219. -- if i == minTasktype then
  220. -- for k, j in pairs(v) do
  221. -- table.insert(retdata,{tasktype = i,sort = j.sort })
  222. -- end
  223. -- end
  224. -- end
  225. -- end
  226. -- ---最新未领取排序
  227. -- if retdata and table.count(retdata) > 0 then
  228. -- for i, v in pairs(retdata) do
  229. -- for k, j in pairs(data_type) do
  230. -- local curnextType = this:GetNextTaskType(data_type,v.tasktype)
  231. -- if curnextType then
  232. -- local nextType = this:GetMinNextType(v.tasktype,v.sort,curnextType)
  233. -- v.tasktype = nextType
  234. -- end
  235. -- end
  236. --
  237. -- end
  238. -- end
  239. -- return retdata
  240. --end
  241. ---获取表里下一类型
  242. --function this:GetNextTaskType(data_type,curtaskType)
  243. -- local curnextType = nil
  244. -- if data_type and table.count(data_type) > 0 then
  245. -- local maxtype = data_type[#data_type].taskType
  246. -- for i, v in pairs(data_type) do
  247. -- if v.taskType > curtaskType and v.taskType - curtaskType < maxtype then
  248. -- maxtype = v.taskType - curtaskType
  249. -- curnextType = v.taskType
  250. -- end
  251. -- end
  252. -- end
  253. -- return curnextType
  254. --end
  255. ---获取后端未领取下一类型
  256. --function this:GetMinNextType(tasktype,sort,curnextType)
  257. -- local nextType = tasktype
  258. -- local ranklist = {}
  259. -- if this.rankInfo and this.rankInfo.rank_list and this.rankInfo.rank_list.award_rank then
  260. -- ranklist = this.rankInfo.rank_list.award_rank
  261. -- end
  262. -- if ranklist and table.count(ranklist) > 0 then
  263. -- local datatype = table.getValue(ranklist,tostring(tasktype))
  264. -- if datatype and table.count(datatype) > 0 then
  265. -- if table.getValue(datatype,tostring(sort)) then
  266. -- local sortdata = table.getValue(datatype,tostring(sort))
  267. -- if sortdata.status == 2 then
  268. -- ---已领取,获取下一等级
  269. -- nextType = curnextType
  270. -- end
  271. -- end
  272. -- end
  273. -- end
  274. -- return nextType
  275. --end
  276. ---个人奖励未领取且有次数的最小taskType
  277. function this:GetUnGetMinlimiteLv(maxlimiteLv,mixlimiteLv,personal_list)
  278. local limiteLv = maxlimiteLv
  279. local sortrank = 0 --排行
  280. local mystatus = 0 --状态
  281. local usecount = 0 --使用次数
  282. local Arr = {}
  283. if personal_list and table.count(personal_list) > 0 then
  284. for i, v in pairs(personal_list) do
  285. local Lvtype = v.taskType[1]
  286. local allnum = v.taskType[2]
  287. local ranklist = this.rankInfo.rank_list.personal_rank
  288. local my_state = 0
  289. local my_rank = 0
  290. local isExtrank_list = true
  291. if table.getValue(ranklist,tostring(Lvtype)) then
  292. local dataLv = table.getValue(ranklist,tostring(Lvtype))
  293. if dataLv then
  294. usecount = dataLv.rank_size
  295. if dataLv.my_info then
  296. my_state = dataLv.my_info.status
  297. my_rank = dataLv.my_info.rank
  298. else
  299. if usecount >= allnum then
  300. my_state = 2
  301. end
  302. end
  303. end
  304. if my_state == 2 then
  305. isExtrank_list = false ---不可领取 或已领取
  306. end
  307. end
  308. table.insert(Arr,{typeLv = Lvtype,isExt = isExtrank_list,state = my_state,rank = my_rank,count = usecount })
  309. end
  310. end
  311. if Arr and table.count(Arr) > 0 then
  312. table.sort(Arr, function(a, b)
  313. return a.typeLv < b.typeLv
  314. end)
  315. local iscanget = true
  316. for i, v in pairs(Arr) do
  317. if v.isExt and v.typeLv <= limiteLv then
  318. limiteLv = v.typeLv
  319. usecount = v.count
  320. mystatus = v.state
  321. sortrank = v.rank
  322. iscanget = false
  323. elseif not v.isExt and v.typeLv == maxlimiteLv and iscanget then
  324. limiteLv = maxlimiteLv
  325. usecount = v.count
  326. mystatus = v.state
  327. sortrank = v.rank
  328. end
  329. end
  330. end
  331. return limiteLv,mystatus,sortrank,usecount
  332. end
  333. ------------------------------------------------追加强化------------------------------------------------------------------------
  334. ---根据任务类型获取前三名称和状态 type:1 名称 2 状态
  335. function this:GetRankNameBytaskType(taskType,type)
  336. local rankinfo = nil
  337. local myrid = SL:GetMetaValue(EMetaVarGetKey.MAIN_ACTOR_ID)
  338. local fist_name = "无"
  339. local second_name = "无"
  340. local third_name = "无"
  341. local fist_state = 0
  342. local second_state = 0
  343. local third_state = 0
  344. if this.rankInfo and this.rankInfo.rank_list and this.rankInfo.rank_list.award_rank then
  345. local award_rank = this.rankInfo.rank_list.award_rank
  346. if award_rank and taskType then
  347. rankinfo = table.getValue(award_rank,tostring(taskType))
  348. end
  349. if rankinfo and table.count(rankinfo) > 0 then
  350. ---前三排行
  351. for i, v in pairs(rankinfo) do
  352. if v.rank_no == 1 then
  353. fist_name = v.name
  354. if myrid == tostring(v.rid) then
  355. fist_state = v.status
  356. elseif myrid ~= tostring(v.rid) and v.status >= 1 then
  357. fist_state = 2
  358. end
  359. elseif v.rank_no == 2 then
  360. second_name = v.name
  361. if myrid == tostring(v.rid) then
  362. second_state = v.status
  363. elseif myrid ~= tostring(v.rid) and v.status >= 1 then
  364. second_state = 2
  365. end
  366. elseif v.rank_no == 3 then
  367. third_name = v.name
  368. if myrid == tostring(v.rid) then
  369. third_state = v.status
  370. elseif myrid ~= tostring(v.rid) and v.status >= 1 then
  371. third_state = 2
  372. end
  373. end
  374. end
  375. end
  376. end
  377. if type==1 then
  378. return fist_name,second_name,third_name
  379. elseif type==2 then
  380. return fist_state,second_state,third_state
  381. end
  382. end
  383. ---获取总次数
  384. function this:GetAllCountlimite(ranking_id,limiteLv)
  385. local cfg = SL:FindConfigs("cfg_newarea_ranking","id",ranking_id)
  386. local reward_list = SL:FindConfigs("cfg_newarea_personalreward","group",cfg[1].subtype)
  387. local allnum = 0
  388. local data = nil
  389. for i, v in pairs(reward_list) do
  390. if v.taskType[1] == limiteLv then
  391. allnum = v.taskType[2]
  392. data = v
  393. end
  394. end
  395. return allnum,data
  396. end
  397. -----------------------------------------------------------------------------------------
  398. ---全服和个人首杀信息
  399. function this.ResFirstkillInfo(id,data)
  400. this.firstkillinfo = data
  401. end
  402. ---全服首杀变化
  403. function this.ResBosskillChange(id,data)
  404. local killids = {}
  405. if data and table.count(data) > 0 then
  406. if this.firstkillinfo and data.group then
  407. killids = table.getValue(this.firstkillinfo.global,tostring(data.group))
  408. end
  409. end
  410. if killids and data.monsterCfgId and table.getValue(killids,tostring(data.monsterCfgId)) then
  411. killids[tostring(data.monsterCfgId)] = data.killInfo
  412. end
  413. end
  414. ---个人首杀变化
  415. function this.ResPalerBosskillInfo(id,data)
  416. local killids = {}
  417. if data and table.count(data) > 0 then
  418. if this.firstkillinfo and data.group then
  419. killids = table.getValue(this.firstkillinfo.personal,tostring(data.group))
  420. end
  421. end
  422. if killids and data.monsterCfgId and table.getValue(killids,tostring(data.monsterCfgId)) then
  423. killids[tostring(data.monsterCfgId)] = data.status
  424. end
  425. end
  426. ---根据组和id 获取个人领取状态
  427. function this:GetNomStateByBossInfo(boss_group,boss_id)
  428. local state = 0 ---奖励领取状态:0 正常 1 可领取 2 已领取
  429. local killids = nil ---同组id
  430. local firstkillinfo = this.firstkillinfo
  431. if firstkillinfo and boss_group then
  432. killids = table.getValue(firstkillinfo.personal,tostring(boss_group))
  433. end
  434. if killids and boss_id and table.getValue(killids,tostring(boss_id)) then
  435. state = table.getValue(killids,tostring(boss_id)) --1 可领取 2 已领取
  436. end
  437. return state
  438. end
  439. ---根据组和id 获取全服首杀领取状态
  440. ---type=1 or nil 状态 type=2 name type=3 使用数量
  441. function this:GetSerStateOrNameByBossInfo(boss_group,boss_id,type)
  442. local myrid = SL:GetMetaValue(EMetaVarGetKey.MAIN_ACTOR_ID)
  443. local personal_count = 0 ---使用次数
  444. local hurt_name = "无"
  445. local kill_name = "无"
  446. local hurt_state = 0 ---奖励领取状态:0 正常 1 可领取 2 已领取
  447. local kill_state = 0 ---奖励领取状态:0 正常 1 可领取 2 已领取
  448. local killids = nil ---同组id
  449. local firstkillinfo = this.firstkillinfo
  450. if firstkillinfo and boss_group then
  451. killids = table.getValue(firstkillinfo.global,tostring(boss_group))
  452. end
  453. if killids and boss_id and table.getValue(killids,tostring(boss_id)) then
  454. local data = table.getValue(killids,tostring(boss_id)) ---伤害信息
  455. personal_count = data.personal_count
  456. for i, v in pairs(data) do
  457. if i == "hurt" then
  458. hurt_name = v.name
  459. if myrid == tostring(v.rid) then
  460. hurt_state = v.status
  461. else
  462. if v.status >= 1 then
  463. hurt_state = 2
  464. end
  465. end
  466. elseif i == "kill" then
  467. kill_name = v.name
  468. if myrid == tostring(v.rid) then
  469. kill_state = v.status
  470. else
  471. if v.status >= 1 then
  472. kill_state = 2
  473. end
  474. end
  475. end
  476. end
  477. end
  478. if type and type == 2 then
  479. return hurt_name,kill_name
  480. elseif type and type == 3 then
  481. return personal_count
  482. else
  483. return hurt_state,kill_state
  484. end
  485. end
  486. -------------------------------------------------------------------
  487. ---活动结束倒计时
  488. function this:GetLeftTimeByRankingId(ranking_id)
  489. local lefttime = 0
  490. local serverTime = Time.GetServerTime()
  491. local openServerTime = SL:GetEnterRoleRes().openServerTime ---开服时间
  492. local ONE_DAY_MILLISECOND = 86400000 ---一天毫秒数
  493. local cfg = SL:FindConfigs("cfg_newarea_ranking","id",ranking_id)
  494. local endTime = (cfg[1].endTime[1] - 1) * ONE_DAY_MILLISECOND + openServerTime
  495. lefttime = endTime - serverTime
  496. return lefttime
  497. end