HeroGrid.lua 21 KB

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