RoleBattle.lua
11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
local RoleBattle = {}
--[[
100 剧情关卡类
200 非剧情类普通关卡
300 每日任务类、日常本类
400 资源获取类关卡
500 PVP关卡
1000 活动期间限定类关卡
2000 其他
]]
local BattleType = {
hang = 100,
tower = 200,
bonus = 300,
pvpc = 500,
pvph = 501,
act_battle = 502,
}
RoleBattle.bind = function (Role)
local checkCheatAttrs = {
["hp"] = 1,
["atk"] = 1,
["def"] = 1,
["hit"] = 1,
["miss"] = 1,
["crit"] = 1,
["atkSpeed"] = 1,
["critHurt"] = 1,
-- ["vampire"] = 1,
-- ["pierce"] = 1,
}
local function checkOneCheat(selfTeamClient, selfTeamServer, enemyClient, enemyServer)
if not selfTeamClient or type(selfTeamClient) ~= "table" then return end
for unitType, clientInfo in pairs(selfTeamClient) do
local serverInfo = selfTeamServer[unitType]
if not serverInfo then return end
for attr, pm in pairs(checkCheatAttrs) do
if not clientInfo[attr] then return end
end
local b1 = ((clientInfo["hp"] + clientInfo["def"] * 7 + clientInfo["miss"] * 4) * (clientInfo["atk"] * 4 + clientInfo["hit"] * 2) * (1 + clientInfo["crit"]/100 * clientInfo["critHurt"]/100) * clientInfo["atkSpeed"] / 600000) ^ 0.8
local b2 = ((serverInfo["hp"] + serverInfo["def"] * 7 + serverInfo["miss"] * 4) * (serverInfo["atk"] * 4 + serverInfo["hit"] * 2) * (1 + serverInfo["crit"]/100 * serverInfo["critHurt"]/100) * serverInfo["atkSpeed"] / 600000) ^ 0.8
if b1 >= b2 * 2 then
return
end
end
return true
end
-- local function getRobotAttrs(info, strength)
-- strength = strength or 10000
-- local unitData = csvdb["unitCsv"][info.unitType]
-- local enemy = {}
-- for arr, _ in pairs(checkCheatAttrs) do
-- enemy[arr] = unitData[attr] * info[attr] * strength / 10000
-- end
-- return enemy
-- end
-- --通过配表构建敌人队伍 通用
-- function BattleEnter:packBattleEnemyCommon( carbonData )
-- local enemys = {}
-- local monsterSet = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"]
-- for phase = 1, #monsterSet do
-- local allEnemys = table.values(monsterSet[phase])
-- table.sort(allEnemys, function(a, b) return a.id < b.id end)
-- local heros = {}
-- for idx, enemy in ipairs(allEnemys) do
-- local info = getRobotAttrs(enemy, carbonData.strength)
-- enemys[idx] = info
-- end
-- break
-- end
-- return enemys
-- end
-- 检查战斗是否作弊
function Role:checkBattleCheat(battleType, params)
if not params.isWin then return true end
local clientInfo = params.info or {}
if not BattleType[battleType] then
print(string.format("NO find battleType: %s", battleType))
return true
end
local selfTeamServer = {}
local enemyServer = {}
local cheat = {}
cheat["hang"] = function()
local team = self:getTeamBattleInfo(self:getTeamFormatByType(TeamSystemType.Hang))
for slot, hero in pairs(team.heros) do
local temp = {}
for arr, _ in pairs(checkCheatAttrs) do
temp[arr] = hero[arr]
end
selfTeamServer[hero.type] = temp
end
-- local carbonData = csvdb["idle_battleCsv"][params.id]
-- enemyServer = packBattleEnemyCommon(carbonData)
end
cheat["tower"] = function()
local team = self:getTeamBattleInfo(self:getTeamFormatByType(TeamSystemType.Tower))
for slot, hero in pairs(team.heros) do
local temp = {}
for arr, _ in pairs(checkCheatAttrs) do
temp[arr] = hero[arr]
end
selfTeamServer[hero.type] = temp
end
-- local carbonData = csvdb["tower_battleCsv"][params.id]
-- enemyServer = packBattleEnemyCommon(carbonData)
end
cheat["bonus"] = function()
local team = self:getTeamBattleInfo(self:getTeamFormatByType(TeamSystemType.BonusBattle))
for slot, hero in pairs(team.heros) do
local temp = {}
for arr, _ in pairs(checkCheatAttrs) do
temp[arr] = hero[arr]
end
selfTeamServer[hero.type] = temp
end
-- local carbonData = csvdb["bonus_battleCsv"][params.id]
-- enemyServer = packBattleEnemyCommon(carbonData)
end
cheat["pvpc"] = function()
if not params.format then return end
local team = self:getTeamBattleInfo(params.format)
for slot, hero in pairs(team.heros) do
local temp = {}
for arr, _ in pairs(checkCheatAttrs) do
temp[arr] = hero[arr]
end
selfTeamServer[hero.type] = temp
end
end
cheat["pvph"] = cheat["pvpc"]
cheat["act_battle"] = cheat["pvpc"]
cheat[battleType]()
local status = checkOneCheat(clientInfo.selfAttr, selfTeamServer, clientInfo.enemyAttr, enemyServer)
if not status then
-- local cheatCount = self:getProperty("cheatCount")
-- cheatCount = cheatCount + 1
-- self:setProperty("cheatCount", cheatCount)
local result = {clientSelf = {}, serverSelf = {}}
for k , v in pairs(clientInfo.selfAttr) do
result.clientSelf[tostring(k)] = v
end
for k , v in pairs(selfTeamServer) do
result.serverSelf[tostring(k)] = v
end
result = json.encode(result)
self:mylog("cheat", {desc = battleType, int1 = 1, text1 = result})
-- for _, v in ipairs(globalCsv.cheat_check) do
-- if cheatCount == v[1] then
-- self:setBan(v[2] / 86400, 5)
-- break
-- end
-- end
end
return true
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").heros) 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:getTeamFormatByType(TeamSystemType.Tower)
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:getTeamFormatByType(TeamSystemType.BonusBattle)
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["bonus_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,
act_battle = function()
for slot, hero in pairs(self:getTeamHerosInfo(params).heros) do
selflist[slot] = hero.type
end
heroscore = self:getTeamBattleValue(params.heros)
for slot , one in pairs(params.supports) do
teamskill[one[1]] = one[2]
end
local carbonData = params.cfg
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").heros) 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) 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.heros) 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) 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 = params.star or 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
return RoleBattle