BeginStory.lua 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. local HeroExcel = require("excel.hero")
  2. local UpNeedExcel = require("excel.upNeed")
  3. local CombatDefine = require("combat.CombatDefine")
  4. local RoleDefine = require("role.RoleDefine")
  5. local PanelDefine = require("broadcast.PanelDefine")
  6. local BagLogic = require("bag.BagLogic")
  7. local ItemDefine = require("bag.ItemDefine")
  8. local HeroGrid = require("hero.HeroGrid")
  9. local Config = require("Config")
  10. -- 战役第五关特殊处理 人生第一次打打则怪物攻击力*1.5 人生第二次打则怪物攻击力*0.5
  11. function handleBattle5(human, combatType, defender)
  12. if combatType == CombatDefine.COMBAT_TYPE1 and human.db.battleID == 5 then
  13. human.db.battleHis = human.db.battleHis or 0
  14. local atkRate
  15. if human.db.battleHis == 0 then
  16. atkRate = 1.5
  17. elseif human.db.battleHis == 1 then
  18. atkRate = 0.5
  19. end
  20. human.db.battleHis = human.db.battleHis + 1
  21. if atkRate then
  22. for index = 1, CombatDefine.COMBAT_HERO_CNT do
  23. local obj = defender[index]
  24. if obj then
  25. obj.attrs[RoleDefine.ATK] = math.ceil(obj.attrs[RoleDefine.ATK] * atkRate)
  26. end
  27. end
  28. end
  29. end
  30. end
  31. -- 征战第8关战斗胜利后回主城
  32. function handleBattle8End(human, isWin, isVideo, combatType, msgRet)
  33. if Config.PROJECT_NAME ~= "ssecy" then
  34. if isWin and not isVideo and combatType == CombatDefine.COMBAT_TYPE1 and human.db.battleID == 9 then
  35. msgRet.data.panelIDs[0] = 1
  36. msgRet.data.panelIDs[1] = PanelDefine.PANEL_ID_1001
  37. end
  38. end
  39. end
  40. -- 征战第12关战斗胜利后回主城
  41. function handleBattle12End(human, isWin, isVideo, combatType, msgRet)
  42. if Config.PROJECT_NAME ~= "ssecy" then
  43. if isWin and not isVideo and combatType == CombatDefine.COMBAT_TYPE1 and human.db.battleID == 13 then
  44. msgRet.data.panelIDs[0] = 1
  45. msgRet.data.panelIDs[1] = PanelDefine.PANEL_ID_1001
  46. end
  47. end
  48. end
  49. -- 比较2个武将
  50. local function isBetterHero(heroGrid, targetGrid)
  51. if not targetGrid then return true end
  52. local heroConfig = HeroExcel.hero[heroGrid.id]
  53. if not heroConfig then return end
  54. local targetConfig = HeroExcel.hero[targetGrid.id]
  55. if not targetConfig then return true end
  56. if heroConfig.star ~= targetConfig.star then
  57. return heroConfig.star > targetConfig.star
  58. end
  59. return heroGrid.zhandouli > targetGrid.zhandouli
  60. end
  61. -- 征战挑战失败提示 武将升级
  62. function handleBattleFail(human, isWin, combatType, isVideo, msgRet)
  63. if isWin or isVideo then return end
  64. if combatType ~= CombatDefine.COMBAT_TYPE1 then return end
  65. if human.db.lv >= 15 then return end -- 人物等级
  66. local targetGrid = nil
  67. for index,heroGrid in pairs(human.db.heroBag) do
  68. if index ~= 0 then
  69. if heroGrid.quality > 0 then
  70. return -- 进阶过就不提示了
  71. end
  72. if isBetterHero(heroGrid, targetGrid) then
  73. targetGrid = heroGrid
  74. end
  75. end
  76. end
  77. if not targetGrid then return end
  78. local heroConfig = HeroExcel.hero[targetGrid.id]
  79. local nowLv = targetGrid.lv
  80. local maxLv = HeroGrid.getMaxLv(heroConfig.star, targetGrid.quality)
  81. if nowLv >= maxLv then -- 进阶
  82. local upcf = UpNeedExcel.upQuality[targetGrid.quality + 1]
  83. if not upcf then return end
  84. -- 判断消耗材料
  85. if human.db.jinbi < upcf.money then return end
  86. if BagLogic.getItemCnt(human, ItemDefine.ITEM_HERO_UPGRADE_ID) < upcf.jinjieshi then
  87. return
  88. end
  89. else -- 升级
  90. local upcf = UpNeedExcel.upLv[nowLv + 1]
  91. if not upcf then return end
  92. if human.db.jinbi < upcf.money then return end
  93. if BagLogic.getItemCnt(human, ItemDefine.ITEM_GREEN_EXP_ID) < upcf.soul then
  94. return
  95. end
  96. end
  97. msgRet.data.param = "1"
  98. end