|
|
@@ -22,7 +22,7 @@ HATCH_SCCUESS_TYPE = 12 -- 孵化成功
|
|
|
MERGE_HERO_TYPE = 13 --融合
|
|
|
QUICK_HATCH_TYPE = 14 --加速
|
|
|
QUERY_MERGE_BEFORE_INFO_TYPE = 15 --获取融合前信息
|
|
|
-WATCH_AD_QUICK_HATCH_TYPE = 16 --观看广告加速孵化 30分钟
|
|
|
+GET_MERGE_HERO_TYPE = 16 --获取融合英雄
|
|
|
|
|
|
AD_HATCH_RESET_FREECNT = 4 --看广告加速孵化次数
|
|
|
|
|
|
@@ -60,66 +60,65 @@ function NewProto(human, type, param)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- -- 观看广告增加孵化速度
|
|
|
- if type == WATCH_AD_QUICK_HATCH_TYPE then
|
|
|
- human.db.adHatchRewardCnt = human.db.adHatchRewardCnt or 0
|
|
|
-
|
|
|
- if human.db.adHatchRewardCnt > 4 then
|
|
|
- Broadcast.sendErr(human, Lang.AD_DRAW_REWARD_LIMIT_ERROR)
|
|
|
- return
|
|
|
- end
|
|
|
+ -- 获取融合前的信息
|
|
|
+ if type == QUERY_MERGE_BEFORE_INFO_TYPE then
|
|
|
+ local tb = Util.split(param, "|")
|
|
|
+ if tb[1] and tb[2] then
|
|
|
+ -- 初始化
|
|
|
+ initMergeInfo(human)
|
|
|
|
|
|
- local itemSpeedTime = 30 * 60
|
|
|
- local nowTime = os.time()
|
|
|
- local mergeInfo = {}
|
|
|
- local mergeTime = 0
|
|
|
- local heroSimple = {}
|
|
|
- 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 cf = sonHeroID and HeroExcel.hero[sonHeroID]
|
|
|
- heroSimple.name = cf and cf.name or ""
|
|
|
+ human.db.heroBag = human.db.heroBag or {}
|
|
|
|
|
|
- --增加今日观看次数
|
|
|
- human.db.adHatchRewardCnt = (human.db.adHatchRewardCnt or 0) + 1
|
|
|
+ local fatherHeroBagIndex = tonumber(tb[1]) or 0
|
|
|
+ local motherHeroBagIndex = tonumber(tb[2]) or 0
|
|
|
|
|
|
- human.db.mergeInfo.endTime = human.db.mergeInfo.endTime - itemSpeedTime
|
|
|
+ local fatherHeroGrid = human.db.heroBag[fatherHeroBagIndex]
|
|
|
+ if not fatherHeroGrid then
|
|
|
+ return
|
|
|
+ end
|
|
|
|
|
|
- Log.write(Log.LOGID_TEST, "human.db.mergeInfo.endTime: " .. human.db.mergeInfo.endTime)
|
|
|
+ local motherHeroGrid = human.db.heroBag[motherHeroBagIndex]
|
|
|
+ if not motherHeroGrid then
|
|
|
+ return
|
|
|
+ end
|
|
|
|
|
|
- local hatchTime = human.db.mergeInfo.endTime - nowTime
|
|
|
+ local mergeInfo = {}
|
|
|
+ local heroSimple = {}
|
|
|
+ local xLv = getxLv(fatherHeroGrid, motherHeroGrid)
|
|
|
+ local cnt = math.floor(xLv / 2) + 1
|
|
|
+ local isHatch = 2
|
|
|
+ local mergeItem = {}
|
|
|
+ local itemId = 178
|
|
|
|
|
|
- if hatchTime < 0 then
|
|
|
- -- 孵化成功
|
|
|
- mergeTime = 0
|
|
|
- isHatch = 3
|
|
|
- Log.write(Log.LOGID_TEST, "孵化成功: " .. Json.Encode(human.db.mergeInfo))
|
|
|
- heroIndex = hatchHero(human)
|
|
|
- end
|
|
|
+ for k = 1, 1 do
|
|
|
+ mergeItem[k] = mergeItem[k] or {}
|
|
|
+ mergeItem[k].getway = mergeItem[k].getway or {}
|
|
|
+ mergeItem[k].suipian = mergeItem[k].suipian or {}
|
|
|
+ mergeItem[k].equip = mergeItem[k].equip or {}
|
|
|
+ mergeItem[k].fuwen = mergeItem[k].fuwen or {}
|
|
|
+ Grid.makeItem(mergeItem[k], itemId, cnt)
|
|
|
+ end
|
|
|
|
|
|
- if heroIndex ~= 0 then
|
|
|
- local heroGrid = human.db.heroBag[heroIndex]
|
|
|
- if not heroGrid 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
|
|
|
+ local sonHeroID = mergeHero(fatherHeroGrid.id, motherHeroGrid.id)
|
|
|
+ if sonHeroID <= 0 then
|
|
|
+ return
|
|
|
+ end
|
|
|
|
|
|
- mergeInfo.mergeTime = mergeTime
|
|
|
- mergeInfo.xLv = xLv
|
|
|
- mergeInfo.heroData = heroSimple
|
|
|
- mergeInfo.isHatch = isHatch
|
|
|
- mergeInfo.adHatchRewardCnt = getResetAdHatchCnt(human)
|
|
|
+ local cf = sonHeroID and HeroExcel.hero[sonHeroID]
|
|
|
+ heroSimple.name = cf and cf.name or ""
|
|
|
+ mergeInfo.mergeTime = 0
|
|
|
+ mergeInfo.xLv = xLv
|
|
|
+ mergeInfo.mergeItem = mergeItem
|
|
|
+ mergeInfo.heroData = heroSimple
|
|
|
+ mergeInfo.isHatch = isHatch
|
|
|
+ mergeInfo.adHatchRewardCnt = getResetAdHatchCnt(human)
|
|
|
|
|
|
- Log.write(Log.LOGID_TEST, "看广告 mergeInfo: " .. Json.Encode(mergeInfo))
|
|
|
+ Log.write(Log.LOGID_TEST, "查询融合前的 mergeInfo: " .. Json.Encode(mergeInfo))
|
|
|
|
|
|
- msgRet.ret = WATCH_AD_QUICK_HATCH_TYPE
|
|
|
- msgRet.tip = Json.Encode(mergeInfo)
|
|
|
- Msg.send(msgRet, human.fd)
|
|
|
+ msgRet.ret = QUERY_MERGE_BEFORE_INFO_TYPE
|
|
|
+ msgRet.tip = Json.Encode(mergeInfo)
|
|
|
+ Msg.send(msgRet, human.fd)
|
|
|
+ end
|
|
|
return
|
|
|
end
|
|
|
|
|
|
@@ -132,7 +131,7 @@ function NewProto(human, type, param)
|
|
|
|
|
|
human.db.heroBag = human.db.heroBag or {}
|
|
|
|
|
|
- local itemId = 178 --生命雨露
|
|
|
+ local itemId = 178 --生命雨露
|
|
|
local fatherHeroBagIndex = tonumber(tb[1]) or 0
|
|
|
local motherHeroBagIndex = tonumber(tb[2]) or 0
|
|
|
|
|
|
@@ -215,68 +214,6 @@ function NewProto(human, type, param)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- -- 获取融合前的信息
|
|
|
- if type == QUERY_MERGE_BEFORE_INFO_TYPE then
|
|
|
- local tb = Util.split(param, "|")
|
|
|
- if tb[1] and tb[2] then
|
|
|
- -- 初始化
|
|
|
- initMergeInfo(human)
|
|
|
-
|
|
|
- human.db.heroBag = human.db.heroBag or {}
|
|
|
-
|
|
|
- local fatherHeroBagIndex = tonumber(tb[1]) or 0
|
|
|
- local motherHeroBagIndex = tonumber(tb[2]) or 0
|
|
|
-
|
|
|
- local fatherHeroGrid = human.db.heroBag[fatherHeroBagIndex]
|
|
|
- if not fatherHeroGrid then
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
- local motherHeroGrid = human.db.heroBag[motherHeroBagIndex]
|
|
|
- if not motherHeroGrid then
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
- local mergeInfo = {}
|
|
|
- local heroSimple = {}
|
|
|
- local xLv = getxLv(fatherHeroGrid, motherHeroGrid)
|
|
|
- local cnt = math.floor(xLv / 2) + 1
|
|
|
- local isHatch = 2
|
|
|
- local mergeItem = {}
|
|
|
- local itemId = 178
|
|
|
-
|
|
|
- for k = 1, 1 do
|
|
|
- mergeItem[k] = mergeItem[k] or {}
|
|
|
- mergeItem[k].getway = mergeItem[k].getway or {}
|
|
|
- mergeItem[k].suipian = mergeItem[k].suipian or {}
|
|
|
- mergeItem[k].equip = mergeItem[k].equip or {}
|
|
|
- mergeItem[k].fuwen = mergeItem[k].fuwen or {}
|
|
|
- Grid.makeItem(mergeItem[k], itemId, cnt)
|
|
|
- end
|
|
|
-
|
|
|
- local sonHeroID = mergeHero(fatherHeroGrid.id, motherHeroGrid.id)
|
|
|
- if sonHeroID <= 0 then
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
- local cf = sonHeroID and HeroExcel.hero[sonHeroID]
|
|
|
- heroSimple.name = cf and cf.name or ""
|
|
|
- mergeInfo.mergeTime = 0
|
|
|
- mergeInfo.xLv = xLv
|
|
|
- mergeInfo.mergeItem = mergeItem
|
|
|
- mergeInfo.heroData = heroSimple
|
|
|
- mergeInfo.isHatch = isHatch
|
|
|
- mergeInfo.adHatchRewardCnt = getResetAdHatchCnt(human)
|
|
|
-
|
|
|
- Log.write(Log.LOGID_TEST, "查询融合前的 mergeInfo: " .. Json.Encode(mergeInfo))
|
|
|
-
|
|
|
- msgRet.ret = QUERY_MERGE_BEFORE_INFO_TYPE
|
|
|
- msgRet.tip = Json.Encode(mergeInfo)
|
|
|
- Msg.send(msgRet, human.fd)
|
|
|
- end
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
-- 获取融合中的信息
|
|
|
if type == QUERY_MERGE_INFO_TYPE then
|
|
|
-- 初始化
|
|
|
@@ -338,10 +275,73 @@ function NewProto(human, type, param)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
+ -- 获取融合英雄
|
|
|
+ if type == GET_MERGE_HERO_TYPE then
|
|
|
+ human.db.adHatchRewardCnt = human.db.adHatchRewardCnt or 0
|
|
|
+
|
|
|
+ if human.db.adHatchRewardCnt > 4 then
|
|
|
+ Broadcast.sendErr(human, Lang.AD_DRAW_REWARD_LIMIT_ERROR)
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local itemSpeedTime = 30 * 60
|
|
|
+ local nowTime = os.time()
|
|
|
+ local mergeInfo = {}
|
|
|
+ local mergeTime = 0
|
|
|
+ local heroSimple = {}
|
|
|
+ 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 cf = sonHeroID and HeroExcel.hero[sonHeroID]
|
|
|
+ heroSimple.name = cf and cf.name or ""
|
|
|
+
|
|
|
+ --增加今日观看次数
|
|
|
+ human.db.adHatchRewardCnt = (human.db.adHatchRewardCnt or 0) + 1
|
|
|
+
|
|
|
+ human.db.mergeInfo.endTime = human.db.mergeInfo.endTime - itemSpeedTime
|
|
|
+
|
|
|
+ Log.write(Log.LOGID_TEST, "human.db.mergeInfo.endTime: " .. human.db.mergeInfo.endTime)
|
|
|
+
|
|
|
+ local hatchTime = human.db.mergeInfo.endTime - nowTime
|
|
|
+
|
|
|
+ if hatchTime < 0 then
|
|
|
+ -- 孵化成功
|
|
|
+ mergeTime = 0
|
|
|
+ isHatch = 3
|
|
|
+ Log.write(Log.LOGID_TEST, "孵化成功: " .. Json.Encode(human.db.mergeInfo))
|
|
|
+ heroIndex = hatchHero(human)
|
|
|
+ end
|
|
|
+
|
|
|
+ if heroIndex ~= 0 then
|
|
|
+ local heroGrid = human.db.heroBag[heroIndex]
|
|
|
+ if not heroGrid 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 = mergeTime
|
|
|
+ mergeInfo.xLv = xLv
|
|
|
+ mergeInfo.heroData = heroSimple
|
|
|
+ mergeInfo.isHatch = isHatch
|
|
|
+ mergeInfo.adHatchRewardCnt = getResetAdHatchCnt(human)
|
|
|
+
|
|
|
+ Log.write(Log.LOGID_TEST, "看广告 mergeInfo: " .. Json.Encode(mergeInfo))
|
|
|
+
|
|
|
+ msgRet.ret = GET_MERGE_HERO_TYPE
|
|
|
+ msgRet.tip = Json.Encode(mergeInfo)
|
|
|
+ Msg.send(msgRet, human.fd)
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
-- 加速孵化
|
|
|
if type == QUICK_HATCH_TYPE then
|
|
|
local tb = Util.split(param, "|")
|
|
|
- local itemId = tonumber(tb[1]) or 0
|
|
|
+ local quickType = tonumber(tb[1]) or 0
|
|
|
local cnt = tonumber(tb[2]) or 0
|
|
|
local isHatch = 2
|
|
|
|
|
|
@@ -359,7 +359,7 @@ function NewProto(human, type, param)
|
|
|
end
|
|
|
|
|
|
local itemSpeedTime = 0
|
|
|
- if itemId == 179 then
|
|
|
+ if quickType == 1 then
|
|
|
local speedTime = (60 * 5 * cnt) -- 正常数量加速券的加速时间
|
|
|
local lastSpeedTime = (60 * 5 * (cnt - 1)) --少一张加速券的加速时间
|
|
|
local itemCnt = 0
|
|
|
@@ -376,15 +376,15 @@ function NewProto(human, type, param)
|
|
|
|
|
|
itemSpeedTime = (60 * 5 * itemCnt)
|
|
|
|
|
|
- local bagCnt = BagLogic.getItemCnt(human, itemId, true)
|
|
|
+ local bagCnt = BagLogic.getItemCnt(human, 179, true)
|
|
|
if bagCnt < itemCnt then
|
|
|
Broadcast.sendErr(human, Lang.ITEM_USE_ERR_NO)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
--使用道具
|
|
|
- ItemLogic.use(human, itemId, itemCnt)
|
|
|
- else
|
|
|
+ ItemLogic.use(human, 179, itemCnt)
|
|
|
+ elseif quickType == 2 then
|
|
|
local zuanshiCnt = doCalcNeedZuanshi(hatchTime)
|
|
|
|
|
|
-- 判断消耗
|
|
|
@@ -396,6 +396,19 @@ function NewProto(human, type, param)
|
|
|
|
|
|
-- 扣钻石
|
|
|
ObjHuman.decZuanshi(human, -zuanshiCnt, "hero_merge")
|
|
|
+ elseif quickType == 3 then
|
|
|
+ human.db.adHatchRewardCnt = human.db.adHatchRewardCnt or 0
|
|
|
+
|
|
|
+ if human.db.adHatchRewardCnt > 4 then
|
|
|
+ Broadcast.sendErr(human, Lang.AD_DRAW_REWARD_LIMIT_ERROR)
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ --加速30分钟
|
|
|
+ itemSpeedTime = 30 * 60
|
|
|
+
|
|
|
+ --增加今日观看次数
|
|
|
+ human.db.adHatchRewardCnt = (human.db.adHatchRewardCnt or 0) + 1
|
|
|
end
|
|
|
|
|
|
human.db.mergeInfo.endTime = human.db.mergeInfo.endTime - itemSpeedTime
|