From 6fc397d60e0659fb871c3040842659f35676d1d0 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Tue, 28 Apr 2020 14:37:54 +0800 Subject: [PATCH] 角色新突破 冒险优化点击地块 --- src/actions/AdvAction.lua | 13 ++++++++++--- src/actions/HeroAction.lua | 83 +++++++++++++++++++++++++++++++++++++++++++++++------------------------------------ 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index 4cc4423..675c4b1 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -350,15 +350,22 @@ function _M.clickBlockRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) - if not isCanContinue(role) then return end + local function returnFail(status) + SendPacket(actionCodes.Adv_clickBlockRpc, MsgPack.pack({events = {}})) + return true or status -- 调试使用 status + end + + if not isCanContinue(role) then + return returnFail() + end local adv = role:getAdvData() - if adv:isWaitChooseArtifact() then return end + if adv:isWaitChooseArtifact() then return returnFail() end adv:log({desc = "clickBlock", int1 = msg.roomId, int2 = msg.blockId}) local status, errorCode = adv:clickBlock(msg.roomId, msg.blockId, msg) - if not status then return errorCode end + if not status then return returnFail(errorCode) end SendPacket(actionCodes.Adv_clickBlockRpc, MsgPack.pack({events = adv:popBackEvents()})) return true diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 727dbac..5b7f51a 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -96,52 +96,62 @@ function _M.talentRpc(agent, data) if not hero then return 1 end local index = msg.index -- 第几个天赋 - local need = {[1] = 1, [2] = 1, [3] = 1, [4] = 1} + local need = {[0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1} if not need[index] then return 2 end - local talent = hero:getProperty("talent") local curStage = talent:getv(0, 1) - if curStage > csvdb["unit_breakCsv"][hero:getProperty("breakL")].talent then return 3 end - local curData = csvdb["unit_talentCsv"][curStage] if not curData then return 4 end - local level = talent:getv(index, 0) - if level >= #curData then return 5 end - - local talentData = curData[level] - if not talentData then return end - local cost = talentData.money:toNumMap() - local cost2 = talentData.cost:toNumMap() - for k,v in pairs(cost2) do - cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v - end - if not role:checkItemEnough(cost) then return 6 end - role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}}) - talent = talent:incrv(index, 1) - - --是否进阶 - local max = true - for i = 1, 4 do - if talent:getv(i, 0) < #curData then - max = false - break - end - end - if max then - talent = talent:setv(0, curStage + 1) + + local talent = hero:getProperty("talent") + if index == 0 then + --是否进阶 + local max = true for i = 1, 4 do - talent = talent:setv(i, 0) + if talent:getv(i, 0) < #curData then + max = false + break + end end + if max then + talent = talent:setv(0, curStage + 1) + for i = 1, 4 do + talent = talent:setv(i, 0) + end + else + return 3 + end + else + + local level = talent:getv(index, 0) + if level >= #curData then return 5 end + + local talentData = curData[level] + if not talentData then return end + + if talentData.lvRequire > hero:getProperty("level") then return 6 end + + local cost = talentData.money:toNumMap() + local cost2 = talentData.cost:toNumMap() + for k,v in pairs(cost2) do + cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v + end + if not role:checkItemEnough(cost) then return 6 end + role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}}) + talent = talent:incrv(index, 1) + + + local aheadLevel = 0 + for i = 1, talent:getv(0, 1) - 1 do + aheadLevel = aheadLevel + #csvdb["unit_talentCsv"][i] + end + aheadLevel = aheadLevel + talent:getv(index, 0) + + role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = aheadLevel}) end - hero:updateProperty({field = "talent", value = talent}) - local aheadLevel = 0 - for i = 1, talent:getv(0, 1) - 1 do - aheadLevel = aheadLevel + #csvdb["unit_talentCsv"][i] - end - aheadLevel = aheadLevel + talent:getv(index, 0) - role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = aheadLevel}) + hero:updateProperty({field = "talent", value = talent}) hero:log({desc = "talent", int1 = index, int2 = talent:getv(index, 0)}) @@ -149,6 +159,7 @@ function _M.talentRpc(agent, data) return true end + -- 暂时没有这个功能 function _M.likeHeroRpc(agent, data) local role = agent.role -- libgit2 0.21.2