HeroGrid.lua 21 KB

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