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 | 18 | function _M.levelUpRpc( agent, data ) |
| 19 | 19 | local role = agent.role |
| 20 | 20 | local msg = MsgPack.unpack(data) |
| 21 | + print("msg.id "..msg.id) | |
| 21 | 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 | 26 | local curData = csvdb["unit_expCsv"][hero:getProperty("level")] |
| 26 | 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 | 29 | role:costItems(cost) |
| 29 | 30 | hero:updateProperty({field = "level", delta = 1}) |
| 30 | - | |
| 31 | + | |
| 31 | 32 | SendPacket(actionCodes.Hero_levelUpRpc, '') |
| 32 | 33 | return true |
| 33 | 34 | end |
| ... | ... | @@ -36,16 +37,16 @@ function _M.breakRpc( agent, data ) |
| 36 | 37 | local role = agent.role |
| 37 | 38 | local msg = MsgPack.unpack(data) |
| 38 | 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 | 44 | local curData = csvdb["unit_breakCsv"][hero:getProperty("breakL")] |
| 44 | 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 | 47 | role:costItems(cost) |
| 47 | 48 | hero:updateProperty({field = "breakL", delta = 1}) |
| 48 | - | |
| 49 | + | |
| 49 | 50 | SendPacket(actionCodes.Hero_breakRpc, '') |
| 50 | 51 | return true |
| 51 | 52 | end |
| ... | ... | @@ -54,25 +55,46 @@ function _M.wakeRpc(agent, data) |
| 54 | 55 | local role = agent.role |
| 55 | 56 | local msg = MsgPack.unpack(data) |
| 56 | 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 | 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 | 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 | 87 | hero:updateProperty({field = "wakeL", delta = 1}) |
| 67 | 88 | |
| 68 | 89 | SendPacket(actionCodes.Hero_wakeRpc, '') |
| 69 | 90 | return true |
| 70 | 91 | end |
| 71 | 92 | |
| 93 | +-- 已取消技能升级功能,觉醒时自动升级技能 | |
| 72 | 94 | function _M.skillUpRpc(agent, data) |
| 73 | 95 | local role = agent.role |
| 74 | 96 | local msg = MsgPack.unpack(data) |
| 75 | - local index = msg.skillIdx -- 第几个技能 -- 1 2 3 | |
| 97 | + local index = msg.skillIdx -- 第几个技能 -- 1 2 3 | |
| 76 | 98 | local hero = role.heros[msg.id] |
| 77 | 99 | if not hero then return end |
| 78 | 100 | local curLevel = hero:getSkillLevel(index) |
| ... | ... | @@ -96,8 +118,8 @@ function _M.talentRpc(agent, data) |
| 96 | 118 | local talent = hero:getProperty("talent") |
| 97 | 119 | local curStage = talent:getv(0, 1) |
| 98 | 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 | 123 | if not curData then return end |
| 102 | 124 | |
| 103 | 125 | local level = talent:getv(index, 0) |
| ... | ... | @@ -216,7 +238,7 @@ function _M.commentHeroRpc(agent, data) |
| 216 | 238 | end |
| 217 | 239 | local commentId = tostring(redisproxy:hincrby("hero:comment:autoincr", "hero:" .. heroType, 1)) |
| 218 | 240 | local comment = { |
| 219 | - commentId = commentId, | |
| 241 | + commentId = commentId, | |
| 220 | 242 | content = content, |
| 221 | 243 | roleId = role:getProperty("id"), |
| 222 | 244 | name = role:getProperty("name"), |
| ... | ... | @@ -291,14 +313,14 @@ function _M.likeCommentRpc(agent, data) |
| 291 | 313 | elseif actType == 2 then |
| 292 | 314 | add = -1 |
| 293 | 315 | else |
| 294 | - return | |
| 316 | + return | |
| 295 | 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 | 321 | local commentRoleKey = string.format("comment:%d:like", role:getProperty("id")) |
| 300 | 322 | local redret = redisproxy:pipelining(function (red) |
| 301 | - red:hexists(commentKey.commentKey, commentId) | |
| 323 | + red:hexists(commentKey.commentKey, commentId) | |
| 302 | 324 | red:lrem(commentRoleKey, 1, commentIndex) |
| 303 | 325 | red:lpush(commentRoleKey, commentIndex) |
| 304 | 326 | red:ltrim(commentRoleKey, 0, 999) |
| ... | ... | @@ -373,7 +395,7 @@ function _M.loveTaskRpc(agent, data) |
| 373 | 395 | local curType = hero:getProperty("type") |
| 374 | 396 | local curPlus = csvdb["unit_love_plusCsv"][curType] |
| 375 | 397 | if not curPlus or curL >= curPlus.limit then return end |
| 376 | - | |
| 398 | + | |
| 377 | 399 | local curEffect = csvdb["unit_love_effectCsv"][curL] |
| 378 | 400 | if not curEffect or curExp < curEffect.loveValue then return end |
| 379 | 401 | |
| ... | ... | @@ -388,7 +410,7 @@ function _M.loveTaskRpc(agent, data) |
| 388 | 410 | end |
| 389 | 411 | hero:updateProperty({field = "loveExp", value = newExp}) |
| 390 | 412 | hero:updateProperty({field = "loveL", value = curL + 1}) |
| 391 | - | |
| 413 | + | |
| 392 | 414 | if role:getProperty("loveStatus"):getv(curType, 0) < curL + 1 then |
| 393 | 415 | role:changeUpdates({{type = "loveStatus", field = curType, value = curL + 1}}) -- 总的 |
| 394 | 416 | end | ... | ... |
src/models/Hero.lua
| ... | ... | @@ -79,4 +79,13 @@ function Hero:data() |
| 79 | 79 | } |
| 80 | 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 | 91 | return Hero |
| 83 | 92 | \ No newline at end of file | ... | ... |
src/models/HeroPlugin.lua
| ... | ... | @@ -47,15 +47,15 @@ function HeroPlugin.bind(Hero) |
| 47 | 47 | |
| 48 | 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 | 51 | local curData = csvdb["unit_talentCsv"][i] |
| 52 | 52 | local effect = curData[#curData].effect:toArray(true, "=") |
| 53 | 53 | talentAttrS[AttsEnumEx[effect[1]]] = (talentAttrS[AttsEnumEx[effect[1]]] or 0) + effect[2] |
| 54 | 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 | 57 | if not curData then -- 已经满阶段了 |
| 58 | - curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]] | |
| 58 | + curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]] | |
| 59 | 59 | local strength = curData[#curData].strength |
| 60 | 60 | for i = 1, 4 do |
| 61 | 61 | talentAttrS[AttsEnumEx[i]] = (talentAttrS[AttsEnumEx[i]] or 0) + strength |
| ... | ... | @@ -69,7 +69,7 @@ function HeroPlugin.bind(Hero) |
| 69 | 69 | --好感度 |
| 70 | 70 | local loveUp = {} |
| 71 | 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 | 73 | for attrId, value in pairs(reward:toNumMap()) do |
| 74 | 74 | loveUp[AttsEnumEx[attrId]] = (loveUp[AttsEnumEx[attrId]] or 0) + value |
| 75 | 75 | end |
| ... | ... | @@ -111,24 +111,25 @@ function HeroPlugin.bind(Hero) |
| 111 | 111 | return battleValue |
| 112 | 112 | end |
| 113 | 113 | |
| 114 | + -- 技能1234 对应必杀技,冒险技,被动技,战斗技 | |
| 114 | 115 | function Hero:getSkillLevel(idx) |
| 115 | 116 | return self:getProperty("skillL"):getv(idx, 1) |
| 116 | 117 | end |
| 117 | 118 | |
| 118 | 119 | function Hero:getSkillData(idx, skin) |
| 119 | - local unitData = csvdb["unitCsv"][self:getSkinId(skin)] | |
| 120 | + local unitData = csvdb["unitCsv"][self:getProperty("type")] | |
| 120 | 121 | if idx == 1 then |
| 121 | - return csvdb["skill_blockCsv"][unitData.block] | |
| 122 | - elseif idx == 2 then | |
| 123 | 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 | 124 | if unitData.adv > 1000 then |
| 128 | 125 | return csvdb["adv_skill_passiveCsv"][unitData.adv] |
| 129 | 126 | else |
| 130 | 127 | return csvdb["adv_skillCsv"][unitData.adv] |
| 131 | 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 | 133 | end |
| 133 | 134 | return {} |
| 134 | 135 | end | ... | ... |