HeroGrid.lua 22 KB

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