Explorar el Código

更新融合逻辑

zhanwencai hace 1 año
padre
commit
cdb9452b37

+ 2 - 2
script/core/ObjHuman.lua

@@ -327,8 +327,8 @@ function sendAttr(human,key)
 	--Msg.trace(msgRet)
 end
 
-function doCalcHero(human, bagIndex, heroAttrs)
-	RoleAttr.doCalcHero(human, bagIndex,heroAttrs)
+function doCalcHero(human, bagIndex)
+	RoleAttr.doCalcHero(human, bagIndex)
 	doCalc(human)
 end
 

BIN
script/file3.tar.gz


+ 10 - 0
script/module/chat/Gm.lua

@@ -1838,3 +1838,13 @@ function d3.merge(human,value)
 		InnerMsg.sendMsg(0, msgRet)]]
 	end	
 end
+
+--重置看广告获取高级召唤卷次数
+function d3.resetad(human)
+    human.db.adRewardCnt = 0
+end
+
+--重置看广告加速孵化次数
+function d3.resetadhatch(human)
+    human.db.adHatchRewardCnt = 0
+end

+ 2 - 1
script/module/hero/HeroGrid.lua

@@ -49,7 +49,7 @@ HERO_LEVELUP_MAXCNT = 5 		-- 最多连升x次
 HERO_LEVELUP_MAXLEVEL = 60 		-- 从x级开始不能连续升多级
 
 -- 创建一个英雄grid
-function createHeroGrid(id,star, xlv)
+function createHeroGrid(id,star, xlv, mergeHeroAttrs)
 	local cf = HeroExcel.hero[id]
 	if not cf then 
 	   assert(nil, "not hero id "..id)
@@ -71,6 +71,7 @@ function createHeroGrid(id,star, xlv)
     grid.oldLV = nil 				--星耀共鸣记录旧等级
     grid.oldQuality = nil 			--星耀共鸣记录旧品质	
     grid.xLv = xlv or 0 			--x等级	默认0
+    grid.mergeHeroAttrs = mergeHeroAttrs or {} --融合英雄的初始属性
 	return grid	
 end
 

+ 37 - 12
script/module/hero/HeroLogic.lua

@@ -168,7 +168,7 @@ local function qualityAdd(heroConfig, quality, attrs)
 end
 
 -- 伙伴基础
-function doCalcHero(grid, attrs, isMerge)
+function doCalcHero(grid, attrs)
     if not grid and attrs then return end
     local heroConfig = HeroExcel.hero[grid.id]
     local attrConfig = HeroDefine.getAttrConfig(grid.id, grid.star)
@@ -176,7 +176,30 @@ function doCalcHero(grid, attrs, isMerge)
         assert(nil, "attrConfig is nil id " .. grid.id .. " star " .. grid.star)
     end
 
-    if isMerge == nil then
+    for _, v in ipairs(attrConfig.attrs) do
+        RoleAttr.updateValue(v[1], v[2], attrs)
+    end
+
+    lvAdd(grid.lv, attrConfig.up, attrs)
+    starAdd(grid.star, attrConfig.atkStarRate, attrConfig.hpStarRate, attrs)
+    qualityAdd(heroConfig, grid.quality, attrs)
+end
+
+-- 融合伙伴基础
+function doCalcMergeHero(grid, attrs)
+    if not grid and attrs then return end
+    local mergeHeroAttrs = grid.mergeHeroAttrs
+    local heroConfig = HeroExcel.hero[grid.id]
+    local attrConfig = HeroDefine.getAttrConfig(grid.id, grid.star)
+    if not attrConfig then
+        assert(nil, "attrConfig is nil id " .. grid.id .. " star " .. grid.star)
+    end
+
+    if type(mergeHeroAttrs) == "table" and next(mergeHeroAttrs) ~= nil then
+        for k, v in pairs(mergeHeroAttrs) do
+            RoleAttr.updateValue(k, v, attrs)
+        end
+    else
         for _, v in ipairs(attrConfig.attrs) do
             RoleAttr.updateValue(v[1], v[2], attrs)
         end
@@ -411,15 +434,19 @@ function addHero(human, id, star, cnt, logType, noSend)
     if not heroConfig then return end
 
     local xLv = 0
-    local heroAttrs = nil
+    local mergeHeroAttrs = nil
     if logType == "hero_merge" then
         human.db.mergeInfo = human.db.mergeInfo or {}
         human.db.mergeInfo.heroInfo.xLv = human.db.mergeInfo.heroInfo.xLv or 0
         human.db.mergeInfo.heroInfo.heroAttrs = human.db.mergeInfo.heroInfo.heroAttrs or RoleDefine.PANEL_ATTR_KEY
 
         xLv = human.db.mergeInfo.heroInfo.xLv
-        heroAttrs = human.db.mergeInfo.heroInfo.heroAttrs
-        Log.write(Log.LOGID_TEST, "添加融合英雄属性 heroAttrs : " .. Json.Encode(heroAttrs))
+        mergeHeroAttrs = mergeHeroAttrs or {}
+        for k, v in pairs(human.db.mergeInfo.heroInfo.heroAttrs) do
+            mergeHeroAttrs[k] = v
+        end
+
+        Log.write(Log.LOGID_TEST, "添加融合英雄属性 heroAttrs : " .. Json.Encode(mergeHeroAttrs))
     end
 
     -- 某些英雄自动分解
@@ -435,8 +462,9 @@ function addHero(human, id, star, cnt, logType, noSend)
 
     local heroIndex, uuid = nil
     for i = 1, cnt do
-        local heroGrid = HeroGrid.createHeroGrid(id, star, xLv)
-        heroIndex = addHeroByGrid(human, heroGrid, logType, noSend,heroAttrs)
+        local heroGrid = HeroGrid.createHeroGrid(id, star, xLv, mergeHeroAttrs)
+        Log.write(Log.LOGID_TEST, "添加融合英雄属性 heroGrid : " .. Json.Encode(heroGrid))
+        heroIndex = addHeroByGrid(human, heroGrid, logType, noSend)
         uuid = heroGrid.uuid
     end
     return heroIndex, uuid
@@ -455,7 +483,7 @@ function writeLogHeroDel(human, logType, heroGrid)
 end
 
 -- 新增英雄
-function addHeroByGrid(human, heroGrid, logType, noSend, heroAttrs)
+function addHeroByGrid(human, heroGrid, logType, noSend)
     if not LogDefine.DEFINE[logType] or not LogDefine.TYPE["hero"] then
         assert()
     end
@@ -476,13 +504,11 @@ function addHeroByGrid(human, heroGrid, logType, noSend, heroAttrs)
 
     local emptyIndex = getEmptyIndex(human)
 
-    Log.write(Log.LOGID_TEST, "emptyIndex " .. emptyIndex)
-
     if not emptyIndex then return end
 
     heroGrid.bagIndex = emptyIndex
     human.db.heroBag[emptyIndex] = heroGrid
-    ObjHuman.doCalcHero(human, emptyIndex, heroAttrs)
+    ObjHuman.doCalcHero(human, emptyIndex)
     if not noSend then
         sendHeroBagUpdate(human, emptyIndex)
     end
@@ -1020,7 +1046,6 @@ function heroJueXingDo(human, heroID, heroIndex, inputIDList, inputIndexList)
     for i = 1, diffCnt do
         makeSkillNet(msgRet.skillUp[i], diffList[i][2])
     end
-
     msgRet.itemList[0] = 0
     if fenjieList then
         for itemID, itemCnt in pairs(fenjieList) do

+ 0 - 1
script/module/hero/Proto.lua

@@ -128,7 +128,6 @@ HeroDynamic = {
     {"maxQuality",  1,      "byte"},	 --最高品阶
     {"skillList",   2,      SkillNet},    --主动技能:2个
 	{"beSkill",     3,      SkillNet},    --被动技能:最多3个
-    {"xLv",        1,      "int"},   	 --xLv 初始值0
 }
 
 

+ 1 - 0
script/module/role/NewLogic.lua

@@ -519,6 +519,7 @@ function hatchHero(human)
         "hero_merge")
 
     Log.write(Log.LOGID_TEST, "孵化英雄成功 下标" .. heroIndex)
+    Log.write(Log.LOGID_TEST, "添加的英雄: " .. Json.Encode(human.db.heroBag[heroIndex]))
 
     local attrs = RoleDefine.PANEL_ATTR_KEY
     for key, value in pairs(attrs) do

+ 13 - 17
script/module/role/RoleAttr.lua

@@ -69,9 +69,9 @@ function cleanHeroAttrCache(human)
 end
 
 -- 重算英雄属性
-function doCalcHero(human, index, heroAttrs)
+function doCalcHero(human, index)
 	local heroGrid = human.db.heroBag[index]
-	local attrs = calcHeroGrid(heroGrid, index, human,heroAttrs)	
+	local attrs = calcHeroGrid(heroGrid, index, human)	
 	if not attrs then return end
     
     RoleStrongLogic.doCalcMoShouPingFen(human, attrs)
@@ -120,7 +120,7 @@ end
 local TEMP_HERO_ATTRS = {}
 local HERO_BASE_ATTRS = {}
 local HERO_OTHER_ATTRS = {}
-function calcHeroGrid(heroGrid, index, human,heroAttrs)	
+function calcHeroGrid(heroGrid, index, human)	
 	if type(heroGrid) ~= "table" then 
 		return 
 	end
@@ -129,22 +129,18 @@ function calcHeroGrid(heroGrid, index, human,heroAttrs)
 	initCombatAttr(HERO_BASE_ATTRS)	
 	initCombatAttr(HERO_OTHER_ATTRS)
 
-    local isMerge = nil
-    if heroAttrs then 
-        isMerge = true
-        for key, value in pairs(heroAttrs) do
-            HERO_BASE_ATTRS[key] = value
-        end
-    else
-        --默认
-        HERO_BASE_ATTRS[RoleDefine.INIT_MP] = 50
-        -- 默认命中100% 暴击伤害
-        HERO_BASE_ATTRS[RoleDefine.JINGZHUN] = RoleDefine.DEFAUT_MINGZHONG
-        HERO_BASE_ATTRS[RoleDefine.BAOJI_HURT_RATE] = RoleDefine.DEFAUT_BAOJI_HURT_RATE
-    end
+    --默认
+    HERO_BASE_ATTRS[RoleDefine.INIT_MP] = 50
+    -- 默认命中100% 暴击伤害
+    HERO_BASE_ATTRS[RoleDefine.JINGZHUN] = RoleDefine.DEFAUT_MINGZHONG
+    HERO_BASE_ATTRS[RoleDefine.BAOJI_HURT_RATE] = RoleDefine.DEFAUT_BAOJI_HURT_RATE
 
 	--不同模块在英雄属性计算 begin
-	HeroLogic.doCalcHero(heroGrid, HERO_BASE_ATTRS, isMerge) -- 基础属性
+    if heroGrid.xLv ~= nil and heroGrid.xLv >= 1 then
+        HeroLogic.doCalcMergeHero(heroGrid, HERO_BASE_ATTRS) -- 融合的基础属性
+    else
+        HeroLogic.doCalcHero(heroGrid, HERO_BASE_ATTRS) -- 基础属性
+    end
 	local heroSkinID, heroSkinSkill = SkinLogic.checkHeroSkin(human, index) 
 	if heroSkinID and heroSkinSkill then -- 皮肤属性
 		HeroLogic.doCalcHeroSkin(heroSkinID, HERO_OTHER_ATTRS)