HeroGrid.lua 23 KB

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