HeroGrid.lua 21 KB

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