From be24b6ad8b0ac8fb3a0bed1890dbe809679b7a86 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Mon, 23 Nov 2020 15:22:37 +0800 Subject: [PATCH] 传递 count --- src/actions/HangAction.lua | 28 +++++++++++++++++++--------- src/models/RoleTask.lua | 6 +++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 4cb323d..900ff89 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -498,7 +498,8 @@ function _M.buyBonusCountRpc(agent, data) return true end -local function bonusWinReward(role, bonusData, bwin) +local function bonusWinReward(role, bonusData, bwin, count) + count = count or 1 local open, actId = role.activity:isOpen("BonusDouble") local actData = csvdb["activity_ctrlCsv"][actId] local extraCnt = role.storeData:getBonusExtraFightCount() @@ -509,26 +510,33 @@ local function bonusWinReward(role, bonusData, bwin) end local bonusC = role.dailyData:getProperty("bonusC") bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return false, 1 end - bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1 + if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] < count then return false, 1 end + bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count role.dailyData:updateProperty({field = "bonusC", value = bonusC}) local reward, change reward = bonusData.reward:toNumMap() - local chance = bonusData.chance:randWeight(true) - if chance[1] ~= 0 then - reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] + for itemId, c in pairs(reward) do + reward[itemId] = c * count end + for i = 1, count do + local chance = bonusData.chance:randWeight(true) + if chance[1] ~= 0 then + reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] + end + end + for k, v in pairs(reward) do reward[k] = v * (coef > 1 and actData.condition or 1) end + if bwin then -- 满星 额外奖励 for k, v in pairs(bonusData.perfect_reward:toNumMap()) do reward[k] = (reward[k] or 0) + v end end reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) - role:checkTaskEnter("BonusPass", {id = id}) + role:checkTaskEnter("BonusPass", {id = id, count = count}) return true, reward, change end @@ -536,6 +544,7 @@ function _M.startBonusBattleRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) local id = msg.id + local count = msg.count or 1 local open, actId = role.activity:isOpen("BonusDouble") @@ -560,11 +569,12 @@ function _M.startBonusBattleRpc(agent, data) if open and actData then coef = tonumber(actData.condition2) end - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 7 end + + if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end local bonusStar = role:getProperty("bonusStar") if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then - local status, reward, change = bonusWinReward(role, bonusData) + local status, reward, change = bonusWinReward(role, bonusData, nil, count) if not status then return 10 * (reward or 0) end SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) else diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index ae6dc7d..1a67026 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -33,7 +33,7 @@ local TaskType = { HangQuick = 303, -- 快速挂机 HangBattle = 304, -- 挂机战斗 - id HangGetGold = 305, -- 挂机获得齿轮 - count - BonusPass = 306, -- 奖励副本通关 - id + BonusPass = 306, -- 奖励副本通关 - id count -- 冒险相关 AdvPass = 401, -- 冒险通过关 - id level score @@ -142,7 +142,7 @@ local CommonListener = { [TaskType.GiveFriendP] = {{20, f("count")}}, [TaskType.UnionBoss] = {{21}}, [TaskType.GetFriendP] = {{22, f("count")}}, - [TaskType.BonusPass] = {{23}}, + [TaskType.BonusPass] = {{23, f("count")}}, [TaskType.AdvStartSelf] = {{24}}, [TaskType.ShopAll] = {{25, f("count")}}, [TaskType.RuneUp] = {{26}}, @@ -244,7 +244,7 @@ local CalendaTaskListener = { func = "checkCalendaTask", listen = { [TaskType.DrawHero] = {{1, 1, f("count")}}, - [TaskType.BonusPass]= {{2, 1}}, + [TaskType.BonusPass]= {{2, 1, f("count")}}, [TaskType.AdvStart]= {{3, 1}}, [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 -- libgit2 0.21.2