GuildData.lua 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  1. local GuildData = class('GuildData')
  2. function TableRemove(ls, value)
  3. for i = #ls, 1, -1 do
  4. if ls[i] == value then
  5. table.remove(ls, i)
  6. end
  7. end
  8. end
  9. local MemberSort = function(a, b)
  10. if a.brief.post == b.brief.post then
  11. if a.brief.offlineTime == b.brief.offlineTime then
  12. return a.brief.uid < b.brief.uid
  13. else
  14. if a.brief.offlineTime == 0 then
  15. return true
  16. elseif b.brief.offlineTime == 0 then
  17. return false
  18. else
  19. return a.brief.offlineTime > b.brief.offlineTime
  20. end
  21. end
  22. else
  23. return a.brief.post > b.brief.post
  24. end
  25. end
  26. local AuditApplySort = function(a, b)
  27. if a.playerBrief.onlineState == b.playerBrief.onlineState then
  28. if a.playerBrief.onlineTime == b.playerBrief.onlineTime then
  29. if a.playerBrief.fightPower == b.playerBrief.fightPower then
  30. return a.playerBrief.uid < b.playerBrief.uid
  31. else
  32. return a.playerBrief.fightPower > b.playerBrief.fightPower
  33. end
  34. else
  35. return a.playerBrief.onlineTime > b.playerBrief.onlineTime
  36. end
  37. else
  38. return a.playerBrief.onlineState
  39. end
  40. end
  41. local LogSort = function(a, b)
  42. return b.time < a.time
  43. end
  44. function GuildData:ctor()
  45. end
  46. function GuildData:Dispose()
  47. self:ClearGuildData()
  48. self.isSubmitApply = nil -- 是否申请过加入该公会
  49. self.nextCDTime = nil -- 下一次可加入公会的时间戳
  50. end
  51. function GuildData:SetBriefData(msg)
  52. if not msg then return end
  53. local brief = self.brief
  54. if not brief then
  55. brief = {}
  56. self.brief = brief
  57. end
  58. brief.id = msg.guild_id
  59. brief.name = msg.guild_name
  60. brief.badge = msg.guild_badge
  61. brief.level = msg.guild_level
  62. brief.active = msg.guild_active
  63. if brief.badge then
  64. local badgeCfgData = ManagerContainer.CfgMgr:GetGuildBadgeCfgById(brief.badge)
  65. if badgeCfgData then
  66. brief.badgeResPath = badgeCfgData.Pic
  67. end
  68. end
  69. if brief.level then
  70. local lvCfgData = ManagerContainer.CfgMgr:GetGuildLvCfgById(brief.level)
  71. if lvCfgData then
  72. self.memberLimit = lvCfgData.PeopleLimit
  73. brief.activeLimit = lvCfgData.ActiveLimit
  74. end
  75. end
  76. end
  77. function GuildData:SetMemberNum(msg)
  78. self.memberNum = msg
  79. end
  80. function GuildData:SetSubmitApply(msg)
  81. self.isSubmitApply = msg
  82. end
  83. function GuildData:SetHasApply(msg)
  84. self.isHasApply = msg
  85. end
  86. function GuildData:SetNextCDTime(msg)
  87. self.nextCDTime = msg
  88. end
  89. function GuildData:SetNotifyData(msg)
  90. if not msg then return end
  91. self:SetBriefData(msg.brief)
  92. self:SetMemberNum(msg.mem_count)
  93. self:SetSubmitApply(msg.is_apply)
  94. end
  95. function GuildData:SetBaseData(msg)
  96. if not msg then return end
  97. self:SetBriefData(msg.guild_brief)
  98. local base = self.base
  99. if not base then
  100. base = {}
  101. self.base = base
  102. end
  103. base.exp = msg.guild_exp or 0
  104. base.activeDay = msg.day_active or 0
  105. base.notice = msg.notice
  106. base.activeTime = msg.active_time
  107. base.recuritType = msg.recruit_type
  108. base.recuritLevel = msg.recruit_level
  109. base.recruitNotice = msg.recruit_notice
  110. if self.brief.level then
  111. local lvCfgData = ManagerContainer.CfgMgr:GetGuildLvCfgById(self.brief.level)
  112. if lvCfgData then
  113. base.expLimit = lvCfgData.ExpRequire
  114. end
  115. end
  116. if not base.expLimit then
  117. base.expLimit = 0
  118. end
  119. end
  120. function GuildData:SetMemberBriefDatas(msg)
  121. if not msg then return end
  122. self.members = {}
  123. self.memberMap = {}
  124. for _, value in pairs(msg) do
  125. local memberBrief = {
  126. uid = value.uid,
  127. offlineTime = value.offline_time,
  128. post = value.title,
  129. }
  130. if self.memberMap[memberBrief.uid] then
  131. self.memberMap[memberBrief.uid].brief = memberBrief
  132. else
  133. local member = {}
  134. member.brief = memberBrief
  135. self.members[#self.members + 1] = member
  136. self.memberMap[memberBrief.uid] = member
  137. end
  138. end
  139. self.memberNum = #self.members
  140. table.sort(self.members, MemberSort)
  141. end
  142. function GuildData:SetMemberInfoDatas(msg)
  143. if not msg then return end
  144. if not self.members or not self.memberMap then return end
  145. for _, value in pairs(msg) do
  146. local brief = value.brief
  147. if brief then
  148. local uid = brief.uid
  149. local member = self.memberMap[uid]
  150. if member then
  151. member.playerBrief = ProtocalDataNormal.ParsePlayerBriefInfo(brief)
  152. member.active = value.total_active
  153. end
  154. end
  155. end
  156. end
  157. function GuildData:SetRoleGuildData(msg, active)
  158. if not msg then return end
  159. local id = msg.guild_id
  160. if id ~= self.brief.id then
  161. return
  162. end
  163. self.nextCDTime = msg.next_join
  164. local role = self.role
  165. if not role then
  166. role = {}
  167. self.role = role
  168. end
  169. local activeInfo = msg.guild_active
  170. if activeInfo then
  171. role.activeTotal = activeInfo.active_value
  172. role.activeDay = activeInfo.day_active_value
  173. role.activeUpdateTime = activeInfo.active_time
  174. else
  175. role.activeTotal = 0
  176. role.activeDay = 0
  177. role.activeUpdateTime = 0
  178. end
  179. role.active = active
  180. role.quitNum = msg.quit_num
  181. end
  182. function GuildData:SetGuildQuitData(quitNum, nextCDTime)
  183. local changed = false
  184. if self.nextCDTime ~= nextCDTime then
  185. self.nextCDTime = nextCDTime
  186. changed = true
  187. end
  188. if self.role then
  189. if self.role.quitNum ~= quitNum then
  190. self.role.quitNum = quitNum
  191. changed = true
  192. end
  193. end
  194. return changed
  195. end
  196. function GuildData:ChangeMemberPost(uid, post)
  197. if not self.members or not self.memberMap then return false end
  198. local member = self.memberMap[uid]
  199. if not member then return false end
  200. local brief = member.brief
  201. if not brief then return false end
  202. if brief.post == post then return false end
  203. brief.post = post
  204. table.sort(self.members, MemberSort)
  205. return true
  206. end
  207. function GuildData:KickMember(uid)
  208. if not self.members or not self.memberMap then return false end
  209. local member = self.memberMap[uid]
  210. if not member then return false end
  211. for i = #self.members, 1, -1 do
  212. if self.members[i] == member then
  213. table.remove(self.members, i)
  214. break
  215. end
  216. end
  217. self.memberNum = #self.members
  218. self.memberMap[uid] = nil
  219. return true
  220. end
  221. function GuildData:SetGuildName(newName)
  222. if not self.brief then return false end
  223. if self.brief.name == newName then return false end
  224. self.brief.name = newName
  225. return true
  226. end
  227. function GuildData:SetGuildNotice(newNotice)
  228. if not self.base then return false end
  229. if self.base.notice == newNotice then return false end
  230. self.base.notice = newNotice
  231. return true
  232. end
  233. function GuildData:SetGuildBadge(newBadge)
  234. if not self.brief then return false end
  235. if self.brief.badge == newBadge then return false end
  236. self.brief.badge = newBadge
  237. local badgeCfgData = ManagerContainer.CfgMgr:GetGuildBadgeCfgById(newBadge)
  238. if badgeCfgData then
  239. self.brief.badgeResPath = badgeCfgData.Pic
  240. end
  241. return true
  242. end
  243. function GuildData:SetGuildRecuitInfo(recuritType, recuritLevel, recruitNotice)
  244. if not self.base then return false end
  245. if self.base.recuritType == recuritType
  246. and self.base.recuritLevel == recuritLevel
  247. and self.base.recruitNotice == recruitNotice then
  248. return false
  249. end
  250. self.base.recuritType = recuritType
  251. self.base.recuritLevel = recuritLevel
  252. self.base.recruitNotice = recruitNotice
  253. return true
  254. end
  255. function GuildData:SetAuditApplyData(uidList)
  256. if not uidList then
  257. self.isHasApply = false
  258. return
  259. end
  260. local dataMap = {}
  261. local datas = {}
  262. if uidList then
  263. for i = 1, #uidList do
  264. local uid = uidList[i]
  265. local data = {}
  266. data.uid = uid
  267. dataMap[uid] = data
  268. datas[#datas + 1] = data
  269. end
  270. end
  271. self.auditApplys = datas
  272. self.auditApplyMap = dataMap
  273. self.isHasApply = (#self.auditApplys > 0)
  274. end
  275. function GuildData:SetAuditApplyPlayBrief(playerBriefs)
  276. if not playerBriefs then return end
  277. if not self.auditApplys or not self.auditApplyMap then return nil end
  278. for i = 1, #playerBriefs do
  279. local playerBrief = playerBriefs[i]
  280. local uid = playerBrief.uid
  281. local auditApply = self.auditApplyMap[uid]
  282. if auditApply then
  283. auditApply.playerBrief = ProtocalDataNormal.ParsePlayerBriefInfo(playerBrief)
  284. end
  285. end
  286. if self.auditLoadings then
  287. for i = #self.auditLoadings, 1, -1 do
  288. local loadUid = self.auditLoadings[i]
  289. local auditApply = self.auditApplyMap[loadUid]
  290. if auditApply and not auditApply.playerBrief then
  291. self.auditApplyMap[loadUid] = nil
  292. TableRemove(self.auditApplys, auditApply)
  293. end
  294. end
  295. end
  296. self.isHasApply = (#self.auditApplys > 0)
  297. self.auditLoadings = {}
  298. end
  299. ---@return integer 0:无变化;1:删除了申请;2:公会成员有变化;3:无变化
  300. function GuildData:SetAuditApplyHandle(handleType, uidList)
  301. if not self.auditApplys or not self.auditApplyMap then return 0 end
  302. local errorCode = nil
  303. if handleType == Enum.GuildAduitApplyHandleType.AllRefuse then
  304. self.auditApplys = nil
  305. self.auditApplyMap = nil
  306. self.isHasApply = false
  307. return 1, errorCode
  308. else
  309. local auditApplyChanged = false
  310. local memberChanged = false
  311. if uidList then
  312. for _, value in pairs(uidList) do
  313. local uid = value.key
  314. local applyType = value.value
  315. errorCode = value.value2
  316. local auditApply = self.auditApplyMap[uid]
  317. if auditApply and applyType ~= Enum.GuildAduitApplyType.Untreated then
  318. self.auditApplyMap[uid] = nil
  319. TableRemove(self.auditApplys, auditApply)
  320. auditApplyChanged = true
  321. end
  322. if applyType == Enum.GuildAduitApplyType.Allow then
  323. if self.members and self.memberMap then
  324. if not self.memberMap[uid] then
  325. local memberBrief = {
  326. uid = uid,
  327. post = Enum.GuildPostType.None,
  328. }
  329. if auditApply then
  330. if auditApply.playerBrief then
  331. if auditApply.playerBrief.onlineState then
  332. memberBrief.offlineTime = 0
  333. else
  334. memberBrief.offlineTime = auditApply.playerBrief.onlineTime
  335. end
  336. else
  337. memberBrief.offlineTime = 0
  338. end
  339. else
  340. memberBrief.offlineTime = 0
  341. end
  342. local member = {}
  343. member.brief = memberBrief
  344. self.members[#self.members + 1] = member
  345. self.memberMap[uid] = member
  346. memberChanged = true
  347. end
  348. end
  349. end
  350. end
  351. end
  352. self.isHasApply = (#self.auditApplys > 0)
  353. if memberChanged then
  354. if self.members and self.memberMap then
  355. self.memberNum = #self.members
  356. table.sort(self.members, MemberSort)
  357. end
  358. return 2, (handleType == Enum.GuildAduitApplyHandleType.One and errorCode or nil)
  359. else
  360. return auditApplyChanged and 1 or 3, (handleType == Enum.GuildAduitApplyHandleType.One and errorCode or nil)
  361. end
  362. end
  363. end
  364. ---@return boolean,boolean|nil,boolean|nil
  365. function GuildData:SetLogs(logs, isEnd)
  366. local addStart = false
  367. local add = false
  368. local addEnd = false
  369. if isEnd then
  370. if self.logWhole ~= isEnd then
  371. self.logWhole = isEnd
  372. addEnd = true
  373. end
  374. end
  375. if not logs then return add, addStart, addEnd end
  376. local len = #logs
  377. if len <= 0 then return add, addStart, addEnd end
  378. if not self.logs then
  379. self.logs = {}
  380. end
  381. local exitLen = #self.logs
  382. local startTime = nil
  383. local endTime = nil
  384. if self.logs[1] then
  385. startTime = self.logs[1].time
  386. end
  387. if self.logs[exitLen] then
  388. endTime = self.logs[exitLen].time
  389. end
  390. for i = 1, len do
  391. local log = logs[i]
  392. local needAdd = true
  393. if startTime and int64.__lt(startTime, log.event_time) then
  394. addStart = true
  395. elseif endTime and int64.__lt(log.event_time, endTime) then
  396. addEnd = true
  397. else
  398. -- 这时候就需要查看是否列表中已存在
  399. for j = 1, exitLen do
  400. if int64.equals(self.logs[j].time, log.event_time) then
  401. needAdd = false
  402. break
  403. end
  404. end
  405. end
  406. if needAdd then
  407. add = true
  408. self.logs[#self.logs + 1] = {
  409. opPost = log.op_title,
  410. opName = CommonUtil.GetVaildNickName(log.op_name),
  411. beOpPost = log.be_op_title,
  412. beOpName = CommonUtil.GetVaildNickName(log.be_op_name),
  413. type = log.event_type,
  414. time = log.event_time,
  415. }
  416. end
  417. end
  418. if add then
  419. table.sort(self.logs, LogSort)
  420. end
  421. return add, addStart, addEnd
  422. end
  423. function GuildData:SetHuntBossList(huntBossMsgs, huntBossExts, huntBossCd)
  424. self.huntBossCd = huntBossCd
  425. if not huntBossMsgs then return end
  426. local huntBossMap = self.huntBossMap
  427. if not huntBossMap then
  428. huntBossMap = {}
  429. self.huntBossMap = huntBossMap
  430. end
  431. for i = 1, #huntBossMsgs do
  432. local huntBossMsg = huntBossMsgs[i]
  433. if huntBossMsg then
  434. local huntBoss = {
  435. id = huntBossMsg.boss_id,
  436. fightTime = huntBossMsg.fight_time,
  437. fightCdTime = huntBossMsg.fight_cd_time
  438. }
  439. if huntBossMap[huntBoss.id] then
  440. LogWarning('[Wboy] Exist Some Boss lastBoss : ' .. Inspect(huntBossMap[huntBoss.id]) .. '\ncurBoss : ' .. Inspect(huntBoss))
  441. end
  442. huntBossMap[huntBoss.id] = huntBoss
  443. end
  444. end
  445. for i = 1, #huntBossExts do
  446. local huntBossExt = huntBossExts[i]
  447. if huntBossExt then
  448. if huntBossMap[huntBossExt.key] then
  449. huntBossMap[huntBossExt.key].remainNum = huntBossExt.value
  450. end
  451. end
  452. end
  453. end
  454. function GuildData:SetHuntBossInfo(bossId, guildActive, fightTime, remainNum)
  455. if self.brief then
  456. self.brief.active = guildActive
  457. end
  458. if not self.huntBossMap then return end
  459. local huntBoss = self.huntBossMap[bossId]
  460. if not huntBoss then
  461. huntBoss = {}
  462. huntBoss.id = bossId
  463. self.huntBossMap[bossId] = huntBoss
  464. end
  465. huntBoss.fightTime = fightTime
  466. huntBoss.fightCdTime = 0
  467. if remainNum then
  468. huntBoss.remainNum = remainNum
  469. end
  470. end
  471. ---@return boolean,boolean|nil,boolean|nil
  472. function GuildData:SetHuntBossLogs(bossId, huntBossLogMsgs, isEnd)
  473. local addStart = false
  474. local add = false
  475. local addEnd = false
  476. if not self.huntBossMap then return add, addStart, addEnd end
  477. local huntBoss = self.huntBossMap[bossId]
  478. if not huntBoss then return add, addStart, addEnd end
  479. local logInfo = huntBoss.logInfo
  480. if not logInfo then
  481. logInfo = {}
  482. huntBoss.logInfo = logInfo
  483. end
  484. if isEnd then
  485. if logInfo.logWhole ~= isEnd then
  486. logInfo.logWhole = isEnd
  487. end
  488. end
  489. if not huntBossLogMsgs then return add, addStart, addEnd end
  490. local len = #huntBossLogMsgs
  491. if len <= 0 then return add, addStart, addEnd end
  492. local logs = logInfo.logs
  493. if not logs then
  494. logs = {}
  495. logInfo.logs = logs
  496. end
  497. local exitLen = #logs
  498. local startTime = nil
  499. local endTime = nil
  500. if logs[1] then
  501. startTime = logs[1].time
  502. end
  503. if logs[exitLen] then
  504. endTime = logs[exitLen].time
  505. end
  506. for i = 1, len do
  507. local huntBossLogMsg = huntBossLogMsgs[i]
  508. local fightLog = huntBossLogMsg.fight_log
  509. if fightLog then
  510. local needAdd = true
  511. if startTime and int64.__lt(startTime, fightLog.fight_time) then
  512. addStart = true
  513. elseif endTime and int64.__lt(fightLog.fight_time, endTime) then
  514. addEnd = true
  515. else
  516. -- 这时候就需要查看是否列表中已存在
  517. for j = 1, exitLen do
  518. if int64.equals(logs[j].time, fightLog.fight_time) then
  519. needAdd = false
  520. break
  521. end
  522. end
  523. end
  524. if needAdd then
  525. add = true
  526. local log = {}
  527. log.playerBrief = ProtocalDataNormal.ParsePlayerBriefInfo(huntBossLogMsg.info)
  528. log.uid = fightLog.uid
  529. log.time = fightLog.fight_time
  530. log.damage = fightLog.damage
  531. logs[#logs + 1] = log
  532. end
  533. end
  534. end
  535. if add then
  536. table.sort(logs, LogSort)
  537. end
  538. return add, addStart, addEnd
  539. end
  540. function GuildData:SetHuntBossMasterReward(bossId, brief, damage)
  541. if not self.huntBossMap then return end
  542. local huntBoss = self.huntBossMap[bossId]
  543. if not huntBoss then return end
  544. local masterReward = huntBoss.masterReward
  545. if not masterReward then
  546. masterReward = {}
  547. huntBoss.masterReward = masterReward
  548. end
  549. masterReward.playerBrief = ProtocalDataNormal.ParsePlayerBriefInfo(brief)
  550. masterReward.damage = damage
  551. end
  552. function GuildData:SetGuildWarInfo(curState, nextStateTime, cp, rank)
  553. local guildWarInfo = self.guildWarInfo
  554. if guildWarInfo and guildWarInfo.curState == curState
  555. and guildWarInfo.nextStateTime == nextStateTime
  556. and guildWarInfo.cp == cp
  557. and guildWarInfo.rank == rank then
  558. return false
  559. end
  560. if not guildWarInfo then
  561. guildWarInfo = {}
  562. self.guildWarInfo = guildWarInfo
  563. end
  564. guildWarInfo.curState = curState
  565. guildWarInfo.nextStateTime = nextStateTime
  566. guildWarInfo.cp = cp
  567. guildWarInfo.rank = rank
  568. return true
  569. end
  570. function GuildData:GetValidMemberNum()
  571. local num = 0
  572. for i = 1, #self.members do
  573. local member = self.members[i]
  574. if member.playerBrief then
  575. num = num + 1
  576. end
  577. end
  578. return num
  579. end
  580. function GuildData:GetNextLoadMemberUid(loadNum)
  581. if not self.members or not self.memberMap then return nil end
  582. local ls = {}
  583. for i = 1, #self.members do
  584. local member = self.members[i]
  585. if not member.playerBrief then
  586. ls[#ls + 1] = member.brief.uid
  587. if #ls >= loadNum then
  588. break
  589. end
  590. end
  591. end
  592. return ls
  593. end
  594. function GuildData:GetNeedLoadMemberMoreInfo(startIdx, endIdx)
  595. if not self.members or not self.memberMap then return nil end
  596. local uids = {}
  597. for i = startIdx, endIdx do
  598. local member = self.members[i]
  599. if member and not member.playerBrief then
  600. uids[#uids + 1] = member.brief.uid
  601. end
  602. end
  603. return uids
  604. end
  605. function GuildData:GetMemberMoreInfoByidx(idx)
  606. if not self.members or not self.memberMap then return nil end
  607. return self.members[idx]
  608. end
  609. function GuildData:GetMemberMoreInfoByUid(uid)
  610. if not self.members or not self.memberMap then return nil end
  611. return self.memberMap[uid]
  612. end
  613. function GuildData:GetId()
  614. return self.brief and self.brief.id or 0
  615. end
  616. function GuildData:GetName()
  617. return self.brief and self.brief.name or nil
  618. end
  619. function GuildData:IsSameGuild(id)
  620. if not id then return false end
  621. if self.brief then
  622. if self.brief.id then
  623. return self.brief.id == id
  624. end
  625. end
  626. return false
  627. end
  628. function GuildData:GetBriefData()
  629. return self.brief
  630. end
  631. function GuildData:GetBaseData()
  632. return self.base
  633. end
  634. function GuildData:GetRoleData()
  635. return self.role
  636. end
  637. function GuildData:GetGuildMemberNum()
  638. return self.memberNum or 0
  639. end
  640. function GuildData:GetGuildMemberLimit()
  641. return self.memberLimit or 0
  642. end
  643. function GuildData:GetGuildMemberPost(uid)
  644. if not self.members or not self.memberMap then return Enum.GuildPostType.None end
  645. local member = self.memberMap[uid]
  646. if not member then return Enum.GuildPostType.None end
  647. local brief = member.brief
  648. if not brief then return Enum.GuildPostType.None end
  649. return brief.post or Enum.GuildPostType.None
  650. end
  651. function GuildData:ClearGuildData()
  652. self.brief = nil
  653. self.base = nil
  654. self.members = nil
  655. self.memberMap = nil
  656. self.memberNum = nil
  657. self.memberLimit = nil
  658. self.role = nil
  659. self.isHasApply = nil
  660. self:ClearAuditApplyData()
  661. self:ClearLogs()
  662. self:ClearHuntBoss()
  663. self:ClearGuildWarInfo()
  664. end
  665. function GuildData:GetIsSubmitApply()
  666. return self.isSubmitApply
  667. end
  668. function GuildData:GetIsHasApply()
  669. return self.isHasApply
  670. end
  671. function GuildData:GetNextCDTime()
  672. return self.nextCDTime
  673. end
  674. function GuildData:GetNextLoadAuditApplyUids(loadNum)
  675. if self.auditLoadings and #self.auditLoadings > 0 then return nil end
  676. if not self.auditApplys or not self.auditApplyMap then return nil end
  677. if not self.auditLoadings then self.auditLoadings = {} end
  678. for i = 1, #self.auditApplys do
  679. local auditApply = self.auditApplys[i]
  680. if not auditApply.playerBrief then
  681. self.auditLoadings[#self.auditLoadings + 1] = auditApply.uid
  682. if #self.auditLoadings >= loadNum then
  683. break
  684. end
  685. end
  686. end
  687. if not self.auditLoadings or #self.auditLoadings <= 0 then
  688. table.sort(self.auditApplys, AuditApplySort)
  689. end
  690. return self.auditLoadings
  691. end
  692. function GuildData:GetNextAuditApplyById(idx)
  693. if not self.auditApplys or not self.auditApplyMap then return nil end
  694. return self.auditApplys[idx]
  695. end
  696. function GuildData:GetAuditApplys()
  697. return self.auditApplys
  698. end
  699. function GuildData:GetAuditApplyUids()
  700. if not self.auditApplys or not self.auditApplyMap then return nil end
  701. local uids = {}
  702. for uid, _ in pairs(self.auditApplyMap) do
  703. uids[#uids + 1] = uid
  704. end
  705. return uids
  706. end
  707. function GuildData:GetAuditApplyNum()
  708. if not self.auditApplys or not self.auditApplyMap then return 0 end
  709. return #self.auditApplys
  710. end
  711. function GuildData:ClearAuditApplyData()
  712. self.auditLoadings = nil
  713. self.auditApplys = nil
  714. self.auditApplyMap = nil
  715. end
  716. function GuildData:GetReloadLogStartTime()
  717. return 0
  718. end
  719. function GuildData:GetNextLoadLogStartTime()
  720. if self.logWhole then return nil end
  721. if self.logs then
  722. local log = self.logs[#self.logs]
  723. if log and log.time then
  724. return log.time
  725. end
  726. end
  727. return self:GetReloadLogStartTime()
  728. end
  729. function GuildData:GetLogById(idx)
  730. if not self.logs then return nil end
  731. return self.logs[idx]
  732. end
  733. function GuildData:GetLogs()
  734. return self.logs
  735. end
  736. function GuildData:GetLogNum()
  737. if not self.logs then return 0 end
  738. return #self.logs
  739. end
  740. function GuildData:GetLogWhole()
  741. return self.logWhole
  742. end
  743. function GuildData:ClearLogs()
  744. self.logs = nil
  745. self.logWhole = nil
  746. end
  747. function GuildData:GetHuntBossInfoById(id)
  748. if not self.huntBossMap then return end
  749. return self.huntBossMap[id]
  750. end
  751. function GuildData:GetHuntBossCd()
  752. return self.huntBossCd
  753. end
  754. function GuildData:ClearHuntBoss()
  755. if self.huntBossMap then
  756. for key, _ in pairs(self.huntBossMap) do
  757. self:ClearHuntBossLogs(key)
  758. self:ClearHuntBossMasterReward(key)
  759. end
  760. end
  761. self.huntBossMap = nil
  762. self.huntBossCd = nil
  763. end
  764. function GuildData:GetReloadHuntBossLogStartTime(id)
  765. if not self:GetHuntBossInfoById(id) then return nil end
  766. return 0
  767. end
  768. function GuildData:GetNextLoadHuntBossLogStartTime(id)
  769. local huntBoss = self:GetHuntBossInfoById(id)
  770. if not huntBoss then return nil end
  771. local logInfo = huntBoss.logInfo
  772. if not logInfo then return nil end
  773. if logInfo.logWhole then return nil end
  774. if logInfo.logs then
  775. local log = logInfo.logs[#logInfo.logs]
  776. if log and log.time then
  777. return log.time
  778. end
  779. end
  780. return self:GetReloadHuntBossLogStartTime(id)
  781. end
  782. function GuildData:GetHuntBossLogById(id, idx)
  783. local huntBoss = self:GetHuntBossInfoById(id)
  784. if not huntBoss then return nil end
  785. local logInfo = huntBoss.logInfo
  786. if not logInfo then return nil end
  787. if not logInfo.logs then return nil end
  788. return logInfo.logs[idx]
  789. end
  790. function GuildData:GetHuntBossLogs(id)
  791. local huntBoss = self:GetHuntBossInfoById(id)
  792. if not huntBoss then return nil end
  793. local logInfo = huntBoss.logInfo
  794. if not logInfo then return nil end
  795. return logInfo.logs
  796. end
  797. function GuildData:GetHuntBossLogNum(id)
  798. local huntBoss = self:GetHuntBossInfoById(id)
  799. if not huntBoss then return nil end
  800. local logInfo = huntBoss.logInfo
  801. if not logInfo then return nil end
  802. return logInfo.logs and #logInfo.logs or 0
  803. end
  804. function GuildData:GetHuntBossLogWhole(id)
  805. local huntBoss = self:GetHuntBossInfoById(id)
  806. if not huntBoss then return false end
  807. local logInfo = huntBoss.logInfo
  808. if not logInfo then return false end
  809. return logInfo.logWhole and true or false
  810. end
  811. function GuildData:ClearHuntBossLogs(id)
  812. local huntBoss = self:GetHuntBossInfoById(id)
  813. if not huntBoss then return end
  814. huntBoss.logInfo = nil
  815. end
  816. function GuildData:GetHuntBossMasterReward(id)
  817. local huntBoss = self:GetHuntBossInfoById(id)
  818. if not huntBoss then return end
  819. return huntBoss.masterReward
  820. end
  821. function GuildData:ClearHuntBossMasterReward(id)
  822. local huntBoss = self:GetHuntBossInfoById(id)
  823. if not huntBoss then return end
  824. huntBoss.masterReward = nil
  825. end
  826. function GuildData:GetGuildWarInfo()
  827. return self.guildWarInfo
  828. end
  829. function GuildData:ClearGuildWarInfo()
  830. self.guildWarInfo = nil
  831. end
  832. return GuildData