From 761b3ea86e0ead6c693edc764761cc028d7bffe3 Mon Sep 17 00:00:00 2001 From: chenyueqi Date: Wed, 3 Mar 2021 17:44:13 +0800 Subject: [PATCH] 再改一波电波塔整容相关信息 --- src/GlobalVar.lua | 5 ----- src/actions/HangAction.lua | 7 ++++++- src/actions/TowerAction.lua | 21 ++++++++++++++++++--- src/models/Role.lua | 2 ++ src/models/RoleBattle.lua | 4 ++-- src/models/RolePlugin.lua | 23 ++++++++++++++++++----- 6 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index b6d4d28..a4692d8 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -369,13 +369,8 @@ DrawCardType = { TeamSystemType = { Hang = 1, BonusBattle = 2, - Tower = 3, Dinner = 4, FriendBattle = 5, - Adv = 6, - Tower1 = 7, - Tower2 = 8, - Tower3 = 9, } -- 某个功能对其他系统功能的加成类型 diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 9a71056..c0702d4 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -326,6 +326,7 @@ function _M.roleFormatRpc(agent , data) local index = msg.index -- 阵容索引 local title = msg.title -- 阵容名称 local tactics = msg.tactics -- 战术 + local tower = msg.tower local team = {} for slot, heroId in pairs(msg.heros) do if not role.heros[heroId] then @@ -361,7 +362,11 @@ function _M.roleFormatRpc(agent , data) team.tactics = msg.tactics end - role:setTeamFormat(index, team) + if tower then + role:setTowerTeamFormat(index, team) + else + role:setTeamFormat(index, team) + end SendPacket(actionCodes.Hang_roleFormatRpc, '') return true diff --git a/src/actions/TowerAction.lua b/src/actions/TowerAction.lua index af1c392..ba50852 100644 --- a/src/actions/TowerAction.lua +++ b/src/actions/TowerAction.lua @@ -25,7 +25,7 @@ function _M.startBattleRpc(agent, data) local id = msg.id local towerType = math.floor(id / 10000) - if not id or not towerType or towerType < 0 or towerType > 3 then return 0 end + if not id or towerType < 0 or towerType > 3 then return 0 end if not role:isFuncUnlock(FuncUnlock.Tower) then return 1 end local towerInfo = role:getProperty("towerInfo") @@ -35,7 +35,20 @@ function _M.startBattleRpc(agent, data) if towerType == 2 and ((towerInfo.l2 or 20001) ~= id or (towerInfo.l or 1) < 10) then return 2 end -- 层数不对 if towerType == 3 and ((towerInfo.l3 or 30001) ~= id or (towerInfo.l or 1) < 10) then return 2 end -- 层数不对 - if not csvdb["tower_battleCsv"][id] then return end + if not csvdb["tower_battleCsv"][id] then return 4 end + + local teams = role:getTowerTeamFormat(towerType + 1) + if not next(teams) then return 5 end + + if towerType ~= 0 then + for _, heroId in pairs(teams.heros) do + local hero = role.heros[heroId] + if not hero then return 6 end + local unit = csvdb["unitCsv"][hero:getProperty("type")] + if unit.camp ~= towerType then return 7 end + end + end + local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) --if curCount < 1 then return end -- 没有次数返回 @@ -78,7 +91,8 @@ function _M.endBattleRpc(agent, data) -- 防作弊 if not role:checkBattleCheat("tower", { isWin = msg.starNum and msg.starNum > 0, - info = msg.info + info = msg.info, + tower = towerType + 1 }) then SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({errorCode = 1})) return true @@ -127,6 +141,7 @@ function _M.endBattleRpc(agent, data) info = msg.info, reward = reward, rank = rank, + tower = towerType + 1 }) role:mylog("tower_action", {desc = "endBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id}) diff --git a/src/models/Role.lua b/src/models/Role.lua index 7d977de..aeed2ff 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -115,6 +115,7 @@ Role.schema = { hangTeams = {"table", {}}, -- pve自选编队 teamIndex = {"table", {}}, -- 各个系统使用的编队索引 type->index 见TeamSystemType advTeams = {"table", {}}, -- 拾荒自选编队 + towerTeams = {"table", {}}, -- 四个电波塔的队伍 bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 @@ -369,6 +370,7 @@ function Role:data() hangTeams = self:getProperty("hangTeams"), teamIndex = self:getProperty("teamIndex"), advTeams = self:getProperty("advTeams"), + towerTeams = self:getProperty("towerTeams"), bonusStar = self:getProperty("bonusStar"), diff --git a/src/models/RoleBattle.lua b/src/models/RoleBattle.lua index 79b9678..7374ed5 100644 --- a/src/models/RoleBattle.lua +++ b/src/models/RoleBattle.lua @@ -104,7 +104,7 @@ function Role:checkBattleCheat(battleType, params) -- enemyServer = packBattleEnemyCommon(carbonData) end cheat["tower"] = function() - local team = self:getTeamBattleInfo(self:getTeamFormatByType(TeamSystemType.Tower)) + local team = self:getTeamBattleInfo(self:getTowerTeamFormat(params.tower)) for slot, hero in pairs(team.heros) do local temp = {} for arr, _ in pairs(checkCheatAttrs) do @@ -198,7 +198,7 @@ function Role:checkBattle(battleType, params) end end, tower = function() - local towerF = self:getTeamFormatByType(TeamSystemType.Tower) + local towerF = self:getTowerTeamFormat(params.tower) for slot, hero in pairs(self:getTeamHerosInfo(towerF).heros) do selflist[slot] = hero.type end diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index e4597e8..40b365d 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1270,10 +1270,10 @@ function RolePlugin.bind(Role) local StdTowerRankTime = toUnixtime("2019010100") local TowerRankInfo = { - [1] = {teamType = TeamSystemType.Tower, rank = RANK_TOWER, rankInfo = RANK_TOWER_INFO}, - [2] = {teamType = TeamSystemType.Tower1, rank = RANK_TOWER1, rankInfo = RANK_TOWER1_INFO}, - [3] = {teamType = TeamSystemType.Tower2, rank = RANK_TOWER2, rankInfo = RANK_TOWER2_INFO}, - [4] = {teamType = TeamSystemType.Tower3, rank = RANK_TOWER3, rankInfo = RANK_TOWER3_INFO}, + [1] = {rank = RANK_TOWER, rankInfo = RANK_TOWER_INFO}, + [2] = {rank = RANK_TOWER1, rankInfo = RANK_TOWER1_INFO}, + [3] = {rank = RANK_TOWER2, rankInfo = RANK_TOWER2_INFO}, + [4] = {rank = RANK_TOWER3, rankInfo = RANK_TOWER3_INFO}, } function Role:setTowerRank(level,tType) tType = tType or 1 @@ -1283,7 +1283,7 @@ function RolePlugin.bind(Role) local info = TowerRankInfo[tType] - local towerTeam = self:getTeamFormatByType(info.teamType) + local towerTeam = self:getTowerTeamFormat(tostring(tType)) local battleV = self:getTeamBattleValue(towerTeam.heros) local score = (level * 10000 + ct) * 10000000 + battleV @@ -1554,6 +1554,19 @@ function RolePlugin.bind(Role) }) end + -- 设置电波塔阵容 + function Role:getTowerTeamFormat(teamIdx) + local teams = self:getProperty("towerTeams") or {} + local team = teams[tostring(teamIdx)] or {} + return team + end + + function Role:setTowerTeamFormat(teamIdx, team) + local teams = self:getProperty("towerTeams") or {} + teams[tostring(teamIdx)] = team + self:updateProperty({field = "towerTeams", value = teams, notNotify = false}) + end + -- update function Role:onRecoverTimer(now) self:updateTimeReset(now, true) -- libgit2 0.21.2