From f60b89b10ed18dadfce852dbe69fefbb659ab093 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Thu, 31 Oct 2019 20:29:05 +0800 Subject: [PATCH] 奖励副本 --- src/ProtocolCode.lua | 6 ++++-- src/actions/AdvAction.lua | 1 + src/actions/CarAction.lua | 2 +- src/actions/DinerAction.lua | 3 +++ src/actions/GmAction.lua | 8 ++++++++ src/actions/HangAction.lua | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/actions/RoleAction.lua | 4 ++-- src/adv/Adv.lua | 15 +-------------- src/models/Daily.lua | 4 +++- src/models/Role.lua | 2 ++ src/models/RolePlugin.lua | 18 ++++++++++++++++++ src/models/RoleTask.lua | 16 +++++++++++++--- 12 files changed, 160 insertions(+), 25 deletions(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 7e652df..7c993c6 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -76,8 +76,10 @@ actionCodes = { Hang_roleFormatRpc = 255, Hang_getRewardRpc = 256, Hang_quickRpc = 257, - -- Hang_getRewardItemRpc = 258, - -- Hang_getRewardCoinRpc = 259, + Hang_bonusFormatRpc = 258, + Hang_buyBonusCountRpc = 259, + Hang_startBonusBattleRpc = 260, + Hang_endBonusBattleRpc = 261, Diner_updateProperty = 300, Diner_addSellRpc = 301, diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index 7938bba..31a8fc9 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -113,6 +113,7 @@ function _M.startAdvRpc( agent, data ) role:getAdvData():initByChapter(chapterId, layer) role:checkTaskEnter("AdvStart", {id = chapterId}) + role:checkTaskEnter("AdvStartSelf", {id = chapterId}) SendPacket(actionCodes.Adv_startAdvRpc, '') return true end diff --git a/src/actions/CarAction.lua b/src/actions/CarAction.lua index 8f014b2..10f32f3 100644 --- a/src/actions/CarAction.lua +++ b/src/actions/CarAction.lua @@ -87,7 +87,7 @@ function _M.equipUpRpc( agent, data ) role:costItems(cost) role:addEquip(typ, lv, -costCount) role:addEquip(typ, nextLv ,count) - role:checkTaskEnter("EquipUp", {}) + role:checkTaskEnter("EquipUp", {count = count}) SendPacket(actionCodes.Car_equipUpRpc, '') return true end diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index 6391dfa..3b08901 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -221,6 +221,9 @@ function _M.expediteSellRpc( agent, data ) role.dinerData:notifyUpdateProperty("expedite", count+1) for k, v in pairs(reward:toNumMap()) do role:addItem({itemId = k,count = v}) + if k == ItemId.Gold then + role:checkTaskEnter("FoodSellGold", {count = v}) + end end role.dinerData:popularAdd(popular) diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index d5cbeab..ddb5344 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -245,6 +245,14 @@ function _M.advt(role, pms) return "成功" end +table.insert(helpDes, {"冒险队等级增加", "advl", "通关次数"}) +function _M.advl(role, pms) + local winCount = tonum(pms.pm1) + winCount = math.max(0, winCount) + role:checkAdvLvByAddWin(winCount) + return "成功" +end + table.insert(helpDes, {"挂机清除" , "idlec"}) function _M.idlec(role, pms) role:updateProperty({field = "hangTeam", value = {}}) diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index d5b220b..cf2303d 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -69,12 +69,12 @@ function _M.startRpc( agent, data ) local msg = MsgPack.unpack(data) local carbonId = msg.carbonId local carbonData = csvdb["idle_battleCsv"][carbonId] - if not carbonData then return end + if not carbonData then return 1 end local hangPass = role:getProperty("hangPass") for _, preCarbonId in ipairs(carbonData.prepose:toArray(true, "=")) do - if not hangPass[preCarbonId] then return end + if not hangPass[preCarbonId] then return 2 end end if checkReward(role) then @@ -333,6 +333,9 @@ function _M.quickRpc(agent , data) end reward = role:award(reward) + if reward[ItemId.Gold] then + role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) + end role:checkTaskEnter("HangQuick") SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({ reward = reward @@ -340,4 +343,103 @@ function _M.quickRpc(agent , data) return true end +function _M.bonusFormatRpc(agent , data) + local role = agent.role + local msg = MsgPack.unpack(data) + local bTeam = role:getProperty("bTeam") + for slot, heroId in pairs(msg.heros) do + if not role.heros[heroId] then + return + end + end + table.clear(bTeam) + bTeam.heros = {} + for slot, heroId in pairs(msg.heros) do + bTeam.heros[slot] = heroId + end + bTeam.leader = msg.leader + + role:updateProperty({field = "bTeam", value = bTeam}) + SendPacket(actionCodes.Hang_bonusFormatRpc, '') + return true +end + +function _M.buyBonusCountRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + + local count = msg.count + local btype = msg.type + + if math.illegalNum(btype, 1, 2) then return 0 end + + local bonusC = role.dailyData:getProperty("bonusC") + bonusC[btype] = bonusC[btype] or {c = 0, b = 0} + local lastCount = globalCsv.bonus_daily_buy_count - bonusC[btype]["b"] + if math.illegalNum(count, 1, lastCount) then return 1 end + + if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return end + + role:costItems({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) + bonusC[btype]["b"] = bonusC[btype]["b"] + 1 + bonusC[btype]["c"] = bonusC[btype]["c"] - 1 + + role.dailyData:updateProperty({field = "bonusC", value = bonusC}) + + SendPacket(actionCodes.Hang_buyBonusCountRpc, '') + return true +end + +function _M.startBonusBattleRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local id = msg.id + + local bonusData = csvdb["bonus_battleCsv"][id] + if not bonusData then return 1 end + local hangPass = role:getProperty("hangPass") + if not hangPass[bonusData.unlock] then return 2 end + + if not next(role:getProperty("bTeam")) then return 3 end + + local bonusC = role.dailyData:getProperty("bonusC") + bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} + if globalCsv.bonus_daily_count - bonusC[bonusData.type]["c"] <= 0 then return 4 end + bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1 + role.dailyData:updateProperty({field = "bonusC", value = bonusC}) + + + role.__bonusBattleCache = { + key = tostring(math.random()), + id = id, + } + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key})) + return true +end + +function _M.endBonusBattleRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local id = msg.id + local key = msg.key + local starNum = msg.starNum + if not role.__bonusBattleCache then return 1 end + + if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then return 2 end + local bonusData = csvdb["bonus_battleCsv"][id] + + local reward + if starNum and starNum > 0 then + reward = role:award(bonusData.reward) + role:checkTaskEnter("BonusPass", {id = id}) + end + + SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({ + starNum = starNum, + reward = reward})) + return true +end + + + return _M \ No newline at end of file diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index acf33cc..94bd84d 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -532,7 +532,7 @@ function _M.achiveRpc(agent, data) local achiveT = role:getProperty("achiveT") local achiveV = role:getProperty("achiveV") - if achiveV[taskId] == -1 then return end + if achiveV[taskId] then return end local curStatus = achiveT[achiveTask.type] or 0 local maxc = achiveTask.condition1 @@ -544,7 +544,7 @@ function _M.achiveRpc(agent, data) local reward = role:award(achiveTask.reward) role:changeUpdates({ - { type = "achiveV", field = taskId, value = -1 } + { type = "achiveV", field = taskId, value = skynet.timex() } }) SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack({reward = reward})) diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index a0f6d81..febbd53 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -174,20 +174,7 @@ function Adv:over(success, isAllPass) end -- 冒险队等级升一下子 - local advL = self.owner:getProperty("advL") - local oldL = advL[1] - advL[2] = (advL[2] or 0) + 1 - for level = ((advL[1] or 0) + 1), #csvdb["adv_rankCsv"] do - local ldata = csvdb["adv_rankCsv"][level] - if ldata.unlock <= advL[2] then - advL[1] = level - self.owner:award(ldata.reward) - end - end - if advL[1] > oldL then - self.owner:checkTaskEnter("AdvLevel", {level = advL[1]}) - end - self.owner:updateProperty("advL", advL) + self.owner:checkAdvLvByAddWin() if self.owner:isFuncOpen(FuncOpenType.AdvWheelSurf) then self.owner._advWheelSurfCount = 0 -- 抽奖进行次数 diff --git a/src/models/Daily.lua b/src/models/Daily.lua index af44859..1d7551d 100644 --- a/src/models/Daily.lua +++ b/src/models/Daily.lua @@ -14,7 +14,8 @@ Daily.schema = { advElC = {"number", 0}, -- 无尽次数(消耗体力) advBC = {"number", 0}, -- 冒险次数购买次数(冒险体力购买次数) advElBC = {"number", 0}, -- 无尽次数购买次数(冒险体力购买次数) - advWs = {"table", {}}, -- 冒险队工坊 + advWs = {"table", {}}, -- 冒险队工坊 + bonusC = {"table", {}} -- 奖励副本 次数 {[type] = {c = 0, b = 0}} } function Daily:updateProperty(params) @@ -54,6 +55,7 @@ function Daily:data() advElC = self:getProperty("advElC"), advElBC = self:getProperty("advElBC"), advWs = self:getProperty("advWs"), + bonusC = self:getProperty("bonusC"), } end diff --git a/src/models/Role.lua b/src/models/Role.lua index da489d5..6f41d96 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -63,6 +63,7 @@ Role.schema = { hangInfo = {"table", {}}, -- 当前挂机信息 hangBag = {"table", {}}, -- 背包 hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限 + bTeam = {"table", {}}, -- 奖励副本队伍 potionBag = {"table", {}}, -- 营养剂背包 @@ -211,6 +212,7 @@ function Role:data() hangInfo = self:getProperty("hangInfo"), hangBag = self:getProperty("hangBag"), hangBagLimit = self:getProperty("hangBagLimit"), + bTeam = self:getProperty("bTeam"), potionBag = self:getProperty("potionBag"), storyB = self:getProperty("storyB"), diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 502f201..14d41c4 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -793,6 +793,24 @@ function RolePlugin.bind(Role) return player.format end end + + function Role:checkAdvLvByAddWin(winCount) + winCount = winCount or 1 + local advL = self:getProperty("advL") + local oldL = advL[1] + advL[2] = (advL[2] or 0) + winCount + for level = ((advL[1] or 0) + 1), #csvdb["adv_rankCsv"] do + local ldata = csvdb["adv_rankCsv"][level] + if ldata.unlock <= advL[2] then + advL[1] = level + self:award(ldata.reward) + end + end + if advL[1] > oldL then + self:checkTaskEnter("AdvLevel", {level = advL[1]}) + end + self:updateProperty({field = "advL", value = advL}) + end end return RolePlugin \ No newline at end of file diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 95a5abd..293aded 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -16,7 +16,7 @@ local TaskType = { --装备相关 AddEquip = 101, -- 获得装备 - equipId rarity SaleEquip = 102, -- 出售装备 - count - EquipUp = 103, -- 装备强化 + EquipUp = 103, -- 装备强化 - count -- 符文(零件)相关 RuneUp = 201, -- 符文强化 @@ -30,6 +30,7 @@ local TaskType = { HangQuick = 303, -- 快速挂机 HangBattle = 304, -- 挂机战斗 - id HangGetGold = 305, -- 挂机获得齿轮 - count + BonusPass = 306, -- 奖励副本通关 - id -- 冒险相关 AdvPass = 401, -- 冒险通过关 - id level score @@ -40,6 +41,7 @@ local TaskType = { AdvOverTask = 406, -- 完成任务 - id AdvOpenBlock = 407, -- 打开地块 - id AdvUsePotion = 408, -- 使用营养剂 + AdvStartSelf = 409, -- 手动冒险 - id --爬塔相关 TowerPass = 501, -- 爬塔通关 - level @@ -75,6 +77,9 @@ local TaskType = { WeChat = 1009, -- 关注微信 WeBlog = 1010, -- 关注微博 SignIn = 1011, -- 签到 + GetFriendP = 1012, -- 获得友情点 - count + ShopAll = 1013, -- 在任意商店购买 + } local function v(value) @@ -119,9 +124,14 @@ local CommonListener = { [TaskType.FoodMGet] = {{v(16)}}, [TaskType.HeroLevelUp] = {{v(17)}}, [TaskType.Wake] = {{v(18)}}, - [TaskType.EquipUp] = {{v(19)}}, + [TaskType.EquipUp] = {{v(19), f("count")}}, [TaskType.GiveFriendP] = {{v(20)}}, [TaskType.UnionBoss] = {{v(21)}}, + [TaskType.GetFriendP] = {{v(22), f("count")}}, + [TaskType.BonusPass] = {{v(23)}}, + [TaskType.AdvStartSelf] = {{v(24)}}, + [TaskType.ShopAll] = {{v(25)}}, + [TaskType.RuneUp] = {{v(26)}}, } } @@ -158,7 +168,7 @@ local AchievListener = { [TaskType.DrawHero] = {{v(29), f("count"), f("pool")}}, [TaskType.AddEquip] = {{v(30), f("rarity")}, {v(34), 1, f("rarity")}}, [TaskType.AddRune] = {{v(31), f("rarity")}, {v(35), 1, f("rarity")}}, - [TaskType.EquipUp] = {{v(32)}}, + [TaskType.EquipUp] = {{v(32), f("count")}}, [TaskType.RuneUp] = {{v(33)}}, [TaskType.AddUnion] = {{v(36)}}, [TaskType.AddFriend] = {{v(37), f("count")}}, -- libgit2 0.21.2