zhanwencai 1 год назад
Родитель
Сommit
0c95e0978b
1 измененных файлов с 76 добавлено и 45 удалено
  1. 76 45
      script/module/role/NewLogic.lua

+ 76 - 45
script/module/role/NewLogic.lua

@@ -15,12 +15,12 @@ local RoleDefine = require("role.RoleDefine")
 local ObjHuman = require("core.ObjHuman")
 local HeroGrid = require("hero.HeroGrid")
 
-AD_DRAW_REWARD_TYPE = 10         --观看广告领取召唤券
-QUERY_MERGE_INFO_TYPE = 11       --获取融合信息
-QUERY_MERGE_BEFOR_INFO_TYPE = 15 --获取融合前信息
-HATCH_SCCUESS_TYPE = 12          -- 孵化成功
-MERGE_HERO_TYPE = 13             --融合
-QUICK_HATCH_TYPE = 14            --加速
+AD_DRAW_REWARD_TYPE = 10          --观看广告领取召唤券
+QUERY_MERGE_INFO_TYPE = 11        --获取融合信息
+QUERY_MERGE_BEFORE_INFO_TYPE = 15 --获取融合前信息
+HATCH_SCCUESS_TYPE = 12           -- 孵化成功
+MERGE_HERO_TYPE = 13              --融合
+QUICK_HATCH_TYPE = 14             --加速
 
 function NewProto(human, type, param)
     -- print("newProto:",type,param)
@@ -130,14 +130,14 @@ function NewProto(human, type, param)
             -- end
 
             -- 记录融合英雄
-            human.db.mergeInfo.heroInfo.heroID         = sonHeroID
-            human.db.mergeInfo.heroInfo.xLv            = xLv
-            human.db.mergeInfo.heroInfo.heroAttrs      = attrs
-            human.db.mergeInfo.mergeStartTime = os.time()
-            human.db.mergeInfo.mergeEndTime   = os.time() + getHatchTime(xLv)
-            human.db.mergeInfo.mergeTime      = getHatchTime(xLv)
-            human.db.mergeInfo.heroInfo.fatherHeroBagIndex      = fatherHeroBagIndex
-            human.db.mergeInfo.heroInfo.motherHeroBagIndex      = motherHeroBagIndex
+            human.db.mergeInfo.heroInfo.heroID             = sonHeroID
+            human.db.mergeInfo.heroInfo.xLv                = xLv
+            human.db.mergeInfo.heroInfo.heroAttrs          = attrs
+            human.db.mergeInfo.mergeStartTime              = os.time()
+            human.db.mergeInfo.mergeEndTime                = os.time() + getHatchTime(xLv)
+            human.db.mergeInfo.mergeTime                   = getHatchTime(xLv)
+            human.db.mergeInfo.heroInfo.fatherHeroBagIndex = fatherHeroBagIndex
+            human.db.mergeInfo.heroInfo.motherHeroBagIndex = motherHeroBagIndex
 
             Log.write(Log.LOGID_TEST, "human.db.mergeInfo : " .. Json.Encode(human.db.mergeInfo))
 
@@ -159,8 +159,8 @@ function NewProto(human, type, param)
         return
     end
 
-    -- 获取融合信息
-    if type == QUERY_MERGE_INFO_TYPE then
+    -- 获取融合前的信息
+    if type == QUERY_MERGE_BEFORE_INFO_TYPE then
         local tb = Util.split(param, "|")
         if tb[1] and tb[2] then
             -- 初始化
@@ -182,8 +182,6 @@ function NewProto(human, type, param)
             end
 
             local mergeInfo  = {}
-            local nowTime    = os.time()
-            local mergeTime  = 0
             local heroSimple = {}
             local xLv        = getxLv(fatherHeroGrid, motherHeroGrid)
             local cnt        = math.floor(xLv / 2) + 1
@@ -193,15 +191,6 @@ function NewProto(human, type, param)
                 return
             end
 
-            if human.db.mergeInfo.mergeEndTime ~= 0 then
-                mergeTime = human.db.mergeInfo.mergeEndTime - nowTime
-                -- 孵化成功
-                if mergeTime <= 0 then
-                    hatchHero(human)
-                    return
-                end
-            end
-
             local cf            = sonHeroID and HeroExcel.hero[sonHeroID]
             heroSimple.name     = cf and cf.name or ""
             mergeInfo.mergeTime = human.db.mergeInfo.mergeTime
@@ -210,7 +199,7 @@ function NewProto(human, type, param)
 
             Log.write(Log.LOGID_TEST, "mergeInfo: " .. Json.Encode(mergeInfo))
 
-            local msgRet = Msg.gc.GC_ROLE_CHANGE_BASEINFO
+            local msgRet = Msg.gc.QUERY_MERGE_BEFORE_INFO_TYPE
             msgRet.ret   = QUERY_MERGE_INFO_TYPE
             msgRet.tip   = Json.Encode(mergeInfo)
             Msg.send(msgRet, human.fd)
@@ -218,6 +207,48 @@ function NewProto(human, type, param)
         return
     end
 
+    -- 获取融合中的信息
+    if type == QUERY_MERGE_INFO_TYPE then
+        -- 初始化
+        initMergeInfo(human)
+
+        human.db.heroBag = human.db.heroBag or {}
+
+        local mergeInfo  = {}
+        local nowTime    = os.time()
+        local mergeTime  = 0
+        local heroSimple = {}
+        local xLv        = human.db.mergeInfo.heroInfo.xLv
+
+        local sonHeroID  = human.db.mergeInfo.heroInfo.heroID
+        if sonHeroID <= 0 then
+            return
+        end
+
+        if human.db.mergeInfo.mergeEndTime ~= 0 then
+            mergeTime = human.db.mergeInfo.mergeEndTime - nowTime
+            -- 孵化成功
+            if mergeTime <= 0 then
+                hatchHero(human)
+                return
+            end
+        end
+
+        local cf            = sonHeroID and HeroExcel.hero[sonHeroID]
+        heroSimple.name     = cf and cf.name or ""
+        mergeInfo.mergeTime = human.db.mergeInfo.mergeTime
+        mergeInfo.xLv       = xLv
+        mergeInfo.heroData  = heroSimple
+
+        Log.write(Log.LOGID_TEST, "mergeInfo: " .. Json.Encode(mergeInfo))
+
+        local msgRet = Msg.gc.GC_ROLE_CHANGE_BASEINFO
+        msgRet.ret   = QUERY_MERGE_INFO_TYPE
+        msgRet.tip   = Json.Encode(mergeInfo)
+        Msg.send(msgRet, human.fd)
+        return
+    end
+
     -- 加速孵化
     if type == QUICK_HATCH_TYPE then
         local tb = Util.split(param, "|")
@@ -266,24 +297,24 @@ end
 -- 孵化英雄
 function hatchHero(human)
     --添加英雄
-    local heroIndex, fjlist               = HeroLogic.addHero(human, human.db.mergeInfo.heroInfo.heroID, nil, 1,
+    local heroIndex, fjlist                        = HeroLogic.addHero(human, human.db.mergeInfo.heroInfo.heroID, nil, 1,
         "hero_merge")
-    local data                            = {}
-    local heroSimple                      = {}
-    local msgRet                          = Msg.gc.GC_ROLE_CHANGE_BASEINFO
-
-    human.db.mergeInfo.mergeStartTime     = 0
-    human.db.mergeInfo.mergeEndTime       = 0
-    human.db.mergeInfo.mergeTime          = 0
-    human.db.mergeInfo.heroInfo           = {}
-    human.db.mergeInfo.heroInfo.heroID    = 0
-    human.db.mergeInfo.heroInfo.xLv       = 0
-    human.db.mergeInfo.fatherHeroBagIndex      = 0
-    human.db.mergeInfo.motherHeroBagIndex      = 0
-    human.db.mergeInfo.heroInfo.heroAttrs = RoleDefine.PANEL_ATTR_KEY
-    human.db.heroBag                      = human.db.heroBag or {}
-
-    local heroGrid                        = human.db.heroBag[heroIndex]
+    local data                                     = {}
+    local heroSimple                               = {}
+    local msgRet                                   = Msg.gc.GC_ROLE_CHANGE_BASEINFO
+
+    human.db.mergeInfo.mergeStartTime              = 0
+    human.db.mergeInfo.mergeEndTime                = 0
+    human.db.mergeInfo.mergeTime                   = 0
+    human.db.mergeInfo.heroInfo                    = {}
+    human.db.mergeInfo.heroInfo.heroID             = 0
+    human.db.mergeInfo.heroInfo.xLv                = 0
+    human.db.mergeInfo.heroInfo.fatherHeroBagIndex = 0
+    human.db.mergeInfo.heroInfo.motherHeroBagIndex = 0
+    human.db.mergeInfo.heroInfo.heroAttrs          = RoleDefine.PANEL_ATTR_KEY
+    human.db.heroBag                               = human.db.heroBag or {}
+
+    local heroGrid                                 = human.db.heroBag[heroIndex]
     if type(heroGrid) ~= "table" then return end
 
     heroSimple.general = heroSimple.general or {}