Commit 1c35c4cf16054294222af7f83af9b3ddfdc60859
1 parent
61dc5eb6
fix hero awake
Showing
4 changed files
with
69 additions
and
37 deletions
Show diff stats
src/actions/HeroAction.lua
| @@ -18,16 +18,17 @@ local _M = {} | @@ -18,16 +18,17 @@ local _M = {} | ||
| 18 | function _M.levelUpRpc( agent, data ) | 18 | function _M.levelUpRpc( agent, data ) |
| 19 | local role = agent.role | 19 | local role = agent.role |
| 20 | local msg = MsgPack.unpack(data) | 20 | local msg = MsgPack.unpack(data) |
| 21 | + print("msg.id "..msg.id) | ||
| 21 | local hero = role.heros[msg.id] | 22 | local hero = role.heros[msg.id] |
| 22 | - if not hero then return end | 23 | + if not hero then return 1 end |
| 23 | 24 | ||
| 24 | - if hero:getProperty("level") >= hero:getMaxLevel() then return end | 25 | + if hero:getProperty("level") >= hero:getMaxLevel() then return 2 end |
| 25 | local curData = csvdb["unit_expCsv"][hero:getProperty("level")] | 26 | local curData = csvdb["unit_expCsv"][hero:getProperty("level")] |
| 26 | local cost = {[ItemId.Exp] = curData.exp, [ItemId.Gold] = curData.gold} | 27 | local cost = {[ItemId.Exp] = curData.exp, [ItemId.Gold] = curData.gold} |
| 27 | - if not role:checkItemEnough(cost) then return end | 28 | + if not role:checkItemEnough(cost) then return 3 end |
| 28 | role:costItems(cost) | 29 | role:costItems(cost) |
| 29 | hero:updateProperty({field = "level", delta = 1}) | 30 | hero:updateProperty({field = "level", delta = 1}) |
| 30 | - | 31 | + |
| 31 | SendPacket(actionCodes.Hero_levelUpRpc, '') | 32 | SendPacket(actionCodes.Hero_levelUpRpc, '') |
| 32 | return true | 33 | return true |
| 33 | end | 34 | end |
| @@ -36,16 +37,16 @@ function _M.breakRpc( agent, data ) | @@ -36,16 +37,16 @@ function _M.breakRpc( agent, data ) | ||
| 36 | local role = agent.role | 37 | local role = agent.role |
| 37 | local msg = MsgPack.unpack(data) | 38 | local msg = MsgPack.unpack(data) |
| 38 | local hero = role.heros[msg.id] | 39 | local hero = role.heros[msg.id] |
| 39 | - if not hero then return end | 40 | + if not hero then return 1 end |
| 40 | 41 | ||
| 41 | - if hero:getProperty("level") < hero:getMaxLevel() then return end | ||
| 42 | - if hero:getProperty("breakL") >= #csvdb["unit_breakCsv"] then return end | 42 | + if hero:getProperty("level") < hero:getMaxLevel() then return 2 end |
| 43 | + if hero:getProperty("breakL") >= #csvdb["unit_breakCsv"] then return 3 end | ||
| 43 | local curData = csvdb["unit_breakCsv"][hero:getProperty("breakL")] | 44 | local curData = csvdb["unit_breakCsv"][hero:getProperty("breakL")] |
| 44 | local cost = {[ItemId.BreakCost] = curData.cost, [ItemId.Gold] = curData.gold} | 45 | local cost = {[ItemId.BreakCost] = curData.cost, [ItemId.Gold] = curData.gold} |
| 45 | - if not role:checkItemEnough(cost) then return end | 46 | + if not role:checkItemEnough(cost) then return 4 end |
| 46 | role:costItems(cost) | 47 | role:costItems(cost) |
| 47 | hero:updateProperty({field = "breakL", delta = 1}) | 48 | hero:updateProperty({field = "breakL", delta = 1}) |
| 48 | - | 49 | + |
| 49 | SendPacket(actionCodes.Hero_breakRpc, '') | 50 | SendPacket(actionCodes.Hero_breakRpc, '') |
| 50 | return true | 51 | return true |
| 51 | end | 52 | end |
| @@ -54,25 +55,46 @@ function _M.wakeRpc(agent, data) | @@ -54,25 +55,46 @@ function _M.wakeRpc(agent, data) | ||
| 54 | local role = agent.role | 55 | local role = agent.role |
| 55 | local msg = MsgPack.unpack(data) | 56 | local msg = MsgPack.unpack(data) |
| 56 | local hero = role.heros[msg.id] | 57 | local hero = role.heros[msg.id] |
| 57 | - if not hero then return end | ||
| 58 | - if hero:getProperty("wakeL") >= #csvdb["unit_wakeCsv"] then return end | ||
| 59 | - local cost = {[hero:getProperty("type")] = csvdb["unit_wakeCsv"][hero:getProperty("wakeL")].cost} | ||
| 60 | - local isEnough, less = role:checkItemEnough(cost) | ||
| 61 | - if not isEnough then | ||
| 62 | - cost[ItemId.HeroFC[csvdb["unitCsv"][hero:getProperty("type")].rare]] = less[hero:getProperty("type")] | ||
| 63 | - if not role:checkItemEnough(cost) then return end | 58 | + if not hero then return 1 end |
| 59 | + if hero:getProperty("wakeL") >= #csvdb["unit_wakeCsv"] then return 2 end | ||
| 60 | + local typ = hero:getProperty("type") | ||
| 61 | + local wakeData = csvdb["unit_wakeCsv"][hero:getProperty("wakeL")] | ||
| 62 | + if not wakeData then return 3 end | ||
| 63 | + | ||
| 64 | + local cost = {[typ] = wakeData.costFigment,[hero:getStampId()] = wakeData.costMaterial} | ||
| 65 | + if not role:checkItemEnough(cost) then | ||
| 66 | + return 4 | ||
| 64 | end | 67 | end |
| 68 | + | ||
| 69 | + local skills = {} | ||
| 70 | + for _,v in pairs(wakeData.skill:toArray(true,"=") ) do | ||
| 71 | + local skillSet = hero:getSkillData(v) | ||
| 72 | + if next(skillSet) then | ||
| 73 | + local skillLv = hero:getSkillLevel(v)+1 | ||
| 74 | + local skillData = skillSet[skillLv] | ||
| 75 | + if skillData and next(skillData) then | ||
| 76 | + skills[v] = skillLv | ||
| 77 | + else | ||
| 78 | + return 5 | ||
| 79 | + end | ||
| 80 | + end | ||
| 81 | + end | ||
| 82 | + | ||
| 65 | role:costItems(cost) | 83 | role:costItems(cost) |
| 84 | + for k,v in pairs(skills) do | ||
| 85 | + hero:updateProperty({field = "skillL", value = hero:getProperty("skillL"):setv(k, v)}) | ||
| 86 | + end | ||
| 66 | hero:updateProperty({field = "wakeL", delta = 1}) | 87 | hero:updateProperty({field = "wakeL", delta = 1}) |
| 67 | 88 | ||
| 68 | SendPacket(actionCodes.Hero_wakeRpc, '') | 89 | SendPacket(actionCodes.Hero_wakeRpc, '') |
| 69 | return true | 90 | return true |
| 70 | end | 91 | end |
| 71 | 92 | ||
| 93 | +-- 已取消技能升级功能,觉醒时自动升级技能 | ||
| 72 | function _M.skillUpRpc(agent, data) | 94 | function _M.skillUpRpc(agent, data) |
| 73 | local role = agent.role | 95 | local role = agent.role |
| 74 | local msg = MsgPack.unpack(data) | 96 | local msg = MsgPack.unpack(data) |
| 75 | - local index = msg.skillIdx -- 第几个技能 -- 1 2 3 | 97 | + local index = msg.skillIdx -- 第几个技能 -- 1 2 3 |
| 76 | local hero = role.heros[msg.id] | 98 | local hero = role.heros[msg.id] |
| 77 | if not hero then return end | 99 | if not hero then return end |
| 78 | local curLevel = hero:getSkillLevel(index) | 100 | local curLevel = hero:getSkillLevel(index) |
| @@ -96,8 +118,8 @@ function _M.talentRpc(agent, data) | @@ -96,8 +118,8 @@ function _M.talentRpc(agent, data) | ||
| 96 | local talent = hero:getProperty("talent") | 118 | local talent = hero:getProperty("talent") |
| 97 | local curStage = talent:getv(0, 1) | 119 | local curStage = talent:getv(0, 1) |
| 98 | if curStage > csvdb["unit_breakCsv"][hero:getProperty("breakL")].talent then return end | 120 | if curStage > csvdb["unit_breakCsv"][hero:getProperty("breakL")].talent then return end |
| 99 | - | ||
| 100 | - local curData = csvdb["unit_talentCsv"][curStage] | 121 | + |
| 122 | + local curData = csvdb["unit_talentCsv"][curStage] | ||
| 101 | if not curData then return end | 123 | if not curData then return end |
| 102 | 124 | ||
| 103 | local level = talent:getv(index, 0) | 125 | local level = talent:getv(index, 0) |
| @@ -216,7 +238,7 @@ function _M.commentHeroRpc(agent, data) | @@ -216,7 +238,7 @@ function _M.commentHeroRpc(agent, data) | ||
| 216 | end | 238 | end |
| 217 | local commentId = tostring(redisproxy:hincrby("hero:comment:autoincr", "hero:" .. heroType, 1)) | 239 | local commentId = tostring(redisproxy:hincrby("hero:comment:autoincr", "hero:" .. heroType, 1)) |
| 218 | local comment = { | 240 | local comment = { |
| 219 | - commentId = commentId, | 241 | + commentId = commentId, |
| 220 | content = content, | 242 | content = content, |
| 221 | roleId = role:getProperty("id"), | 243 | roleId = role:getProperty("id"), |
| 222 | name = role:getProperty("name"), | 244 | name = role:getProperty("name"), |
| @@ -291,14 +313,14 @@ function _M.likeCommentRpc(agent, data) | @@ -291,14 +313,14 @@ function _M.likeCommentRpc(agent, data) | ||
| 291 | elseif actType == 2 then | 313 | elseif actType == 2 then |
| 292 | add = -1 | 314 | add = -1 |
| 293 | else | 315 | else |
| 294 | - return | 316 | + return |
| 295 | end | 317 | end |
| 296 | 318 | ||
| 297 | - local result = {status = 0} | ||
| 298 | - local commentIndex = heroType .. ":" .. commentId | 319 | + local result = {status = 0} |
| 320 | + local commentIndex = heroType .. ":" .. commentId | ||
| 299 | local commentRoleKey = string.format("comment:%d:like", role:getProperty("id")) | 321 | local commentRoleKey = string.format("comment:%d:like", role:getProperty("id")) |
| 300 | local redret = redisproxy:pipelining(function (red) | 322 | local redret = redisproxy:pipelining(function (red) |
| 301 | - red:hexists(commentKey.commentKey, commentId) | 323 | + red:hexists(commentKey.commentKey, commentId) |
| 302 | red:lrem(commentRoleKey, 1, commentIndex) | 324 | red:lrem(commentRoleKey, 1, commentIndex) |
| 303 | red:lpush(commentRoleKey, commentIndex) | 325 | red:lpush(commentRoleKey, commentIndex) |
| 304 | red:ltrim(commentRoleKey, 0, 999) | 326 | red:ltrim(commentRoleKey, 0, 999) |
| @@ -373,7 +395,7 @@ function _M.loveTaskRpc(agent, data) | @@ -373,7 +395,7 @@ function _M.loveTaskRpc(agent, data) | ||
| 373 | local curType = hero:getProperty("type") | 395 | local curType = hero:getProperty("type") |
| 374 | local curPlus = csvdb["unit_love_plusCsv"][curType] | 396 | local curPlus = csvdb["unit_love_plusCsv"][curType] |
| 375 | if not curPlus or curL >= curPlus.limit then return end | 397 | if not curPlus or curL >= curPlus.limit then return end |
| 376 | - | 398 | + |
| 377 | local curEffect = csvdb["unit_love_effectCsv"][curL] | 399 | local curEffect = csvdb["unit_love_effectCsv"][curL] |
| 378 | if not curEffect or curExp < curEffect.loveValue then return end | 400 | if not curEffect or curExp < curEffect.loveValue then return end |
| 379 | 401 | ||
| @@ -388,7 +410,7 @@ function _M.loveTaskRpc(agent, data) | @@ -388,7 +410,7 @@ function _M.loveTaskRpc(agent, data) | ||
| 388 | end | 410 | end |
| 389 | hero:updateProperty({field = "loveExp", value = newExp}) | 411 | hero:updateProperty({field = "loveExp", value = newExp}) |
| 390 | hero:updateProperty({field = "loveL", value = curL + 1}) | 412 | hero:updateProperty({field = "loveL", value = curL + 1}) |
| 391 | - | 413 | + |
| 392 | if role:getProperty("loveStatus"):getv(curType, 0) < curL + 1 then | 414 | if role:getProperty("loveStatus"):getv(curType, 0) < curL + 1 then |
| 393 | role:changeUpdates({{type = "loveStatus", field = curType, value = curL + 1}}) -- 总的 | 415 | role:changeUpdates({{type = "loveStatus", field = curType, value = curL + 1}}) -- 总的 |
| 394 | end | 416 | end |
src/models/Hero.lua
| @@ -79,4 +79,13 @@ function Hero:data() | @@ -79,4 +79,13 @@ function Hero:data() | ||
| 79 | } | 79 | } |
| 80 | end | 80 | end |
| 81 | 81 | ||
| 82 | +function Hero:getStampId() | ||
| 83 | + local typs = { | ||
| 84 | + [1]=50, | ||
| 85 | + [2]=51, | ||
| 86 | + [3]=52, | ||
| 87 | + } | ||
| 88 | + return typs[csvdb["unitCsv"][self:getProperty("type")].camp] | ||
| 89 | +end | ||
| 90 | + | ||
| 82 | return Hero | 91 | return Hero |
| 83 | \ No newline at end of file | 92 | \ No newline at end of file |
src/models/HeroPlugin.lua
| @@ -47,15 +47,15 @@ function HeroPlugin.bind(Hero) | @@ -47,15 +47,15 @@ function HeroPlugin.bind(Hero) | ||
| 47 | 47 | ||
| 48 | local talentAttrS = {} | 48 | local talentAttrS = {} |
| 49 | -- 天赋阶段属性 | 49 | -- 天赋阶段属性 |
| 50 | - for i = 1, (talent:getv(0, 1) - 1) do | 50 | + for i = 1, (talent:getv(0, 1) - 1) do |
| 51 | local curData = csvdb["unit_talentCsv"][i] | 51 | local curData = csvdb["unit_talentCsv"][i] |
| 52 | local effect = curData[#curData].effect:toArray(true, "=") | 52 | local effect = curData[#curData].effect:toArray(true, "=") |
| 53 | talentAttrS[AttsEnumEx[effect[1]]] = (talentAttrS[AttsEnumEx[effect[1]]] or 0) + effect[2] | 53 | talentAttrS[AttsEnumEx[effect[1]]] = (talentAttrS[AttsEnumEx[effect[1]]] or 0) + effect[2] |
| 54 | end | 54 | end |
| 55 | -- 四个基础属性 | 55 | -- 四个基础属性 |
| 56 | - local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)] | 56 | + local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)] |
| 57 | if not curData then -- 已经满阶段了 | 57 | if not curData then -- 已经满阶段了 |
| 58 | - curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]] | 58 | + curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]] |
| 59 | local strength = curData[#curData].strength | 59 | local strength = curData[#curData].strength |
| 60 | for i = 1, 4 do | 60 | for i = 1, 4 do |
| 61 | talentAttrS[AttsEnumEx[i]] = (talentAttrS[AttsEnumEx[i]] or 0) + strength | 61 | talentAttrS[AttsEnumEx[i]] = (talentAttrS[AttsEnumEx[i]] or 0) + strength |
| @@ -69,7 +69,7 @@ function HeroPlugin.bind(Hero) | @@ -69,7 +69,7 @@ function HeroPlugin.bind(Hero) | ||
| 69 | --好感度 | 69 | --好感度 |
| 70 | local loveUp = {} | 70 | local loveUp = {} |
| 71 | for i = 0, self:getProperty("loveL") do | 71 | for i = 0, self:getProperty("loveL") do |
| 72 | - local reward = csvdb["unit_love_effectCsv"][i]["reward"] | 72 | + local reward = csvdb["unit_love_effectCsv"][i]["reward"] |
| 73 | for attrId, value in pairs(reward:toNumMap()) do | 73 | for attrId, value in pairs(reward:toNumMap()) do |
| 74 | loveUp[AttsEnumEx[attrId]] = (loveUp[AttsEnumEx[attrId]] or 0) + value | 74 | loveUp[AttsEnumEx[attrId]] = (loveUp[AttsEnumEx[attrId]] or 0) + value |
| 75 | end | 75 | end |
| @@ -111,24 +111,25 @@ function HeroPlugin.bind(Hero) | @@ -111,24 +111,25 @@ function HeroPlugin.bind(Hero) | ||
| 111 | return battleValue | 111 | return battleValue |
| 112 | end | 112 | end |
| 113 | 113 | ||
| 114 | + -- 技能1234 对应必杀技,冒险技,被动技,战斗技 | ||
| 114 | function Hero:getSkillLevel(idx) | 115 | function Hero:getSkillLevel(idx) |
| 115 | return self:getProperty("skillL"):getv(idx, 1) | 116 | return self:getProperty("skillL"):getv(idx, 1) |
| 116 | end | 117 | end |
| 117 | 118 | ||
| 118 | function Hero:getSkillData(idx, skin) | 119 | function Hero:getSkillData(idx, skin) |
| 119 | - local unitData = csvdb["unitCsv"][self:getSkinId(skin)] | 120 | + local unitData = csvdb["unitCsv"][self:getProperty("type")] |
| 120 | if idx == 1 then | 121 | if idx == 1 then |
| 121 | - return csvdb["skill_blockCsv"][unitData.block] | ||
| 122 | - elseif idx == 2 then | ||
| 123 | return csvdb["skill_specialCsv"][unitData.special] | 122 | return csvdb["skill_specialCsv"][unitData.special] |
| 124 | - elseif idx == 3 then | ||
| 125 | - return csvdb["skill_passiveCsv"][unitData.passive] | ||
| 126 | - elseif idx == 4 then --冒险技能 | 123 | + elseif idx == 2 then |
| 127 | if unitData.adv > 1000 then | 124 | if unitData.adv > 1000 then |
| 128 | return csvdb["adv_skill_passiveCsv"][unitData.adv] | 125 | return csvdb["adv_skill_passiveCsv"][unitData.adv] |
| 129 | else | 126 | else |
| 130 | return csvdb["adv_skillCsv"][unitData.adv] | 127 | return csvdb["adv_skillCsv"][unitData.adv] |
| 131 | end | 128 | end |
| 129 | + elseif idx == 3 then | ||
| 130 | + return csvdb["skill_passiveCsv"][unitData.passive] | ||
| 131 | + elseif idx == 4 then | ||
| 132 | + return csvdb["skill_blockCsv"][unitData.block] | ||
| 132 | end | 133 | end |
| 133 | return {} | 134 | return {} |
| 134 | end | 135 | end |