AngelMajorEquipment.lua 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. --- 大天使装备
  2. --- Generated by EmmyLua(https://github.com/EmmyLua)
  3. --- Created by zhoutao.
  4. --- DateTime: 2024/11/8 17:54
  5. AngelMajorEquipment = {}
  6. local this = {}
  7. this.RedId = 102
  8. --- 发送大天使装备属性信息
  9. --- @param actor table 角色
  10. function AngelMajorEquipment.sendAngelEquipAttrInfo(actor)
  11. local attrInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  12. if table.isNullOrEmpty(attrInfo) then
  13. sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, {})
  14. return
  15. end
  16. sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, attrInfo)
  17. end
  18. --- 获取指定大天使装备属性
  19. ---@param actor table 角色
  20. ---@param msgData table 消息数据
  21. function AngelMajorEquipment.getEquipAttrById(actor, msgData)
  22. if not this.isOpen(actor) then
  23. return
  24. end
  25. local itemConfigId = msgData["itemConfigId"]
  26. if not this.isAngelEquip(itemConfigId) then
  27. return
  28. end
  29. local itemId = msgData["itemId"]
  30. local attrInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  31. if table.isNullOrEmpty(attrInfo) then
  32. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_ATTR_INFO, {})
  33. return
  34. end
  35. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_ATTR_INFO, {
  36. [itemId] = attrInfo[itemId]
  37. })
  38. end
  39. --- 穿戴大天使装备后增减对应的属性值
  40. ---@param actor table 角色
  41. ---@param oldItemId number 旧道具唯一id
  42. ---@param itemId number 新道具唯一id
  43. ---@param itemConfigId number 道具配置id
  44. function AngelMajorEquipment.afterPutOnAngelEquipment(actor, oldItemId, itemId, itemConfigId)
  45. if not this.isOpen(actor) then
  46. return
  47. end
  48. if this.isAngelEquip(itemConfigId) then
  49. local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  50. local basicAtt = ""
  51. if not table.isNullOrEmpty(equipAttr) then
  52. local attrInfo = equipAttr[itemId]
  53. if not table.isNullOrEmpty(attrInfo) then
  54. local level = attrInfo["level"]
  55. local groupId = ConfigDataManager.getTableValue("cfg_equip_angelGroup", "angelEquipGroup", "id",
  56. itemConfigId)
  57. local tableValue = ConfigDataManager.getTable("cfg_equip_angelAtt", "ornamentsGroup", groupId, "lv",
  58. level)
  59. if table.isNullOrEmpty(tableValue) then
  60. gameDebug.print(
  61. "getAngelEquipAttrTableValue is nil itemConfigId:" .. itemConfigId .. " itemLevel:" .. level)
  62. return
  63. end
  64. basicAtt = tableValue[1]["basicatt"]
  65. if string.isNullOrEmpty(basicAtt) then
  66. return
  67. end
  68. end
  69. end
  70. if oldItemId and oldItemId == 0 then
  71. -- 增加属性
  72. this.addAngelEquipAttr(actor, basicAtt, itemId)
  73. -- 增加圣杯词条属性
  74. if not table.isNullOrEmpty(equipAttr) then
  75. local attrInfo = equipAttr[itemId]
  76. if not table.isNullOrEmpty(attrInfo) then
  77. local grails = attrInfo["grails"]
  78. if not table.isNullOrEmpty(grails) then
  79. for grailId, _ in pairs(grails) do
  80. AngelMajorGrail.grailAttrHandle(actor, getitemextdata(actor, grailId) or AngelMajorGrail.getGrailInfo(actor, grailId), grailId, true)
  81. end
  82. end
  83. end
  84. end
  85. else
  86. -- 将穿着的装备提升的属性移除
  87. local key = string.format(RoleAttrKey.ANGEL_MAJOR_EQUIPMENT, oldItemId)
  88. RoleAttr.clearRoleAttrAndDB(actor, key)
  89. -- 增加属性
  90. this.addAngelEquipAttr(actor, basicAtt, itemId)
  91. -- 减少并增加圣杯词条属性
  92. if not table.isNullOrEmpty(equipAttr) then
  93. local oldAttrInfo = equipAttr[oldItemId]
  94. if not table.isNullOrEmpty(oldAttrInfo) then
  95. local oldGrails = oldAttrInfo["grails"]
  96. if not table.isNullOrEmpty(oldGrails) then
  97. for grailId, _ in pairs(oldGrails) do
  98. AngelMajorGrail.grailAttrHandle(actor, getitemextdata(actor, grailId) or AngelMajorGrail.getGrailInfo(actor, grailId), grailId, false)
  99. end
  100. end
  101. end
  102. local newAttrInfo = equipAttr[itemId]
  103. if not table.isNullOrEmpty(newAttrInfo) then
  104. local newGrails = newAttrInfo["grails"]
  105. if not table.isNullOrEmpty(newGrails) then
  106. for grailId, _ in pairs(newGrails) do
  107. AngelMajorGrail.grailAttrHandle(actor, getitemextdata(actor, grailId) or AngelMajorGrail.getGrailInfo(actor, grailId), grailId, true)
  108. end
  109. end
  110. end
  111. end
  112. end
  113. -- 发送当前装备下圣杯词条信息
  114. this.SendOptEquipGrailInfo(actor, itemId, 1)
  115. -- 判断圣杯红点
  116. local result = AngelMajorGrail.checkEnter(actor)
  117. RedPoint.sendOneRedPoint(actor, this.RedId, result)
  118. -- 更新开服竞技排行数据
  119. local lv = AngelMajorEquipment.getLvSum(actor)
  120. OpenServerCompetition.updateRankData(actor, CompetitionType.ANGEL, lv)
  121. -- 判断是否满足大天使圣杯套装并增加属性
  122. AngelMajorGrail.checkAngelGrailSuitCondition(actor)
  123. end
  124. end
  125. --- 脱下大天使装备后减对应的属性值
  126. ---@param actor table 角色
  127. ---@param itemId number 道具唯一id
  128. ---@param itemConfigId number 道具配置id
  129. function AngelMajorEquipment.afterTakeOffAngelEquipment(actor, itemId, itemConfigId)
  130. if not this.isOpen(actor) then
  131. return
  132. end
  133. if this.isAngelEquip(itemConfigId) then
  134. local key = string.format(RoleAttrKey.ANGEL_MAJOR_EQUIPMENT, itemId)
  135. RoleAttr.clearRoleAttrAndDB(actor, key)
  136. -- 去除圣杯词条属性
  137. local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  138. if not table.isNullOrEmpty(equipInfo) then
  139. local attrInfo = equipInfo[itemId]
  140. if not table.isNullOrEmpty(attrInfo) then
  141. if not table.isNullOrEmpty(attrInfo) then
  142. local grails = attrInfo["grails"]
  143. if not table.isNullOrEmpty(grails) then
  144. for grailId, _ in pairs(grails) do
  145. AngelMajorGrail.grailAttrHandle(actor, getitemextdata(actor, grailId) or AngelMajorGrail.getGrailInfo(actor, grailId), grailId, false)
  146. end
  147. end
  148. end
  149. end
  150. end
  151. -- 发送当前装备下圣杯词条信息
  152. this.SendOptEquipGrailInfo(actor, itemId, 2)
  153. -- 判断圣杯红点
  154. local result = AngelMajorGrail.checkEnter(actor)
  155. RedPoint.sendOneRedPoint(actor, this.RedId, result)
  156. -- 更新开服竞技排行数据
  157. local lv = AngelMajorEquipment.getLvSum(actor)
  158. OpenServerCompetition.updateRankData(actor, CompetitionType.ANGEL, lv)
  159. -- 判断是否满足大天使圣杯套装并增加属性
  160. AngelMajorGrail.checkAngelGrailSuitCondition(actor)
  161. end
  162. end
  163. function this.SendOptEquipGrailInfo(actor, equipId, opt)
  164. local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  165. if table.isNullOrEmpty(equipAttr) then
  166. gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.getEquipAllEntryInfo equipAttr is nil")
  167. return
  168. end
  169. local equipInfo = equipAttr[equipId]
  170. if table.isNullOrEmpty(equipInfo) then
  171. gameDebug.print(getbaseinfo(actor, "rolename"), " AngelMajorGrail.getEquipAllEntryInfo equipInfo is nil")
  172. return
  173. end
  174. local grails = equipInfo["grails"]
  175. local res = {}
  176. if not table.isNullOrEmpty(grails) then
  177. for grailId, info in pairs(grails) do
  178. local temp = AngelMajorGrail.combineRes(grailId, info, getitemextdata(actor, grailId) or AngelMajorGrail.getGrailInfo(actor, grailId))
  179. local attrInfo = temp["attrInfo"]
  180. if opt == 2 then
  181. attrInfo["active"] = false
  182. else
  183. if attrInfo and AngelMajorGrail.isActiveGrail(actor, grailId) then
  184. attrInfo["active"] = true
  185. end
  186. end
  187. res[grailId] = temp
  188. end
  189. end
  190. sendluamsg(actor, LuaMessageIdToClient.RES_EQUIP_OPT_ENTRY_INFO, {
  191. opt = opt,
  192. res = res
  193. })
  194. end
  195. --- 初始化大天使装备成长属性
  196. ---@param actor table 角色
  197. ---@param itemId number 道具唯一id
  198. ---@param cfgId number 道具配置id
  199. function AngelMajorEquipment.initAngelEquipmentAttr(actor, itemId, cfgId)
  200. if this.isAngelEquip(cfgId) then
  201. local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  202. -- 初始化装备成长属性
  203. if not table.isNullOrEmpty(equipAttr) then
  204. local itemAttr = equipAttr[itemId]
  205. if table.isNullOrEmpty(itemAttr) then
  206. equipAttr[itemId] = {
  207. ["level"] = 0,
  208. ["exp"] = 0,
  209. ["rank"] = 1,
  210. ["grails"] = {}
  211. }
  212. end
  213. else
  214. equipAttr = {
  215. [itemId] = {
  216. ["level"] = 0,
  217. ["exp"] = 0,
  218. ["rank"] = 1,
  219. ["grails"] = {}
  220. }
  221. }
  222. end
  223. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipAttr)
  224. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_ATTR_INFO, {
  225. [itemId] = equipAttr[itemId]
  226. })
  227. end
  228. end
  229. --- 销毁大天使装备
  230. ---@param actor table 角色
  231. ---@param cfgId number 道具配置id
  232. ---@param itemId number 道具唯一id
  233. function AngelMajorEquipment.destroyAngelEquip(actor, cfgId, itemId)
  234. if not this.isOpen(actor) then
  235. return
  236. end
  237. if this.isAngelEquip(cfgId) then
  238. local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  239. if table.isNullOrEmpty(equipAttr) then
  240. return
  241. end
  242. -- 清除圣杯词条数据
  243. -- local attrInfo = equipAttr[itemId]
  244. -- if not table.isNullOrEmpty(attrInfo) then
  245. -- local grails = attrInfo["grails"]
  246. -- if not table.isNullOrEmpty(grails) then
  247. -- local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
  248. -- for grailId, _ in pairs(grails) do
  249. -- grailInfo[grailId] = nil
  250. -- end
  251. -- setplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO, grailInfo)
  252. -- end
  253. -- end
  254. equipAttr[itemId] = nil
  255. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipAttr)
  256. sendluamsg(actor, LuaMessageIdToClient.RES_DESTROY_ANGEL_EQUIPMENT, itemId)
  257. end
  258. end
  259. --- 突破大天使装备
  260. ---@param actor table 角色
  261. ---@param itemId number 道具唯一id
  262. function AngelMajorEquipment.breakEquipment(actor, msgData)
  263. if not this.isOpen(actor) then
  264. return
  265. end
  266. local itemConfigId = msgData["itemConfigId"]
  267. if not this.isAngelEquip(itemConfigId) then
  268. return
  269. end
  270. local itemId = msgData["itemId"]
  271. local groupId = msgData["groupId"]
  272. local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  273. local attrInfo = equipAttr[itemId]
  274. if table.isNullOrEmpty(attrInfo) then
  275. return
  276. end
  277. local level = attrInfo["level"]
  278. local rank = attrInfo["rank"]
  279. local grails = attrInfo["grails"]
  280. local tableValue = ConfigDataManager.getTable("cfg_equip_angelAtt", "ornamentsGroup", groupId, "lv", level)
  281. if table.isNullOrEmpty(tableValue) then
  282. return
  283. end
  284. local breakMaterial = tableValue[1]["breakmaterial"]
  285. if string.isNullOrEmpty(breakMaterial) then
  286. return
  287. end
  288. -- 根据配置的道具信息消耗道具进行突破
  289. local items = string.split(breakMaterial, "|")
  290. local result = true
  291. for _, costItems in pairs(items) do
  292. local tmps = string.split(costItems, "#")
  293. local costItemId = tmps[1]
  294. local costItemCount = tmps[2]
  295. if not Bag.checkItem(actor, costItemId, costItemCount) then
  296. result = false
  297. break
  298. end
  299. end
  300. if result then
  301. for _, costItems in pairs(items) do
  302. local tmps = string.split(costItems, "#")
  303. local costItemId = tmps[1]
  304. local costItemCount = tmps[2]
  305. removeitemfrombag(actor, costItemId, costItemCount, 0, 9999, ItemAction.ANGEL_EQUIPMENT_BREAK_COST)
  306. end
  307. equipAttr[itemId] = {
  308. ["level"] = level + 1,
  309. ["exp"] = 0,
  310. ["rank"] = rank + 1,
  311. ["grails"] = grails
  312. }
  313. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipAttr)
  314. -- 突破后增加对应的属性
  315. local basicAtt = tableValue[1]["basicatt"]
  316. if string.isNullOrEmpty(basicAtt) then
  317. return
  318. end
  319. this.addAngelEquipAttr(actor, basicAtt, itemId)
  320. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_ATTR_INFO, {
  321. [itemId] = equipAttr[itemId]
  322. })
  323. -- 响应装备突破结果
  324. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_BREAK_RESULT, result)
  325. else
  326. -- 响应装备突破结果
  327. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_BREAK_RESULT, result)
  328. end
  329. -- 红点判断
  330. local checkEnter = AngelMajorGrail.checkEnter(actor)
  331. RedPoint.sendOneRedPoint(actor, this.RedId, checkEnter)
  332. end
  333. --- 攻击指定怪物增加大天使装备经验值
  334. ---@param actor table 角色
  335. ---@param fightData table 战斗数据
  336. function AngelMajorEquipment.attack(actor, fightData)
  337. if not this.isOpen(actor) then
  338. return
  339. end
  340. if isofflineplay(actor) then
  341. return
  342. end
  343. local targetType = fightData["targettype"]
  344. local targetConfigId = fightData["targetcfgid"]
  345. if targetType == 2 then
  346. local angelExp = ConfigDataManager.getTableValue("cfg_monster", "angelExp", "id", targetConfigId)
  347. angelExp = angelExp and tonumber(angelExp) or 0
  348. if angelExp == 0 then
  349. return
  350. end
  351. local equipmentData = getputonequipinfo(actor)
  352. if table.isNullOrEmpty(equipmentData) then
  353. return
  354. end
  355. local isLevelUp = false
  356. local mark = false
  357. local attrInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  358. if table.isNullOrEmpty(attrInfo) then
  359. return
  360. end
  361. local equipId = {}
  362. for _, v in pairs(equipmentData) do
  363. local tempExp = angelExp
  364. -- 判断是否拥有大天使装备经验加成buff
  365. local expBoostInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO)
  366. if not table.isNullOrEmpty(expBoostInfo) then
  367. local delayTime = expBoostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["delayTime"]
  368. local value = expBoostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["value"]
  369. local now = getbaseinfo(actor, "now")
  370. if now <= delayTime then
  371. tempExp = math.round(tempExp + (tempExp * value / 100))
  372. end
  373. end
  374. mark, isLevelUp = this.addAngelEquipExp(actor, attrInfo, v, tempExp, isLevelUp)
  375. if not mark then
  376. break
  377. end
  378. table.insert(equipId, v["id"])
  379. end
  380. if isLevelUp then
  381. -- 更新开服竞技排行数据
  382. local lv = AngelMajorEquipment.getLvSum(actor)
  383. OpenServerCompetition.updateRankData(actor, CompetitionType.ANGEL, lv)
  384. end
  385. local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  386. local res = {}
  387. for _, v in pairs(equipId) do
  388. res[v] = equipInfo[v]
  389. end
  390. sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, res)
  391. end
  392. end
  393. --- 检查type=2的类型是否满足穿戴条件
  394. ---@param actor table 角色
  395. ---@param id number cfg_equip_angelSuit表id
  396. ---@return boolean, number 是否满足穿戴条件,增加的天赋点
  397. function AngelMajorEquipment.checkDressedConditionType2(actor, id)
  398. local tableValue = ConfigDataManager.getTable("cfg_equip_angelSuit", "id", id, "career",
  399. getbaseinfo(actor, "getbasecareer"))
  400. if table.isNullOrEmpty(tableValue) then
  401. gameDebug.print("AngelMajorEquipment.checkDressedCondition cfg_equip_angelSuit表id不存在")
  402. return false, 0
  403. end
  404. local dressedEquip = getputonequipinfo(actor)
  405. if table.isNullOrEmpty(dressedEquip) then
  406. return false, 0
  407. end
  408. local dressedCount = 0
  409. for _, v in pairs(dressedEquip) do
  410. local itemConfigId = v["cfgid"]
  411. if this.isAngelEquip(itemConfigId) then
  412. dressedCount = dressedCount + 1
  413. end
  414. end
  415. local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  416. local wearingCount = tableValue[1]["wearingcount"]
  417. if dressedCount < tonumber(wearingCount) then
  418. return false, 0
  419. end
  420. -- 装备组#部件数量#等级|装备组#部件数量#等级
  421. local angelLv = tableValue[1]["angellv"]
  422. if string.isNullOrEmpty(angelLv) then
  423. return false, 0
  424. end
  425. local split = string.split(angelLv, "|")
  426. local result = true
  427. local temp = {}
  428. for _, v in pairs(split) do
  429. -- 判断条件是否满足
  430. local tmp_split = string.split(v, "#")
  431. local groupId = tmp_split[1]
  432. local count = tmp_split[2]
  433. local level = tmp_split[3]
  434. local sum = 0
  435. for _, equipInfo in pairs(dressedEquip) do
  436. local itemConfigId = equipInfo["cfgid"]
  437. if this.isAngelEquip(itemConfigId) then
  438. local itemId = tonumber(equipInfo["id"])
  439. if not table.contains(temp, itemId) then
  440. local equipGroupId = ConfigDataManager.getTableValue("cfg_equip_angelGroup", "angelEquipSuit", "id",
  441. itemConfigId)
  442. if tonumber(groupId) == tonumber(equipGroupId) then
  443. local attrInfo = equipAttr[itemId]
  444. local equipLevel = attrInfo["level"]
  445. if equipLevel >= tonumber(level) then
  446. sum = sum + 1
  447. if sum >= tonumber(count) then
  448. table.insert(temp, itemId)
  449. goto outer
  450. end
  451. end
  452. end
  453. end
  454. end
  455. end
  456. ::outer::
  457. if sum < tonumber(count) then
  458. result = false
  459. end
  460. end
  461. return result, result and tableValue[1]["count"] or 0
  462. end
  463. --- 检查条件是否满足增加天赋点,满足直接被动增加
  464. ---@param actor table 角色
  465. function this.checkConditionIncrementTalentPoint(actor)
  466. -- 获取穿着的装备等级和
  467. local levelSum = AngelMajorEquipment.getLvSum(actor)
  468. if levelSum == 0 then
  469. return
  470. end
  471. local tableValues = ConfigDataManager.getTable("cfg_equip_angelSuit", "type", 1, "career",
  472. getbaseinfo(actor, "getbasecareer"))
  473. local alreadyIncrementId = getplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_ALREADY_INCREMENT_ID)
  474. alreadyIncrementId = alreadyIncrementId and tonumber(alreadyIncrementId) or 0
  475. for _, tableValue in pairs(tableValues) do
  476. local id = tonumber(tableValue["id"])
  477. if alreadyIncrementId >= id then
  478. goto continue
  479. end
  480. local angelLv = tableValue["angellv"]
  481. if levelSum >= tonumber(angelLv) then
  482. AngelMajorTalent.incrementTalentPoint(actor, tableValue["count"])
  483. setplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_ALREADY_INCREMENT_ID, id)
  484. else
  485. break
  486. end
  487. ::continue::
  488. end
  489. end
  490. -- 获取大天使装备等级和
  491. function AngelMajorEquipment.getLvSum(actor)
  492. local dressedEquipment = getputonequipinfo(actor)
  493. if table.isNullOrEmpty(dressedEquipment) then
  494. return 0
  495. end
  496. local equipAttr = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA) or {}
  497. local levelSum = 0
  498. for _, v in pairs(dressedEquipment) do
  499. local itemId = v["id"]
  500. local itemConfigId = v["cfgid"]
  501. if this.isAngelEquip(itemConfigId) then
  502. local attr = equipAttr[itemId]
  503. levelSum = levelSum + tonumber(attr["level"])
  504. end
  505. end
  506. return levelSum
  507. end
  508. --- 使用大天使经验药水或经验加成药水
  509. ---@param actor table 角色对象
  510. ---@param itemConfigId number 道具配置id
  511. ---@param count number 使用数量
  512. function AngelMajorEquipment.useExperienceBoostItem(actor, itemConfigId, count)
  513. local tableValue = ConfigDataManager.getTable("cfg_item", "id", itemConfigId)
  514. if not tableValue then
  515. return
  516. end
  517. local type = tonumber(tableValue[1]["type"])
  518. local subType = tonumber(tableValue[1]["subtype"])
  519. -- 经验加成药水使用
  520. if type == ItemType.DRUG and subType == ItemSubType.ANGEL_EXP_BOOST then
  521. local useParam = tableValue[1]["useparam"]
  522. if string.isNullOrEmpty(useParam) then
  523. return
  524. end
  525. local param = string.split(useParam, "#")
  526. local buffId = tonumber(param[3])
  527. local buffInfo = ConfigDataManager.getTable("cfg_buff", "id", buffId)
  528. local totalTime = tonumber(buffInfo[1]["bufftotaltime"])
  529. local boostValue = tonumber(param[1])
  530. local boostInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO)
  531. local now = getbaseinfo(actor, "now")
  532. for i = 1, count do
  533. if not table.isNullOrEmpty(boostInfo) then
  534. local time = boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["delayTime"]
  535. local value = boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["value"]
  536. if time and time > now then
  537. boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)] = {
  538. ["delayTime"] = time + totalTime,
  539. ["value"] = boostValue > value and boostValue or value
  540. }
  541. else
  542. local endTime = now + totalTime
  543. boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)] = {
  544. ["delayTime"] = endTime,
  545. ["value"] = boostValue > value and boostValue or value
  546. }
  547. end
  548. else
  549. local endTime = now + totalTime
  550. boostInfo = {
  551. [tonumber(BuffId.ANGEL_EXP_BOOST_ID)] = {
  552. ["delayTime"] = endTime,
  553. ["value"] = boostValue
  554. }
  555. }
  556. end
  557. end
  558. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO, boostInfo)
  559. this.delayCloseExpBoostBuff(actor, boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["delayTime"] - now)
  560. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIP_EXP_BOOST_INFO, boostInfo)
  561. end
  562. -- 经验药水使用
  563. if type == ItemType.DRUG and subType == ItemSubType.ANGEL_EXP then
  564. local useParam = tableValue[1]["useparam"]
  565. if string.isNullOrEmpty(useParam) then
  566. return
  567. end
  568. local partAndExp = string.toStringStringMap(useParam, "#", "|")
  569. local putOnEquipInfo = getputonequipinfo(actor)
  570. if table.isNullOrEmpty(putOnEquipInfo) then
  571. return
  572. end
  573. local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  574. for i = 1, count do
  575. local isLevelUp = false
  576. for _, v in pairs(putOnEquipInfo) do
  577. local cfgId = v["cfgid"]
  578. if this.isAngelEquip(cfgId) then
  579. local part = ConfigDataManager.getTableValue("cfg_item", "strPart", "id", cfgId)
  580. if string.contains(part, "#") then
  581. local partSplit = string.split(part, "#")
  582. local exp = 0
  583. for _, partItem in pairs(partSplit) do
  584. exp = partAndExp[partItem]
  585. end
  586. if exp then
  587. exp = tonumber(exp)
  588. _, isLevelUp = this.addAngelEquipExp(actor, equipInfo, v, exp, isLevelUp)
  589. end
  590. else
  591. if partAndExp[part] then
  592. local exp = tonumber(partAndExp[part])
  593. _, isLevelUp = this.addAngelEquipExp(actor, equipInfo, v, exp, isLevelUp)
  594. end
  595. end
  596. end
  597. end
  598. if isLevelUp then
  599. -- 更新开服竞技排行数据
  600. local lv = AngelMajorEquipment.getLvSum(actor)
  601. OpenServerCompetition.updateRankData(actor, CompetitionType.ANGEL, lv)
  602. sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, equipInfo)
  603. end
  604. end
  605. sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, equipInfo)
  606. end
  607. end
  608. --- 获取指定玩家的指定大天使装备成长属性
  609. ---@param actor table 角色对象
  610. ---@param msgData table 消息数据
  611. function AngelMajorEquipment.getPlayerAngelEquipInfo(actor, msgData)
  612. local rid = msgData["rid"]
  613. local hostId = msgData["hostId"]
  614. local serverId = getbaseinfo(actor, "serverid")
  615. local targetActor = getactor(actor, rid)
  616. -- 非本服玩家走异步接口拿数据
  617. if not string.isNullOrEmpty(hostId) and tonumber(hostId) ~= tonumber(serverId) then
  618. getplaydefasync(actor, targetActor:toString(), PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, actor:toString())
  619. else
  620. local equipInfo = getplaydef(targetActor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  621. if table.isNullOrEmpty(equipInfo) then
  622. return
  623. end
  624. sendluamsg(actor, LuaMessageIdToClient.RES_OTHER_ANGE_EQUIP_INFO, equipInfo)
  625. end
  626. end
  627. --- 发送对应玩家的大天使装备信息
  628. ---@param actor table 角色对象
  629. ---@param equipInfo table 大天使装备信息
  630. ---@param params table 参数
  631. function AngelMajorEquipment.sendPlayerAngelEquipInfo(actor, equipInfo, params)
  632. local player = getactor(params)
  633. sendluamsg(player, LuaMessageIdToClient.RES_OTHER_ANGE_EQUIP_INFO, equipInfo)
  634. end
  635. --- 添加大天使装备的圣杯等级
  636. ---@param actor table 角色对象
  637. ---@param grailId number 圣杯id
  638. ---@param grailLevel number 圣杯等级
  639. function AngelMajorEquipment.addGrailLevel(actor, grailId, grailLevel)
  640. local equipData = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  641. if not table.isNullOrEmpty(equipData) then
  642. for _, v in pairs(equipData) do
  643. local grails = v["grails"]
  644. if not table.isNullOrEmpty(grails) and not table.isNullOrEmpty(grails[grailId]) then
  645. grails[grailId]["level"] = grailLevel
  646. end
  647. end
  648. end
  649. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipData)
  650. end
  651. --- 登录
  652. ---@param actor table 角色对象
  653. function AngelMajorEquipment.login(actor)
  654. -- 发送所有大天使装备信息
  655. AngelMajorEquipment.sendAngelEquipAttrInfo(actor)
  656. -- 大天使经验药水过期计算
  657. local boostInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO)
  658. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIP_EXP_BOOST_INFO, boostInfo and boostInfo or {})
  659. if not table.isNullOrEmpty(boostInfo) then
  660. local now = getbaseinfo(actor, "now")
  661. local delayTime = boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["delayTime"]
  662. this.delayCloseExpBoostBuff(actor, delayTime - now)
  663. end
  664. end
  665. --- 获取已穿戴的大天使装备id列表
  666. ---@param actor table 角色对象
  667. ---@return table 大天使装备id列表
  668. function AngelMajorEquipment.getPutOnEquipIds(actor)
  669. local putOnEquipIds = {}
  670. local equipInfo = getputonequipinfo(actor)
  671. if not table.isNullOrEmpty(equipInfo) then
  672. for _, v in pairs(equipInfo) do
  673. local cfgId = v["cfgid"]
  674. if this.isAngelEquip(cfgId) then
  675. table.insert(putOnEquipIds, v["id"])
  676. end
  677. end
  678. end
  679. return putOnEquipIds
  680. end
  681. --- 判断是否开启
  682. ---@param actor table 角色对象
  683. function this.isOpen(actor)
  684. -- 获取当前角色等级
  685. local level = getbaseinfo(actor, "level")
  686. -- 获取等级限制配置
  687. local levelLimit = ConfigDataManager.getTableValue("cfg_global", "value", "id",
  688. GlobalConfigId.ANGEL_EQUIPMENT_LEVEL_LIMIT)
  689. if string.isNullOrEmpty(levelLimit) then
  690. return false
  691. end
  692. -- 返回结果
  693. return level >= tonumber(levelLimit)
  694. end
  695. --- 判断是否为大天使装备
  696. ---@param itemConfigId number 道具配置id
  697. function this.isAngelEquip(itemConfigId)
  698. local tableValue = ConfigDataManager.getTable("cfg_equip_angelGroup", "id", itemConfigId)
  699. return not table.isNullOrEmpty(tableValue)
  700. end
  701. function AngelMajorEquipment.isAngelEquip(itemConfigId)
  702. return this.isAngelEquip(itemConfigId)
  703. end
  704. --- 给角色添加大天使装备对应的属性
  705. ---@param actor table 角色对象
  706. ---@param basicAtt string 增加的属性
  707. ---@param itemId number 道具id
  708. function this.addAngelEquipAttr(actor, basicAtt, itemId)
  709. if string.isNullOrEmpty(basicAtt) then
  710. return
  711. end
  712. local attrTable = string.split(basicAtt, "|")
  713. local temp = {}
  714. for _, attr in pairs(attrTable) do
  715. local tmps = string.split(attr, "#")
  716. local attrId = tmps[1]
  717. local attrValue = tmps[2]
  718. if tonumber(attrValue) == 0 then
  719. goto continue
  720. end
  721. temp[tonumber(attrId)] = tonumber(attrValue)
  722. ::continue::
  723. end
  724. -- 表里配的不是增长的属性值,所以此处先清空之前增加的属性值再做添加属性操作
  725. local attrKey = string.format(RoleAttrKey.ANGEL_MAJOR_EQUIPMENT, itemId)
  726. RoleAttr.clearRoleAttrAndDB(actor, attrKey)
  727. RoleAttr.addAndSaveRoleAttr(actor, attrKey, temp)
  728. this.checkConditionIncrementTalentPoint(actor)
  729. end
  730. --- 添加大天使装备经验
  731. ---@param actor table 角色对象
  732. ---@param attrInfo table 大天使装备属性信息
  733. ---@param equip table 装备信息
  734. ---@param tempExp number 临时经验值
  735. ---@param isLevelUp boolean 是否升级
  736. function this.addAngelEquipExp(actor, attrInfo, equip, tempExp, isLevelUp)
  737. local itemId = equip["id"]
  738. local itemConfigId = equip["cfgid"]
  739. if not this.isAngelEquip(itemConfigId) then
  740. return true, isLevelUp
  741. end
  742. if table.isNullOrEmpty(attrInfo) then
  743. return false, isLevelUp
  744. end
  745. local itemAttrInfo = attrInfo[itemId]
  746. if table.isNullOrEmpty(itemAttrInfo) then
  747. return false, isLevelUp
  748. end
  749. local itemLevel = itemAttrInfo["level"]
  750. local itemExp = itemAttrInfo["exp"]
  751. local rank = itemAttrInfo["rank"]
  752. local grails = itemAttrInfo["grails"]
  753. local groupId = ConfigDataManager.getTableValue("cfg_equip_angelGroup", "angelEquipGroup", "id", itemConfigId)
  754. local tableValue = ConfigDataManager.getTable("cfg_equip_angelAtt", "ornamentsGroup", groupId, "lv", itemLevel)
  755. if not tableValue then
  756. return true, isLevelUp
  757. end
  758. local levelUpNeedExp = tableValue[1]["lvdeplete"]
  759. -- 如果达到满级则直接返回
  760. if string.isNullOrEmpty(levelUpNeedExp) then
  761. return true, isLevelUp
  762. end
  763. local breakMaterial = tableValue[1]["breakmaterial"]
  764. if not string.isNullOrEmpty(breakMaterial) and itemExp == tonumber(levelUpNeedExp) then
  765. -- 此前已经达到突破等级后直接跳过此次循环
  766. return true, isLevelUp
  767. end
  768. if tempExp >= tonumber(levelUpNeedExp) then
  769. while tempExp >= tonumber(levelUpNeedExp) do
  770. tempExp = tempExp - tonumber(levelUpNeedExp)
  771. itemLevel = itemLevel + 1
  772. isLevelUp = true
  773. local angelAtt =
  774. ConfigDataManager.getTable("cfg_equip_angelAtt", "ornamentsGroup", groupId, "lv", itemLevel)
  775. breakMaterial = angelAtt[1]["breakmaterial"]
  776. levelUpNeedExp = angelAtt[1]["lvdeplete"]
  777. -- 突破材料判断,达到突破等级后
  778. if not string.isNullOrEmpty(breakMaterial) then
  779. attrInfo[itemId] = {
  780. ["level"] = itemLevel,
  781. ["exp"] = tonumber(levelUpNeedExp),
  782. ["rank"] = rank,
  783. ["grails"] = grails
  784. }
  785. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
  786. -- 通知客户端可以突破
  787. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_CAN_BREAK, itemId)
  788. this.addAngelEquipAttr(actor, angelAtt[1]["basicatt"], itemId)
  789. return true, isLevelUp
  790. else
  791. attrInfo[itemId] = {
  792. ["level"] = itemLevel,
  793. ["exp"] = 0,
  794. ["rank"] = rank,
  795. ["grails"] = grails
  796. }
  797. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
  798. end
  799. end
  800. if isLevelUp then
  801. -- 升级后增加对应的属性
  802. local basicAtt = ConfigDataManager.getTableValue("cfg_equip_angelAtt", "basicAtt", "ornamentsGroup",
  803. groupId, "lv", itemLevel)
  804. if string.isNullOrEmpty(basicAtt) then
  805. return true, isLevelUp
  806. end
  807. this.addAngelEquipAttr(actor, basicAtt, itemId)
  808. end
  809. end
  810. local addExp = itemExp + tempExp
  811. if addExp >= tonumber(levelUpNeedExp) then
  812. -- 突破材料判断,达到突破等级后
  813. if not string.isNullOrEmpty(breakMaterial) then
  814. attrInfo[itemId] = {
  815. ["level"] = itemLevel,
  816. ["exp"] = tonumber(levelUpNeedExp),
  817. ["rank"] = rank,
  818. ["grails"] = grails
  819. }
  820. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
  821. -- 通知客户端可以突破
  822. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_CAN_BREAK, itemId)
  823. return true, isLevelUp
  824. else
  825. -- 没有达到突破等级,直接升级
  826. itemLevel = itemLevel + 1
  827. isLevelUp = true
  828. itemExp = addExp - tonumber(levelUpNeedExp)
  829. attrInfo[itemId] = {
  830. ["level"] = itemLevel,
  831. ["exp"] = itemExp,
  832. ["rank"] = rank,
  833. ["grails"] = grails
  834. }
  835. -- 升级后增加对应的属性
  836. local basicAtt = ConfigDataManager.getTableValue("cfg_equip_angelAtt", "basicAtt", "ornamentsGroup",
  837. groupId, "lv", itemLevel)
  838. if string.isNullOrEmpty(basicAtt) then
  839. return true, isLevelUp
  840. end
  841. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
  842. this.addAngelEquipAttr(actor, basicAtt, itemId)
  843. end
  844. else
  845. attrInfo[itemId] = {
  846. ["level"] = itemLevel,
  847. ["exp"] = addExp,
  848. ["rank"] = rank,
  849. ["grails"] = grails
  850. }
  851. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, attrInfo)
  852. end
  853. return true, isLevelUp
  854. end
  855. --- 延迟关闭天使装备经验加成buff
  856. ---@param actor table 角色对象
  857. ---@param delayTime number 延迟时间
  858. function this.delayCloseExpBoostBuff(actor, delayTime)
  859. intervalcalldelay(actor, delayTime, 1000, 1, "angelexpboostclear")
  860. end
  861. --- 天使装备经验加成buff延迟关闭
  862. function angelexpboostclear(actor)
  863. local boostInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO)
  864. if not table.isNullOrEmpty(boostInfo) then
  865. local now = getbaseinfo(actor, "now")
  866. local delayTime = boostInfo[tonumber(BuffId.ANGEL_EXP_BOOST_ID)]["delayTime"]
  867. if now >= delayTime then
  868. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIP_EXP_BOOST_INFO, {})
  869. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_EQUIP_EXP_BOOST_INFO, {
  870. [tonumber(BuffId.ANGEL_EXP_BOOST_ID)] = {}
  871. })
  872. end
  873. end
  874. end
  875. --- 根据条件发送已激活与可激活的天赋大师id信息
  876. ---@param actor table 角色
  877. --[[function this.sendActiveTalentInfo(actor)
  878. local career = getbaseinfo(actor, "getbasecareer")
  879. local tables = ConfigDataManager.getTable("cfg_equip_angelSuit", "type", 2, "career", career)
  880. local res = {}
  881. local activeIds = getplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_ACTIVE_ID)
  882. activeIds = activeIds and activeIds or {}
  883. local canActiveIds = getplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_CAN_ACTIVE_ID)
  884. canActiveIds = canActiveIds and canActiveIds or {}
  885. for _, v in pairs(tables) do
  886. local id = tonumber(v["id"])
  887. if table.contains(activeIds, id) then
  888. goto mark
  889. end
  890. local result, _ = AngelMajorEquipment.checkDressedConditionType2(actor, id)
  891. if result then
  892. if table.contains(canActiveIds, id) then
  893. goto mark
  894. else
  895. table.insert(canActiveIds, id)
  896. setplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_CAN_ACTIVE_ID, canActiveIds)
  897. end
  898. else
  899. if table.contains(canActiveIds, id) then
  900. table.removeByValue(canActiveIds, id)
  901. setplaydef(actor, PlayerDefKey.angel.ANGEL_TALENT_CAN_ACTIVE_ID, canActiveIds)
  902. else
  903. goto mark
  904. end
  905. end
  906. :: mark ::
  907. end
  908. res["activeIds"] = activeIds and activeIds or {}
  909. res["canActiveIds"] = canActiveIds and canActiveIds or {}
  910. sendluamsg(actor, LuaMessageIdToClient.RES_ANGEL_TALENT_ACTIVE_INFO, res)
  911. end]]
  912. --- 测试增加大天使装备经验
  913. ---@param actor table 角色对象
  914. ---@param exp number 经验值
  915. function addangelequipexp(actor, exp)
  916. local angelExp = tonumber(exp)
  917. local equipmentData = getputonequipinfo(actor)
  918. if table.isNullOrEmpty(equipmentData) then
  919. return
  920. end
  921. local isLevelUp = false
  922. local mark = false
  923. local attrInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  924. for _, v in pairs(equipmentData) do
  925. local tempExp = angelExp
  926. mark, isLevelUp = this.addAngelEquipExp(actor, attrInfo, v, tempExp, isLevelUp)
  927. if not mark then
  928. break
  929. end
  930. end
  931. if isLevelUp then
  932. -- 更新开服竞技排行数据
  933. local lv = AngelMajorEquipment.getLvSum(actor)
  934. OpenServerCompetition.updateRankData(actor, CompetitionType.ANGEL, lv)
  935. sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, attrInfo)
  936. end
  937. sendluamsg(actor, LuaMessageIdToClient.RES_ALL_ANGEL_EQUIPMENT_ATTR_INFO, attrInfo)
  938. end
  939. function AngelMajorEquipment.grailsDataHandle()
  940. local isHandle = getsysvar(SystemVarConst.GRAILS_DATA_IS_HANDLE)
  941. if not isHandle then
  942. jprint("================================>grailsDataHandle start")
  943. local allRole = getallrolesummaryinfos()
  944. if not table.isNullOrEmpty(allRole) then
  945. for _, role in pairs(allRole) do
  946. local actor = role["actor"]
  947. local equipData = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  948. if not table.isNullOrEmpty(equipData) then
  949. local grailInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_GRAIL_ENTRY_INFO)
  950. for _, v in pairs(equipData) do
  951. local grails = v["grails"]
  952. if not table.isNullOrEmpty(grails) then
  953. for grailId, data in pairs(grails) do
  954. local level = data["level"]
  955. if string.isNullOrEmpty(level) then
  956. local entryInfo = grailInfo[grailId]
  957. if not table.isNullOrEmpty(entryInfo) then
  958. grails[grailId]["level"] = entryInfo["level"]
  959. end
  960. end
  961. end
  962. end
  963. end
  964. end
  965. setplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA, equipData)
  966. end
  967. end
  968. setsysvar(SystemVarConst.GRAILS_DATA_IS_HANDLE, true)
  969. jprint("================================>grailsDataHandle end")
  970. end
  971. end
  972. --- 合服变量处理
  973. function AngelMajorEquipment.combine()
  974. local hosts = gethosts()
  975. for _, host in ipairs(hosts) do
  976. setsysvar(host, SystemVarConst.GRAILS_DATA_IS_HANDLE, false)
  977. end
  978. end
  979. --- 获取大天使装备总阶数与总等级
  980. --- @param actor table 角色对象
  981. --- @return number rank, number level 阶数,等级
  982. function AngelMajorEquipment.getTotalInfo(actor)
  983. local equipmentData = getputonequipinfo(actor)
  984. if table.isNullOrEmpty(equipmentData) then
  985. return 0, 0
  986. end
  987. local equipInfo = getplaydef(actor, PlayerDefKey.angel.ANGEL_EQUIPMENT_ATTR_DATA)
  988. if table.isNullOrEmpty(equipInfo) then
  989. return 0, 0
  990. end
  991. local rank = 0
  992. local level = 0
  993. local count = 0
  994. for _, v in pairs(equipmentData) do
  995. local itemId = v["id"]
  996. local itemConfigId = v["cfgid"]
  997. if this.isAngelEquip(itemConfigId) then
  998. local attrInfo = equipInfo[itemId]
  999. if not table.isNullOrEmpty(attrInfo) then
  1000. rank = rank + attrInfo["rank"]
  1001. level = level + attrInfo["level"]
  1002. count = count + 1
  1003. end
  1004. end
  1005. end
  1006. return rank, level
  1007. end