From f603a60f151bcc11f3ed64f16d0b26cc4552bb68 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Mon, 16 Dec 2019 17:10:58 +0800 Subject: [PATCH] 支援技实装 --- src/ProtocolCode.lua | 1 + src/actions/FriendAction.lua | 10 ++++++++++ src/actions/HangAction.lua | 19 +++++++++++++++++++ src/actions/PvpAction.lua | 8 ++++++++ src/actions/TowerAction.lua | 8 ++++++++ src/models/RolePlugin.lua | 6 ++++-- 6 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 21ef125..c7f06b6 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -127,6 +127,7 @@ actionCodes = { Friend_pointRpc = 459, Friend_updateProperty = 460, Friend_randomRpc = 461, + Friend_battleInfoRpc = 462, Pvp_formatCommonRpc = 500, diff --git a/src/actions/FriendAction.lua b/src/actions/FriendAction.lua index 882b668..17304f2 100644 --- a/src/actions/FriendAction.lua +++ b/src/actions/FriendAction.lua @@ -642,5 +642,15 @@ function _M.randomRpc(agent, data) return true end +function _M.battleInfoRpc(agent, data) + local role = agent.role + local roleId = role:getProperty("id") + local msg = MsgPack.unpack(data) + local objId = msg.roleId + local online, matchInfo = rpcRole(objId, "friendBattleInfo") + SendPacket(actionCodes.Friend_battleInfoRpc, MsgPack.pack({matchInfo = matchInfo})) + return true +end + return _M \ No newline at end of file diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 34f52bd..4dbd15a 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -202,12 +202,22 @@ function _M.roleFormatRpc(agent , data) return end end + + local supports = {} + for slot, support in pairs(msg.supports or {}) do + if slot ~= 1 and slot ~= 2 then return end + local level = role.dinerData:getProperty("dishTree"):getv(support, 0) + if level <= 0 then return end + supports[slot] = support + end + table.clear(hangTeam) hangTeam.heros = {} for slot, heroId in pairs(msg.heros) do hangTeam.heros[slot] = heroId end hangTeam.leader = msg.leader + hangTeam.supports = supports role:saveHangTeam(hangTeam) SendPacket(actionCodes.Hang_roleFormatRpc, '') return true @@ -351,12 +361,21 @@ function _M.bonusFormatRpc(agent , data) return end end + local supports = {} + for slot, support in pairs(msg.supports) do + if slot ~= 1 and slot ~= 2 then return end + local level = role.dinerData:getProperty("dishTree"):getv(support, 0) + if level <= 0 then return end + supports[slot] = support + end + table.clear(bTeam) bTeam.heros = {} for slot, heroId in pairs(msg.heros) do bTeam.heros[slot] = heroId end bTeam.leader = msg.leader + bTeam.supports = supports role:updateProperty({field = "bTeam", value = bTeam}) SendPacket(actionCodes.Hang_bonusFormatRpc, '') diff --git a/src/actions/PvpAction.lua b/src/actions/PvpAction.lua index 017b44a..9d334bf 100644 --- a/src/actions/PvpAction.lua +++ b/src/actions/PvpAction.lua @@ -29,6 +29,13 @@ function _M.formatCommonRpc(agent , data) if not msg.heros or not next(msg.heros) then return end + local supports = {} + for slot, support in pairs(msg.supports) do + if slot ~= 1 and slot ~= 2 then return end + local level = role.dinerData:getProperty("dishTree"):getv(support, 0) + if level <= 0 then return end + supports[slot] = support + end table.clear(pvpTC) pvpTC.heros = {} @@ -36,6 +43,7 @@ function _M.formatCommonRpc(agent , data) pvpTC.heros[slot] = heroId end pvpTC.leader = msg.leader + pvpTC.supports = supports role:savePvpCTeam(pvpTC) SendPacket(actionCodes.Pvp_formatCommonRpc, '') diff --git a/src/actions/TowerAction.lua b/src/actions/TowerAction.lua index 8f7e411..5455bb9 100644 --- a/src/actions/TowerAction.lua +++ b/src/actions/TowerAction.lua @@ -17,12 +17,20 @@ function _M.roleFormatRpc(agent , data) return end end + local supports = {} + for slot, support in pairs(msg.supports) do + if slot ~= 1 and slot ~= 2 then return end + local level = role.dinerData:getProperty("dishTree"):getv(support, 0) + if level <= 0 then return end + supports[slot] = support + end table.clear(towerTeam) towerTeam.heros = {} for slot, heroId in pairs(msg.heros) do towerTeam.heros[slot] = heroId end towerTeam.leader = msg.leader + towerTeam.supports = supports role:updateProperty({field = "towerF", value = towerTeam}) SendPacket(actionCodes.Tower_roleFormatRpc, '') diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 1ade6b3..3cb48d5 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -821,7 +821,7 @@ function RolePlugin.bind(Role) end function Role:getTeamBattleInfo(team) - local teamInfo = {heros = {}} + local teamInfo = {heros = {}, supports = {}} local activeRelation = self:getHeroActiveRelation(team.heros) for slot, id in pairs(team.heros or {}) do @@ -840,7 +840,9 @@ function RolePlugin.bind(Role) info.specialLevel = hero:getSkillLevel(1) teamInfo.heros[slot] = info end - -- todo 支援技能 + for slot, id in pairs(team.supports or {}) do + teamInfo.supports[slot] = {id, self.dinerData:getProperty("dishTree"):getv(id, 0)} + end return teamInfo end -- libgit2 0.21.2