diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 65daf62..cd73f6c 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -209,6 +209,7 @@ function _M.endBattleRpc(agent, data) return true end local carbonId = msg.carbonId + local isWin = msg.starNum and msg.starNum > 0 local carbonData = csvdb["idle_battleCsv"][carbonId] if not carbonData then return 2 @@ -222,8 +223,9 @@ function _M.endBattleRpc(agent, data) if role:checkHangPass(carbonId) then return 4 end + local reward, change - if msg.starNum and msg.starNum > 0 then --win + if isWin then --win role:hangFinish(carbonId) if carbonData.main ~= 1 then hangInfo.bossTime = nil @@ -262,8 +264,12 @@ function _M.endBattleRpc(agent, data) end role:updateProperty({field = "hangInfo", value = hangInfo}) - local team = role:getProperty("pvpTC") - + role:checkBattle("hang", { + id = carbonId, + isWin = isWin, + info = msg.info, + reward = reward, + }) SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({ starNum = msg.starNum, @@ -533,6 +539,12 @@ function _M.endBonusBattleRpc(agent, data) role:checkTaskEnter("BonusPass", {id = id}) end + role:checkBattle("bonus", { + id = id, + isWin = starNum and starNum > 0, + info = msg.info, + reward = reward, + }) SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({ starNum = starNum, reward = reward, diff --git a/src/actions/PvpAction.lua b/src/actions/PvpAction.lua index 8a7bbc1..aa52fdb 100644 --- a/src/actions/PvpAction.lua +++ b/src/actions/PvpAction.lua @@ -335,11 +335,6 @@ function _M.endBattleRpc(agent, data) local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) - _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病 - _pvpRecordInfoCacheC = {} -- 记录刷新了 - _pvpRecordBattleInfoCacheC = {} -- 取新纪录的时候搞 - _pvpStartBattleCacheC = nil - -- 请求上传录像 local params = { ["roleid"] = roleId, @@ -388,7 +383,22 @@ function _M.endBattleRpc(agent, data) if isWin then role:checkTaskEnter("PvpWin", {score = myScore}) end + + role:checkBattle("pvpc", { + isWin = isWin, + info = msg.info, + robotId = match.t == 2 and match.id or nil, + enemy = match.t == 1 and _pvpBattleInfoCacheC[match.id] or nil, + score = myScore, + reward = reward, + rank = myRank, + }) + _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病 + _pvpRecordInfoCacheC = {} -- 记录刷新了 + _pvpRecordBattleInfoCacheC = {} -- 取新纪录的时候搞 + _pvpStartBattleCacheC = nil + SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({ reward = reward, change = change, @@ -676,6 +686,17 @@ function _M.endBattleHRpc(agent, data) end end) + role:checkBattle("pvph", { + isWin = isWin, + info = msg.info, + robotId = match.t == 2 and match.id or nil, + enemy = match.t == 1 and (revenge and _pvpRecordBattleInfoCacheH[match.id] or _pvpBattleInfoCacheH[match.id]) or nil, + score = myScore, + reward = reward, + rank = myRank, + }) + + _pvpBattleInfoCacheH = {} --重新发阵容了 没毛病 _pvpRecordInfoCacheH = {} -- 记录刷新了 _pvpRecordBattleInfoCacheH = {} -- 取新纪录的时候搞 @@ -686,7 +707,7 @@ function _M.endBattleHRpc(agent, data) if isWin then role:checkTaskEnter("PvpWin", {score = myScore}) end - + SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({ reward = reward, change = change, diff --git a/src/actions/TowerAction.lua b/src/actions/TowerAction.lua index 2d07a0f..bda2777 100644 --- a/src/actions/TowerAction.lua +++ b/src/actions/TowerAction.lua @@ -114,6 +114,21 @@ function _M.endBattleRpc(agent, data) towerInfo.k = nil role:updateProperty({field = "towerInfo", value = towerInfo}) + + local rank = redisproxy:ZREVRANK(RANK_TOWER, role:getProperty("id")) + if not rank then + rank = -1 + else + rank = rank + 1 + end + role:checkBattle("tower", { + id = id, + isWin = msg.starNum and msg.starNum > 0, + info = msg.info, + reward = reward, + rank = rank, + }) + SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward, change = change})) return true end diff --git a/src/models/Role.lua b/src/models/Role.lua index 5e05863..2f4a52a 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -7,6 +7,7 @@ local RoleTask = import(".RoleTask") --角色任务 local RoleChangeStruct = import(".RoleChangeStruct") --角色数据额结构更改 local RolePvp = import(".RolePvp") -- pvp local RoleCross = import(".RoleCross") -- 跨服务请求相关 +local RoleBattle = import(".RoleBattle") -- 跨服务请求相关 RoleLog.bind(Role) RolePlugin.bind(Role) @@ -15,6 +16,7 @@ RoleTask.bind(Role) RoleChangeStruct.bind(Role) RolePvp.bind(Role) RoleCross.bind(Role) +RoleBattle.bind(Role) function Role:ctor( properties ) Role.super.ctor(self, properties) diff --git a/src/models/RoleBattle.lua b/src/models/RoleBattle.lua new file mode 100644 index 0000000..873bcc8 --- /dev/null +++ b/src/models/RoleBattle.lua @@ -0,0 +1,182 @@ +local RoleBattle = {} + +--[[ + 100 剧情关卡类 + 200 非剧情类普通关卡 + 300 每日任务类、日常本类 + 400 资源获取类关卡 + 500 PVP关卡 + 1000 活动期间限定类关卡 + 2000 其他 +]] + +local BattleType = { + "hang" = 100, + "tower" = 200, + "bonus" = 300, + "pvpc" = 500, + "pvph" = 501, +} + +RoleBattle.bind = function (Role) + + +-- TODO 检查战斗是否作弊 +local function checkBattleCheat() + +end + + + +function Role:checkBattle(battleType, params) + local clientInfo = params.info or {} + + if not BattleType[battleType] then + print(string.format("NO find battleType: %s", battleType)) + return + end + + local selflist = {} + local heroscore = 0 + local teamskill = {} + local enemylist = {} + + local fixData = { + hang = function() + for slot, hero in pairs(self:getProperty("hangTS")) do + selflist[slot] = hero.type + end + heroscore = self:getProperty("hangTBV") + for slot , one in pairs(self:getProperty("hangTB").supports) do + teamskill[one[1]] = one[2] + end + local carbonData = csvdb["idle_battleCsv"][params.id] + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"] + for slot, one in pairs(monsterData[1]) do + enemylist[#enemylist + 1] = one["unitType"] + end + end, + tower = function() + local towerF = self:getProperty("towerF") + for slot, hero in pairs(self:getTeamHerosInfo(towerF.heros)) do + selflist[slot] = hero.type + end + heroscore = self:getTeamBattleValue(towerF.heros) + for slot , one in pairs(self:getTeamBattleInfo(towerF).supports) do + teamskill[one[1]] = one[2] + end + local carbonData = csvdb["tower_battleCsv"][params.id] + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"] + for slot, one in pairs(monsterData[1]) do + enemylist[#enemylist + 1] = one["unitType"] + end + end, + bonus = function() + local bTeam = self:getProperty("bTeam") + for slot, hero in pairs(self:getTeamHerosInfo(bTeam.heros)) do + selflist[slot] = hero.type + end + heroscore = self:getTeamBattleValue(bTeam.heros) + for slot , one in pairs(self:getTeamBattleInfo(bTeam).supports) do + teamskill[one[1]] = one[2] + end + local carbonData = csvdb["tower_battleCsv"][params.id] + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"] + for slot, one in pairs(monsterData[1]) do + enemylist[#enemylist + 1] = one["unitType"] + end + end, + pvpc = function() + for slot, hero in pairs(self:getProperty("pvpTSC")) do + selflist[slot] = hero.type + end + heroscore = self:getProperty("pvpTBVC") + for slot , one in pairs(self:getProperty("pvpTBC").supports) do + teamskill[one[1]] = one[2] + end + if params.robotId then + local carbonData = csvdb["pvp_robotCsv"][params.robotId] + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"] + for slot, one in pairs(monsterData[1]) do + enemylist[#enemylist + 1] = one["unitType"] + end + else + for slot, one in pairs((params.enemy or {})["heros"] or {}) do + enemylist[slot] = one["type"] + end + end + end, + pvph = function() + for idx, team in pairs(self:getProperty("pvpTSH")) do + selflist[idx] = selflist[idx] or {} + for slot, hero in pairs(team) do + selflist[idx][slot] = hero.type + end + end + for _, one in pairs(self:getProperty("pvpTBVH")) do + heroscore = heroscore + one + end + for idx, team in pairs(self:getProperty("pvpTBH")) do + for slot , one in pairs(team.supports) do + teamskill[one[1]] = one[2] + end + end + + if params.robotId then + local carbonData = csvdb["pvp_robot_groupCsv"][params.robotId] + for idx = 1, 3 do + enemylist[idx] = enemylist[idx] or {} + local monsterData = csvdb[carbonData["monster" .. idx]:match("/([^/]*)$") .. "Csv"] + for slot, one in pairs(monsterData[1]) do + enemylist[idx][#enemylist + 1] = one["unitType"] + end + end + else + for idx, team in pairs(params.enemy or {}) do + enemylist[idx] = enemylist[idx] or {} + for slot, one in pairs(team["heros"] or {}) do + enemylist[idx][slot] = one["type"] + end + end + end + end + } + + if fixData[battleType] then + fixData[battleType]() + end + + -- robotId = match.t == 2 and match.id or nil, + -- enemy = match.t == 1 and (revenge and _pvpRecordBattleInfoCacheH[match.id] or _pvpBattleInfoCacheH[match.id]) or nil, + -- score = myScore, + -- reward = reward, + self:log("mission", { + mission_threadid = battleType == "hang" and math.floor((params.id % 100) / 100) or 0, -- 大关卡ID + mission_id = params.id or 0, -- 关卡ID + mission_type = BattleType[battleType], -- 关卡类型,见关卡类型枚举表 + mission_herolist = selflist, -- 英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] + mission_heroscore = heroscore, -- 编队总评分 + mission_enemylist = enemylist, -- 地方英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] + mission_damage = clientInfo.damage or {}, -- 英雄输出值。示例:{'heroid1':1000,'heroid2':2000,………..} + mission_ultskill = clientInfo.ultskill or {}, -- 大招使用情况。示例:{'heroid1':1000,'heroid2':2000,………..} + mission_reward = params.reward or {}, -- 获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + mission_starttime = clientInfo.start or 0, -- 战斗开始时间,格式 unixtime 秒级 + mission_roundtime = clientInfo.atime or 0, -- 对局时长(秒) + mission_result = params.isWin and 1 or 2, -- 战斗结果(0-无效,1-胜利,2-失败) + mission_star = 0, -- 战斗完成星数,无星级的话填写0 + mission_restriction = 0, -- 周期内参与限制(0表示没有上限) + mission_difficulty = 0, -- 关卡困难度,无难度区分的话填写0 + mission_strength = 1, -- 消耗的体力或次数 + mission_score = params.score or 0, -- 本局分数,PVP玩法记录为对战后积分,无得分的填0 + mission_cleartype = 1, -- 1正常通关;2代理拾荒 + mission_rank = params.rank, -- 对战后排名,适用于PVP玩法和电波塔,其他玩法留空 + misson_monsterkill = clientInfo.kill or {}, -- 击杀怪物ID和数量,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + misson_teamskill = teamskill, -- 编队支援技能和技能等级情况,json格式记录,{"teamskill1":1,"teamskill2":2,………..} + }) +end + + + + + +end \ No newline at end of file diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index b3e1ced..305f257 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -172,16 +172,16 @@ local MethodType = { item_subreason = true, -- 道具流动二级原因,抽卡:卡池ID,装备强化:装备ID,副本掉落:副本ID item_other = true, -- 其他(可包含阶数,强化等级,随机属性) }, - mission = { --玩家副本完成情况 --TODO + mission = { --玩家副本完成情况 mission_threadid = true, -- 大关卡ID mission_id = true, -- 关卡ID mission_type = true, -- 关卡类型,见关卡类型枚举表 mission_sequenceid = "ucode", -- 本次对战ID,用于关联一次动作产生多条不同类型的日志 - mission_herolist = true, -- 英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] + mission_herolist = "json", -- 英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] mission_heroscore = true, -- 编队总评分 - mission_enemylist = true, -- 地方英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] - mission_damage = true, -- 英雄输出值。示例:{'heroid1':1000,'heroid2':2000,………..} - mission_ultskill = true, -- 大招使用情况。示例:{'heroid1':1000,'heroid2':2000,………..} + mission_enemylist = "json", -- 地方英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] + mission_damage = "json", -- 英雄输出值。示例:{'heroid1':1000,'heroid2':2000,………..} + mission_ultskill = "json", -- 大招使用情况。示例:{'heroid1':1000,'heroid2':2000,………..} mission_reward = "json", -- 获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} mission_starttime = true, -- 战斗开始时间,格式 unixtime 秒级 mission_roundtime = true, -- 对局时长(秒) @@ -197,7 +197,7 @@ local MethodType = { misson_teamskill = "json", -- 编队支援技能和技能等级情况,json格式记录,{"teamskill1":1,"teamskill2":2,………..} misson_teambond = "json", -- 编队羁绊和羁绊等级,json格式记录,{"bondid1":1,"bondid2":2,………..} }, - residence_reward = { --玩家挂机或排名奖励 --TODO + residence_reward = { --玩家挂机或排名奖励 mission_threadid = true, --大关卡ID mission_id = true, --关卡ID mission_type = true, --关卡类型,见关卡类型枚举表 @@ -523,6 +523,7 @@ function RoleLog.bind(Role) }) end + function Role:startActionUcode() if not self._uniqueCount then self._uniqueCount = 0 -- libgit2 0.21.2