EquipWash.lua 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. -- 装备图鉴
  2. local Msg = require("core.Msg")
  3. local EquipExcel = require("excel.equip").equip
  4. local EquipRareExcel = require("excel.equip").rare
  5. local ItemDefine = require("bag.ItemDefine")
  6. local Grid = require("bag.Grid")
  7. local EquipLogic = require("equip.EquipLogic")
  8. local BagLogic = require("bag.BagLogic")
  9. local EquipLogicGrid = require("equip.EquipLogicGrid")
  10. local Lang = require("common.Lang")
  11. local Broadcast = require("broadcast.Broadcast")
  12. local HeroLogic = require("hero.HeroLogic")
  13. local Util = require("common.Util")
  14. local HeroGrowUp = require("absAct.HeroGrowUp")
  15. -- 取出合适的装备
  16. local function getEquipGrid(human, bagIndex, heroUuid, pos)
  17. local equipGrid = human.db.equipBag[bagIndex]
  18. if not equipGrid then
  19. -- 取英雄身上的
  20. local heroGrid = HeroLogic.getHeroGridByUuid(human, heroUuid)
  21. if not heroGrid then return end
  22. equipGrid = heroGrid.equip and heroGrid.equip[pos]
  23. return equipGrid, heroGrid
  24. end
  25. return equipGrid
  26. end
  27. -- 查询装备图鉴 全部信息
  28. function fenjieQuey(human, inputList)
  29. local indexTable = { }
  30. for i = 1, inputList[0] do
  31. local index = inputList[i]
  32. local equipGrid = human.db.equipBag[index]
  33. if not equipGrid then
  34. return
  35. end
  36. if not EquipRareExcel[equipGrid.quality] then return end
  37. if indexTable[index] then
  38. -- 重复id
  39. return
  40. end
  41. indexTable[index] = true
  42. end
  43. local itemList = { }
  44. for i = 1, inputList[0] do
  45. local index = inputList[i]
  46. local equipGrid = human.db.equipBag[index]
  47. local equipConfig = EquipExcel[equipGrid.id]
  48. if not equipConfig then return end
  49. for k, v in ipairs(EquipRareExcel[equipGrid.quality].disassembly) do
  50. itemList[v[1]] = itemList[v[1]] or 0
  51. itemList[v[1]] = itemList[v[1]] + v[2]
  52. end
  53. end
  54. local msgRet = Msg.gc.GC_EQUIP_FEN_JIE_QUERY
  55. local len = 0
  56. for k, v in pairs(itemList) do
  57. len = len + 1
  58. Grid.makeItem(msgRet.list[len], k, v)
  59. end
  60. msgRet.list[0] = len
  61. Msg.send(msgRet, human.fd)
  62. end
  63. -- 查询装备图鉴 全部信息
  64. function fenjieDo(human, inputList)
  65. local indexTable = { }
  66. for i = 1, inputList[0] do
  67. local index = inputList[i]
  68. local equipGrid = human.db.equipBag[index]
  69. if not equipGrid then
  70. return
  71. end
  72. if not EquipRareExcel[equipGrid.quality] then return end
  73. if indexTable[index] then
  74. -- 重复id
  75. return
  76. end
  77. indexTable[index] = true
  78. end
  79. local itemList = { }
  80. for i = 1, inputList[0] do
  81. local index = inputList[i]
  82. local equipGrid = human.db.equipBag[index]
  83. local equipConfig = EquipExcel[equipGrid.id]
  84. if not equipConfig then return end
  85. for k, v in ipairs(EquipRareExcel[equipGrid.quality].disassembly) do
  86. itemList[v[1]] = itemList[v[1]] or 0
  87. itemList[v[1]] = itemList[v[1]] + v[2]
  88. end
  89. EquipLogic.delEquip(human, index, "equip_fenjie")
  90. HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE21, 1)
  91. end
  92. BagLogic.addItemList(human, itemList, "equip_fenjie")
  93. local msgRet = Msg.gc.GC_EQUIP_FEN_JIE_DO
  94. Msg.send(msgRet, human.fd)
  95. end
  96. -- 洗练查询
  97. function randomQuery(human, bagIndex, heroUuid, pos)
  98. local equipGrid = getEquipGrid(human, bagIndex, heroUuid, pos)
  99. if not equipGrid then return end
  100. local rareExcel = EquipRareExcel[equipGrid.quality]
  101. if not rareExcel then return end
  102. local msgRet = Msg.gc.GC_EQUIP_RAMDOM_QUERY
  103. Grid.makeItem(msgRet.equipOld, equipGrid.id, 1, nil, equipGrid, bagIndex)
  104. -- 当前洗练属性
  105. local washAttr = equipGrid.washAttr
  106. local washQuality = equipGrid.washQuality
  107. msgRet.equipNew[0] = 0
  108. if washAttr and washQuality then
  109. local washEquipGrid = EquipLogicGrid.createTempGrid(equipGrid.id, equipGrid.washAttr, equipGrid.washQuality)
  110. Grid.makeItem(msgRet.equipNew[1], washEquipGrid.id, 1, nil, washEquipGrid, bagIndex)
  111. msgRet.equipNew[0] = 1
  112. end
  113. msgRet.needItem[0] = #rareExcel.rebirth
  114. for i = 1, msgRet.needItem[0] do
  115. Grid.makeItem(msgRet.needItem[i], rareExcel.rebirth[i][1], rareExcel.rebirth[i][2])
  116. end
  117. Msg.send(msgRet, human.fd)
  118. end
  119. -- 已穿戴的装备
  120. function putList(human, pos)
  121. local msgRet = Msg.gc.GC_EQUIP_PUT_LIST
  122. local cnt = 0
  123. for index = 1, human.db.heroBag[0] do
  124. local heroGrid = human.db.heroBag[index]
  125. if heroGrid and heroGrid.lv >= 2 then
  126. -- 所有部位
  127. if pos == 0 then
  128. for i = 1, ItemDefine.EQUIP_MAX_CNT do
  129. local equipGrid = heroGrid.equip and heroGrid.equip[i]
  130. if equipGrid then
  131. cnt = cnt + 1
  132. local net = msgRet.putList[cnt]
  133. if i ~= ItemDefine.EQUIP_SUBTYPE_SHUIJIN then
  134. Grid.makeItem(net.equip, equipGrid.id, 1, nil, equipGrid)
  135. net.pos = i
  136. end
  137. if cnt >= 10 then
  138. msgRet.isEnd = 0
  139. msgRet.putList[0] = cnt
  140. Msg.send(msgRet, human.fd)
  141. cnt = 0
  142. end
  143. end
  144. end
  145. else
  146. local equipGrid = heroGrid.equip and heroGrid.equip[pos]
  147. if equipGrid then
  148. cnt = cnt + 1
  149. local net = msgRet.putList[cnt]
  150. if i ~= ItemDefine.EQUIP_SUBTYPE_SHUIJIN then
  151. Grid.makeItem(net.equip, equipGrid.id, 1, nil, equipGrid)
  152. net.pos = pos
  153. end
  154. if cnt >= 10 then
  155. msgRet.isEnd = 0
  156. msgRet.putList[0] = cnt
  157. Msg.send(msgRet, human.fd)
  158. cnt = 0
  159. end
  160. end
  161. end
  162. end
  163. end
  164. msgRet.isEnd = 1
  165. msgRet.putList[0] = cnt
  166. Msg.send(msgRet, human.fd)
  167. end
  168. -- 洗练
  169. function randomDo(human, bagIndex, heroUuid, pos)
  170. local equipGrid = getEquipGrid(human, bagIndex, heroUuid, pos)
  171. if not equipGrid then return end
  172. local rareExcel = EquipRareExcel[equipGrid.quality]
  173. if not rareExcel then return end
  174. for i = 1, #rareExcel.rebirth do
  175. local needItemID = rareExcel.rebirth[i][1]
  176. local needItemCnt = rareExcel.rebirth[i][2]
  177. local nowItemCnt = BagLogic.getItemCnt(human, needItemID)
  178. if nowItemCnt < needItemCnt then
  179. return Broadcast.sendErr(human, Util.format(Lang.XIANZHI_NO_ITEM, ItemDefine.getValue(needItemID,"name")))
  180. end
  181. end
  182. for i = 1, #rareExcel.rebirth do
  183. local needItemID = rareExcel.rebirth[i][1]
  184. local needItemCnt = rareExcel.rebirth[i][2]
  185. BagLogic.delItem(human, needItemID, needItemCnt, "equip_wash")
  186. end
  187. local attr, quality = EquipLogic.randomAttr(equipGrid.id, true, equipGrid.quality)
  188. equipGrid.washAttr = attr
  189. equipGrid.washQuality = quality
  190. HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE19, 1)
  191. Broadcast.sendErr(human, Lang.EQUIP_WASH_RANDOM_SUC)
  192. randomQuery(human, bagIndex, heroUuid, pos)
  193. end
  194. -- 洗练查询
  195. function randomSave(human, bagIndex, heroUuid, pos)
  196. local equipGrid, heroGrid = getEquipGrid(human, bagIndex, heroUuid, pos)
  197. if not equipGrid then return end
  198. local washAttr = equipGrid.washAttr
  199. local washQuality = equipGrid.washQuality
  200. if not washAttr or not washQuality then return end
  201. equipGrid.attr = washAttr
  202. equipGrid.quality = washQuality
  203. equipGrid.washAttr = nil
  204. equipGrid.washQuality = nil
  205. EquipLogic.checkAttr(equipGrid)
  206. -- 更新背包的
  207. if not heroGrid then
  208. EquipLogic.sendEquipChange(human, bagIndex, equipGrid, EquipLogic.EQUIP_BAG_OP_CHANGE)
  209. end
  210. Broadcast.sendErr(human, Lang.EQUIP_WASH_SAVE_SUC)
  211. randomQuery(human, bagIndex, heroUuid, pos)
  212. end