|
|
@@ -184,7 +184,7 @@ function NewProto(human, type, param)
|
|
|
local mergeInfo = {}
|
|
|
local heroSimple = {}
|
|
|
local xLv = getxLv(fatherHeroGrid, motherHeroGrid)
|
|
|
- local cnt = math.floor(xLv / 2) + 1
|
|
|
+ local isHatch = 2
|
|
|
|
|
|
local sonHeroID = mergeHero(fatherHeroGrid.id, motherHeroGrid.id)
|
|
|
if sonHeroID <= 0 then
|
|
|
@@ -196,6 +196,7 @@ function NewProto(human, type, param)
|
|
|
mergeInfo.mergeTime = human.db.mergeInfo.mergeTime
|
|
|
mergeInfo.xLv = xLv
|
|
|
mergeInfo.heroData = heroSimple
|
|
|
+ mergeInfo.isHatch = isHatch
|
|
|
|
|
|
Log.write(Log.LOGID_TEST, "mergeInfo: " .. Json.Encode(mergeInfo))
|
|
|
|
|
|
@@ -218,10 +219,19 @@ function NewProto(human, type, param)
|
|
|
local nowTime = os.time()
|
|
|
local mergeTime = 0
|
|
|
local heroSimple = {}
|
|
|
- local xLv = human.db.mergeInfo.heroInfo.xLv
|
|
|
+ local xLv = human.db.mergeInfo.heroInfo.xLv or 0
|
|
|
+ local heroIndex = 0
|
|
|
+ local sonHeroID = human.db.mergeInfo.heroInfo.heroID or 0
|
|
|
+ local isHatch = 2
|
|
|
|
|
|
- local sonHeroID = human.db.mergeInfo.heroInfo.heroID
|
|
|
if sonHeroID <= 0 then
|
|
|
+ mergeInfo.mergeTime = human.db.mergeInfo.mergeTime
|
|
|
+ mergeInfo.xLv = xLv
|
|
|
+ mergeInfo.heroData = heroSimple
|
|
|
+ mergeInfo.isHatch = isHatch
|
|
|
+ msgRet.ret = QUERY_MERGE_INFO_TYPE
|
|
|
+ msgRet.tip = Json.Encode(mergeInfo)
|
|
|
+ Msg.send(msgRet, human.fd)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
@@ -229,17 +239,27 @@ function NewProto(human, type, param)
|
|
|
mergeTime = human.db.mergeInfo.mergeEndTime - nowTime
|
|
|
-- 孵化成功
|
|
|
if mergeTime <= 0 then
|
|
|
- hatchHero(human)
|
|
|
+ heroIndex = hatchHero(human)
|
|
|
return
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- local cf = sonHeroID and HeroExcel.hero[sonHeroID]
|
|
|
- heroSimple.name = cf and cf.name or ""
|
|
|
+ if heroIndex ~= 0 then
|
|
|
+ local isHatch = 3
|
|
|
+ local heroGrid = human.db.heroBag[heroIndex]
|
|
|
+ if type(heroGrid) ~= "table" then return end
|
|
|
+ heroSimple.general = heroSimple.general or {}
|
|
|
+ HeroGrid.makeHeroSimple(heroSimple, heroGrid, nil, human)
|
|
|
+ else
|
|
|
+ local cf = sonHeroID and HeroExcel.hero[sonHeroID]
|
|
|
+ heroSimple.name = cf and cf.name or ""
|
|
|
+ isHatch = 1
|
|
|
+ end
|
|
|
+
|
|
|
mergeInfo.mergeTime = human.db.mergeInfo.mergeTime
|
|
|
mergeInfo.xLv = xLv
|
|
|
mergeInfo.heroData = heroSimple
|
|
|
-
|
|
|
+ mergeInfo.isHatch = isHatch
|
|
|
Log.write(Log.LOGID_TEST, "mergeInfo: " .. Json.Encode(mergeInfo))
|
|
|
|
|
|
local msgRet = Msg.gc.GC_ROLE_CHANGE_BASEINFO
|
|
|
@@ -254,21 +274,36 @@ function NewProto(human, type, param)
|
|
|
local tb = Util.split(param, "|")
|
|
|
local itemId = tonumber(tb[1]) or 0
|
|
|
local cnt = tonumber(tb[2]) or 0
|
|
|
+ local isHatch = 2
|
|
|
|
|
|
if tb[1] and tb[2] then
|
|
|
-- 初始化
|
|
|
initMergeInfo(human)
|
|
|
|
|
|
- --使用道具
|
|
|
- ItemLogic.use(human, itemId, cnt)
|
|
|
-
|
|
|
- local remainingTime = human.db.mergeInfo.mergeTime - (60 * cnt)
|
|
|
+ local remainingTime = 0
|
|
|
+ if itemId == 179 then
|
|
|
+ --使用道具
|
|
|
+ ItemLogic.use(human, itemId, cnt)
|
|
|
+ remainingTime = human.db.mergeInfo.mergeTime - (60 * 5 * cnt)
|
|
|
+ else
|
|
|
+ -- 判断消耗
|
|
|
+ local needZuanshi = cnt
|
|
|
+ if not ObjHuman.checkRMB(human, needZuanshi) then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 扣钻石
|
|
|
+ ObjHuman.decZuanshi(human, -needZuanshi, "hero_merge")
|
|
|
+ remainingTime = human.db.mergeInfo.mergeTime - (30 * needZuanshi)
|
|
|
+ end
|
|
|
|
|
|
Log.write(Log.LOGID_TEST, "remainingTime: " .. remainingTime)
|
|
|
|
|
|
-- 孵化成功
|
|
|
if remainingTime <= 0 then
|
|
|
- hatchHero(human)
|
|
|
+ -- hatchHero(human)
|
|
|
+ human.db.mergeInfo.mergeTime = 0
|
|
|
+ isHatch = 3
|
|
|
-- return
|
|
|
end
|
|
|
|
|
|
@@ -278,11 +313,10 @@ function NewProto(human, type, param)
|
|
|
|
|
|
local mergeInfo = {}
|
|
|
local heroSimple = {}
|
|
|
- -- heroSimple.general = heroSimple.general or {}
|
|
|
- -- HeroGrid.makeHeroSimpleByID(heroSimple, human.db.mergeInfo.heroId, nil, nil, human)
|
|
|
-
|
|
|
mergeInfo.mergeTime = human.db.mergeInfo.mergeTime
|
|
|
mergeInfo.heroData = heroSimple
|
|
|
+ mergeInfo.xLv = human.db.mergeInfo.heroInfo.xLv
|
|
|
+ mergeInfo.isHatch = isHatch
|
|
|
|
|
|
local msgRet = Msg.gc.GC_ROLE_CHANGE_BASEINFO
|
|
|
msgRet.ret = QUICK_HATCH_TYPE
|
|
|
@@ -314,18 +348,19 @@ function hatchHero(human)
|
|
|
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
|
|
|
+ return heroIndex
|
|
|
+ -- local heroGrid = human.db.heroBag[heroIndex]
|
|
|
+ -- if type(heroGrid) ~= "table" then return end
|
|
|
|
|
|
- heroSimple.general = heroSimple.general or {}
|
|
|
- HeroGrid.makeHeroSimple(heroSimple, heroGrid, nil, human)
|
|
|
+ -- heroSimple.general = heroSimple.general or {}
|
|
|
+ -- HeroGrid.makeHeroSimple(heroSimple, heroGrid, nil, human)
|
|
|
|
|
|
- data.heroData = heroSimple
|
|
|
- data.mergeTime = human.db.mergeInfo.mergeTime
|
|
|
+ -- data.heroData = heroSimple
|
|
|
+ -- data.mergeTime = human.db.mergeInfo.mergeTime
|
|
|
|
|
|
- msgRet.ret = HATCH_SCCUESS_TYPE
|
|
|
- msgRet.tip = Json.Encode(data)
|
|
|
- Msg.send(msgRet, human.fd)
|
|
|
+ -- msgRet.ret = HATCH_SCCUESS_TYPE
|
|
|
+ -- msgRet.tip = Json.Encode(data)
|
|
|
+ -- Msg.send(msgRet, human.fd)
|
|
|
end
|
|
|
|
|
|
-- 初始化融合信息
|