WinnerRelicLogic.lua 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. local Msg = require("core.Msg")
  2. local CommonDB = require("common.CommonDB")
  3. local relicModule = require("excel.ServerRelic")
  4. local Grid = require("bag.Grid")
  5. local BagLogic = require("bag.BagLogic")
  6. local RoleAttr = require("role.RoleAttr")
  7. local ObjHuman = require("core.ObjHuman")
  8. local RoleDefine = require("role.RoleDefine")
  9. local Lang = require("common.Lang")
  10. local Broadcast = require("broadcast.Broadcast")
  11. local HuanJingTowerLogic = require("huanjingTower.HuanjingTowerLogic")
  12. local HeroConfig = require("excel.hero").hero
  13. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  14. local HeroLogic = require("hero.HeroLogic")
  15. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  16. local Util = require("common.Util")
  17. local LOGTYPE = "WinnerRelic"
  18. local relicUpgradeConfig = relicModule.RelicUpgrade -- 获取升级配置表
  19. local relicDataConfig = relicModule.RelicData -- 获取遗物数据表
  20. local COND_TOWER_LEVEL = 500 --开启本系统需要通关恶魔之塔的层数
  21. --[[
  22. DB =
  23. {{
  24. -- 激活状态
  25. status ={
  26. --{[1601] = 3,(star级别)
  27. --[1602] = 0,
  28. }
  29. -- 装备状态(整合到同一命名空间)
  30. --equipped = {
  31. [1601] = {heoidx, heoidx}
  32. -- }}
  33. ]]
  34. --判断是否开启圣者遗物
  35. local function isOpen(human)
  36. local towerLevel = HuanJingTowerLogic.getTowerLevel(human)
  37. if towerLevel >= COND_TOWER_LEVEL then
  38. return true
  39. end
  40. return false
  41. end
  42. -- 获取对应类型的遗物
  43. local function generateCfgByType(type_m)
  44. local tbl = {}
  45. for relicId, relicCfg in pairs(relicDataConfig) do
  46. if relicCfg.nType == type_m then
  47. tbl[relicId] = relicCfg
  48. end
  49. end
  50. if not next(tbl) then
  51. return nil
  52. end
  53. return tbl
  54. end
  55. -- 红点判断
  56. local function dotJudgment(human, cfgHtbl)
  57. -- print("当前进入遗物类型红点判断")
  58. local relicData = human.db.relicListData
  59. for relicId, relicCfg in pairs(cfgHtbl) do
  60. local nLevel = 0
  61. if relicData and relicData.status and relicData.status[relicId] then
  62. nLevel = relicData.status[relicId]
  63. end
  64. -- print("当前遗物等级",nLevel)
  65. if nLevel == nil or nLevel == 0 then
  66. if BagLogic.getItemCnt(human, relicCfg.nProp) >= 1 then
  67. return true
  68. end
  69. elseif nLevel +1 <= 10 then
  70. local num = relicUpgradeConfig and relicUpgradeConfig[nLevel +1] and relicUpgradeConfig[nLevel +1].CostNum or 0
  71. if BagLogic.getItemCnt(human, relicCfg.nProp) >= num then
  72. return true
  73. end
  74. end
  75. end
  76. -- print("当前不包含红点")
  77. return false
  78. end
  79. local function AddTableAttr(tNode, tConfig, tConfig2,tstar)
  80. tNode[0] = 4
  81. tNode[1].key = tConfig.HP
  82. tNode[1].value = tConfig2.nLife* tstar
  83. tNode[2].key = tConfig.ATK
  84. tNode[2].value= tConfig2.nAttack*tstar
  85. tNode[3].key = tConfig.DEF
  86. tNode[3].value = tConfig2.nDefense*tstar
  87. tNode[4].key = tConfig.SPEED
  88. tNode[4].value = tConfig2.nSpeed*tstar
  89. end
  90. local function AddTableAttr2(tNode, tConfig, tConfig2)
  91. tNode[0] = 4
  92. tNode[1].key = tConfig.HP
  93. tNode[1].value = tConfig2.nLife
  94. tNode[2].key = tConfig.ATK
  95. tNode[2].value= tConfig2.nAttack
  96. tNode[3].key = tConfig.DEF
  97. tNode[3].value = tConfig2.nDefense
  98. tNode[4].key = tConfig.SPEED
  99. tNode[4].value = tConfig2.nSpeed
  100. end
  101. function Listofrelics(human)
  102. -- if not isOpen(human) then
  103. -- return Broadcast.sendErr(human, Lang.COMMON_NOT_OPEN)
  104. -- end
  105. local tMsgData = Msg.gc.GC_SACRED_RELIC_QUERY
  106. local RelicConfigs = tMsgData.SacredRelicConfigs
  107. local relicData = human.db.relicListData or {} --数据库
  108. relicData.status = relicData.status or {}
  109. relicData.equipped = relicData.equipped or {}
  110. RelicConfigs[0] = 0
  111. local len = 0
  112. for relicId, relicCfg in pairs(relicDataConfig) do
  113. len = len + 1
  114. RelicConfigs[0] = len
  115. local playerRelicData = (relicData and relicData.status and relicData.status[relicId]) or 0 -- 默认未激活
  116. local currentStar = playerRelicData or 0
  117. local msgEntry = RelicConfigs[len]
  118. -- 基础属性
  119. msgEntry.id = relicId
  120. msgEntry.name = relicCfg.nName
  121. msgEntry.activateItem = relicCfg.nProp
  122. AddTableAttr(msgEntry.attr, RoleDefine, relicCfg, currentStar)
  123. AddTableAttr2(msgEntry.nextattr, RoleDefine, relicCfg)
  124. msgEntry.effectDesc = relicCfg.nEffectdescription
  125. local bonusValues = {}
  126. if relicCfg.nLifeBonus then table.insert(bonusValues, relicCfg.nLifeBonus) end
  127. if relicCfg.nAttackBonus then table.insert(bonusValues, relicCfg.nAttackBonus) end
  128. if relicCfg.nDefenseBonus then table.insert(bonusValues, relicCfg.nDefenseBonus) end
  129. if relicCfg.nSpeedBonus then table.insert(bonusValues, relicCfg.nSpeedBonus) end
  130. msgEntry.effectData[0] = 4
  131. msgEntry.effectNextData[0] = 4
  132. msgEntry.effectMaxData[0] = 4
  133. for i, bonusArray in ipairs(bonusValues) do
  134. local replaceValue = currentStar > 0 and bonusArray[currentStar] or 0
  135. local replaceValueNext = currentStar + 1 > 0 and currentStar + 1 <= 10 and bonusArray[currentStar+1] or 0
  136. local replaceValueMax = bonusArray and bonusArray[10] or 0
  137. -- effectDesc = string.gsub(effectDesc, "X%%", tostring(replaceValue).."%%", 1)
  138. msgEntry.effectData[i] = replaceValue
  139. msgEntry.effectNextData[i] = replaceValueNext
  140. msgEntry.effectMaxData[i] = replaceValueMax
  141. end
  142. msgEntry.type = relicCfg.nType
  143. local nextStar = currentStar + 1
  144. local costNum = nextStar <= 10 and relicUpgradeConfig and relicUpgradeConfig[nextStar] and relicUpgradeConfig[nextStar].CostNum or 0
  145. Grid.makeItem(msgEntry.upGradeCost, relicCfg.nProp, costNum)
  146. msgEntry.upGradeCost.cnt = costNum or 0
  147. msgEntry.starLevel = currentStar or 0
  148. if relicUpgradeConfig and relicUpgradeConfig[currentStar] then
  149. msgEntry.equipLimit = relicUpgradeConfig[currentStar].EquipHeroNum or 0
  150. else
  151. msgEntry.equipLimit = 0
  152. end
  153. if relicData and relicData.equipped and relicData.equipped[relicId] then
  154. msgEntry.heroIdx[0] = #relicData.equipped[relicId]
  155. for idx, rid in ipairs(relicData.equipped[relicId]) do
  156. msgEntry.heroIdx[idx] = rid
  157. end
  158. else
  159. msgEntry.heroIdx = {} -- 先初始化为空表
  160. msgEntry.heroIdx[0] = 0
  161. end
  162. end
  163. Msg.send(tMsgData, human.fd)
  164. end
  165. function ActiveandUpgrade(human,relicId)
  166. -- print("开始激活圣者遗物")
  167. local relicCfg = relicDataConfig[relicId]
  168. if not relicCfg then
  169. return Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
  170. end
  171. human.db.relicListData = human.db.relicListData or {}
  172. human.db.relicListData.status = human.db.relicListData.status or {}
  173. local relicData=human.db.relicListData
  174. local playerRelicData = relicData and relicData.status and relicData.status[relicId] or 0
  175. local currentStar = playerRelicData or 0
  176. -- 检查是否已达到最大星级
  177. if currentStar >=10 then
  178. return Broadcast.sendErr(human, Lang.COMMON_MAX_LEVEL)
  179. end
  180. local nextStar = currentStar +1
  181. if nextStar > 10 or not relicUpgradeConfig or not relicUpgradeConfig[nextStar] then
  182. return Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
  183. end
  184. local costItemId = relicCfg and relicCfg.nProp
  185. local costNum = relicUpgradeConfig and relicUpgradeConfig[nextStar] and relicUpgradeConfig[nextStar].CostNum or 0
  186. if not costItemId or BagLogic.getItemCnt(human, costItemId) < costNum then
  187. return Broadcast.sendErr(human, Lang.COMMON_ITEM_NOT_ENOUGH)
  188. end
  189. BagLogic.delItem(human, costItemId, costNum, LOGTYPE)
  190. --更新数据
  191. playerRelicData = nextStar or 0
  192. human.db.relicListData.status = human.db.relicListData.status or {}
  193. human.db.relicListData.status[relicId] = playerRelicData
  194. --返回数据
  195. local tMsgData = Msg.gc.GC_SACRED_RELIC_UPGRADE
  196. local RelicData = tMsgData.data or {}
  197. RelicData.id = relicId
  198. RelicData.name = relicCfg.nName
  199. RelicData.activateItem = relicCfg.nProp
  200. AddTableAttr(RelicData.attr, RoleDefine, relicCfg, nextStar)
  201. AddTableAttr2(RelicData.nextattr, RoleDefine, relicCfg)
  202. local bonusValues = {}
  203. RelicData.effectDesc = relicCfg.nEffectdescription
  204. if relicCfg.nLifeBonus then table.insert(bonusValues, relicCfg.nLifeBonus) end
  205. if relicCfg.nAttackBonus then table.insert(bonusValues, relicCfg.nAttackBonus) end
  206. if relicCfg.nDefenseBonus then table.insert(bonusValues, relicCfg.nDefenseBonus) end
  207. if relicCfg.nSpeedBonus then table.insert(bonusValues, relicCfg.nSpeedBonus) end
  208. RelicData.effectData[0] = 4
  209. RelicData.effectNextData[0] = 4
  210. RelicData.effectMaxData[0] = 4
  211. for i, bonusArray in ipairs(bonusValues) do
  212. local replaceValue = nextStar > 0 and bonusArray[nextStar] or 0
  213. local replaceValueNext = nextStar + 1 > 0 and nextStar + 1 <= 10 and bonusArray[nextStar+1] or 0
  214. local replaceValueMax = bonusArray and bonusArray[10] or 0
  215. -- effectDesc = string.gsub(effectDesc, "X%%", tostring(replaceValue).."%%", 1)
  216. RelicData.effectData[i] = replaceValue
  217. RelicData.effectNextData[i] = replaceValueNext
  218. RelicData.effectMaxData[i] = replaceValueMax
  219. end
  220. RelicData.type = relicCfg.nType or {}
  221. local costNum = nextStar+1 <= 10 and relicUpgradeConfig and relicUpgradeConfig[nextStar+1] and relicUpgradeConfig[nextStar+1].CostNum or 0
  222. Grid.makeItem(RelicData.upGradeCost, relicCfg.nProp, costNum)
  223. RelicData.upGradeCost.cnt = costNum or 0
  224. RelicData.starLevel = nextStar or 0
  225. if relicUpgradeConfig and relicUpgradeConfig[nextStar] then
  226. RelicData.equipLimit = relicUpgradeConfig[nextStar].EquipHeroNum or 0
  227. else
  228. RelicData.equipLimit = 0
  229. end
  230. if relicData and relicData.equipped and relicData.equipped[relicId] then
  231. RelicData.heroIdx[0] = #relicData.equipped[relicId]
  232. for idx, rid in ipairs(relicData.equipped[relicId]) do
  233. RelicData.heroIdx[idx] = rid
  234. local heroID = HeroLogic.getHeroIdByIndex(human, rid)
  235. local heroGrid = HeroLogic.getHeroGrid(human, heroID, rid)
  236. if heroGrid and heroGrid.relic and heroGrid.relilc.star then
  237. heroGrid.relilc.star = nextStar or 0
  238. end
  239. end
  240. else
  241. RelicData.heroIdx = {} -- 先初始化为空表
  242. RelicData.heroIdx[0] = 0
  243. end
  244. --更新英雄身上穿的遗物的星级
  245. -- tMsgData = relicData
  246. Msg.send(tMsgData, human.fd)
  247. --重算战力
  248. RoleAttr.cleanHeroAttrCache(human)
  249. RoleAttr.doCalc(human)
  250. ObjHuman.sendAttr(human, RoleDefine.ZHANDOULI)
  251. --刷新红点,
  252. nextStar = nextStar + 1
  253. costNum = nextStar <= 10 and relicUpgradeConfig and relicUpgradeConfig[nextStar] and relicUpgradeConfig[nextStar].CostNum or 0
  254. if nextStar > 10 or BagLogic.getItemCnt(human, costItemId) < costNum then
  255. local dotID = 0
  256. if relicCfg.nType == 1 then
  257. dotID = RoleSystemDefine.ROLE_SYS_ID_2022
  258. elseif relicCfg.nType == 2 then
  259. dotID = RoleSystemDefine.ROLE_SYS_ID_2023
  260. elseif relicCfg.nType == 3 then
  261. dotID = RoleSystemDefine.ROLE_SYS_ID_2024
  262. end
  263. RoleSystemLogic.onDot(human, dotID)
  264. --刷新入口处
  265. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2021)
  266. end
  267. end
  268. function putmsg(human,RelicData,relicCfg,oldid,isexist)
  269. -- print("当前进入给old赋值")
  270. local relicId = oldid
  271. if isexist then
  272. RelicData.id = oldid
  273. else
  274. RelicData.id = 0
  275. end
  276. local relicData =human.db.relicListData or {}
  277. local playerRelicData = human.db.relicListData and human.db.relicListData.status and human.db.relicListData.status[oldid] or 0
  278. local currentStar = playerRelicData or 0
  279. RelicData.name = relicCfg.nName
  280. RelicData.activateItem = relicCfg.nProp
  281. AddTableAttr(RelicData.attr, RoleDefine, relicCfg, currentStar)
  282. AddTableAttr2(RelicData.nextattr, RoleDefine, relicCfg)
  283. RelicData.effectDesc = relicCfg.nEffectdescription
  284. local bonusValues = {}
  285. if relicCfg.nLifeBonus then table.insert(bonusValues, relicCfg.nLifeBonus) end
  286. if relicCfg.nAttackBonus then table.insert(bonusValues, relicCfg.nAttackBonus) end
  287. if relicCfg.nDefenseBonus then table.insert(bonusValues, relicCfg.nDefenseBonus) end
  288. if relicCfg.nSpeedBonus then table.insert(bonusValues, relicCfg.nSpeedBonus) end
  289. RelicData.effectData[0] = 4
  290. RelicData.effectNextData[0] = 4
  291. RelicData.effectMaxData[0] = 4
  292. for i, bonusArray in ipairs(bonusValues) do
  293. local replaceValue = currentStar > 0 and bonusArray[currentStar] or 0
  294. local replaceValueNext = currentStar + 1 > 0 and currentStar + 1 <= 10 and bonusArray[currentStar+1] or 0
  295. local replaceValueMax = bonusArray and bonusArray[10] or 0
  296. -- effectDesc = string.gsub(effectDesc, "X%%", tostring(replaceValue).."%%", 1)
  297. RelicData.effectData[i] = replaceValue
  298. RelicData.effectNextData[i] = replaceValueNext
  299. RelicData.effectMaxData[i] = replaceValueMax
  300. end
  301. RelicData.type = relicCfg.nType
  302. local costNum = currentStar+1 <= 10 and relicUpgradeConfig and relicUpgradeConfig[currentStar+1] and relicUpgradeConfig[currentStar+1].CostNum or 0
  303. Grid.makeItem(RelicData.upGradeCost, relicCfg.nProp, costNum)
  304. RelicData.upGradeCost.cnt = costNum or 0
  305. RelicData.starLevel = currentStar or 0
  306. if relicUpgradeConfig and relicUpgradeConfig[currentStar] then
  307. RelicData.equipLimit = relicUpgradeConfig[currentStar].EquipHeroNum or 0
  308. else
  309. RelicData.equipLimit = 0
  310. end
  311. -- 填充已装备英雄信息
  312. if relicData and relicData.equipped and relicData.equipped[relicId] then
  313. RelicData.heroIdx[0] = #relicData.equipped[relicId]
  314. for idx, rid in ipairs(relicData.equipped[relicId]) do
  315. RelicData.heroIdx[idx] = rid
  316. end
  317. else
  318. RelicData.heroIdx = {} -- 先初始化为空表
  319. RelicData.heroIdx[0] = 0
  320. end
  321. -- print("当前结束old赋值")
  322. end
  323. -- 装备/卸下圣者遗物
  324. function EquipeandRemove(human, heroID, heroIdx, relicId, operate)
  325. local relicCfg = relicDataConfig and relicDataConfig[relicId]
  326. local playerRelicData = human.db.relicListData and human.db.relicListData.status and human.db.relicListData.status[relicId] or 0
  327. local currentStar = playerRelicData or 0
  328. -- 检查系统是否开启
  329. if not isOpen(human) then
  330. return Broadcast.sendErr(human, Lang.COMMON_NOT_OPEN)
  331. end
  332. --检查英雄是否存在
  333. local heroGrid = HeroLogic.getHeroGrid(human, heroID, heroIdx)
  334. if not heroGrid then
  335. return Broadcast.sendErr(human, Lang.HERO_NOT_EXIST)
  336. end
  337. --检查英雄是否达到14星
  338. if heroGrid.star < 14 then
  339. return Broadcast.sendErr(human, Lang.SACRED_RELIC_HERO_LEVEL_LIMIT)
  340. end
  341. -- 初始化遗物数据
  342. human.db.relicListData = human.db.relicListData or {}
  343. local relicData =human.db.relicListData or {}
  344. -- 装备操作
  345. local tMsgData = Msg.gc.GC_SACRED_RELIC_EQUIP
  346. local RelicData = tMsgData.olddata
  347. tMsgData.heroIdx = heroIdx
  348. local oldcfg = relicCfg
  349. local oldid = relicId
  350. local isexist, nIndex = false, -1
  351. if human.db and human.db.relicListData and human.db.relicListData.equipped then
  352. for id, heroList in pairs(human.db.relicListData.equipped) do
  353. for idx, heroid in pairs(heroList) do
  354. if heroid == heroIdx then
  355. oldcfg = relicDataConfig and relicDataConfig[id]
  356. oldid = id
  357. isexist = true
  358. nIndex = idx
  359. break
  360. end
  361. end
  362. if isexist then
  363. break
  364. end
  365. end
  366. end
  367. putmsg(human,RelicData,oldcfg,oldid,isexist)
  368. if operate == 1 then
  369. local LEN = human.db.relicListData and human.db.relicListData.equipped and human.db.relicListData.equipped[relicId] and #human.db.relicListData.equipped[relicId]
  370. local star = human.db and human.db.relicListData and human.db.relicListData.status and human.db.relicListData.status[relicId] or 0
  371. local NumLimit = relicUpgradeConfig and relicUpgradeConfig[star] and relicUpgradeConfig[star].EquipHeroNum or 0
  372. if LEN and LEN >= NumLimit then
  373. return Broadcast.sendErr(human, Lang.RELIC_EQUIP_LIMIT)
  374. end
  375. -- print("当前进入装备操作")
  376. -- 如果当前英雄已经装备了遗物
  377. human.db.relicListData.equipped = human.db.relicListData.equipped or {}
  378. human.db.relicListData.equipped[relicId] = human.db.relicListData.equipped[relicId] or {}
  379. if heroGrid and heroGrid.relic and heroGrid.relic.star and heroGrid.relic.star >0 then
  380. -- 遍历找到对应的英雄索引并移除
  381. if isexist and -1 ~= nIndex then
  382. table.remove(relicData.equipped[oldid],nIndex)
  383. RelicData.heroIdx[0] = #relicData.equipped[oldid]
  384. for idx, rid in ipairs(relicData.equipped[oldid]) do
  385. RelicData.heroIdx[idx] = rid
  386. end
  387. else
  388. RelicData.heroIdx = {} -- 先初始化为空表
  389. RelicData.heroIdx[0] = 0
  390. end
  391. end
  392. heroGrid.relic = {}
  393. if not human.db.relicListData.equipped[relicId] then
  394. human.db.relicListData.equipped[relicId] = {} -- 初始化
  395. end
  396. if human.db.relicListData and human.db.relicListData.equipped and human.db.relicListData.equipped[relicId] then
  397. for _, idx in ipairs(human.db.relicListData.equipped[relicId]) do
  398. if idx == heroIdx then
  399. return
  400. end
  401. end
  402. table.insert(human.db.relicListData.equipped[relicId],heroIdx)
  403. -- print("成功装备遗物", relicId, "给英雄", heroIdx)
  404. end
  405. heroGrid.relic = heroGrid.relic or {}
  406. heroGrid.relic.relicID = relicId
  407. heroGrid.relic.star = human.db.relicListData and human.db.relicListData.status and human.db.relicListData.status[relicId] or 0
  408. -- print("成功装备遗物", relicId, "给英雄", heroIdx,"当前遗物星级为",heroGrid.relic.star)
  409. else
  410. if human.db.relicListData and human.db.relicListData.equipped and human.db.relicListData.equipped[relicId] then
  411. for idx,rid in pairs(human.db.relicListData.equipped[relicId]) do
  412. if rid == heroIdx then
  413. table.remove(human.db.relicListData.equipped[relicId],idx)
  414. break
  415. end
  416. end
  417. else
  418. return Broadcast.sendErr(human, Lang.RELIC_HERO_NO_EQUPPED)
  419. end
  420. heroGrid.relic = {}
  421. end
  422. --获取更新之后的数据
  423. local nRelicData = tMsgData.newdata
  424. if operate == 0 then
  425. nRelicData.id = 0
  426. else
  427. nRelicData.id = relicId
  428. end
  429. tMsgData.heroIdx = heroIdx
  430. nRelicData.name = relicCfg.nName
  431. nRelicData.activateItem = relicCfg.nProp
  432. AddTableAttr(nRelicData.attr, RoleDefine, relicCfg, currentStar)
  433. AddTableAttr2(nRelicData.nextattr, RoleDefine, relicCfg)
  434. nRelicData.effectDesc = relicCfg.nEffectdescription
  435. local nbonusValues = {}
  436. if relicCfg.nLifeBonus then table.insert(nbonusValues, relicCfg.nLifeBonus) end
  437. if relicCfg.nAttackBonus then table.insert(nbonusValues, relicCfg.nAttackBonus) end
  438. if relicCfg.nDefenseBonus then table.insert(nbonusValues, relicCfg.nDefenseBonus) end
  439. if relicCfg.nSpeedBonus then table.insert(nbonusValues, relicCfg.nSpeedBonus) end
  440. nRelicData.effectData[0] = 4
  441. nRelicData.effectNextData[0] = 4
  442. nRelicData.effectMaxData[0] = 4
  443. for i, bonusArray in ipairs(nbonusValues) do
  444. local replaceValue = currentStar > 0 and bonusArray[currentStar] or 0
  445. local replaceValueNext = currentStar + 1 > 0 and currentStar + 1 <= 10 and bonusArray[currentStar+1] or 0
  446. local replaceValueMax = bonusArray and bonusArray[10] or 0
  447. -- effectDesc = string.gsub(effectDesc, "X%%", tostring(replaceValue).."%%", 1)
  448. nRelicData.effectData[i] = replaceValue
  449. nRelicData.effectNextData[i] = replaceValueNext
  450. nRelicData.effectMaxData[i] = replaceValueMax
  451. end
  452. nRelicData.type = relicCfg.nType
  453. local costNum = currentStar+1 <= 10 and relicUpgradeConfig and relicUpgradeConfig[currentStar+1] and relicUpgradeConfig[currentStar+1].CostNum or 0
  454. Grid.makeItem(nRelicData.upGradeCost, relicCfg.nProp, costNum)
  455. nRelicData.upGradeCost.cnt = costNum or 0
  456. nRelicData.starLevel = currentStar or 0
  457. if relicUpgradeConfig and relicUpgradeConfig[currentStar] then
  458. nRelicData.equipLimit = relicUpgradeConfig[currentStar].EquipHeroNum or 0
  459. else
  460. nRelicData.equipLimit = 0
  461. end
  462. -- 填充已装备英雄信息
  463. if relicData and relicData.equipped and relicData.equipped[relicId] then
  464. nRelicData.heroIdx[0] = #relicData.equipped[relicId]
  465. for idx, rid in ipairs(relicData.equipped[relicId]) do
  466. nRelicData.heroIdx[idx] = rid
  467. end
  468. else
  469. nRelicData.heroIdx = {} -- 先初始化为空表
  470. nRelicData.heroIdx[0] = 0
  471. end
  472. -- table.print_lua_table(tMsgData)
  473. Msg.send(tMsgData, human.fd)
  474. --重算战力
  475. HeroLogic.sendHeroBagUpdate(human,heroIdx)
  476. -- print("圣者遗物装备完毕")
  477. ObjHuman.doCalcHero(human, heroIdx)
  478. HeroLogic.sendHeroBagDynamic(human, heroID, heroIdx)
  479. HeroLogic.refreshDot(human, heroGrid.uuid)
  480. end
  481. -- 遗物对英雄属性加成
  482. function doCalcHero(human,heroGrid,addAttrs)
  483. local Life,Attack,Defense,Speed = 0, 0, 0, 0
  484. local reliData = human and human.db and human.db.relicListData and human.db.relicListData.status
  485. if not reliData then
  486. return
  487. end
  488. for relicId, star in pairs(human.db.relicListData.status) do
  489. local relicData = relicDataConfig and relicDataConfig[relicId]
  490. Life = relicData and relicData.nLife or 0
  491. Attack = relicData and relicData.nAttack or 0
  492. Defense = relicData and relicData.nDefense or 0
  493. Speed = relicData and relicData.nSpeed or 0
  494. star = star or 1
  495. RoleAttr.updateValue(RoleDefine.HP,Life * star,addAttrs)
  496. RoleAttr.updateValue(RoleDefine.ATK,Attack * star,addAttrs)
  497. RoleAttr.updateValue(RoleDefine.DEF,Defense * star,addAttrs)
  498. RoleAttr.updateValue(RoleDefine.SPEED,Speed * star,addAttrs)
  499. end
  500. end
  501. --红点
  502. function isDot(human, dotConfig)
  503. if not isOpen(human) then
  504. return false
  505. end
  506. --入口处的红点判断
  507. if dotConfig.id == RoleSystemDefine.ROLE_SYS_ID_2021 then
  508. return dotJudgment(human, relicDataConfig)
  509. else
  510. -- print("当前进红点分页111111 id = "..dotConfig.id)
  511. --单个分页的红点
  512. local RelicType = 0
  513. if dotConfig.id == RoleSystemDefine.ROLE_SYS_ID_2022 then
  514. RelicType = 1
  515. elseif dotConfig.id == RoleSystemDefine.ROLE_SYS_ID_2023 then
  516. RelicType = 2
  517. elseif dotConfig.id == RoleSystemDefine.ROLE_SYS_ID_2024 then
  518. RelicType = 3
  519. end
  520. local cfgHtbl = generateCfgByType(RelicType)
  521. if not cfgHtbl then
  522. return false
  523. end
  524. return dotJudgment(human, cfgHtbl)
  525. end
  526. end
  527. function WinnerRelic_GetSkillID(nRelicID, nStar)
  528. local tConfig = relicDataConfig[nRelicID]
  529. if nil == tConfig then
  530. return 0
  531. end
  532. return tConfig.skillID[nStar] or 0
  533. end
  534. --对应遗物加成描述中的第一个x
  535. function WinnerRelic_GetRateLife(nRelicID, nStar)
  536. local tConfig = relicDataConfig[nRelicID]
  537. if nil == tConfig then
  538. return 0
  539. end
  540. return tConfig.nLifeBonus[nStar]
  541. end
  542. --对应遗物加成描述中的第二个x
  543. function WinnerRelic_GetRateAttack(nRelicID, nStar)
  544. local tConfig = relicDataConfig[nRelicID]
  545. if nil == tConfig then
  546. return 0
  547. end
  548. return tConfig.nAttackBonus[nStar]
  549. end
  550. --对应遗物加成描述中的第三个x
  551. function WinnerRelic_GetRateDef(nRelicID, nStar)
  552. local tConfig = relicDataConfig[nRelicID]
  553. if nil == tConfig then
  554. return 0
  555. end
  556. return tConfig.nDefenseBonus[nStar]
  557. end
  558. --对应遗物加成描述中的第四个x
  559. function WinnerRelic_GetRateSpeed(nRelicID, nStar)
  560. local tConfig = relicDataConfig[nRelicID]
  561. if nil == tConfig then
  562. return 0
  563. end
  564. return tConfig.nSpeedBonus[nStar]
  565. end