UIEquipTipsCtr.lua 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. local UIEquipTipsCtr = class("UIEquipTipsCtr", require("UICtrBase"))
  2. local ConditionJudge = require("Common/ConditionJudge")
  3. function UIEquipTipsCtr:Init(view)
  4. self.view = view
  5. end
  6. function UIEquipTipsCtr:SetData(data)
  7. self.data = data
  8. self.asyncIdx = 0
  9. end
  10. function UIEquipTipsCtr:GetAsyncIdx()
  11. self.asyncIdx = self.asyncIdx + 1
  12. return self.asyncIdx
  13. end
  14. function UIEquipTipsCtr:GetData()
  15. return self.data
  16. end
  17. function UIEquipTipsCtr:GetHeroId()
  18. return self.data[1].id
  19. end
  20. function UIEquipTipsCtr:GetHeroConfigId()
  21. return self.data[1].heroConfigId
  22. end
  23. -- 获得道具配置id
  24. function UIEquipTipsCtr:GetCfgId()
  25. return self.data[1].cfgId
  26. end
  27. function UIEquipTipsCtr:GetNickName()
  28. return self.data[1].nickName
  29. end
  30. function UIEquipTipsCtr:GetSlotIndex()
  31. return self.data[1].slotIndex
  32. end
  33. function UIEquipTipsCtr:GetSlotType()
  34. return self.data[1].slotType
  35. end
  36. function UIEquipTipsCtr:GetNeedChange()
  37. return self.data[1].noChange
  38. end
  39. function UIEquipTipsCtr:GetCanRefine()
  40. return self.data[1].canRefine
  41. end
  42. --这个界面打开是否只是为了查看,不做任何更改的操作
  43. function UIEquipTipsCtr:GetIsView()
  44. return self.data[1]._isView or false;
  45. end
  46. function UIEquipTipsCtr:GetEnterType()
  47. return self.data[2]
  48. end
  49. function UIEquipTipsCtr:GetNeedBtns()
  50. return self.data[3]
  51. end
  52. function UIEquipTipsCtr:GetSlot()
  53. if self.data[1]._slots then
  54. return self.data[1]._slots;
  55. else
  56. local _output = ManagerContainer.DataMgr.UserData:GetCurSlotInfos(self:GetSlotIndex());
  57. return _output;
  58. end
  59. end
  60. function UIEquipTipsCtr:GetCardIdList()
  61. return self.data[1]._cardIdList;
  62. end
  63. function UIEquipTipsCtr:CanEquipCard()
  64. local cardData = ManagerContainer.CfgMgr:GetCardDataById(self.data[1].cfgId)
  65. local slotType = cardData.CardLocation
  66. local slotsRoot = ManagerContainer.DataMgr.UserData:GetAllSlotInfos()
  67. for _,v in pairs(slotsRoot) do
  68. if #v.slot_list > 0 then
  69. local slot = v.slot_list[slotType]
  70. if slot.equip_id > 0 then
  71. for j = 1, Constant.CARD_SLOT_LIMIT do
  72. local id = slot.card_id_list[j] or 0
  73. local condition = ManagerContainer.CfgMgr:GetCardUnlockConditionById(slotType * 100 + j)
  74. if condition ~= nil then
  75. local result = ConditionJudge:ConditionPassResult1(condition.UnlockingCondition)
  76. if result then
  77. return true
  78. end
  79. end
  80. end
  81. end
  82. end
  83. end
  84. return false
  85. end
  86. function UIEquipTipsCtr:OnOneKeyCardUp()
  87. local id = self:GetHeroId()
  88. local logicData, jobType
  89. if id == 1 then
  90. logicData = ManagerContainer.DataMgr.UserData:GetHeroData()
  91. local jobData = ManagerContainer.CfgMgr:GetJobDataById(logicData.configId)
  92. jobType = jobData.JobType
  93. else
  94. logicData = ManagerContainer.DataMgr.PartnerData:GetPartnerDataByUniqueId(id)
  95. local cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(logicData.configId)
  96. jobType = cfgData.JobType
  97. end
  98. if jobType == nil then return end
  99. local slot = ManagerContainer.DataMgr.UserData:GetSlotInfoById(id)
  100. local slotList = slot.slot_list
  101. if slotList == nil then
  102. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("CardHandling")
  103. return
  104. end
  105. local slotType = self:GetSlotType()
  106. local result = false
  107. local hasEmpty, hasCard = false, false
  108. local slotCards = {}
  109. local emptySlot = 0
  110. if slotList[slotType] ~= nil then
  111. local cardList = slotList[slotType].card_id_list
  112. local cardSlotCount = ManagerContainer.RedPointMgr.HeroRPCtr:GetCardSlotCountByType(slotType)
  113. local idxes = {}
  114. for j = 1, cardSlotCount do
  115. if cardList[j] == 0 or cardList[j] == nil then
  116. idxes[#idxes + 1] = j
  117. emptySlot = emptySlot + 1
  118. hasEmpty = true
  119. end
  120. end
  121. if emptySlot == 0 then
  122. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("NoCardTips2")
  123. return
  124. end
  125. local list = ManagerContainer.DataMgr.CardData:GetAllCardDatasByType(slotType)
  126. local cardDatas = CommonUtil.ArrayFilterSelections(list, Enum.FilterType.AND, {"Profession"}, {jobType})
  127. if list ~= nil and cardDatas ~= nil then
  128. if not hasCard then
  129. hasCard = #list > #cardDatas
  130. end
  131. end
  132. if cardDatas ~= nil and next(cardDatas) then
  133. local data = {}
  134. data.slot_id = slotType
  135. data.card_slot_info = {}
  136. slotCards[#slotCards + 1] = data
  137. CommonUtil.ArraySortSelections(cardDatas, Enum.TableSortRule.Down, "CardType", "CardLevel", "FightPower", "cfgId")
  138. local cardIdx = 1
  139. local cfgId, count
  140. for j = 1, emptySlot do
  141. if idxes[j] and cardDatas[cardIdx] then
  142. if cfgId ~= cardDatas[cardIdx].cfgId then
  143. cfgId = cardDatas[cardIdx].cfgId
  144. count = cardDatas[cardIdx].num
  145. end
  146. result = true
  147. local data1 = {key = idxes[j], value = cardDatas[cardIdx].cfgId}
  148. data.card_slot_info[#data.card_slot_info + 1] = data1
  149. count = count - 1
  150. if count <= 0 then
  151. cardIdx = cardIdx + 1
  152. end
  153. end
  154. end
  155. end
  156. end
  157. if result then
  158. local data2 = {}
  159. data2.hero_id = id
  160. data2.eqiup_slot_data = slotCards
  161. local oldSlot = CommonUtil.TableClone(ManagerContainer.DataMgr.UserData:GetCurSlotInfos(id))
  162. ManagerContainer.LuaUIMgr:SetOldSlot(oldSlot)
  163. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CARD_EQUIP_ALL_REQ, data2)
  164. else
  165. if hasEmpty then
  166. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(hasCard and "NoCardTips2" or "NoCardTips")
  167. end
  168. end
  169. end
  170. function UIEquipTipsCtr:OnOneKeyCardDown()
  171. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CARD_DOWN_REQ, {hero_id = self:GetHeroId(), sub_slot_index = self:GetSlotType(), card_slot_index = 0})
  172. end
  173. function UIEquipTipsCtr:InsertedCards(slotType)
  174. local id = self:GetHeroId()
  175. local slot = ManagerContainer.DataMgr.UserData:GetSlotInfoById(id)
  176. local slotList = slot.slot_list
  177. if slotList == nil then return false end
  178. local result = false
  179. if slotList[slotType] ~= nil then
  180. local cardList = slotList[slotType].card_id_list
  181. for _,v in pairs(cardList) do
  182. if v > 0 then
  183. result = true
  184. end
  185. end
  186. end
  187. return result
  188. end
  189. function UIEquipTipsCtr:OnDispose()
  190. self.data = nil
  191. self.view = nil
  192. end
  193. return UIEquipTipsCtr