HeroGrid.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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. -- print("当前传入的信息数组,makeHeroSimple",net,index,human,others,tuJian)
  200. -- table.print_lua_table(grid)
  201. local id = grid and (grid.id or grid.heroID)
  202. local cf = id and HeroExcel.hero[id]
  203. local star = grid and grid.star or (cf and cf.star or 1)
  204. local upStarConfig = HeroDefine.getNextAttrConfig(id, star)
  205. local jobConfig = cf and cf.job and HeroExcel.job[cf.job]
  206. local isGongMing = XingYaoGongMing.isGongMing(human, index)
  207. net.id = id or 0
  208. net.index = index or 0
  209. net.uuid = grid and grid.uuid or ""
  210. net.gl = cf and cf.gl or 0
  211. net.camp = cf and cf.camp or 0
  212. net.job = cf and cf.job or 0
  213. net.star = others and others.star or star --cf and cf.star or 0 星级调整 dxzeng
  214. net.icon = grid and grid.head or (cf and cf.head or 0)
  215. net.body = grid and grid.body or (cf and cf.body or 0)
  216. if grid and human and index then -- todo 皮肤这个以后可能还是需要继续整理
  217. local skinConf = SkinLogic.getHeroSkin(human, index)
  218. if skinConf then
  219. net.icon = skinConf.head
  220. net.body = skinConf.body
  221. end
  222. end
  223. net.up = upStarConfig == nil and 0 or 1 --是否能够升星
  224. net.lv = others and others.lv or (grid and grid.lv or 1)
  225. net.xLv = others and others.xLv or (grid and grid.xLv or 0)
  226. net.zhandouli = grid and grid.zhandouli or 0
  227. net.quality = grid and grid.quality or 0
  228. net.isLock = (grid and grid.isLock) and 1 or 0
  229. net.hp = others and others.hp or 0
  230. net.hpMax = others and others.hpMax or 0
  231. net.cnt = others and others.cnt or 1
  232. net.isget = HeroBook.isGetHero(human, id) or 0
  233. net.weightLv = cf and cf.grade or 0
  234. net.name = cf and cf.name or ""
  235. net.grade = cf and cf.grade or 0
  236. net.jobDesc = jobConfig and jobConfig.desc or ""
  237. net.label = cf and cf.label or ""
  238. net.order = cf and cf.order or 0
  239. net.isGongMing = isGongMing or 0
  240. --遗物ID
  241. net.relic.relicID = grid and grid.relic and grid.relic.relicID or 0
  242. net.relic.star = grid and grid.relic and grid.relic.star or 0
  243. --是否发送图鉴信息
  244. net.general[0] = 0
  245. if tuJian then
  246. local tj = HeroExcel.tujian[id]
  247. if tj ~= nil then
  248. net.general[0] = 1
  249. net.general[1].cm = tj.cm or 0
  250. net.general[1].kg = tj.kg or 0
  251. net.general[1].age = tj.age or 0
  252. net.general[1].cup = tj.cup or ""
  253. net.general[1].character = tj.character or ""
  254. net.general[1].interest = tj.interest or ""
  255. net.general[1].desc = tj.desc or ""
  256. end
  257. end
  258. --宝石
  259. --根据客户端要求,如果没有宝石数据,就拼接一份默认数据下发
  260. net.gemData[0] = 0
  261. if net.id and net.id ~= 0 then
  262. net.gemData[0] = HeroDefine.HEROGEMMAX
  263. HeroGem.assembleData(grid and grid.gem, net.gemData, net.job)
  264. end
  265. if grid and grid.skinOn then
  266. local skinCfg = SkinExcel[grid.skinOn]
  267. if skinCfg then
  268. net.icon = skinCfg.icon
  269. print("[makeHeroSimple] 设置了玩家英雄头像框显示数据 icon = "..skinCfg.icon)
  270. end
  271. end
  272. end
  273. -- 封装英雄信息装备符文
  274. function fontHeroDetailInfo(net, grid, index, human, others, tuJian)
  275. makeHeroSimple(net,grid, index, human, others, tuJian)
  276. net.equips = grid.equip or {}
  277. for k,v in pairs(net.equips) do
  278. if next(v) then
  279. v.name = EquipExcel.equip[v.id].name
  280. end
  281. end
  282. net.fuWens = grid.fuwen or {}
  283. for k,v in pairs(net.fuWens) do
  284. if next(v) then
  285. v.name = FuwenExcel[v.id].name
  286. end
  287. end
  288. end
  289. -- 根据英雄id封装英雄信息heroSimple
  290. function makeHeroOrMonster(net, id, index, others, human,tujian)
  291. local grid = getCacheHeroGrid(id)
  292. if not grid then
  293. makeHeroSimpleByMonsterID(net, id, others)
  294. else
  295. makeHeroSimple(net, grid, index, human, others,tujian)
  296. end
  297. end
  298. -- 根据英雄id封装英雄信息heroSimple
  299. function makeHeroSimpleByID(net, id, index, others, human, tujian)
  300. local star = others and others.star or nil
  301. local grid = getCacheHeroGrid(id, star, others)
  302. makeHeroSimple(net, grid, index, human, others,tujian)
  303. end
  304. -- 根据怪物id封装英雄信息
  305. function makeHeroSimpleByMonsterID(net, id, others)
  306. makeHeroSimpleByID(net, nil, nil, others)
  307. local mcf = MonsterExcel.monster[id]
  308. if not mcf then return end
  309. net.id = id
  310. net.camp = mcf.camp
  311. net.job = mcf.job
  312. net.star = mcf.star
  313. net.icon = mcf.head
  314. net.body = mcf.body
  315. net.lv = others and others.lv or 1
  316. net.hp = others and others.hp or 0
  317. net.hpMax = others and others.hpMax or 0
  318. end
  319. function makeHeroSimpleByGeneral(net, id)
  320. local tj = HeroExcel.tujian[id]
  321. if tj ~= nil then
  322. net.general[0] = 1
  323. net.general[1].cm = tj.cm or 0
  324. net.general[1].kg = tj.kg or 0
  325. net.general[1].age = tj.age or 0
  326. net.general[1].cup = tj.cup or ""
  327. net.general[1].character = tj.character or ""
  328. net.general[1].interest = tj.interest or ""
  329. net.general[1].desc = tj.desc or ""
  330. end
  331. end
  332. function makeHeroNice(net, id, cnt, isNew, index,human)
  333. net.itemData[0] = 0
  334. net.heroSimple[0] = 0
  335. net.heroStatic[0] = 0
  336. if cnt then
  337. net.itemData[0] = 1
  338. Grid.makeItem(net.itemData[1], id, cnt)
  339. end
  340. local heroConfig = HeroExcel.hero[id]
  341. local specialConfig = HeroExcel.specialHero[id]
  342. if heroConfig then
  343. net.heroSimple[0] = 1
  344. makeHeroSimpleByID(net.heroSimple[1], id, index)
  345. if human then
  346. local skinbody = SkinLogic.getBodyByHeroId(human, id)
  347. if skinbody then
  348. net.heroSimple[1].body = skinbody
  349. end
  350. end
  351. net.heroStatic[0] = 1
  352. makeHeroStatic(net.heroStatic[1], id)
  353. end
  354. net.body = specialConfig and (heroConfig and heroConfig.body or 0) or 0
  355. net.isNew = isNew and 1 or 0
  356. net.weightLv = heroConfig and heroConfig.grade or 0
  357. net.attrs[0] = 0
  358. net.attrsMax[0] = 0
  359. net.bubble = ""
  360. if heroConfig then
  361. local bubble = PaomaExcel.bubble[heroConfig.id]
  362. net.bubble = bubble and bubble.drawCard or ""
  363. local heroGrid = getCacheHeroGridTujian(id)
  364. for key = RoleDefine.ATK, RoleDefine.SPEED do
  365. local value = heroGrid.attrs[key]
  366. net.attrs[0] = net.attrs[0] + 1
  367. net.attrs[net.attrs[0]].key = key
  368. net.attrs[net.attrs[0]].value = value
  369. net.attrsMax[0] = net.attrsMax[0] + 1
  370. net.attrsMax[net.attrsMax[0]].key = key
  371. net.attrsMax[net.attrsMax[0]].value = HeroDefine.getTujianMaxValue(key)
  372. end
  373. end
  374. end
  375. -- 填充英雄详细信息:静态
  376. function makeHeroStatic(net, id, tuJian)
  377. local cf = id and HeroExcel.hero[id]
  378. if not cf then
  379. net.id=0
  380. net.name =""
  381. net.body =0
  382. net.job = 0
  383. net.weightLv=0
  384. net.normalAtkID=0
  385. net.skillList[0]=0
  386. net.beSkill[0]=0
  387. net.skin=0
  388. return
  389. end
  390. local star = cf.star
  391. if tuJian and tuJian == 1 then
  392. local tuJianConfig = HeroExcel.tujian[id]
  393. if tuJianConfig then
  394. local maxStarIndex = #tuJianConfig.star
  395. star = tuJianConfig.star[maxStarIndex]
  396. end
  397. end
  398. net.id = id
  399. net.name = cf.name
  400. net.body = cf.body
  401. net.job = cf.job
  402. net.weightLv = cf.grade
  403. local attrConfig = HeroDefine.getAttrConfig(id, star)
  404. net.normalAtkID = attrConfig.normalAtkID
  405. net.skillList[0] = #attrConfig.skillList
  406. for i = 1, net.skillList[0] do
  407. HeroLogic.makeSkillNet(net.skillList[i], attrConfig.skillList[i])
  408. end
  409. net.beSkill[0] = #attrConfig.beSkillList
  410. for i = 1, net.beSkill[0] do
  411. HeroLogic.makeSkillNet(net.beSkill[i], attrConfig.beSkillList[i])
  412. end
  413. net.skin = #cf.skin > 0 and 1 or 0
  414. end
  415. -- 最多连续升x级
  416. function getLevelUpCnt(human, nowLv, maxLv)
  417. local cnt = 0
  418. local needJinbi = 0
  419. local needItemCnt = 0
  420. if human and human.db and human.db.bag then
  421. local bagItemCnt = BagLogic.getItemCnt(human, ItemDefine.ITEM_GREEN_EXP_ID)
  422. local bagJinbi = human.db.jinbi
  423. for i = 1, HERO_LEVELUP_MAXCNT do
  424. local nextLv = nowLv + i
  425. local upcf = UpNeedExcel.upLv[nextLv]
  426. if not upcf then break end
  427. if nextLv > maxLv then break end
  428. if i > 1 then
  429. if (needJinbi + upcf.money > bagJinbi) or
  430. (needItemCnt + upcf.soul > bagItemCnt) then
  431. break
  432. end
  433. end
  434. cnt = cnt + 1
  435. needJinbi = needJinbi + upcf.money
  436. needItemCnt = needItemCnt + upcf.soul
  437. if nowLv >= HERO_LEVELUP_MAXLEVEL then
  438. break -- 小于一定等级不能连升
  439. end
  440. end
  441. end
  442. return cnt, needJinbi, needItemCnt
  443. end
  444. -- 填充英雄详细信息:动态
  445. function makeHeroDynamic(net, grid, index, human)
  446. local id = grid and grid.id
  447. local cf = id and HeroExcel.hero[id]
  448. local lv = grid and grid.lv or 1
  449. local xLv = grid and grid.xLv or 0
  450. local star = grid and grid.star or 1 -- 星级调整成动态值 dxzeng --cf and cf.star or 0
  451. local quality = grid and grid.quality or 0
  452. local maxLv = getMaxLv(star, quality)
  453. -- 最大品阶
  454. net.maxQuality = getMaxQuality(star)
  455. net.id = id or 0
  456. net.lv = lv
  457. net.xLv = xLv
  458. net.uuid = grid and grid.uuid or ""
  459. net.head = cf and cf.head or 0
  460. net.quality = quality
  461. net.maxLv = maxLv
  462. net.techLv = human and UnionTecLogic.getTechLvByJob(human, cf.job) or 0
  463. net.star = star
  464. net.upLv = 0
  465. if lv >= maxLv then -- 升阶
  466. local upcf = quality < getMaxQuality(star) and UpNeedExcel.upQuality[quality + 1]
  467. net.upLvJinbi = upcf and upcf.money or 0
  468. net.upLvSoul = upcf and upcf.jinjieshi or 0
  469. else -- 升级
  470. if grid and human and index then
  471. net.upLv, net.upLvJinbi, net.upLvSoul = getLevelUpCnt(human, lv, maxLv)
  472. else
  473. local upcf = UpNeedExcel.upLv[lv + 1]
  474. net.upLvJinbi = upcf and upcf.money or 0
  475. net.upLvSoul = upcf and upcf.soul or 0
  476. end
  477. end
  478. net.skin[0] = 0
  479. if grid and human and index then -- todo 皮肤这个以后可能还是需要继续整理
  480. local skinConf, skinSkillConf = SkinLogic.getHeroSkin(human, index)
  481. if skinConf then
  482. net.head = skinConf.head
  483. net.skin[0] = 1 -- 皮肤技能相关
  484. local skinNet = net.skin[1]
  485. skinNet.name = skinConf.name
  486. skinNet.body = skinConf.body
  487. skinNet.normalAtkID = skinSkillConf.normalAtkID
  488. skinNet.skillList[0] = #skinSkillConf.skillList
  489. for i = 1, skinNet.skillList[0] do
  490. HeroLogic.makeSkillNet(skinNet.skillList[i], skinSkillConf.skillList[i])
  491. end
  492. skinNet.beSkill[0] = #skinSkillConf.beSkillID
  493. for i = 1, skinNet.beSkill[0] do
  494. HeroLogic.makeSkillNet(skinNet.beSkill[i], skinSkillConf.beSkillID[i])
  495. end
  496. end
  497. end
  498. -- 技能变更
  499. net.skillList[0] = 0
  500. net.beSkill[0] = 0
  501. if grid and grid.star ~= cf.star then
  502. local attrConfig = HeroDefine.getAttrConfig(id, grid.star)
  503. net.skillList[0] = #attrConfig.skillList
  504. for i = 1, net.skillList[0] do
  505. HeroLogic.makeSkillNet(net.skillList[i], attrConfig.skillList[i])
  506. end
  507. net.beSkill[0] = #attrConfig.beSkillList
  508. for i = 1, net.beSkill[0] do
  509. HeroLogic.makeSkillNet(net.beSkill[i], attrConfig.beSkillList[i])
  510. end
  511. end
  512. local attrs = nil
  513. if human and index then
  514. attrs = ObjHuman.getHeroAttrs(human, index)
  515. elseif grid and grid.attrs then
  516. attrs = grid.attrs
  517. end
  518. net.attrs[0] = 0
  519. if attrs then
  520. for key, value in pairs(attrs)do
  521. -- print(" net.attrs[0] ", net.attrs[0], key)
  522. if RoleDefine.isPanelAttr(key) or RoleDefine.isPingFenAttr(key) then
  523. net.attrs[0] = net.attrs[0] + 1
  524. net.attrs[net.attrs[0]].key = key
  525. net.attrs[net.attrs[0]].value = value
  526. end
  527. end
  528. end
  529. net.zhandouli = grid and grid.zhandouli or 0
  530. end
  531. -- 根据英雄id填充动态信息
  532. function makeHeroDynamicByID(net, id,star)
  533. local grid = getCacheHeroGrid(id,star)
  534. makeHeroDynamic(net, grid)
  535. end
  536. --
  537. function makeHeroInfo(net, grid)
  538. local id = grid and grid.id
  539. local cf = id and HeroExcel.hero[id]
  540. net.id = id or 0
  541. net.camp = cf and cf.camp or 0
  542. net.icon = cf and cf.head or 0
  543. net.lv = grid and grid.lv or 0
  544. net.star = grid and grid.star or 0
  545. net.label = cf and cf.label or ""
  546. end
  547. function makeMonsterSimpleData(net, id, lv)
  548. local mcf = MonsterExcel.monster[id]
  549. if not mcf then return end
  550. net.id = id or 0
  551. net.icon = mcf.head
  552. net.lv = lv or 1
  553. net.camp = mcf.camp
  554. net.star = mcf.star
  555. net.label = mcf and mcf.label or ""
  556. return true
  557. end
  558. function getMonsterOutIDBody(id)
  559. local monsterOutConfig = MonsterExcel.monsterOut[id]
  560. if not monsterOutConfig then return 0 end
  561. local monsterID = monsterOutConfig.member[1][1]
  562. local monsterConfig = MonsterExcel.monster[monsterID]
  563. if not monsterConfig then return 0 end
  564. return monsterConfig.body
  565. end