From a6508219f2328c5af95cef8b158c9c5456969f67 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Tue, 2 Jun 2020 20:42:31 +0800 Subject: [PATCH] 挂机奖励 --- src/ProtocolCode.lua | 1 + src/actions/HangAction.lua | 19 +++++++++++++++++++ src/models/HeroPlugin.lua | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/models/Role.lua | 2 ++ src/models/RolePlugin.lua | 1 + 5 files changed, 69 insertions(+), 0 deletions(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index a9bca0e..60db68e 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -98,6 +98,7 @@ actionCodes = { Hang_buyBonusCountRpc = 259, Hang_startBonusBattleRpc = 260, Hang_endBonusBattleRpc = 261, + Hang_hangGiftRpc = 262, Diner_updateProperty = 300, Diner_addSellRpc = 301, diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index f2ca5b1..f269e0d 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -486,6 +486,25 @@ function _M.endBonusBattleRpc(agent, data) return true end +function _M.hangGiftRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + + local id = msg.id + local carbonData = csvdb["idle_battleCsv"][id] + if not carbonData or carbonData.item_clear_special == "" then return 1 end + + local hangGift = role:getProperty("hangGift") + if hangGift[id] then return 2 end + + local reward = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}}) + role:log("hang_action", {desc = "hangGift", int1 = id}) + + role:changeUpdates({{type = "hangGift", field = id, value = 1}}) + + SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack(reward)) + return true +end return _M \ No newline at end of file diff --git a/src/models/HeroPlugin.lua b/src/models/HeroPlugin.lua index 14d7ef6..6cfde19 100644 --- a/src/models/HeroPlugin.lua +++ b/src/models/HeroPlugin.lua @@ -214,6 +214,52 @@ function HeroPlugin.bind(Hero) end return {} end + + function Hero:getRunes() + local rune = self:getProperty("rune") + if not rune or rune == "" then + rune = "1=0 2=0 3=0 4=0 5=0 6=0" + end + local result = rune:toNumMap() + for i = 1, 6 do + if not result[i] then + result[i] = 0 + end + end + return result + end + + -- 101 冒险战斗被动技 + -- 102 挂机战斗被动技 + function Hero:getRuneSkill(skillType) + local suits = {} + for _,uid in pairs(self:getRunes()) do + if uid > 0 then + local runeData = self.owner.runeBag[uid] + if not runeData then return end + local csvData = csvdb["runeCsv"][runeData.type][runeData.id] + if not suits[csvData.suit] then suits[csvData.suit] = {} end + table.insert(suits[csvData.suit],csvData) + end + end + + for suitId,runes in pairs(suits) do + local suitCsv = csvdb["rune_suitCsv"][tonumber(suitId)] + if not suitCsv then return end + local effects = suitCsv.effect:toTableArray(true) + local count = #runes + if count >= 2 and effects[1][1] == skillType then + return effects[1][2] + end + if count >= 4 and effects[2][1] == skillType then + return effects[2][2] + end + if count >= 6 and effects[3][1] == skillType then + return effects[3][2] + end + end + return + end end diff --git a/src/models/Role.lua b/src/models/Role.lua index 110b220..0ca0f1d 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -86,6 +86,7 @@ Role.schema = { --挂机相关 hangPass = {"table", {}}, -- 挂机通过的最大关卡 + hangGift = {"table", {}}, -- 挂机奖励 {id = 1} hangTeam = {"table", {}}, -- 挂机队伍 hangTS = {"table", {}}, -- 挂机队伍他人可读的队伍信息 hangTB = {"table", {}}, -- 挂机队伍他人可用的战斗信息mao @@ -321,6 +322,7 @@ function Role:data() advSup = self:getProperty("advSup"), hangPass = self:getProperty("hangPass"), + hangGift = self:getProperty("hangGift"), hangTeam = self:getProperty("hangTeam"), hangInfo = self:getProperty("hangInfo"), hangBag = self:getProperty("hangBag"), diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 81d7c04..d7d1779 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1192,6 +1192,7 @@ function RolePlugin.bind(Role) info.level = hero:getProperty("level") info.blockLevel = hero:getSkillLevel(4) info.specialLevel = hero:getSkillLevel(1) + info.runeSkill = hero:getRuneSkill(102) teamInfo.heros[slot] = info end for slot, id in pairs(team.supports or {}) do -- libgit2 0.21.2