HeroGrid.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. -----------------------------------------------------------
  2. -- 英雄格子相关
  3. -- createHeroGrid 创建英雄对象
  4. -- getCacheHeroGrid 获取通用缓存英雄对象
  5. -- getHeroGridCalcCache 临时计算用的英雄格子
  6. -- createOthers 有时候要给HeroSimple额外附上一些特殊值,如等级血量等,会用到
  7. -- makeHeroSimple 根据英雄对象封装英雄信息HeroSimple
  8. -- makeHeroSimpleByID 根据英雄id封装英雄信息HeroSimple
  9. -- makeHeroSimpleByMonsterID 根据怪物id封装英雄信息HeroSimple
  10. -- makeHeroStatic 根据英雄id封装英雄静态信息HeroStatic
  11. -- makeHeroDynamic 根据英雄对象封装英雄动态信息HeroDynamic
  12. -- makeHeroDynamicByID 根据英雄id封装英雄动态信息HeroDynamic
  13. -- makeHeroInfo 根据英雄id封装英雄基础信息
  14. -- makeMonsterSimpleData 根据怪物id封装
  15. -- makeHeroNice 封装特殊英雄信息
  16. -- getMaxQuality 根据星级获取英雄最高品阶
  17. -- getMaxLv 根据星级和品阶获取英雄最大等级
  18. -- getHeroBodyById 根据英雄id获取英雄形象body
  19. -----------------------------------------------------------
  20. local lua_mongo = _G.lua_mongo
  21. local Util = require("common.Util")
  22. local UpNeedExcel = require("excel.upNeed")
  23. local HeroExcel = require("excel.hero")
  24. local MonsterExcel = require("excel.monster")
  25. local ObjHuman = require("core.ObjHuman")
  26. local RoleDefine = require("role.RoleDefine")
  27. local HeroDefine = require("hero.HeroDefine")
  28. local HeroLogic = require("hero.HeroLogic")
  29. local RoleAttr = require("role.RoleAttr")
  30. local EquipExcel = require("excel.equip")
  31. local ItemDefine = require("bag.ItemDefine")
  32. local BagLogic = require("bag.BagLogic")
  33. local Grid = require("bag.Grid")
  34. local SkinLogic = require("skin.SkinLogic")
  35. local PaomaExcel = require("excel.paoma")
  36. local UnionTecLogic = require("union.UnionTecLogic")
  37. local HeroBook = require("hero.HeroBook")
  38. local XingYaoGongMing = require("xingYaoMen.XingYaoGongMing")
  39. local FuwenExcel = require("excel.fuwen").fuwen
  40. local Log = require("common.Log")
  41. local Json = require("common.Json")
  42. local HeroGem = require("hero.HeroGem")
  43. local SkinExcel = require("excel.skin").skin
  44. HERO_GRID_CACHE = HERO_GRID_CACHE or {} -- 为静态英雄数据使用
  45. HERO_GRID_CACHE_TUJIAN = HERO_GRID_CACHE_TUJIAN or {}
  46. HERO_LEVELUP_MAXCNT = 5 -- 最多连升x次
  47. HERO_LEVELUP_MAXLEVEL = 60 -- 从x级开始不能连续升多级
  48. -- 创建一个英雄grid
  49. function createHeroGrid(id,star, xlv, mergeHeroAttrs)
  50. local cf = HeroExcel.hero[id]
  51. if not cf then
  52. assert(nil, "not hero id "..id)
  53. return
  54. end
  55. local grid = {}
  56. grid.uuid = lua_mongo.id() --唯一标识
  57. grid.id = id
  58. grid.lv = 1 --等级
  59. -- 星级调整成动态值 dxzeng
  60. grid.star = star or cf.star --星级 起始星级
  61. grid.quality = 0 --品质
  62. grid.zhandouli = 0 --战斗力
  63. grid.equip = nil --装备 1-6对应6个部位
  64. grid.shuijingAttrID = nil --水晶随机属性ID
  65. grid.fuwen = nil --符文 1-2对应2个符文 因为只凭一个id或一个索引无法的到所上符文的详细信息
  66. grid.bingshu = nil --兵书 [index] = bingshuGrid
  67. grid.oldLV = nil --星耀共鸣记录旧等级
  68. grid.oldQuality = nil --星耀共鸣记录旧品质
  69. grid.xLv = xlv or 0 --x等级 默认0
  70. grid.mergeHeroAttrs = mergeHeroAttrs or {} --融合英雄的初始属性
  71. grid.relic = {} --遗物
  72. return grid
  73. end
  74. -- 初始化的英雄 无添加
  75. function getCacheHeroGrid(id, star, others)
  76. if not id then return end
  77. local cf = HeroExcel.hero[id]
  78. if not cf then return end
  79. star = star or cf.star
  80. local grid = HERO_GRID_CACHE[id] and HERO_GRID_CACHE[id][star] or nil
  81. if not grid or others then
  82. if not cf then return end
  83. local grid = createHeroGrid(id, star)
  84. if others then
  85. grid.lv = others.lv and others.lv or grid.lv
  86. grid.xLv = others.xLv and others.xLv or (grid.xLv or 0)
  87. grid.quality = others.quality and others.quality or grid.quality
  88. grid.star = others.star and others.star or grid.star
  89. end
  90. grid.attrs = Util.copyTable(RoleAttr.calcHeroGrid(grid))
  91. grid.zhandouli = grid.attrs[RoleDefine.ZHANDOULI] or 0
  92. HERO_GRID_CACHE[id] = HERO_GRID_CACHE[id] or {}
  93. HERO_GRID_CACHE[id][star] = grid
  94. end
  95. return HERO_GRID_CACHE[id][star]
  96. end
  97. -- 图鉴的英雄,经过美化
  98. function getCacheHeroGridTujian(id)
  99. if not id then return end
  100. local grid = HERO_GRID_CACHE_TUJIAN[id]
  101. if not grid then
  102. local cf = HeroExcel.hero[id]
  103. if not cf then return end
  104. local grid = createHeroGrid(id,cf.star)
  105. local maxQuality = getMaxQuality(cf.star)
  106. grid.lv = getMaxLv(cf.star, maxQuality)
  107. grid.quality = maxQuality
  108. -- 星级调整成动态值 dxzeng
  109. grid.star = cf.star
  110. grid.attrs = Util.copyTable(RoleAttr.calcHeroGrid(grid))
  111. grid.zhandouli = grid.attrs[RoleDefine.ZHANDOULI] or 0
  112. -- 英雄如果有推荐,用推荐
  113. local scf = HeroExcel.strategy[cf.id]
  114. local equipLen = scf and #scf.equips or 0
  115. for i = 1, equipLen do
  116. grid.equip = grid.equip or {}
  117. grid.equip[i] = scf.equips[i]
  118. if i == ItemDefine.EQUIP_SUBTYPE_SHUIJIN then
  119. grid.shuijingAttrID = scf.shuijing
  120. end
  121. end
  122. HERO_GRID_CACHE_TUJIAN[id] = grid
  123. end
  124. return HERO_GRID_CACHE_TUJIAN[id]
  125. end
  126. -- 临时用的英雄
  127. local HERO_GRID_CALC_CACHE = {}
  128. function getHeroGridCalcCache(grid)
  129. Util.cleanTable(HERO_GRID_CALC_CACHE)
  130. Util.copyTableSimple(grid, HERO_GRID_CALC_CACHE)
  131. return HERO_GRID_CALC_CACHE
  132. end
  133. -- 根据id取形象
  134. function getHeroBodyById(id)
  135. local cf = HeroExcel.hero[id]
  136. if not cf then
  137. return 0
  138. end
  139. return cf.body
  140. end
  141. -- 获取英雄最高品阶
  142. function getMaxQuality(star)
  143. local starConfig = HeroExcel.star[star]
  144. if not starConfig then return 0 end
  145. local maxQuality = starConfig.maxQuality
  146. return maxQuality
  147. end
  148. -- 获取英雄最高等级
  149. function getMaxLv(star, quality)
  150. local starConfig = HeroExcel.star[star]
  151. if not starConfig then return 0 end
  152. if not starConfig.maxLv[quality+1] then
  153. return starConfig.maxLv[#starConfig.maxLv][2]
  154. end
  155. local maxLv = starConfig.maxLv[quality+1][2]
  156. return maxLv
  157. end
  158. -- 获取英雄等级 能达到的最高品阶
  159. function getMaxQualityByLv(star, lv)
  160. local maxQuality = getMaxQuality(star)
  161. local starConfig = HeroExcel.star[star]
  162. if not starConfig then return 0 end
  163. local quality = 0
  164. for i = 1, maxQuality do
  165. local maxLv = getMaxLv(star, quality)
  166. if lv >= maxLv then
  167. quality = i
  168. else
  169. break
  170. end
  171. end
  172. return quality <= maxQuality and quality or maxQuality
  173. end
  174. -- 获取英雄当前能升的最大等级
  175. function getNowQualityMaxLv(star, quality)
  176. local starConfig = HeroExcel.star[star]
  177. if not starConfig then
  178. return 0
  179. end
  180. -- 当前阶级+1 才是对应能升的最大等级
  181. local nTrueQuality = quality + 1
  182. if not starConfig.maxLv[nTrueQuality] then
  183. return starConfig.maxLv[#starConfig.maxLv][2]
  184. end
  185. return starConfig.maxLv[nTrueQuality][2]
  186. end
  187. -- 额外数据
  188. local TEMP_OTHERS = {}
  189. function createOthers(lv, hp, hpMax, star)
  190. TEMP_OTHERS.lv = lv
  191. TEMP_OTHERS.hp = hp
  192. TEMP_OTHERS.hpMax = hpMax
  193. TEMP_OTHERS.star = star
  194. TEMP_OTHERS.quality = getMaxQuality(star)
  195. return TEMP_OTHERS
  196. end
  197. -- 封装英雄信息
  198. function makeHeroSimple(net, grid, index, human, others, tuJian)
  199. local id = grid and (grid.id or grid.heroID)
  200. local cf = id and HeroExcel.hero[id]
  201. local star = grid and grid.star or (cf and cf.star or 1)
  202. local upStarConfig = HeroDefine.getNextAttrConfig(id, star)
  203. local jobConfig = cf and cf.job and HeroExcel.job[cf.job]
  204. local isGongMing = XingYaoGongMing.isGongMing(human, index)
  205. --统一在这里处理下英雄皮肤和头像可能存在数据异常的问题
  206. if grid and cf then
  207. if (grid.head and grid.head ~= cf.head) or (grid.body and grid.body ~= cf.body) then
  208. local bl = false
  209. if grid.skinOn then
  210. local skinCfg = SkinExcel[grid.skinOn]
  211. if skinCfg and skinCfg.heroId == grid.id then
  212. grid.head = skinCfg.head
  213. bl = true
  214. end
  215. end
  216. if not bl then
  217. grid.skinOn = nil
  218. grid.head = cf.head
  219. end
  220. grid.body = cf.body
  221. end
  222. end
  223. net.id = id or 0
  224. net.index = index or 0
  225. net.uuid = grid and grid.uuid or ""
  226. net.gl = cf and cf.gl or 0
  227. net.camp = cf and cf.camp or 0
  228. net.job = cf and cf.job or 0
  229. net.star = others and others.star or star --cf and cf.star or 0 星级调整 dxzeng
  230. net.icon = grid and grid.head or (cf and cf.head or 0)
  231. net.body = grid and grid.body or (cf and cf.body or 0)
  232. -- if grid and human and index then -- todo 皮肤这个以后可能还是需要继续整理
  233. -- local skinConf = SkinLogic.getHeroSkin(human, index)
  234. -- if skinConf then
  235. -- net.icon = skinConf.head
  236. -- net.body = skinConf.body
  237. -- end
  238. -- end
  239. net.up = upStarConfig == nil and 0 or 1 --是否能够升星
  240. net.lv = others and others.lv or (grid and grid.lv or 1)
  241. net.xLv = others and others.xLv or (grid and grid.xLv or 0)
  242. net.zhandouli = grid and grid.zhandouli or 0
  243. net.quality = grid and grid.quality or 0
  244. net.isLock = (grid and grid.isLock) and 1 or 0
  245. net.hp = others and others.hp or 0
  246. net.hpMax = others and others.hpMax or 0
  247. net.cnt = others and others.cnt or 1
  248. net.isget = HeroBook.isGetHero(human, id) or 0
  249. net.weightLv = cf and cf.grade or 0
  250. net.name = cf and cf.name or ""
  251. net.grade = cf and cf.grade or 0
  252. net.jobDesc = jobConfig and jobConfig.desc or ""
  253. net.label = cf and cf.label or ""
  254. net.order = cf and cf.order or 0
  255. net.isGongMing = isGongMing or 0
  256. --遗物ID
  257. net.relic.relicID = grid and grid.relic and grid.relic.relicID or 0
  258. net.relic.star = grid and grid.relic and grid.relic.star or 0
  259. --是否发送图鉴信息
  260. net.general[0] = 0
  261. if tuJian then
  262. local tj = HeroExcel.tujian[id]
  263. if tj ~= nil then
  264. net.general[0] = 1
  265. net.general[1].cm = tj.cm or 0
  266. net.general[1].kg = tj.kg or 0
  267. net.general[1].age = tj.age or 0
  268. net.general[1].cup = tj.cup or ""
  269. net.general[1].character = tj.character or ""
  270. net.general[1].interest = tj.interest or ""
  271. net.general[1].desc = tj.desc or ""
  272. end
  273. end
  274. --宝石
  275. --根据客户端要求,如果没有宝石数据,就拼接一份默认数据下发
  276. net.gemData[0] = 0
  277. if net.id and net.id ~= 0 then
  278. net.gemData[0] = HeroDefine.HEROGEMMAX
  279. HeroGem.assembleData(grid and grid.gem, net.gemData, net.job)
  280. end
  281. -- if grid and grid.skinOn then
  282. -- local skinCfg = SkinExcel[grid.skinOn]
  283. -- if skinCfg then
  284. -- net.icon = skinCfg.icon
  285. -- print("[makeHeroSimple] 设置了玩家英雄头像框显示数据 icon = "..skinCfg.icon)
  286. -- end
  287. -- end
  288. end
  289. -- 封装英雄信息装备符文
  290. function fontHeroDetailInfo(net, grid, index, human, others, tuJian)
  291. makeHeroSimple(net,grid, index, human, others, tuJian)
  292. net.equips = grid.equip or {}
  293. for k,v in pairs(net.equips) do
  294. if next(v) then
  295. v.name = EquipExcel.equip[v.id].name
  296. end
  297. end
  298. net.fuWens = grid.fuwen or {}
  299. for k,v in pairs(net.fuWens) do
  300. if next(v) then
  301. v.name = FuwenExcel[v.id].name
  302. end
  303. end
  304. end
  305. -- 根据英雄id封装英雄信息heroSimple
  306. function makeHeroOrMonster(net, id, index, others, human,tujian)
  307. local grid = getCacheHeroGrid(id)
  308. if not grid then
  309. makeHeroSimpleByMonsterID(net, id, others)
  310. else
  311. makeHeroSimple(net, grid, index, human, others,tujian)
  312. end
  313. end
  314. -- 根据英雄id封装英雄信息heroSimple
  315. function makeHeroSimpleByID(net, id, index, others, human, tujian)
  316. local star = others and others.star or nil
  317. local grid = getCacheHeroGrid(id, star, others)
  318. makeHeroSimple(net, grid, index, human, others,tujian)
  319. end
  320. -- 根据怪物id封装英雄信息
  321. function makeHeroSimpleByMonsterID(net, id, others)
  322. makeHeroSimpleByID(net, nil, nil, others)
  323. local mcf = MonsterExcel.monster[id]
  324. if not mcf then return end
  325. net.id = id
  326. net.camp = mcf.camp
  327. net.job = mcf.job
  328. net.star = mcf.star
  329. net.icon = mcf.head
  330. net.body = mcf.body
  331. net.lv = others and others.lv or 1
  332. net.hp = others and others.hp or 0
  333. net.hpMax = others and others.hpMax or 0
  334. end
  335. function makeHeroSimpleByGeneral(net, id)
  336. local tj = HeroExcel.tujian[id]
  337. if tj ~= nil then
  338. net.general[0] = 1
  339. net.general[1].cm = tj.cm or 0
  340. net.general[1].kg = tj.kg or 0
  341. net.general[1].age = tj.age or 0
  342. net.general[1].cup = tj.cup or ""
  343. net.general[1].character = tj.character or ""
  344. net.general[1].interest = tj.interest or ""
  345. net.general[1].desc = tj.desc or ""
  346. end
  347. end
  348. function makeHeroNice(net, id, cnt, isNew, index,human)
  349. net.itemData[0] = 0
  350. net.heroSimple[0] = 0
  351. net.heroStatic[0] = 0
  352. if cnt then
  353. net.itemData[0] = 1
  354. Grid.makeItem(net.itemData[1], id, cnt)
  355. end
  356. local heroConfig = HeroExcel.hero[id]
  357. local specialConfig = HeroExcel.specialHero[id]
  358. if heroConfig then
  359. net.heroSimple[0] = 1
  360. makeHeroSimpleByID(net.heroSimple[1], id, index)
  361. if human then
  362. local skinbody = SkinLogic.getBodyByHeroId(human, id)
  363. if skinbody then
  364. net.heroSimple[1].body = skinbody
  365. end
  366. end
  367. net.heroStatic[0] = 1
  368. makeHeroStatic(net.heroStatic[1], id)
  369. end
  370. net.body = specialConfig and (heroConfig and heroConfig.body or 0) or 0
  371. net.isNew = isNew and 1 or 0
  372. net.weightLv = heroConfig and heroConfig.grade or 0
  373. net.attrs[0] = 0
  374. net.attrsMax[0] = 0
  375. net.bubble = ""
  376. if heroConfig then
  377. local bubble = PaomaExcel.bubble[heroConfig.id]
  378. net.bubble = bubble and bubble.drawCard or ""
  379. local heroGrid = getCacheHeroGridTujian(id)
  380. for key = RoleDefine.ATK, RoleDefine.SPEED do
  381. local value = heroGrid.attrs[key]
  382. net.attrs[0] = net.attrs[0] + 1
  383. net.attrs[net.attrs[0]].key = key
  384. net.attrs[net.attrs[0]].value = value
  385. net.attrsMax[0] = net.attrsMax[0] + 1
  386. net.attrsMax[net.attrsMax[0]].key = key
  387. net.attrsMax[net.attrsMax[0]].value = HeroDefine.getTujianMaxValue(key)
  388. end
  389. end
  390. end
  391. -- 填充英雄详细信息:静态
  392. function makeHeroStatic(net, id, tuJian)
  393. local cf = id and HeroExcel.hero[id]
  394. if not cf then
  395. net.id=0
  396. net.name =""
  397. net.body =0
  398. net.job = 0
  399. net.weightLv=0
  400. net.normalAtkID=0
  401. net.skillList[0]=0
  402. net.beSkill[0]=0
  403. net.skin=0
  404. return
  405. end
  406. local star = cf.star
  407. if tuJian and tuJian == 1 then
  408. local tuJianConfig = HeroExcel.tujian[id]
  409. if tuJianConfig then
  410. local maxStarIndex = #tuJianConfig.star
  411. star = tuJianConfig.star[maxStarIndex]
  412. end
  413. end
  414. net.id = id
  415. net.name = cf.name
  416. net.body = cf.body
  417. net.job = cf.job
  418. net.weightLv = cf.grade
  419. local attrConfig = HeroDefine.getAttrConfig(id, star)
  420. net.normalAtkID = attrConfig.normalAtkID
  421. net.skillList[0] = #attrConfig.skillList
  422. for i = 1, net.skillList[0] do
  423. HeroLogic.makeSkillNet(net.skillList[i], attrConfig.skillList[i])
  424. end
  425. net.beSkill[0] = #attrConfig.beSkillList
  426. for i = 1, net.beSkill[0] do
  427. HeroLogic.makeSkillNet(net.beSkill[i], attrConfig.beSkillList[i])
  428. end
  429. net.skin = #cf.skin > 0 and 1 or 0
  430. end
  431. -- 最多连续升x级
  432. function getLevelUpCnt(human, nowLv, maxLv)
  433. local cnt = 0
  434. local needJinbi = 0
  435. local needItemCnt = 0
  436. if human and human.db and human.db.bag then
  437. local bagItemCnt = BagLogic.getItemCnt(human, ItemDefine.ITEM_GREEN_EXP_ID)
  438. local bagJinbi = human.db.jinbi
  439. for i = 1, HERO_LEVELUP_MAXCNT do
  440. local nextLv = nowLv + i
  441. local upcf = UpNeedExcel.upLv[nextLv]
  442. if not upcf then break end
  443. if nextLv > maxLv then break end
  444. if i > 1 then
  445. if (needJinbi + upcf.money > bagJinbi) or
  446. (needItemCnt + upcf.soul > bagItemCnt) then
  447. break
  448. end
  449. end
  450. cnt = cnt + 1
  451. needJinbi = needJinbi + upcf.money
  452. needItemCnt = needItemCnt + upcf.soul
  453. if nowLv >= HERO_LEVELUP_MAXLEVEL then
  454. break -- 小于一定等级不能连升
  455. end
  456. end
  457. end
  458. return cnt, needJinbi, needItemCnt
  459. end
  460. -- 填充英雄详细信息:动态
  461. function makeHeroDynamic(net, grid, index, human)
  462. local id = grid and grid.id
  463. local cf = id and HeroExcel.hero[id]
  464. local lv = grid and grid.lv or 1
  465. local xLv = grid and grid.xLv or 0
  466. local star = grid and grid.star or 1 -- 星级调整成动态值 dxzeng --cf and cf.star or 0
  467. local quality = grid and grid.quality or 0
  468. local maxLv = getMaxLv(star, quality)
  469. -- 最大品阶
  470. net.maxQuality = getMaxQuality(star)
  471. net.id = id or 0
  472. net.lv = lv
  473. net.xLv = xLv
  474. net.uuid = grid and grid.uuid or ""
  475. net.head = cf and cf.head or 0
  476. net.quality = quality
  477. net.maxLv = maxLv
  478. net.techLv = human and UnionTecLogic.getTechLvByJob(human, cf.job) or 0
  479. net.star = star
  480. net.upLv = 0
  481. if lv >= maxLv then -- 升阶
  482. local upcf = quality < getMaxQuality(star) and UpNeedExcel.upQuality[quality + 1]
  483. net.upLvJinbi = upcf and upcf.money or 0
  484. net.upLvSoul = upcf and upcf.jinjieshi or 0
  485. else -- 升级
  486. if grid and human and index then
  487. net.upLv, net.upLvJinbi, net.upLvSoul = getLevelUpCnt(human, lv, maxLv)
  488. else
  489. local upcf = UpNeedExcel.upLv[lv + 1]
  490. net.upLvJinbi = upcf and upcf.money or 0
  491. net.upLvSoul = upcf and upcf.soul or 0
  492. end
  493. end
  494. net.skin[0] = 0
  495. if grid and human and index then -- todo 皮肤这个以后可能还是需要继续整理
  496. local skinConf, skinSkillConf = SkinLogic.getHeroSkin(human, index)
  497. if skinConf then
  498. net.head = skinConf.head
  499. net.skin[0] = 1 -- 皮肤技能相关
  500. local skinNet = net.skin[1]
  501. skinNet.name = skinConf.name
  502. skinNet.body = skinConf.body
  503. skinNet.normalAtkID = skinSkillConf.normalAtkID
  504. skinNet.skillList[0] = #skinSkillConf.skillList
  505. for i = 1, skinNet.skillList[0] do
  506. HeroLogic.makeSkillNet(skinNet.skillList[i], skinSkillConf.skillList[i])
  507. end
  508. skinNet.beSkill[0] = #skinSkillConf.beSkillID
  509. for i = 1, skinNet.beSkill[0] do
  510. HeroLogic.makeSkillNet(skinNet.beSkill[i], skinSkillConf.beSkillID[i])
  511. end
  512. end
  513. end
  514. -- 技能变更
  515. net.skillList[0] = 0
  516. net.beSkill[0] = 0
  517. if grid and grid.star ~= cf.star then
  518. local attrConfig = HeroDefine.getAttrConfig(id, grid.star)
  519. net.skillList[0] = #attrConfig.skillList
  520. for i = 1, net.skillList[0] do
  521. HeroLogic.makeSkillNet(net.skillList[i], attrConfig.skillList[i])
  522. end
  523. net.beSkill[0] = #attrConfig.beSkillList
  524. for i = 1, net.beSkill[0] do
  525. HeroLogic.makeSkillNet(net.beSkill[i], attrConfig.beSkillList[i])
  526. end
  527. end
  528. local attrs = nil
  529. if human and index then
  530. attrs = ObjHuman.getHeroAttrs(human, index)
  531. elseif grid and grid.attrs then
  532. attrs = grid.attrs
  533. end
  534. net.attrs[0] = 0
  535. if attrs then
  536. for key, value in pairs(attrs)do
  537. -- print(" net.attrs[0] ", net.attrs[0], key)
  538. if RoleDefine.isPanelAttr(key) or RoleDefine.isPingFenAttr(key) then
  539. net.attrs[0] = net.attrs[0] + 1
  540. net.attrs[net.attrs[0]].key = key
  541. net.attrs[net.attrs[0]].value = value
  542. end
  543. end
  544. end
  545. net.zhandouli = grid and grid.zhandouli or 0
  546. end
  547. -- 根据英雄id填充动态信息
  548. function makeHeroDynamicByID(net, id,star)
  549. local grid = getCacheHeroGrid(id,star)
  550. makeHeroDynamic(net, grid)
  551. end
  552. --
  553. function makeHeroInfo(net, grid)
  554. local id = grid and grid.id
  555. local cf = id and HeroExcel.hero[id]
  556. net.id = id or 0
  557. net.camp = cf and cf.camp or 0
  558. net.icon = cf and cf.head or 0
  559. net.lv = grid and grid.lv or 0
  560. net.star = grid and grid.star or 0
  561. net.label = cf and cf.label or ""
  562. end
  563. function makeMonsterSimpleData(net, id, lv)
  564. local mcf = MonsterExcel.monster[id]
  565. if not mcf then return end
  566. net.id = id or 0
  567. net.icon = mcf.head
  568. net.lv = lv or 1
  569. net.camp = mcf.camp
  570. net.star = mcf.star
  571. net.label = mcf and mcf.label or ""
  572. return true
  573. end
  574. function getMonsterOutIDBody(id)
  575. local monsterOutConfig = MonsterExcel.monsterOut[id]
  576. if not monsterOutConfig then return 0 end
  577. local monsterID = monsterOutConfig.member[1][1]
  578. local monsterConfig = MonsterExcel.monster[monsterID]
  579. if not monsterConfig then return 0 end
  580. return monsterConfig.body
  581. end