NewLogic.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. local Msg = require("core.Msg")
  2. local Broadcast = require("broadcast.Broadcast")
  3. local Lang = require("common.Lang")
  4. local Grid = require("bag.Grid")
  5. local MergeRule = require("excel.mergeConfig").rule
  6. local BagLogic = require("bag.BagLogic")
  7. local Log = require("common.Log")
  8. local Util = require("common.Util")
  9. local ItemLogic = require("bag.ItemLogic")
  10. local HeroLogic = require("hero.HeroLogic")
  11. local HeroExcel = require("excel.hero")
  12. local RoleDefine = require("role.RoleDefine")
  13. local ObjHuman = require("core.ObjHuman")
  14. local HeroGrid = require("hero.HeroGrid")
  15. local Json = require("common.Json")
  16. local FenjieLogic = require("hecheng.FenjieLogic")
  17. local HeroBook = require("hero.HeroBook")
  18. AD_DRAW_REWARD_TYPE = 10 --观看广告领取召唤券
  19. QUERY_MERGE_INFO_TYPE = 11 --获取融合信息
  20. HATCH_SCCUESS_TYPE = 12 -- 孵化成功
  21. MERGE_HERO_TYPE = 13 --融合
  22. QUICK_HATCH_TYPE = 14 --加速
  23. QUERY_MERGE_BEFORE_INFO_TYPE = 15 --获取融合前信息
  24. GET_MERGE_HERO_TYPE = 16 --获取融合英雄
  25. QUERY_QUICK_HATCH_ZUANSHI = 17 --查询加速孵化需要的钻石
  26. AD_HATCH_RESET_FREECNT = 4 --看广告加速孵化次数
  27. function NewProto(human, type, param)
  28. -- print("newProto:",type,param)
  29. -- local msgRet = Msg.gc.GC_ROLE_CHANGE_BASEINFO
  30. -- msgRet.ret = type
  31. -- msgRet.tip = "test data"
  32. -- Msg.send(msgRet,human.fd)
  33. local msgRet = Msg.gc.GC_ROLE_CHANGE_BASEINFO
  34. -- 观看广告获取召唤券
  35. if type == AD_DRAW_REWARD_TYPE then
  36. human.db.adRewardCnt = human.db.adRewardCnt or 0
  37. if human.db.adRewardCnt > 4 then
  38. Broadcast.sendErr(human, Lang.AD_DRAW_REWARD_LIMIT_ERROR)
  39. return
  40. end
  41. --增加今日观看次数
  42. human.db.adRewardCnt = (human.db.adRewardCnt or 0) + 1
  43. Log.write(Log.LOGID_TEST, "adRewardCnt: " .. human.db.adRewardCnt)
  44. -- 添加高级召唤卷
  45. BagLogic.addItem(human, 118, 1, "draw_ad_reward")
  46. msgRet.ret = AD_DRAW_REWARD_TYPE
  47. msgRet.tip = Lang.AD_DRAW_REWARD_SUCCESS
  48. Msg.send(msgRet, human.fd)
  49. Broadcast.sendErr(human, Lang.AD_DRAW_REWARD_SUCCESS)
  50. return
  51. end
  52. -- 查询加速孵化需要的钻石
  53. if type == QUERY_QUICK_HATCH_ZUANSHI then
  54. -- 初始化
  55. initMergeInfo(human)
  56. local info = {}
  57. local nowTime = os.time
  58. local hatchTime = human.db.mergeInfo.endTime - nowTime
  59. info.zuanshi = doCalcNeedZuanshi(hatchTime)
  60. info.isTip = getTodayIsTip(human)
  61. msgRet.ret = QUERY_QUICK_HATCH_ZUANSHI
  62. msgRet.tip = Json.Encode(info)
  63. Msg.send(msgRet, human.fd)
  64. return
  65. end
  66. -- 获取融合前的信息
  67. if type == QUERY_MERGE_BEFORE_INFO_TYPE then
  68. local tb = Util.split(param, "|")
  69. if tb[1] and tb[2] then
  70. -- 初始化
  71. initMergeInfo(human)
  72. human.db.heroBag = human.db.heroBag or {}
  73. local fatherHeroBagIndex = tonumber(tb[1]) or 0
  74. local motherHeroBagIndex = tonumber(tb[2]) or 0
  75. Log.write(Log.LOGID_TEST, "查询融合前的 fatherHeroBagIndex: " .. fatherHeroBagIndex)
  76. Log.write(Log.LOGID_TEST, "查询融合前的 motherHeroBagIndex: " .. motherHeroBagIndex)
  77. local fatherHeroGrid = human.db.heroBag[fatherHeroBagIndex]
  78. if not fatherHeroGrid then
  79. return
  80. end
  81. Log.write(Log.LOGID_TEST, "查询融合前的 fatherHeroGrid: " .. Json.Encode(fatherHeroGrid))
  82. local motherHeroGrid = human.db.heroBag[motherHeroBagIndex]
  83. if not motherHeroGrid then
  84. return
  85. end
  86. Log.write(Log.LOGID_TEST, "查询融合前的 motherHeroGrid: " .. Json.Encode(motherHeroBagIndex))
  87. local mergeInfo = {}
  88. local heroSimple = {}
  89. local xLv = getxLv(fatherHeroGrid, motherHeroGrid)
  90. local cnt = math.floor(xLv / 2) + 1
  91. local isHatch = 2
  92. local mergeItem = {}
  93. local itemId = 178
  94. for k = 1, 1 do
  95. mergeItem[k] = mergeItem[k] or {}
  96. mergeItem[k].getway = mergeItem[k].getway or {}
  97. mergeItem[k].suipian = mergeItem[k].suipian or {}
  98. mergeItem[k].equip = mergeItem[k].equip or {}
  99. mergeItem[k].fuwen = mergeItem[k].fuwen or {}
  100. Grid.makeItem(mergeItem[k], itemId, cnt)
  101. end
  102. local sonHeroID = mergeHero(fatherHeroGrid.id, motherHeroGrid.id)
  103. local cf = sonHeroID and HeroExcel.hero[sonHeroID]
  104. heroSimple.name = cf and cf.name or ""
  105. if cf.grade >= 6 then
  106. heroSimple.name = "?????"
  107. end
  108. mergeInfo.mergeTime = 0
  109. mergeInfo.xLv = xLv
  110. mergeInfo.mergeItem = mergeItem
  111. mergeInfo.heroData = heroSimple
  112. mergeInfo.isHatch = isHatch
  113. mergeInfo.adHatchRewardCnt = getResetAdHatchCnt(human)
  114. mergeInfo.isTip = getTodayIsTip(human)
  115. Log.write(Log.LOGID_TEST, "查询融合前的 mergeInfo: " .. Json.Encode(mergeInfo))
  116. msgRet.ret = QUERY_MERGE_BEFORE_INFO_TYPE
  117. msgRet.tip = Json.Encode(mergeInfo)
  118. Msg.send(msgRet, human.fd)
  119. end
  120. return
  121. end
  122. -- 开始融合
  123. if type == MERGE_HERO_TYPE then
  124. local tb = Util.split(param, "|")
  125. if tb[1] and tb[2] then
  126. -- 初始化
  127. initMergeInfo(human)
  128. human.db.heroBag = human.db.heroBag or {}
  129. local itemId = 178 --生命雨露
  130. local fatherHeroBagIndex = tonumber(tb[1]) or 0
  131. local motherHeroBagIndex = tonumber(tb[2]) or 0
  132. local fatherHeroGrid = human.db.heroBag[fatherHeroBagIndex]
  133. if not fatherHeroGrid then
  134. return
  135. end
  136. local motherHeroGrid = human.db.heroBag[motherHeroBagIndex]
  137. if not motherHeroGrid then
  138. return
  139. end
  140. local fatherHeroAttr = ObjHuman.getHeroAttrs(human, fatherHeroBagIndex)
  141. local motherHeroAttr = ObjHuman.getHeroAttrs(human, motherHeroBagIndex)
  142. local mergeInfo = {}
  143. local attrs = RoleDefine.PANEL_ATTR_KEY
  144. local sonHeroID = mergeHero(fatherHeroGrid.id, motherHeroGrid.id)
  145. if sonHeroID <= 0 then
  146. return
  147. end
  148. for key, value in pairs(attrs) do
  149. local param1 = fatherHeroAttr[key] or 0
  150. local param2 = motherHeroAttr[key] or 0
  151. attrs[key] = math.floor(((param1 + param2) / 4))
  152. end
  153. Log.write(Log.LOGID_TEST, "融合后的属性: " .. Json.Encode(attrs))
  154. local xLv = getxLv(fatherHeroGrid, motherHeroGrid)
  155. local cnt = math.floor(xLv / 2) + 1
  156. local heroSimple = {}
  157. Log.write(Log.LOGID_TEST, "xLv: " .. xLv)
  158. Log.write(Log.LOGID_TEST, "cnt: " .. cnt)
  159. local bagCnt = BagLogic.getItemCnt(human, itemId, true)
  160. if bagCnt < cnt then
  161. Broadcast.sendErr(human, Lang.ITEM_USE_ERR_NO)
  162. return
  163. end
  164. --使用道具
  165. ItemLogic.use(human, itemId, cnt)
  166. local outItems = {}
  167. local delHeroList = { [1] = fatherHeroBagIndex, [2] = motherHeroBagIndex }
  168. for heroIndex in pairs(delHeroList) do
  169. local heroID = HeroLogic.getHeroIdByIndex(human, heroIndex)
  170. local inputIDList = { [0] = 1, [1] = heroID }
  171. local inputIndexList = { [0] = 1, [1] = heroIndex }
  172. outItems[#outItems + 1] = FenjieLogic.fenjie(human, FenjieLogic.FENJIE_DO_MERGE, inputIDList,
  173. inputIndexList, nil, "hero_merge")
  174. end
  175. BagLogic.sendItemGetList3(human, outItems, "tenStar_displace")
  176. -- 删除英雄
  177. -- HeroLogic.delHeroByIndex(human, fatherHeroBagIndex, "hero_merge")
  178. -- HeroLogic.delHeroByIndex(human, motherHeroBagIndex, "hero_merge")
  179. -- 记录融合英雄
  180. human.db.mergeInfo.heroInfo.heroID = sonHeroID
  181. human.db.mergeInfo.heroInfo.xLv = xLv
  182. human.db.mergeInfo.heroInfo.heroAttrs = attrs
  183. human.db.mergeInfo.startTime = os.time()
  184. human.db.mergeInfo.endTime = os.time() + getHatchTime(xLv)
  185. human.db.mergeInfo.heroInfo.fatherHeroBagIndex = fatherHeroBagIndex
  186. human.db.mergeInfo.heroInfo.motherHeroBagIndex = motherHeroBagIndex
  187. local cf = sonHeroID and HeroExcel.hero[sonHeroID]
  188. heroSimple.name = cf and cf.name or ""
  189. if cf.grade >= 6 then
  190. heroSimple.name = "?????"
  191. end
  192. mergeInfo.mergeTime = getHatchTime(xLv)
  193. mergeInfo.xLv = xLv
  194. mergeInfo.heroData = heroSimple
  195. mergeInfo.isHatch = 1
  196. mergeInfo.adHatchRewardCnt = getResetAdHatchCnt(human)
  197. mergeInfo.isTip = getTodayIsTip(human)
  198. Log.write(Log.LOGID_TEST, "融合 mergeInfo: " .. Json.Encode(mergeInfo))
  199. Broadcast.sendErr(human, Lang.MERGE_SUCCESS)
  200. msgRet.ret = MERGE_HERO_TYPE
  201. msgRet.tip = Json.Encode(mergeInfo)
  202. Msg.send(msgRet, human.fd)
  203. end
  204. return
  205. end
  206. -- 获取融合中的信息
  207. if type == QUERY_MERGE_INFO_TYPE then
  208. -- 初始化
  209. initMergeInfo(human)
  210. human.db.heroBag = human.db.heroBag or {}
  211. local mergeInfo = {}
  212. local mergeTime = 0
  213. local heroSimple = {}
  214. local xLv = human.db.mergeInfo.heroInfo.xLv or 0
  215. local sonHeroID = human.db.mergeInfo.heroInfo.heroID or 0
  216. local isHatch = 2
  217. if sonHeroID == 0 then
  218. mergeInfo.mergeTime = mergeTime
  219. mergeInfo.xLv = xLv
  220. mergeInfo.heroData = heroSimple
  221. mergeInfo.isHatch = isHatch
  222. msgRet.ret = QUERY_MERGE_INFO_TYPE
  223. msgRet.tip = Json.Encode(mergeInfo)
  224. Msg.send(msgRet, human.fd)
  225. return
  226. end
  227. local mergeTime = human.db.mergeInfo.endTime - os.time()
  228. if mergeTime < 0 then
  229. -- 孵化成功
  230. mergeTime = 0
  231. isHatch = 3
  232. else
  233. isHatch = 1
  234. end
  235. local cf = sonHeroID and HeroExcel.hero[sonHeroID]
  236. heroSimple.name = cf and cf.name or ""
  237. if cf.grade >= 6 then
  238. heroSimple.name = "?????"
  239. end
  240. mergeInfo.mergeTime = mergeTime
  241. mergeInfo.xLv = xLv
  242. mergeInfo.heroData = heroSimple
  243. mergeInfo.isHatch = isHatch
  244. mergeInfo.adHatchRewardCnt = getResetAdHatchCnt(human)
  245. mergeInfo.isTip = getTodayIsTip(human)
  246. msgRet.ret = QUERY_MERGE_INFO_TYPE
  247. msgRet.tip = Json.Encode(mergeInfo)
  248. Log.write(Log.LOGID_TEST, "融合中 msgRet: " .. Json.Encode(msgRet))
  249. Msg.send(msgRet, human.fd)
  250. return
  251. end
  252. -- 获取融合英雄
  253. if type == GET_MERGE_HERO_TYPE then
  254. local nowTime = os.time()
  255. local mergeInfo = {}
  256. local heroSimple = {}
  257. local xLv = human.db.mergeInfo.heroInfo.xLv or 0
  258. local sonHeroID = human.db.mergeInfo.heroInfo.heroID or 0
  259. local hatchTime = human.db.mergeInfo.endTime - nowTime
  260. local isHatch = 2
  261. local heroIndex = 0
  262. local msgTyep = GET_MERGE_HERO_TYPE
  263. local heroNiceNet = {}
  264. if hatchTime <= 0 then
  265. -- 孵化成功
  266. hatchTime = 0
  267. heroIndex = hatchHero(human)
  268. local heroGrid = human.db.heroBag[heroIndex]
  269. if not heroGrid then return end
  270. heroSimple.general = heroSimple.general or {}
  271. HeroGrid.makeHeroSimple(heroSimple, heroGrid, heroIndex, human)
  272. for i = 1, 1 do
  273. local heroID = sonHeroID
  274. local index = heroIndex
  275. local heroConfig = HeroExcel[heroID]
  276. local isNew = not HeroBook.isGet(human, heroConfig.id, heroConfig.star)
  277. HeroGrid.makeHeroNice(heroNiceNet, heroID, nil, isNew, index)
  278. end
  279. else
  280. local cf = sonHeroID and HeroExcel.hero[sonHeroID]
  281. heroSimple.name = cf and cf.name or ""
  282. if cf.grade >= 6 then
  283. heroSimple.name = "?????"
  284. end
  285. isHatch = 1
  286. msgTyep = QUERY_MERGE_INFO_TYPE
  287. end
  288. mergeInfo.mergeTime = hatchTime
  289. mergeInfo.xLv = xLv
  290. mergeInfo.heroData = heroSimple
  291. mergeInfo.isHatch = isHatch
  292. mergeInfo.adHatchRewardCnt = getResetAdHatchCnt(human)
  293. mergeInfo.isTip = getTodayIsTip(human)
  294. mergeInfo.heroNiceNet = heroNiceNet
  295. msgRet.ret = msgTyep
  296. msgRet.tip = Json.Encode(mergeInfo)
  297. Log.write(Log.LOGID_TEST, "获取英雄 ret: " .. Json.Encode(msgRet))
  298. Msg.send(msgRet, human.fd)
  299. return
  300. end
  301. -- 加速孵化
  302. if type == QUICK_HATCH_TYPE then
  303. local tb = Util.split(param, "|")
  304. local quickType = tonumber(tb[1]) or 0
  305. local cnt = tonumber(tb[2]) or 0
  306. local isHatch = 1
  307. if tb[1] and tb[2] then
  308. -- 初始化
  309. initMergeInfo(human)
  310. -- 剩余时间
  311. local nowTime = os.time()
  312. local hatchTime = human.db.mergeInfo.endTime - nowTime
  313. if hatchTime <= 0
  314. then
  315. Broadcast.sendErr(human, Lang.QUICK_HATCH_TIME_OUT)
  316. return
  317. end
  318. local itemSpeedTime = 0
  319. if quickType == 1 then
  320. local speedTime = (60 * 5 * cnt) -- 正常数量加速券的加速时间
  321. local lastSpeedTime = (60 * 5 * (cnt - 1)) --少一张加速券的加速时间
  322. local itemCnt = 0
  323. if hatchTime > lastSpeedTime and hatchTime <= speedTime then
  324. itemCnt = cnt
  325. elseif hatchTime > 0 and hatchTime <= lastSpeedTime then
  326. itemCnt = cnt - 1
  327. elseif hatchTime >= speedTime then
  328. itemCnt = cnt
  329. else
  330. itemCnt = 0
  331. end
  332. itemSpeedTime = (60 * 5 * itemCnt)
  333. local bagCnt = BagLogic.getItemCnt(human, 179, true)
  334. if bagCnt < itemCnt then
  335. Broadcast.sendErr(human, Lang.ITEM_USE_ERR_NO)
  336. return
  337. end
  338. --使用道具
  339. ItemLogic.use(human, 179, itemCnt)
  340. elseif quickType == 2 then
  341. local zuanshiCnt = doCalcNeedZuanshi(hatchTime)
  342. -- 判断消耗
  343. if not ObjHuman.checkRMB(human, zuanshiCnt) then
  344. return
  345. end
  346. itemSpeedTime = (30 * zuanshiCnt)
  347. -- 扣钻石
  348. ObjHuman.decZuanshi(human, -zuanshiCnt, "hero_merge")
  349. if tb[3] then
  350. human.db.isTip = human.db.isTip or 1
  351. human.db.isTip = tonumber(tb[3])
  352. end
  353. elseif quickType == 3 then
  354. human.db.adHatchRewardCnt = human.db.adHatchRewardCnt or 0
  355. if human.db.adHatchRewardCnt > 4 then
  356. Broadcast.sendErr(human, Lang.AD_DRAW_REWARD_LIMIT_ERROR)
  357. return
  358. end
  359. --加速30分钟
  360. itemSpeedTime = 30 * 60
  361. --增加今日观看次数
  362. human.db.adHatchRewardCnt = (human.db.adHatchRewardCnt or 0) + 1
  363. end
  364. human.db.mergeInfo.endTime = human.db.mergeInfo.endTime - itemSpeedTime
  365. local hatchTime = human.db.mergeInfo.endTime - nowTime
  366. -- 孵化成功
  367. if hatchTime < 0 then
  368. hatchTime = 0
  369. isHatch = 3
  370. end
  371. local mergeInfo = {}
  372. local heroSimple = {}
  373. local sonHeroID = human.db.mergeInfo.heroInfo.heroID or 0
  374. local cf = sonHeroID and HeroExcel.hero[sonHeroID]
  375. heroSimple.name = cf and cf.name or ""
  376. if cf.grade >= 6 then
  377. heroSimple.name = "?????"
  378. end
  379. mergeInfo.mergeTime = hatchTime
  380. mergeInfo.heroData = heroSimple
  381. mergeInfo.xLv = human.db.mergeInfo.heroInfo.xLv
  382. mergeInfo.isHatch = isHatch
  383. mergeInfo.adHatchRewardCnt = getResetAdHatchCnt(human)
  384. mergeInfo.isTip = getTodayIsTip(human)
  385. msgRet.ret = QUICK_HATCH_TYPE
  386. msgRet.tip = Json.Encode(mergeInfo)
  387. Log.write(Log.LOGID_TEST, "加速孵化 ret: " .. Json.Encode(msgRet))
  388. Msg.send(msgRet, human.fd)
  389. return
  390. end
  391. return
  392. end
  393. end
  394. -- 孵化英雄
  395. function hatchHero(human)
  396. --添加英雄
  397. local heroIndex, fjlist = HeroLogic.addHero(human, human.db.mergeInfo.heroInfo.heroID, nil, 1,
  398. "hero_merge")
  399. Log.write(Log.LOGID_TEST, "孵化英雄成功 下标" .. heroIndex)
  400. local attrs = RoleDefine.PANEL_ATTR_KEY
  401. for key, value in pairs(attrs) do
  402. attrs[key] = 1
  403. end
  404. human.db.mergeInfo.startTime = 0
  405. human.db.mergeInfo.endTime = 0
  406. human.db.mergeInfo.heroInfo = {}
  407. human.db.mergeInfo.heroInfo.heroID = 0
  408. human.db.mergeInfo.heroInfo.xLv = 0
  409. human.db.mergeInfo.heroInfo.fatherHeroBagIndex = 0
  410. human.db.mergeInfo.heroInfo.motherHeroBagIndex = 0
  411. human.db.mergeInfo.heroInfo.heroAttrs = attrs
  412. Log.write(Log.LOGID_TEST, "孵化重置 mergeInfo: " .. Json.Encode(human.db.mergeInfo))
  413. return heroIndex
  414. end
  415. -- 初始化融合信息
  416. function initMergeInfo(human)
  417. human.db.mergeInfo = human.db.mergeInfo or {}
  418. human.db.mergeInfo.startTime = human.db.mergeInfo.startTime or 0 --融合时间 时间戳
  419. human.db.mergeInfo.endTime = human.db.mergeInfo.endTime or 0 --孵化时间 单位s
  420. human.db.mergeInfo.heroInfo = human.db.mergeInfo.heroInfo or {}
  421. human.db.mergeInfo.heroInfo.heroID = human.db.mergeInfo.heroInfo.heroID or 0
  422. human.db.mergeInfo.heroInfo.xLv = human.db.mergeInfo.heroInfo.xLv or 0
  423. human.db.mergeInfo.heroInfo.fatherHeroBagIndex = human.db.mergeInfo.heroInfo.fatherHeroBagIndex or 0
  424. human.db.mergeInfo.heroInfo.motherHeroBagIndex = human.db.mergeInfo.heroInfo.motherHeroBagIndex or 0
  425. human.db.mergeInfo.heroInfo.heroAttrs = human.db.mergeInfo.heroInfo.heroAttrs or RoleDefine.PANEL_ATTR_KEY
  426. end
  427. -- 获取孵化时间 单位s
  428. function getHatchTime(xLv)
  429. local time = (xLv * 5) + (xLv - 1) * (xLv - 1) - 5
  430. if time < 0 then
  431. return 0
  432. end
  433. return time * 60
  434. end
  435. -- 计算需要钻石数量
  436. function doCalcNeedZuanshi(hatchTime)
  437. local cnt = 0
  438. if hatchTime > 0 then
  439. cnt = math.ceil(hatchTime / 30)
  440. end
  441. return cnt
  442. end
  443. -- 获取xlv
  444. function getxLv(fatherHeroGrid, motherHeroGrid)
  445. local fatherHeroXLv = fatherHeroGrid.xLv or 0
  446. local motherHeroXLv = motherHeroGrid.xLv or 0
  447. local params1 = math.max(fatherHeroXLv, motherHeroXLv)
  448. local params2 = math.floor((fatherHeroGrid.lv + motherHeroGrid.lv) / 200) + 1
  449. local xLv = params1 + params2
  450. if xLv > 50 then
  451. return 50
  452. end
  453. return xLv
  454. end
  455. -- 融合获取英雄ID
  456. function mergeHero(fatherHeroID, motherHeroID)
  457. local fatherHeroConfig = HeroExcel.hero[fatherHeroID]
  458. local motherHeroConfig = HeroExcel.hero[motherHeroID]
  459. if not fatherHeroConfig or not motherHeroConfig then
  460. return 0
  461. end
  462. --规则3 heroID + heroID
  463. for _, config in pairs(MergeRule[3].items) do
  464. if fatherHeroID == config[1] and motherHeroID == config[2] then
  465. return config[3]
  466. end
  467. end
  468. --规则2 种族 + heroID
  469. for _, config in pairs(MergeRule[2].items) do
  470. if fatherHeroConfig.camp == config[1] and motherHeroID == config[2] then
  471. return config[3]
  472. end
  473. end
  474. --规则1 种族 + 种族
  475. for _, config in pairs(MergeRule[1].items) do
  476. if fatherHeroConfig.camp == config[1] and motherHeroConfig.camp == config[2] then
  477. return config[3]
  478. end
  479. end
  480. return 0
  481. end
  482. -- 获取剩余融化孵化加速广告观看次数
  483. function getResetAdHatchCnt(human)
  484. local adHatchRewardCnt = human.db.adHatchRewardCnt or 0
  485. return math.max(AD_HATCH_RESET_FREECNT - adHatchRewardCnt, 0)
  486. end
  487. -- 获取是否今日不再提示
  488. function getTodayIsTip(human)
  489. local isTip = human.db.isTip or 1
  490. return tonumber(isTip)
  491. end