Commit d4e9b817bc72ba8bd8078651cea3c21d57d1eff6
1 parent
05ab09a2
战斗 日志
Showing
6 changed files
with
248 additions
and
15 deletions
Show diff stats
src/actions/HangAction.lua
| ... | ... | @@ -209,6 +209,7 @@ function _M.endBattleRpc(agent, data) |
| 209 | 209 | return true |
| 210 | 210 | end |
| 211 | 211 | local carbonId = msg.carbonId |
| 212 | + local isWin = msg.starNum and msg.starNum > 0 | |
| 212 | 213 | local carbonData = csvdb["idle_battleCsv"][carbonId] |
| 213 | 214 | if not carbonData then |
| 214 | 215 | return 2 |
| ... | ... | @@ -222,8 +223,9 @@ function _M.endBattleRpc(agent, data) |
| 222 | 223 | if role:checkHangPass(carbonId) then |
| 223 | 224 | return 4 |
| 224 | 225 | end |
| 226 | + | |
| 225 | 227 | local reward, change |
| 226 | - if msg.starNum and msg.starNum > 0 then --win | |
| 228 | + if isWin then --win | |
| 227 | 229 | role:hangFinish(carbonId) |
| 228 | 230 | if carbonData.main ~= 1 then |
| 229 | 231 | hangInfo.bossTime = nil |
| ... | ... | @@ -262,8 +264,12 @@ function _M.endBattleRpc(agent, data) |
| 262 | 264 | end |
| 263 | 265 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
| 264 | 266 | |
| 265 | - local team = role:getProperty("pvpTC") | |
| 266 | - | |
| 267 | + role:checkBattle("hang", { | |
| 268 | + id = carbonId, | |
| 269 | + isWin = isWin, | |
| 270 | + info = msg.info, | |
| 271 | + reward = reward, | |
| 272 | + }) | |
| 267 | 273 | |
| 268 | 274 | SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({ |
| 269 | 275 | starNum = msg.starNum, |
| ... | ... | @@ -533,6 +539,12 @@ function _M.endBonusBattleRpc(agent, data) |
| 533 | 539 | role:checkTaskEnter("BonusPass", {id = id}) |
| 534 | 540 | end |
| 535 | 541 | |
| 542 | + role:checkBattle("bonus", { | |
| 543 | + id = id, | |
| 544 | + isWin = starNum and starNum > 0, | |
| 545 | + info = msg.info, | |
| 546 | + reward = reward, | |
| 547 | + }) | |
| 536 | 548 | SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({ |
| 537 | 549 | starNum = starNum, |
| 538 | 550 | reward = reward, | ... | ... |
src/actions/PvpAction.lua
| ... | ... | @@ -335,11 +335,6 @@ function _M.endBattleRpc(agent, data) |
| 335 | 335 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) |
| 336 | 336 | local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) |
| 337 | 337 | |
| 338 | - _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病 | |
| 339 | - _pvpRecordInfoCacheC = {} -- 记录刷新了 | |
| 340 | - _pvpRecordBattleInfoCacheC = {} -- 取新纪录的时候搞 | |
| 341 | - _pvpStartBattleCacheC = nil | |
| 342 | - | |
| 343 | 338 | -- 请求上传录像 |
| 344 | 339 | local params = { |
| 345 | 340 | ["roleid"] = roleId, |
| ... | ... | @@ -388,7 +383,22 @@ function _M.endBattleRpc(agent, data) |
| 388 | 383 | if isWin then |
| 389 | 384 | role:checkTaskEnter("PvpWin", {score = myScore}) |
| 390 | 385 | end |
| 386 | + | |
| 387 | + role:checkBattle("pvpc", { | |
| 388 | + isWin = isWin, | |
| 389 | + info = msg.info, | |
| 390 | + robotId = match.t == 2 and match.id or nil, | |
| 391 | + enemy = match.t == 1 and _pvpBattleInfoCacheC[match.id] or nil, | |
| 392 | + score = myScore, | |
| 393 | + reward = reward, | |
| 394 | + rank = myRank, | |
| 395 | + }) | |
| 391 | 396 | |
| 397 | + _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病 | |
| 398 | + _pvpRecordInfoCacheC = {} -- 记录刷新了 | |
| 399 | + _pvpRecordBattleInfoCacheC = {} -- 取新纪录的时候搞 | |
| 400 | + _pvpStartBattleCacheC = nil | |
| 401 | + | |
| 392 | 402 | SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({ |
| 393 | 403 | reward = reward, |
| 394 | 404 | change = change, |
| ... | ... | @@ -676,6 +686,17 @@ function _M.endBattleHRpc(agent, data) |
| 676 | 686 | end |
| 677 | 687 | end) |
| 678 | 688 | |
| 689 | + role:checkBattle("pvph", { | |
| 690 | + isWin = isWin, | |
| 691 | + info = msg.info, | |
| 692 | + robotId = match.t == 2 and match.id or nil, | |
| 693 | + enemy = match.t == 1 and (revenge and _pvpRecordBattleInfoCacheH[match.id] or _pvpBattleInfoCacheH[match.id]) or nil, | |
| 694 | + score = myScore, | |
| 695 | + reward = reward, | |
| 696 | + rank = myRank, | |
| 697 | + }) | |
| 698 | + | |
| 699 | + | |
| 679 | 700 | _pvpBattleInfoCacheH = {} --重新发阵容了 没毛病 |
| 680 | 701 | _pvpRecordInfoCacheH = {} -- 记录刷新了 |
| 681 | 702 | _pvpRecordBattleInfoCacheH = {} -- 取新纪录的时候搞 |
| ... | ... | @@ -686,7 +707,7 @@ function _M.endBattleHRpc(agent, data) |
| 686 | 707 | if isWin then |
| 687 | 708 | role:checkTaskEnter("PvpWin", {score = myScore}) |
| 688 | 709 | end |
| 689 | - | |
| 710 | + | |
| 690 | 711 | SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({ |
| 691 | 712 | reward = reward, |
| 692 | 713 | change = change, | ... | ... |
src/actions/TowerAction.lua
| ... | ... | @@ -114,6 +114,21 @@ function _M.endBattleRpc(agent, data) |
| 114 | 114 | towerInfo.k = nil |
| 115 | 115 | role:updateProperty({field = "towerInfo", value = towerInfo}) |
| 116 | 116 | |
| 117 | + | |
| 118 | + local rank = redisproxy:ZREVRANK(RANK_TOWER, role:getProperty("id")) | |
| 119 | + if not rank then | |
| 120 | + rank = -1 | |
| 121 | + else | |
| 122 | + rank = rank + 1 | |
| 123 | + end | |
| 124 | + role:checkBattle("tower", { | |
| 125 | + id = id, | |
| 126 | + isWin = msg.starNum and msg.starNum > 0, | |
| 127 | + info = msg.info, | |
| 128 | + reward = reward, | |
| 129 | + rank = rank, | |
| 130 | + }) | |
| 131 | + | |
| 117 | 132 | SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward, change = change})) |
| 118 | 133 | return true |
| 119 | 134 | end | ... | ... |
src/models/Role.lua
| ... | ... | @@ -7,6 +7,7 @@ local RoleTask = import(".RoleTask") --角色任务 |
| 7 | 7 | local RoleChangeStruct = import(".RoleChangeStruct") --角色数据额结构更改 |
| 8 | 8 | local RolePvp = import(".RolePvp") -- pvp |
| 9 | 9 | local RoleCross = import(".RoleCross") -- 跨服务请求相关 |
| 10 | +local RoleBattle = import(".RoleBattle") -- 跨服务请求相关 | |
| 10 | 11 | |
| 11 | 12 | RoleLog.bind(Role) |
| 12 | 13 | RolePlugin.bind(Role) |
| ... | ... | @@ -15,6 +16,7 @@ RoleTask.bind(Role) |
| 15 | 16 | RoleChangeStruct.bind(Role) |
| 16 | 17 | RolePvp.bind(Role) |
| 17 | 18 | RoleCross.bind(Role) |
| 19 | +RoleBattle.bind(Role) | |
| 18 | 20 | |
| 19 | 21 | function Role:ctor( properties ) |
| 20 | 22 | Role.super.ctor(self, properties) | ... | ... |
| ... | ... | @@ -0,0 +1,182 @@ |
| 1 | +local RoleBattle = {} | |
| 2 | + | |
| 3 | +--[[ | |
| 4 | + 100 剧情关卡类 | |
| 5 | + 200 非剧情类普通关卡 | |
| 6 | + 300 每日任务类、日常本类 | |
| 7 | + 400 资源获取类关卡 | |
| 8 | + 500 PVP关卡 | |
| 9 | + 1000 活动期间限定类关卡 | |
| 10 | + 2000 其他 | |
| 11 | +]] | |
| 12 | + | |
| 13 | +local BattleType = { | |
| 14 | + "hang" = 100, | |
| 15 | + "tower" = 200, | |
| 16 | + "bonus" = 300, | |
| 17 | + "pvpc" = 500, | |
| 18 | + "pvph" = 501, | |
| 19 | +} | |
| 20 | + | |
| 21 | +RoleBattle.bind = function (Role) | |
| 22 | + | |
| 23 | + | |
| 24 | +-- TODO 检查战斗是否作弊 | |
| 25 | +local function checkBattleCheat() | |
| 26 | + | |
| 27 | +end | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | +function Role:checkBattle(battleType, params) | |
| 32 | + local clientInfo = params.info or {} | |
| 33 | + | |
| 34 | + if not BattleType[battleType] then | |
| 35 | + print(string.format("NO find battleType: %s", battleType)) | |
| 36 | + return | |
| 37 | + end | |
| 38 | + | |
| 39 | + local selflist = {} | |
| 40 | + local heroscore = 0 | |
| 41 | + local teamskill = {} | |
| 42 | + local enemylist = {} | |
| 43 | + | |
| 44 | + local fixData = { | |
| 45 | + hang = function() | |
| 46 | + for slot, hero in pairs(self:getProperty("hangTS")) do | |
| 47 | + selflist[slot] = hero.type | |
| 48 | + end | |
| 49 | + heroscore = self:getProperty("hangTBV") | |
| 50 | + for slot , one in pairs(self:getProperty("hangTB").supports) do | |
| 51 | + teamskill[one[1]] = one[2] | |
| 52 | + end | |
| 53 | + local carbonData = csvdb["idle_battleCsv"][params.id] | |
| 54 | + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"] | |
| 55 | + for slot, one in pairs(monsterData[1]) do | |
| 56 | + enemylist[#enemylist + 1] = one["unitType"] | |
| 57 | + end | |
| 58 | + end, | |
| 59 | + tower = function() | |
| 60 | + local towerF = self:getProperty("towerF") | |
| 61 | + for slot, hero in pairs(self:getTeamHerosInfo(towerF.heros)) do | |
| 62 | + selflist[slot] = hero.type | |
| 63 | + end | |
| 64 | + heroscore = self:getTeamBattleValue(towerF.heros) | |
| 65 | + for slot , one in pairs(self:getTeamBattleInfo(towerF).supports) do | |
| 66 | + teamskill[one[1]] = one[2] | |
| 67 | + end | |
| 68 | + local carbonData = csvdb["tower_battleCsv"][params.id] | |
| 69 | + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"] | |
| 70 | + for slot, one in pairs(monsterData[1]) do | |
| 71 | + enemylist[#enemylist + 1] = one["unitType"] | |
| 72 | + end | |
| 73 | + end, | |
| 74 | + bonus = function() | |
| 75 | + local bTeam = self:getProperty("bTeam") | |
| 76 | + for slot, hero in pairs(self:getTeamHerosInfo(bTeam.heros)) do | |
| 77 | + selflist[slot] = hero.type | |
| 78 | + end | |
| 79 | + heroscore = self:getTeamBattleValue(bTeam.heros) | |
| 80 | + for slot , one in pairs(self:getTeamBattleInfo(bTeam).supports) do | |
| 81 | + teamskill[one[1]] = one[2] | |
| 82 | + end | |
| 83 | + local carbonData = csvdb["tower_battleCsv"][params.id] | |
| 84 | + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"] | |
| 85 | + for slot, one in pairs(monsterData[1]) do | |
| 86 | + enemylist[#enemylist + 1] = one["unitType"] | |
| 87 | + end | |
| 88 | + end, | |
| 89 | + pvpc = function() | |
| 90 | + for slot, hero in pairs(self:getProperty("pvpTSC")) do | |
| 91 | + selflist[slot] = hero.type | |
| 92 | + end | |
| 93 | + heroscore = self:getProperty("pvpTBVC") | |
| 94 | + for slot , one in pairs(self:getProperty("pvpTBC").supports) do | |
| 95 | + teamskill[one[1]] = one[2] | |
| 96 | + end | |
| 97 | + if params.robotId then | |
| 98 | + local carbonData = csvdb["pvp_robotCsv"][params.robotId] | |
| 99 | + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"] | |
| 100 | + for slot, one in pairs(monsterData[1]) do | |
| 101 | + enemylist[#enemylist + 1] = one["unitType"] | |
| 102 | + end | |
| 103 | + else | |
| 104 | + for slot, one in pairs((params.enemy or {})["heros"] or {}) do | |
| 105 | + enemylist[slot] = one["type"] | |
| 106 | + end | |
| 107 | + end | |
| 108 | + end, | |
| 109 | + pvph = function() | |
| 110 | + for idx, team in pairs(self:getProperty("pvpTSH")) do | |
| 111 | + selflist[idx] = selflist[idx] or {} | |
| 112 | + for slot, hero in pairs(team) do | |
| 113 | + selflist[idx][slot] = hero.type | |
| 114 | + end | |
| 115 | + end | |
| 116 | + for _, one in pairs(self:getProperty("pvpTBVH")) do | |
| 117 | + heroscore = heroscore + one | |
| 118 | + end | |
| 119 | + for idx, team in pairs(self:getProperty("pvpTBH")) do | |
| 120 | + for slot , one in pairs(team.supports) do | |
| 121 | + teamskill[one[1]] = one[2] | |
| 122 | + end | |
| 123 | + end | |
| 124 | + | |
| 125 | + if params.robotId then | |
| 126 | + local carbonData = csvdb["pvp_robot_groupCsv"][params.robotId] | |
| 127 | + for idx = 1, 3 do | |
| 128 | + enemylist[idx] = enemylist[idx] or {} | |
| 129 | + local monsterData = csvdb[carbonData["monster" .. idx]:match("/([^/]*)$") .. "Csv"] | |
| 130 | + for slot, one in pairs(monsterData[1]) do | |
| 131 | + enemylist[idx][#enemylist + 1] = one["unitType"] | |
| 132 | + end | |
| 133 | + end | |
| 134 | + else | |
| 135 | + for idx, team in pairs(params.enemy or {}) do | |
| 136 | + enemylist[idx] = enemylist[idx] or {} | |
| 137 | + for slot, one in pairs(team["heros"] or {}) do | |
| 138 | + enemylist[idx][slot] = one["type"] | |
| 139 | + end | |
| 140 | + end | |
| 141 | + end | |
| 142 | + end | |
| 143 | + } | |
| 144 | + | |
| 145 | + if fixData[battleType] then | |
| 146 | + fixData[battleType]() | |
| 147 | + end | |
| 148 | + | |
| 149 | + -- robotId = match.t == 2 and match.id or nil, | |
| 150 | + -- enemy = match.t == 1 and (revenge and _pvpRecordBattleInfoCacheH[match.id] or _pvpBattleInfoCacheH[match.id]) or nil, | |
| 151 | + -- score = myScore, | |
| 152 | + -- reward = reward, | |
| 153 | + self:log("mission", { | |
| 154 | + mission_threadid = battleType == "hang" and math.floor((params.id % 100) / 100) or 0, -- 大关卡ID | |
| 155 | + mission_id = params.id or 0, -- 关卡ID | |
| 156 | + mission_type = BattleType[battleType], -- 关卡类型,见关卡类型枚举表 | |
| 157 | + mission_herolist = selflist, -- 英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] | |
| 158 | + mission_heroscore = heroscore, -- 编队总评分 | |
| 159 | + mission_enemylist = enemylist, -- 地方英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] | |
| 160 | + mission_damage = clientInfo.damage or {}, -- 英雄输出值。示例:{'heroid1':1000,'heroid2':2000,………..} | |
| 161 | + mission_ultskill = clientInfo.ultskill or {}, -- 大招使用情况。示例:{'heroid1':1000,'heroid2':2000,………..} | |
| 162 | + mission_reward = params.reward or {}, -- 获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} | |
| 163 | + mission_starttime = clientInfo.start or 0, -- 战斗开始时间,格式 unixtime 秒级 | |
| 164 | + mission_roundtime = clientInfo.atime or 0, -- 对局时长(秒) | |
| 165 | + mission_result = params.isWin and 1 or 2, -- 战斗结果(0-无效,1-胜利,2-失败) | |
| 166 | + mission_star = 0, -- 战斗完成星数,无星级的话填写0 | |
| 167 | + mission_restriction = 0, -- 周期内参与限制(0表示没有上限) | |
| 168 | + mission_difficulty = 0, -- 关卡困难度,无难度区分的话填写0 | |
| 169 | + mission_strength = 1, -- 消耗的体力或次数 | |
| 170 | + mission_score = params.score or 0, -- 本局分数,PVP玩法记录为对战后积分,无得分的填0 | |
| 171 | + mission_cleartype = 1, -- 1正常通关;2代理拾荒 | |
| 172 | + mission_rank = params.rank, -- 对战后排名,适用于PVP玩法和电波塔,其他玩法留空 | |
| 173 | + misson_monsterkill = clientInfo.kill or {}, -- 击杀怪物ID和数量,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} | |
| 174 | + misson_teamskill = teamskill, -- 编队支援技能和技能等级情况,json格式记录,{"teamskill1":1,"teamskill2":2,………..} | |
| 175 | + }) | |
| 176 | +end | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | +end | |
| 0 | 183 | \ No newline at end of file | ... | ... |
src/models/RoleLog.lua
| ... | ... | @@ -172,16 +172,16 @@ local MethodType = { |
| 172 | 172 | item_subreason = true, -- 道具流动二级原因,抽卡:卡池ID,装备强化:装备ID,副本掉落:副本ID |
| 173 | 173 | item_other = true, -- 其他(可包含阶数,强化等级,随机属性) |
| 174 | 174 | }, |
| 175 | - mission = { --玩家副本完成情况 --TODO | |
| 175 | + mission = { --玩家副本完成情况 | |
| 176 | 176 | mission_threadid = true, -- 大关卡ID |
| 177 | 177 | mission_id = true, -- 关卡ID |
| 178 | 178 | mission_type = true, -- 关卡类型,见关卡类型枚举表 |
| 179 | 179 | mission_sequenceid = "ucode", -- 本次对战ID,用于关联一次动作产生多条不同类型的日志 |
| 180 | - mission_herolist = true, -- 英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] | |
| 180 | + mission_herolist = "json", -- 英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] | |
| 181 | 181 | mission_heroscore = true, -- 编队总评分 |
| 182 | - mission_enemylist = true, -- 地方英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] | |
| 183 | - mission_damage = true, -- 英雄输出值。示例:{'heroid1':1000,'heroid2':2000,………..} | |
| 184 | - mission_ultskill = true, -- 大招使用情况。示例:{'heroid1':1000,'heroid2':2000,………..} | |
| 182 | + mission_enemylist = "json", -- 地方英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] | |
| 183 | + mission_damage = "json", -- 英雄输出值。示例:{'heroid1':1000,'heroid2':2000,………..} | |
| 184 | + mission_ultskill = "json", -- 大招使用情况。示例:{'heroid1':1000,'heroid2':2000,………..} | |
| 185 | 185 | mission_reward = "json", -- 获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} |
| 186 | 186 | mission_starttime = true, -- 战斗开始时间,格式 unixtime 秒级 |
| 187 | 187 | mission_roundtime = true, -- 对局时长(秒) |
| ... | ... | @@ -197,7 +197,7 @@ local MethodType = { |
| 197 | 197 | misson_teamskill = "json", -- 编队支援技能和技能等级情况,json格式记录,{"teamskill1":1,"teamskill2":2,………..} |
| 198 | 198 | misson_teambond = "json", -- 编队羁绊和羁绊等级,json格式记录,{"bondid1":1,"bondid2":2,………..} |
| 199 | 199 | }, |
| 200 | - residence_reward = { --玩家挂机或排名奖励 --TODO | |
| 200 | + residence_reward = { --玩家挂机或排名奖励 | |
| 201 | 201 | mission_threadid = true, --大关卡ID |
| 202 | 202 | mission_id = true, --关卡ID |
| 203 | 203 | mission_type = true, --关卡类型,见关卡类型枚举表 |
| ... | ... | @@ -523,6 +523,7 @@ function RoleLog.bind(Role) |
| 523 | 523 | }) |
| 524 | 524 | end |
| 525 | 525 | |
| 526 | + | |
| 526 | 527 | function Role:startActionUcode() |
| 527 | 528 | if not self._uniqueCount then |
| 528 | 529 | self._uniqueCount = 0 | ... | ... |