diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 283065f..ed2c242 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -18,16 +18,17 @@ local _M = {} function _M.levelUpRpc( agent, data ) local role = agent.role local msg = MsgPack.unpack(data) + print("msg.id "..msg.id) local hero = role.heros[msg.id] - if not hero then return end + if not hero then return 1 end - if hero:getProperty("level") >= hero:getMaxLevel() then return end + if hero:getProperty("level") >= hero:getMaxLevel() then return 2 end local curData = csvdb["unit_expCsv"][hero:getProperty("level")] local cost = {[ItemId.Exp] = curData.exp, [ItemId.Gold] = curData.gold} - if not role:checkItemEnough(cost) then return end + if not role:checkItemEnough(cost) then return 3 end role:costItems(cost) hero:updateProperty({field = "level", delta = 1}) - + SendPacket(actionCodes.Hero_levelUpRpc, '') return true end @@ -36,16 +37,16 @@ function _M.breakRpc( agent, data ) local role = agent.role local msg = MsgPack.unpack(data) local hero = role.heros[msg.id] - if not hero then return end + if not hero then return 1 end - if hero:getProperty("level") < hero:getMaxLevel() then return end - if hero:getProperty("breakL") >= #csvdb["unit_breakCsv"] then return end + if hero:getProperty("level") < hero:getMaxLevel() then return 2 end + if hero:getProperty("breakL") >= #csvdb["unit_breakCsv"] then return 3 end local curData = csvdb["unit_breakCsv"][hero:getProperty("breakL")] local cost = {[ItemId.BreakCost] = curData.cost, [ItemId.Gold] = curData.gold} - if not role:checkItemEnough(cost) then return end + if not role:checkItemEnough(cost) then return 4 end role:costItems(cost) hero:updateProperty({field = "breakL", delta = 1}) - + SendPacket(actionCodes.Hero_breakRpc, '') return true end @@ -54,25 +55,46 @@ function _M.wakeRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) local hero = role.heros[msg.id] - if not hero then return end - if hero:getProperty("wakeL") >= #csvdb["unit_wakeCsv"] then return end - local cost = {[hero:getProperty("type")] = csvdb["unit_wakeCsv"][hero:getProperty("wakeL")].cost} - local isEnough, less = role:checkItemEnough(cost) - if not isEnough then - cost[ItemId.HeroFC[csvdb["unitCsv"][hero:getProperty("type")].rare]] = less[hero:getProperty("type")] - if not role:checkItemEnough(cost) then return end + if not hero then return 1 end + if hero:getProperty("wakeL") >= #csvdb["unit_wakeCsv"] then return 2 end + local typ = hero:getProperty("type") + local wakeData = csvdb["unit_wakeCsv"][hero:getProperty("wakeL")] + if not wakeData then return 3 end + + local cost = {[typ] = wakeData.costFigment,[hero:getStampId()] = wakeData.costMaterial} + if not role:checkItemEnough(cost) then + return 4 end + + local skills = {} + for _,v in pairs(wakeData.skill:toArray(true,"=") ) do + local skillSet = hero:getSkillData(v) + if next(skillSet) then + local skillLv = hero:getSkillLevel(v)+1 + local skillData = skillSet[skillLv] + if skillData and next(skillData) then + skills[v] = skillLv + else + return 5 + end + end + end + role:costItems(cost) + for k,v in pairs(skills) do + hero:updateProperty({field = "skillL", value = hero:getProperty("skillL"):setv(k, v)}) + end hero:updateProperty({field = "wakeL", delta = 1}) SendPacket(actionCodes.Hero_wakeRpc, '') return true end +-- 已取消技能升级功能,觉醒时自动升级技能 function _M.skillUpRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) - local index = msg.skillIdx -- 第几个技能 -- 1 2 3 + local index = msg.skillIdx -- 第几个技能 -- 1 2 3 local hero = role.heros[msg.id] if not hero then return end local curLevel = hero:getSkillLevel(index) @@ -96,8 +118,8 @@ function _M.talentRpc(agent, data) local talent = hero:getProperty("talent") local curStage = talent:getv(0, 1) if curStage > csvdb["unit_breakCsv"][hero:getProperty("breakL")].talent then return end - - local curData = csvdb["unit_talentCsv"][curStage] + + local curData = csvdb["unit_talentCsv"][curStage] if not curData then return end local level = talent:getv(index, 0) @@ -216,7 +238,7 @@ function _M.commentHeroRpc(agent, data) end local commentId = tostring(redisproxy:hincrby("hero:comment:autoincr", "hero:" .. heroType, 1)) local comment = { - commentId = commentId, + commentId = commentId, content = content, roleId = role:getProperty("id"), name = role:getProperty("name"), @@ -291,14 +313,14 @@ function _M.likeCommentRpc(agent, data) elseif actType == 2 then add = -1 else - return + return end - local result = {status = 0} - local commentIndex = heroType .. ":" .. commentId + local result = {status = 0} + local commentIndex = heroType .. ":" .. commentId local commentRoleKey = string.format("comment:%d:like", role:getProperty("id")) local redret = redisproxy:pipelining(function (red) - red:hexists(commentKey.commentKey, commentId) + red:hexists(commentKey.commentKey, commentId) red:lrem(commentRoleKey, 1, commentIndex) red:lpush(commentRoleKey, commentIndex) red:ltrim(commentRoleKey, 0, 999) @@ -373,7 +395,7 @@ function _M.loveTaskRpc(agent, data) local curType = hero:getProperty("type") local curPlus = csvdb["unit_love_plusCsv"][curType] if not curPlus or curL >= curPlus.limit then return end - + local curEffect = csvdb["unit_love_effectCsv"][curL] if not curEffect or curExp < curEffect.loveValue then return end @@ -388,7 +410,7 @@ function _M.loveTaskRpc(agent, data) end hero:updateProperty({field = "loveExp", value = newExp}) hero:updateProperty({field = "loveL", value = curL + 1}) - + if role:getProperty("loveStatus"):getv(curType, 0) < curL + 1 then role:changeUpdates({{type = "loveStatus", field = curType, value = curL + 1}}) -- 总的 end diff --git a/src/csvdata b/src/csvdata index e63f75d..b4fb9d3 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit e63f75d1f6fefcda1a84322964d5a5a158a8a4a6 +Subproject commit b4fb9d39bc675e3d277e308f6f7c5f4184f8b55e diff --git a/src/models/Hero.lua b/src/models/Hero.lua index 2e5d5b9..0fbf5e7 100644 --- a/src/models/Hero.lua +++ b/src/models/Hero.lua @@ -79,4 +79,13 @@ function Hero:data() } end +function Hero:getStampId() + local typs = { + [1]=50, + [2]=51, + [3]=52, + } + return typs[csvdb["unitCsv"][self:getProperty("type")].camp] +end + return Hero \ No newline at end of file diff --git a/src/models/HeroPlugin.lua b/src/models/HeroPlugin.lua index ed7a363..9509381 100644 --- a/src/models/HeroPlugin.lua +++ b/src/models/HeroPlugin.lua @@ -47,15 +47,15 @@ function HeroPlugin.bind(Hero) local talentAttrS = {} -- 天赋阶段属性 - for i = 1, (talent:getv(0, 1) - 1) do + for i = 1, (talent:getv(0, 1) - 1) do local curData = csvdb["unit_talentCsv"][i] local effect = curData[#curData].effect:toArray(true, "=") talentAttrS[AttsEnumEx[effect[1]]] = (talentAttrS[AttsEnumEx[effect[1]]] or 0) + effect[2] end -- 四个基础属性 - local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)] + local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)] if not curData then -- 已经满阶段了 - curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]] + curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]] local strength = curData[#curData].strength for i = 1, 4 do talentAttrS[AttsEnumEx[i]] = (talentAttrS[AttsEnumEx[i]] or 0) + strength @@ -69,7 +69,7 @@ function HeroPlugin.bind(Hero) --好感度 local loveUp = {} for i = 0, self:getProperty("loveL") do - local reward = csvdb["unit_love_effectCsv"][i]["reward"] + local reward = csvdb["unit_love_effectCsv"][i]["reward"] for attrId, value in pairs(reward:toNumMap()) do loveUp[AttsEnumEx[attrId]] = (loveUp[AttsEnumEx[attrId]] or 0) + value end @@ -111,24 +111,25 @@ function HeroPlugin.bind(Hero) return battleValue end + -- 技能1234 对应必杀技,冒险技,被动技,战斗技 function Hero:getSkillLevel(idx) return self:getProperty("skillL"):getv(idx, 1) end function Hero:getSkillData(idx, skin) - local unitData = csvdb["unitCsv"][self:getSkinId(skin)] + local unitData = csvdb["unitCsv"][self:getProperty("type")] if idx == 1 then - return csvdb["skill_blockCsv"][unitData.block] - elseif idx == 2 then return csvdb["skill_specialCsv"][unitData.special] - elseif idx == 3 then - return csvdb["skill_passiveCsv"][unitData.passive] - elseif idx == 4 then --冒险技能 + elseif idx == 2 then if unitData.adv > 1000 then return csvdb["adv_skill_passiveCsv"][unitData.adv] else return csvdb["adv_skillCsv"][unitData.adv] end + elseif idx == 3 then + return csvdb["skill_passiveCsv"][unitData.passive] + elseif idx == 4 then + return csvdb["skill_blockCsv"][unitData.block] end return {} end -- libgit2 0.21.2