XingYaoPower.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. -- 星曜之门-星耀之力
  2. local ObjHuman = require("core.ObjHuman")
  3. local Util = require("common.Util")
  4. local Msg = require("core.Msg")
  5. local Broadcast = require("broadcast.Broadcast")
  6. local Lang = require("common.Lang")
  7. local BagLogic = require("bag.BagLogic")
  8. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  9. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  10. local XingYaoMenExcel = require("excel.xingYaoMen")
  11. local HeroGrid = require("hero.HeroGrid")
  12. local Grid = require("bag.Grid")
  13. local RoleAttr = require("role.RoleAttr")
  14. local ItemDefine = require("bag.ItemDefine")
  15. local HeroExcel = require("excel.hero")
  16. -- human.db.XingYaoPower[camp] = {
  17. -- lv, --等级
  18. -- lvAttrs, --进度增加的属性,升级清除 lvAttrs[key] = value
  19. -- exp, --经验
  20. -- qualityID --品阶id对应配置表
  21. -- }
  22. -- human.db.XingYaoPower.resetCnt --重置次数
  23. function updateDaily(human)
  24. if not human.db.XingYaoPower then return end
  25. human.db.XingYaoPower.resetCnt = nil
  26. end
  27. local function getPowerData(human,camp)
  28. if not human.db.XingYaoPower then return end
  29. return human.db.XingYaoPower[camp]
  30. end
  31. function GC_XINGYAOMEN_POWER_REDS(human,camp)
  32. local msgRet = Msg.gc.GC_XINGYAOMEN_POWER_REDS
  33. local lvRed = lvRed(human,camp)
  34. local qualityRed = qualityRed(human,camp)
  35. msgRet.camp = camp
  36. msgRet.lvRed = lvRed and 1 or 0
  37. msgRet.qualityRed = qualityRed and 1 or 0
  38. --Msg.trace(msgRet)
  39. Msg.send(msgRet,human.fd)
  40. end
  41. local function makeXyPowerLvNet(human,net,camp)
  42. net.camp = camp
  43. local db = getPowerData(human,camp)
  44. net.lv = db and db.lv or 0
  45. end
  46. function CG_XINGYAOMEN_POWER_QUERY(human)
  47. if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_10042,true) then
  48. return
  49. end
  50. local defineCnf = XingYaoMenExcel.powerDefine[1]
  51. local msgRet = Msg.gc.GC_XINGYAOMEN_POWER_QUERY
  52. msgRet.lvs[0] = #defineCnf.camps
  53. for i=1,#defineCnf.camps do
  54. local camp = defineCnf.camps[i]
  55. makeXyPowerLvNet(human,msgRet.lvs[i],camp)
  56. end
  57. msgRet.reds[0] = #defineCnf.camps
  58. for camp=1,#defineCnf.camps do
  59. msgRet.reds[camp] = 0
  60. if lvRed(human,camp) or qualityRed(human,camp) then
  61. msgRet.reds[camp] = 1
  62. end
  63. end
  64. --Msg.trace(msgRet)
  65. Msg.send(msgRet,human.fd)
  66. RoleSystemLogic.sendSystemReds(human, RoleSystemDefine.ROLE_SYS_ID_404)
  67. end
  68. local function checkCamp(camp)
  69. local defineCnf = XingYaoMenExcel.powerDefine[1]
  70. for i=1,#defineCnf.camps do
  71. if camp == defineCnf.camps[i] then
  72. return true
  73. end
  74. end
  75. end
  76. local function makeLvAttrs(human,net,camp)
  77. local db = getPowerData(human,camp)
  78. local nowLV = db and db.lv or 0
  79. net.attrs[0] = 0
  80. local conf = XingYaoMenExcel.powerLv[nowLV]
  81. local attrs = nil
  82. if conf then
  83. for i=1,#conf.attrs do
  84. local key = conf.attrs[i][1]
  85. local value = conf.attrs[i][2]
  86. attrs = attrs or {}
  87. attrs[key] = (attrs[key] or 0) + value
  88. end
  89. end
  90. if db and db.lvAttrs then
  91. for key,value in pairs(db.lvAttrs) do
  92. attrs = attrs or {}
  93. attrs[key] = (attrs[key] or 0) + value
  94. end
  95. end
  96. if attrs then
  97. for key,value in pairs(attrs) do
  98. net.attrs[0] = net.attrs[0] + 1
  99. local index = net.attrs[0]
  100. net.attrs[index].key = key
  101. net.attrs[index].value = value
  102. end
  103. end
  104. local defConf = XingYaoMenExcel.powerDefine[1]
  105. net.attrsShow[0] = #defConf.powerLvAttrs
  106. for i=1,#defConf.powerLvAttrs do
  107. net.attrsShow[i].key = defConf.powerLvAttrs[i]
  108. net.attrsShow[i].value = 0
  109. end
  110. end
  111. local function makeQualityAttrs(human,net,camp)
  112. local db = getPowerData(human,camp)
  113. local qualityID = db and db.qualityID or 0
  114. net.attrs[0] = 0
  115. local attrs = {}
  116. if qualityID > 0 then
  117. for i=1,qualityID do
  118. local conf = XingYaoMenExcel.powerQuality[i]
  119. if conf then
  120. for j=1,#conf.attrs do
  121. local key = conf.attrs[j][1]
  122. local value = conf.attrs[j][2]
  123. attrs[key] = (attrs[key] or 0) + value
  124. end
  125. end
  126. end
  127. end
  128. for key,value in pairs(attrs) do
  129. net.attrs[0] = net.attrs[0] + 1
  130. local index = net.attrs[0]
  131. net.attrs[index].key = key
  132. net.attrs[index].value = value
  133. end
  134. local defConf = XingYaoMenExcel.powerDefine[1]
  135. net.attrsShow[0] = #defConf.powerQualitAttrs
  136. for i=1,#defConf.powerQualitAttrs do
  137. net.attrsShow[i].key = defConf.powerQualitAttrs[i]
  138. net.attrsShow[i].value = 0
  139. end
  140. end
  141. function CG_XINGYAOMEN_POWERLV_QUERY(human,camp)
  142. if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_10042,true) then
  143. return
  144. end
  145. if not checkCamp(camp) then return end
  146. local msgRet = Msg.gc.GC_XINGYAOMEN_POWERLV_QUERY
  147. makeXyPowerLvNet(human,msgRet.lv,camp)
  148. local db = getPowerData(human,camp)
  149. local nowExp = db and db.exp or 0
  150. local nowLV = db and db.lv or 0
  151. local conf = XingYaoMenExcel.powerLv
  152. local nextLV = math.min(nowLV + 1,#conf)
  153. local nextConf = conf[nextLV]
  154. msgRet.nowExp = nowExp
  155. msgRet.needExp = nextConf.needExp
  156. makeLvAttrs(human,msgRet.lvAttrs,camp)
  157. makeQualityAttrs(human,msgRet.qualityAttrs,camp)
  158. msgRet.upCost[0] = 0
  159. msgRet.nextAttrs[0] = 0
  160. if nowLV < #conf then
  161. msgRet.upCost[0] = 2
  162. local campsLVupItem = XingYaoMenExcel.powerDefine[1].campsLVupItem[camp]
  163. Grid.makeItem(msgRet.upCost[1],campsLVupItem,nextConf.upCost)
  164. Grid.makeItem(msgRet.upCost[2],ItemDefine.ITEM_JINBI_ID,nextConf.upCostJinBi)
  165. local attrsAdd = nextConf.attrsAdd
  166. for _,attr in pairs(attrsAdd) do
  167. msgRet.nextAttrs[0] = msgRet.nextAttrs[0] + 1
  168. local index = msgRet.nextAttrs[0]
  169. msgRet.nextAttrs[index].key = attr[1]
  170. msgRet.nextAttrs[index].value = attr[2]
  171. end
  172. end
  173. --Msg.trace(msgRet)
  174. Msg.send(msgRet,human.fd)
  175. GC_XINGYAOMEN_POWER_REDS(human,camp)
  176. end
  177. function CG_XINGYAOMEN_POWERLV_UP(human,camp)
  178. if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_10042,true) then
  179. return
  180. end
  181. if not checkCamp(camp) then return end
  182. local db = getPowerData(human,camp)
  183. local nowLV = db and db.lv or 0
  184. local conf = XingYaoMenExcel.powerLv
  185. if nowLV >= #conf then return end
  186. local defConf = XingYaoMenExcel.powerDefine[1]
  187. local campsLVupItem = defConf.campsLVupItem[camp]
  188. local nextConf = conf[nowLV+1]
  189. local upCost = nextConf.upCost
  190. if not BagLogic.checkItemCnt(human, campsLVupItem, upCost) then return end
  191. if not BagLogic.checkItemCnt(human, ItemDefine.ITEM_JINBI_ID, nextConf.upCostJinBi) then return end
  192. BagLogic.delItem(human, campsLVupItem, upCost, "xingyao_power")
  193. BagLogic.delItem(human, ItemDefine.ITEM_JINBI_ID, nextConf.upCostJinBi, "xingyao_power")
  194. local powerLvUpExp = defConf.powerLvUpExp
  195. human.db.XingYaoPower = human.db.XingYaoPower or {}
  196. human.db.XingYaoPower[camp] = human.db.XingYaoPower[camp] or {}
  197. human.db.XingYaoPower[camp].exp = (human.db.XingYaoPower[camp].exp or 0) + powerLvUpExp
  198. if human.db.XingYaoPower[camp].exp >= nextConf.needExp then
  199. human.db.XingYaoPower[camp].lv = nowLV + 1
  200. human.db.XingYaoPower[camp].lvAttrs = nil
  201. human.db.XingYaoPower[camp].exp = 0
  202. else
  203. local attrsAdd = nextConf.attrsAdd
  204. for _,attr in pairs(attrsAdd) do
  205. human.db.XingYaoPower[camp].lvAttrs = human.db.XingYaoPower[camp].lvAttrs or {}
  206. human.db.XingYaoPower[camp].lvAttrs[attr[1]] = (human.db.XingYaoPower[camp].lvAttrs[attr[1]] or 0) + attr[2]
  207. end
  208. end
  209. ObjHuman.doCalcHeros(human)
  210. CG_XINGYAOMEN_POWERLV_QUERY(human,camp)
  211. GC_XINGYAOMEN_POWER_REDS(human,camp)
  212. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_404)
  213. RoleSystemLogic.sendSystemReds(human, RoleSystemDefine.ROLE_SYS_ID_10042)
  214. end
  215. function getQualityMax(human,camp)
  216. local db = getPowerData(human,camp)
  217. local nowLV = db and db.lv or 0
  218. local conf = XingYaoMenExcel.powerLv
  219. if not conf[nowLV] then return 0,0 end
  220. local qualityMax = conf[nowLV].qualityMax
  221. local qualityMaxID = 0
  222. for qualityID,data in ipairs(XingYaoMenExcel.powerQuality) do
  223. if data.quality == qualityMax then
  224. qualityMaxID = qualityID
  225. end
  226. end
  227. return qualityMax + 1,qualityMaxID + 1
  228. end
  229. local function getQualityCanUp(human,camp)
  230. local db = getPowerData(human,camp)
  231. local qualityID = db and db.qualityID or 0
  232. local conf = XingYaoMenExcel.powerLv
  233. local qualityConf = XingYaoMenExcel.powerQuality
  234. local quality = qualityConf[qualityID] and qualityConf[qualityID].quality or 0
  235. local star = qualityConf[qualityID] and qualityConf[qualityID].star or 0
  236. if star == 0 then
  237. quality = quality - 1
  238. end
  239. for lv,data in ipairs(conf) do
  240. if quality < data.qualityMax then
  241. return lv
  242. end
  243. end
  244. return 0
  245. end
  246. function CG_XINGYAOMEN_POWERQUALITY_QUERY(human,camp)
  247. if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_10042,true) then
  248. return
  249. end
  250. if not checkCamp(camp) then return end
  251. local msgRet = Msg.gc.GC_XINGYAOMEN_POWERQUALITY_QUERY
  252. makeXyPowerLvNet(human,msgRet.lv,camp)
  253. makeLvAttrs(human,msgRet.lvAttrs,camp)
  254. makeQualityAttrs(human,msgRet.qualityAttrs,camp)
  255. local db = getPowerData(human,camp)
  256. local qualityID = db and db.qualityID or 0
  257. local conf = XingYaoMenExcel.powerQuality
  258. local quality = 0
  259. local star = 0
  260. if conf[qualityID] then
  261. quality,star = conf[qualityID].quality,conf[qualityID].star
  262. end
  263. msgRet.lvCanUp = 0
  264. msgRet.upCost[0] = 0
  265. msgRet.nextAttrs[0] = 0
  266. local qualityMax,qualityMaxID = getQualityMax(human,camp)
  267. if qualityID >= qualityMaxID then
  268. msgRet.lvCanUp = getQualityCanUp(human,camp)
  269. end
  270. msgRet.quality = quality
  271. msgRet.star = star
  272. if conf[qualityID+1] and qualityID < qualityMaxID then
  273. local upCost = conf[qualityID+1].upCost
  274. msgRet.upCost[0] = #upCost
  275. for i=1,#upCost do
  276. Grid.makeItem(msgRet.upCost[i],upCost[i][1],upCost[i][2])
  277. end
  278. local attrs = conf[qualityID+1].attrs
  279. msgRet.nextAttrs[0] = #attrs
  280. for i=1,#attrs do
  281. msgRet.nextAttrs[i].key = attrs[i][1]
  282. msgRet.nextAttrs[i].value = attrs[i][2]
  283. end
  284. end
  285. --Msg.trace(msgRet)
  286. Msg.send(msgRet,human.fd)
  287. end
  288. function CG_XINGYAOMEN_POWERQUALITY_UP(human,camp)
  289. if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_10042,true) then
  290. return
  291. end
  292. if not checkCamp(camp) then return end
  293. local db = getPowerData(human,camp)
  294. local qualityID = db and db.qualityID or 0
  295. local qualityMax,qualityMaxID = getQualityMax(human,camp)
  296. local conf = XingYaoMenExcel.powerQuality
  297. local quality = conf[qualityID] and conf[qualityID].quality or 0
  298. if qualityID >= #conf or qualityID >= qualityMaxID then return end
  299. local upCost = conf[qualityID+1].upCost
  300. for _,item in pairs(upCost) do
  301. if not BagLogic.checkItemCnt(human, item[1], item[2]) then return end
  302. end
  303. for _,item in pairs(upCost) do
  304. BagLogic.delItem(human, item[1], item[2], "xingyao_power")
  305. end
  306. human.db.XingYaoPower = human.db.XingYaoPower or {}
  307. human.db.XingYaoPower[camp] = human.db.XingYaoPower[camp] or {}
  308. human.db.XingYaoPower[camp].qualityID = qualityID + 1
  309. ObjHuman.doCalcHeros(human)
  310. CG_XINGYAOMEN_POWERQUALITY_QUERY(human,camp)
  311. GC_XINGYAOMEN_POWER_REDS(human,camp)
  312. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_404)
  313. RoleSystemLogic.sendSystemReds(human, RoleSystemDefine.ROLE_SYS_ID_10042)
  314. end
  315. local function getQualityBack(human,camp)
  316. local db = getPowerData(human,camp)
  317. local qualityID = db and db.qualityID or 0
  318. local conf = XingYaoMenExcel.powerQuality
  319. local backItem = nil
  320. if qualityID > 0 then
  321. backItem = {}
  322. for i=1,qualityID do
  323. local upCost = conf[i].upCost
  324. for j=1,#upCost do
  325. backItem[upCost[j][1]] = (backItem[upCost[j][1]] or 0) + upCost[j][2]
  326. end
  327. end
  328. end
  329. return backItem
  330. end
  331. function CG_XINGYAOMEN_POWERQUALITY_RESET(human,camp)
  332. if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_10042,true) then
  333. return
  334. end
  335. ObjHuman.updateDaily(human)
  336. local defineCnf = XingYaoMenExcel.powerDefine[1]
  337. local msgRet = Msg.gc.GC_XINGYAOMEN_POWERQUALITY_RESET
  338. msgRet.resetMax = defineCnf.resetCnt
  339. local resetCnt = human.db.XingYaoPower and human.db.XingYaoPower.resetCnt or 0
  340. msgRet.resetLeft = defineCnf.resetCnt - resetCnt
  341. Grid.makeItem(msgRet.resetCost,defineCnf.resetCost[1],defineCnf.resetCost[2])
  342. local backItem = getQualityBack(human,camp)
  343. msgRet.backItem[0] = 0
  344. if backItem then
  345. for itemID,itemCnt in pairs(backItem) do
  346. msgRet.backItem[0] = msgRet.backItem[0] + 1
  347. local index = msgRet.backItem[0]
  348. Grid.makeItem(msgRet.backItem[index],itemID,itemCnt)
  349. end
  350. end
  351. --Msg.trace(msgRet)
  352. Msg.send(msgRet,human.fd)
  353. end
  354. function CG_XINGYAOMEN_POWERQUALITY_RESET_DO(human,camp)
  355. if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_10042,true) then
  356. return
  357. end
  358. if not checkCamp(camp) then return end
  359. ObjHuman.updateDaily(human)
  360. local defineCnf = XingYaoMenExcel.powerDefine[1]
  361. if not BagLogic.checkItemCnt(human,defineCnf.resetCost[1],defineCnf.resetCost[2]) then return end
  362. BagLogic.delItem(human,defineCnf.resetCost[1],defineCnf.resetCost[2],"xingyao_power")
  363. local resetCnt = human.db.XingYaoPower and human.db.XingYaoPower.resetCnt or 0
  364. local resetLeft = defineCnf.resetCnt - resetCnt
  365. if resetLeft <= 0 then
  366. return Broadcast.sendErr(human,Lang.XINGYAOMEN_RESETCNT_ERR)
  367. end
  368. local db = getPowerData(human,camp)
  369. local qualityID = db and db.qualityID or 0
  370. if qualityID == 0 then
  371. return Broadcast.sendErr(human,Lang.XINGYAOMEN_RESET_ERR)
  372. end
  373. local backItem = getQualityBack(human,camp)
  374. if not backItem then return end
  375. for itemID,itemCnt in pairs(backItem) do
  376. BagLogic.addItem(human,itemID,itemCnt,"xingyao_power")
  377. end
  378. human.db.XingYaoPower = human.db.XingYaoPower or {}
  379. human.db.XingYaoPower.resetCnt = resetCnt + 1
  380. human.db.XingYaoPower[camp].qualityID = nil
  381. ObjHuman.doCalcHeros(human)
  382. CG_XINGYAOMEN_POWERQUALITY_RESET(human,camp)
  383. CG_XINGYAOMEN_POWERQUALITY_QUERY(human,camp)
  384. GC_XINGYAOMEN_POWER_REDS(human,camp)
  385. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_404)
  386. RoleSystemLogic.sendSystemReds(human, RoleSystemDefine.ROLE_SYS_ID_10042)
  387. end
  388. function CG_XINGYAOMEN_POWERQUALITY_ATTRS(human,camp)
  389. if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_10042,true) then
  390. return
  391. end
  392. if not checkCamp(camp) then return end
  393. local msgRet = Msg.gc.GC_XINGYAOMEN_POWERQUALITY_ATTRS
  394. msgRet.camp = camp
  395. local defConf = XingYaoMenExcel.powerDefine[1]
  396. msgRet.attrsShow[0] = #defConf.powerQualitAttrs
  397. for i=1,#defConf.powerQualitAttrs do
  398. msgRet.attrsShow[i].key = defConf.powerQualitAttrs[i]
  399. msgRet.attrsShow[i].value = 0
  400. end
  401. msgRet.showList[0] = 0
  402. local list = {}
  403. for key,data in ipairs(XingYaoMenExcel.powerQuality) do
  404. local quality = data.quality
  405. if data.star ~= 0 then
  406. quality = quality + 1
  407. end
  408. list[quality] = list[quality] or {}
  409. for _,attr in pairs(data.attrs) do
  410. local key = attr[1]
  411. local value = attr[2]
  412. list[quality] = list[quality] or {}
  413. list[quality][key] = (list[quality][key] or 0) + value
  414. end
  415. end
  416. for i=1,#list do
  417. local allAttrs = {}
  418. msgRet.showList[0] = msgRet.showList[0] + 1
  419. local index = msgRet.showList[0]
  420. msgRet.showList[index].quality = i
  421. msgRet.showList[index].attrs[0] = 0
  422. for j=1,#list do
  423. if j <= i then
  424. for key,value in pairs(list[j]) do
  425. allAttrs[key] = (allAttrs[key] or 0) + value
  426. end
  427. end
  428. end
  429. for key,value in pairs(allAttrs) do
  430. msgRet.showList[index].attrs[0] = msgRet.showList[index].attrs[0] + 1
  431. local attrIndex = msgRet.showList[index].attrs[0]
  432. msgRet.showList[index].attrs[attrIndex].key = key
  433. msgRet.showList[index].attrs[attrIndex].value = value
  434. end
  435. end
  436. --Msg.trace(msgRet)
  437. Msg.send(msgRet,human.fd)
  438. end
  439. function lvRed(human,camp)
  440. local db = getPowerData(human,camp)
  441. local nowLV = db and db.lv or 0
  442. local conf = XingYaoMenExcel.powerLv
  443. if nowLV >= #conf then return end
  444. local nextConf = conf[nowLV+1]
  445. local upCost = nextConf.upCost
  446. local campsLVupItem = XingYaoMenExcel.powerDefine[1].campsLVupItem[camp]
  447. local now = BagLogic.getItemCnt(human,campsLVupItem)
  448. if upCost > now then return end
  449. if human.db.jinbi < nextConf.upCostJinBi then return end
  450. return true
  451. end
  452. function qualityRed(human,camp)
  453. local db = getPowerData(human,camp)
  454. local qualityID = db and db.qualityID or 0
  455. local qualityMax,qualityMaxID = getQualityMax(human,camp)
  456. local conf = XingYaoMenExcel.powerQuality
  457. local quality = conf[qualityID] and conf[qualityID].quality or 0
  458. if qualityID >= #conf or qualityID >= qualityMaxID then return end
  459. local upCost = conf[qualityID+1].upCost
  460. for _,item in pairs(upCost) do
  461. local now = BagLogic.getItemCnt(human,item[1])
  462. if item[2] > now then return end
  463. end
  464. return true
  465. end
  466. function isDot(human)
  467. local defineCnf = XingYaoMenExcel.powerDefine[1]
  468. for camp=1,#defineCnf.camps do
  469. local lvRed = lvRed(human,camp)
  470. if lvRed then return true end
  471. local qualityRed = qualityRed(human,camp)
  472. if qualityRed then return true end
  473. end
  474. end
  475. function doCalcHero(human,heroGrid,attrs)
  476. if not human then return end
  477. local cf = HeroExcel.hero[heroGrid.id]
  478. local camp = cf.camp
  479. if not checkCamp(camp) then return end
  480. local db = getPowerData(human,camp)
  481. if not db then return end
  482. local defineCnf = XingYaoMenExcel.powerDefine[1]
  483. local attrsList = {}
  484. local nowLV = db and db.lv or 0
  485. local powerConf = XingYaoMenExcel.powerLv[nowLV]
  486. if powerConf then
  487. for i=1,#powerConf.attrs do
  488. local key = powerConf.attrs[i][1]
  489. local value = powerConf.attrs[i][2]
  490. attrsList[key] = (attrsList[key] or 0) + value
  491. end
  492. end
  493. if db and db.lvAttrs then
  494. for key,value in pairs(db.lvAttrs) do
  495. attrsList[key] = (attrsList[key] or 0) + value
  496. end
  497. end
  498. local qualityID = db and db.qualityID or 0
  499. if qualityID > 0 then
  500. for i=1,qualityID do
  501. local qualityConf = XingYaoMenExcel.powerQuality[i]
  502. if qualityConf then
  503. for j=1,#qualityConf.attrs do
  504. local key = qualityConf.attrs[j][1]
  505. local value = qualityConf.attrs[j][2]
  506. attrsList[key] = (attrsList[key] or 0) + value
  507. end
  508. end
  509. end
  510. end
  511. for key,value in pairs(attrsList) do
  512. RoleAttr.updateValue(key,value,attrs)
  513. end
  514. end