Переглянути джерело

增加主线闯关小游戏功能

gitxsm 1 рік тому
батько
коміт
9a8821a12a

+ 3 - 1
script/common/ProtoID.lua

@@ -1327,4 +1327,6 @@ _ENV[1357]="GC_NEW_FIRST_CHARGE_QUERY"
 _ENV[1358]="CG_NEW_FIRST_CHARGE_GET"
 _ENV[1360]="CG_ONLINEAWARD_QUERY"
 _ENV[1361]="GC_ONLINEAWARD_QUERY"
-_ENV[1362]="CG_ONLINEAWARD_CLAIM"
+_ENV[1362]="CG_ONLINEAWARD_CLAIM"
+_ENV[1365]="CG_BATTLE_GETGAMEREWARD"
+_ENV[1366]="GC_BATTLE_GETGAMEREWARD"

+ 105 - 4
script/module/battle/BattleLogic.lua

@@ -780,6 +780,20 @@ function initAfterStart()
 end
 
 function onLogin(human)
+    --处理老号已经在小游戏玩法上线前已经推过图没有获得小游戏次数
+    if not human.db.battleGameTimes then
+        local gameTimes = 0
+        local battleID = human.db.battleID
+        local allCfg = BattleExcel.node
+        for i=1, battleID-1 do
+            local cfg = allCfg[i]
+            if cfg and cfg and type(cfg.gameType) == "number" and cfg.gameType == 1 then
+                gameTimes = gameTimes + 1
+            end
+        end
+        human.db.battleGameTimes = gameTimes
+    end
+
     if human.db.lv >= BATTLE_LOGIN_LEV_TIPS then
         return
     end
@@ -1427,6 +1441,8 @@ function query(human)
     
     fontVideoInfo(human, msgRet.videoInfo, monsterConfig)
     fontExtraDataSSZH(msgRet.extraDataSSZH, nowNodeConfig.mapID, nNowBattleID, human)
+
+    msgRet.battleGameTimes = human.db.battleGameTimes or 0
     -- Msg.trace(msgRet)
     Msg.send(msgRet, human.fd)
 
@@ -2456,6 +2472,14 @@ function onFightEnd(human, result, fightTypeID, param1, combatInfo)
     -- end
     
     BattleLogic_SetBattleBattleID(human, nextBattleID)
+
+    --增加小游戏次数
+    if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
+        if config and type(config.gameType) == "number" and config.gameType == 1 then
+            human.db.battleGameTimes = (human.db.battleGameTimes or 0) + 1
+        end
+    end
+
     -- human.db.battleID = battleID + 1
     -- 通过第10关,默认开启二倍速
     if nextBattleID == 10 and EliteDefine.COPY_ELITE_NORMAL == nBattleType then
@@ -2619,6 +2643,21 @@ function setBattleByGm(human, val, maxBattleID)
         maxBattleID = val
     end
 
+    local nBattleType = BattleLogic_GetBattleType(human)
+    if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
+        local gameTimes = 0
+        local battleID = BattleLogic_GetBattleGuaJiID(human)
+        local allCfg = BattleExcel.node
+        for i=battleID, val-1 do
+            local singleCfg = allCfg[i]
+            if singleCfg and type(singleCfg.gameType) == "number" and singleCfg.gameType == 1 then
+                gameTimes = gameTimes + 1
+            end
+        end
+        human.db.battleGameTimes = (human.db.battleGameTimes or 0) + gameTimes
+    end
+
+
     BattleLogic_SetBattleBattleID(human, val)
     BattleLogic_SetBattleGuaJiID(human, val)
     setBattleID(human, val)
@@ -3442,7 +3481,7 @@ end
 
 -- 获取未领取奖励
 local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
-    print("1:[BattleLogic_GetNorewardReceived] id = "..human.db._id.." nBattleType = "..nBattleType)
+    --print("1:[BattleLogic_GetNorewardReceived] id = "..human.db._id.." nBattleType = "..nBattleType)
 
     local nBattleID = BattleLogic_GetBattleIDByType(human, nBattleType)
     local tBattleConfig = BattleLogic_GetBattleConfigByType(nBattleType)
@@ -3470,7 +3509,7 @@ local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
     local battleNumber = #tBattleConfig.node
 
     -- local nGuajiID = human.db.guajiID or 0
-    print("[BattleLogic_GetNorewardReceived] nGuajiID = "..nGuaJiID.. " nBattleID = "..nBattleID)
+    --print("[BattleLogic_GetNorewardReceived] nGuajiID = "..nGuaJiID.. " nBattleID = "..nBattleID)
 
     -- 判断ID得用战斗ID-1, 因为挂机ID可以设置
     local nJudeNum = nGuaJiID
@@ -3482,7 +3521,7 @@ local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
         nJudeNum = nBattleID - 1
     end
 
-    print("[BattleLogic_GetNorewardReceived] nJudeNum = "..nJudeNum)
+    --print("[BattleLogic_GetNorewardReceived] nJudeNum = "..nJudeNum)
 
     for k,v in ipairs(tBattleConfig.node) do
         if #v.tongguan ~= 0 then
@@ -3515,7 +3554,7 @@ local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
                             HeroGrid.makeHeroSimpleByID(net.heroReward[1], cf[1][1], nil, other, human)
                             HeroGrid.makeHeroSimpleByGeneral(net.heroReward[1], cf[1][1])
 
-                            local tHeroInfo = Util.printTable(net.heroReward)
+                            -- local tHeroInfo = Util.printTable(net.heroReward)
                             -- print("[BattleLogic_GetNorewardReceived] 英雄数据 k = "..k.." 获取的数据 = "..tHeroInfo)
                         else
                             net.reward[0] = 1
@@ -3757,4 +3796,66 @@ function BattleLogic_AddMopup(human, nGoodsID, nGoodsNum)
 
     print("[BattleLogic_AddMopup] 玩家增加扫荡次数 name = "
             ..human.db.name.." nAddNum ="..nGoodsNum)
+end
+
+
+--获取小游戏奖励
+function GetGameReward(human, indexStr)
+    local battleGameTimes = human.db.battleGameTimes
+    
+    if not battleGameTimes or battleGameTimes <= 0 then
+        return Broadcast.sendErr(human, Lang.JINBI_EXCHANGE_ERR_CNT)
+    end
+
+    local indexVec = Util.split(indexStr, "|")
+    if #indexVec <= 0 or #indexVec > 3 then
+        return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
+    end
+
+    local maxTimes = 1
+    local maxTimesIdx
+    local sumIndexTbl = {}
+
+    for _, idx in ipairs(indexVec) do
+        idx = tonumber(idx)
+        if not sumIndexTbl[idx] then
+            sumIndexTbl[idx] = 1
+        else
+            sumIndexTbl[idx] = sumIndexTbl[idx] + 1
+            maxTimes = sumIndexTbl[idx]
+            maxTimesIdx = idx
+        end
+    end
+
+    local itemId, itemCnt = 0,0
+    local configs = BattleExcel.gameReward
+
+    if maxTimes <= 1 then
+        local randIndex = math.random(1, #indexVec)
+        maxTimesIdx = tonumber(indexVec[randIndex])
+    end
+
+    for _, v in ipairs(configs) do
+        if v.itemID == maxTimesIdx then
+            itemId = v.itemID
+            if maxTimes <= 1 then
+                itemCnt = v.itemCnt
+            else
+                itemCnt = v["itemCnt"..maxTimes]
+            end
+            break
+        end
+    end
+
+    if not itemId or not itemCnt  then
+        return Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
+    end
+
+    battleGameTimes = battleGameTimes - 1
+    human.db.battleGameTimes = battleGameTimes
+    BagLogic.addItemList(human, { {itemId, itemCnt} }, "battle")
+
+    local msgRet = Msg.gc.GC_BATTLE_GETGAMEREWARD
+    msgRet.battleGameTimes = battleGameTimes
+    Msg.send(msgRet, human.fd)
 end

+ 5 - 0
script/module/battle/Handler.lua

@@ -85,4 +85,9 @@ end
 
 function CG_BATTLE_TONGGUAN_REWARD_GET_COPY(human,msg)
     BattleLogic.CG_BATTLE_TONGGUAN_REWARD_GET_COPY(human,msg.index)
+end
+
+--获得小游戏奖励
+function CG_BATTLE_GETGAMEREWARD(human,msg)
+    BattleLogic.GetGameReward(human,msg.indexStr)
 end

+ 10 - 0
script/module/battle/Proto.lua

@@ -99,6 +99,7 @@ GC_BATTLE_QUERY = {
 	{"tongguan",	    2, 	    Tongguan},              -- 通关奖励 长度为0不需要展示
     {"extraDataSSZH",	1,		BattleExtraDataSSZH},	-- 额外数据(闪烁战火)
     {"videoInfo",       1,      CombatVideoStruct},     -- 播放数据
+	{"battleGameTimes",	1,	    "byte"},	            -- 普通闯关获得的游戏次数
 }
 
 -- 世界地图
@@ -337,4 +338,13 @@ GC_BATTLE_QUERY_ALL = {
 	{"list",15,Tongguan},--查询副本返回数据
 	{"curIndex",1,"int"},--想请求的记录条数会累加到最大关卡
 	{"isEnd",1,"byte"},--未领取奖励是否发送结束
+}
+
+
+CG_BATTLE_GETGAMEREWARD = {
+	{"indexStr",	1,	    "string"},	            --图案id,格式: 101|102|103
+}
+
+GC_BATTLE_GETGAMEREWARD = {
+	{"battleGameTimes",	1,	    "byte"},	            -- 普通闯关获得的游戏次数
 }

+ 32 - 0
script/module/combat/TargetMode.lua

@@ -1156,6 +1156,37 @@ local function handler30(attacker,targetMode)
 	end
 end
 
+--从技能目标中根据职业选择
+--[=[
+		@param2 = {
+		handlerID,
+		jobs    -- 职业集合
+		cnt,
+	}
+]=]--
+
+local function handler34(attacker,targetMode, skillTargets)
+	local job = targetMode[2] or {}
+	local cnt = targetMode[3] or 1
+	local targetObjList = {}
+
+	for _,obj in ipairs (skillTargets) do
+		if canTarget(obj) and table.find(job,obj.job) then
+			targetObjList[#targetObjList + 1] = obj
+		end
+	end
+
+	-- 筛选最后的targets
+	table.shuffle(targetObjList)
+	for i = 1,#targetObjList do
+		targets[#targets+1] = targetObjList[i]
+		if #targets >= cnt then
+			break
+		end
+	end
+end
+
+
 
 
 ------------------------------ 分界线 ------------------------------
@@ -1199,5 +1230,6 @@ handler[31] = handler31	--31 同行人数最多
 handler[32] = handler32	--32 指定buff选择
 handler[33] = handler33	--32 指定buff选择
 handler[0] = handler0 -- 技能选取 和11相同
+handler[34] = handler34	--从技能目标中根据职业选择
 
 --对象选择器end

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

@@ -222,6 +222,7 @@ function createDefaultRole(account, serverTag)
 		heroBook = nil,                         -- 获得过的图鉴英雄[id]= true
 		shop = nil,                             -- 商店购买物品次数记录 shop[shopType][itemID] = cnt
 		
+		battleGameTimes = nil,					-- 普通闯关的获得的游戏次数
 		battleType = 1,							-- 战役类型(1、普通,2、精英,3、困难)
 		maxBattleTime = nil,					-- 最新关卡通关时间
 		guajiID = 0,						    -- 已通关关卡/挂机关卡