fa565e0c
zhouhaihai
优化结构
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
-- 跨越 agent 获取数据使用
local RoleCross = {}
--*********************************** agent 存在时调用 ****************************************--
RoleCross.bind = function (Role)
-- 好友列表简约信息
function Role:friendSInfo()
local info = {
name = self:getProperty("name"),
level = self:getProperty("level"),
headId = self:getProperty("headId"),
ltime = self:getProperty("ltime"),
battleV = self:getProperty("pvpTBVC") ~= 0 and self:getProperty("pvpTBVC") or self:getProperty("hangTBV")
}
return info
end
-- 好友详细队伍信息
function Role:friendInfo()
local info = self:friendSInfo()
|
2b31c43f
zhouhaihai
bug
|
22
23
|
local team = self:getProperty("pvpTBVC") ~= 0 and self:getProperty("pvpTSC") or self:getProperty("hangTS")
info.team = team
|
fa565e0c
zhouhaihai
优化结构
|
24
25
26
|
return info
end
|
6136eaca
liuzujun
添加好友表
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
function Role:addFriend(friendId)
local res = mysqlproxy:query(string.format("SELECT * FROM `Friend` WHERE `roleid` = %s AND `fid` = %s;", self:getProperty("id"), friendId))
for _, data in ipairs(res) do
local friend = require("models.Friend").new({key = string.format("%d",data.id), id = data.id})
if friend:load(data) then
self.friends[friend:getProperty("fid")] = friend
end
end
end
function Role:delFriend(friendId)
self.friends[friendId] = nil
end
|
fa565e0c
zhouhaihai
优化结构
|
41
42
43
44
45
|
-- 好友队伍战斗信息
function Role:friendBattleInfo()
return self:getProperty("pvpTBVC") ~= 0 and self:getProperty("pvpTBC") or self:getProperty("hangTB")
end
|
4cf74232
zhouhaihai
pvp
|
46
47
|
-- pvp 数据
function Role:pvpCInfo()
|
fa565e0c
zhouhaihai
优化结构
|
48
49
50
51
|
local info = {
name = self:getProperty("name"),
level = self:getProperty("level"),
headId = self:getProperty("headId"),
|
fa565e0c
zhouhaihai
优化结构
|
52
|
battleV = self:getProperty("pvpTBVC"),
|
821e2704
zhouhaihai
heros 增加 supports
|
53
|
team = self:getProperty("pvpTSC"),
|
4cf74232
zhouhaihai
pvp
|
54
|
battleInfo = self:getProperty("pvpTBC")
|
fa565e0c
zhouhaihai
优化结构
|
55
56
57
58
|
}
return info
end
|
4c5d72ab
zhouhaihai
高级pvp
|
59
60
61
62
63
64
65
|
-- pvp 数据
function Role:pvpHInfo()
local info = {
name = self:getProperty("name"),
level = self:getProperty("level"),
headId = self:getProperty("headId"),
battleV = self:getProperty("pvpTBVH"),
|
821e2704
zhouhaihai
heros 增加 supports
|
66
|
team = self:getProperty("pvpTSH"),
|
4c5d72ab
zhouhaihai
高级pvp
|
67
68
69
70
71
|
battleInfo = self:getProperty("pvpTBH")
}
return info
end
|
cfd68b3a
zhouhaihai
时间重置 新逻辑
|
72
73
74
75
76
77
78
79
80
81
82
83
|
-- 高级pvp 排行榜
function Role:pvpHRankInfo()
local info = {
name = self:getProperty("name"),
level = self:getProperty("level"),
headId = self:getProperty("headId"),
ltime = self:getProperty("ltime"),
battleV = self:getProperty("pvpTBVH"),
}
return info
end
|
9cede2e2
zhouhaihai
主推红点 和冒险次数
|
84
85
86
87
88
89
90
91
92
|
function Role:redPTag(tag, pms)
pms = pms or 1
local redp = self:getProperty("redp")
if not redp[tag] or redp[tag] ~= pms then
redp[tag] = pms
self:updateProperty({field = "redp", value = redp})
end
end
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
93
94
95
96
97
98
|
function Role:accountInit(initData)
-- 道具
local reward = {}
for k , v in pairs(initData.items or {}) do
reward[tonumber(k)] = v
end
|
3133cb76
zhouhaihai
日志
|
99
|
self:award(reward, {log = {desc = "gm"}})
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
-- 英雄
local breakL = 0
for i = 0, #csvdb["unit_breakCsv"] do
if initData.heros.level >= csvdb["unit_breakCsv"][i].levelLimit then
breakL = i
else
break
end
end
local equip = ""
for slot, equipId in pairs(initData.heros.equip) do
equip = equip:setv(slot, equipId)
end
for _, heroId in ipairs(initData.heros.ids) do
local hero = self:isHaveHero(heroId)
local status
if not hero then
|
3133cb76
zhouhaihai
日志
|
121
|
status, hero = self:addHero({type = heroId, log = {desc = "gm"}})
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
122
123
124
125
126
127
128
|
else
status = true
end
if status then
local rune = ""
for slot , runeId in pairs(initData.heros.rune) do
slot = tonumber(slot)
|
3133cb76
zhouhaihai
日志
|
129
|
local status, rune_ = self:addRune({type = slot, id = runeId, log = {desc = "gm"}})
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
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
|
if status == 0 then
rune = rune:setv(slot, rune_:getProperty("uid"))
if initData.heros.runeL and initData.heros.runeL > 0 then
rune_:updateProperty({field = "level",value = initData.heros.runeL})
end
rune_:updateProperty({field = "refer",value = hero:getProperty("id")})
end
end
local talent = ""
if initData.heros.talent and initData.heros.talent > 0 then
talent = talent:setv(0, initData.heros.talent)
local talentData = csvdb["unit_talentCsv"][initData.heros.talent]
for i = 1, 4 do
talent = talent:setv(i, #talentData)
end
end
local aheadLevel = 0
for i = 1, initData.heros.talent - 1 do
aheadLevel = aheadLevel + #csvdb["unit_talentCsv"][i]
end
aheadLevel = aheadLevel + talent:getv(1, 0)
hero:updateProperties({
level = initData.heros.level,
breakL = breakL,
wakeL = initData.heros.wakeL,
talent = talent,
equip = equip,
rune = rune,
})
self:checkTaskEnter("Wake", {heroType = heroId, wakeL = initData.heros.wakeL})
self:checkTaskEnter("WakeCG", {heroType = heroId})
self:checkTaskEnter("HeroTalent", {heroType = heroId, alv = aheadLevel})
end
end
self:checkTaskEnter("HeroLevelUp", {level = initData.heros.level})
-- fb
local carbonId = initData.fb
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
170
171
172
173
|
local addPre
addPre = function(carbonId)
local carbonData = csvdb["idle_battleCsv"][carbonId]
for _, pre in ipairs(carbonData.prepose:toArray(true, "=")) do
|
33be3111
zhouhaihai
修改hangPass 结构
|
174
|
self:checkHangPass(pre)
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
175
176
177
178
|
self:checkTaskEnter("HangPass", {id = pre})
addPre(pre)
end
end
|
33be3111
zhouhaihai
修改hangPass 结构
|
179
|
self:checkHangPass(carbonId)
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
180
|
addPre(carbonId)
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
self:checkTaskEnter("HangPass", {id = carbonId})
-- talent
if initData.talent and initData.talent > 0 then
local dishTree = self.dinerData:getProperty("dishTree")
for _, v in pairs(csvdb["diner_treeCsv"]) do
for id, _ in pairs(v) do
dishTree = dishTree:setv(id, initData.talent)
end
end
self.dinerData:updateProperty({field = "dishTree", value = dishTree})
end
-- diner
if initData.diner and initData.diner > 0 then
local buildL = self.dinerData:getProperty("buildL")
for typ, _ in pairs(csvdb["diner_buildingCsv"]) do
buildL = buildL:setv(typ, initData.diner)
end
self.dinerData:updateProperty({field = "buildL", value = buildL})
end
return "成功"
end
|
fa565e0c
zhouhaihai
优化结构
|
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
|
end
--*********************************** agent 不存在时调用 ***************************************--
local CMD = {}
local SRole
local function unpackRoleField(field, value)
if not SRole.schema[field] then
return nil
end
local typ, def = table.unpack(SRole.schema[field])
if typ == "number" then
value = tonumber(value or def)
elseif typ == "table" then
if type(value) == "string" then
value = MsgPack.unpack(value)
else
value = def
end
end
return value
end
local function packRoleField(field, value)
if not SRole.schema[field] then
return nil
end
local typ, def = table.unpack(SRole.schema[field])
if typ == "table" then
if type(value) == "table" then
value = MsgPack.pack(value)
end
end
return value
end
local function getRoleKey(roleId)
return string.format("role:%d", roleId)
end
function CMD.setProperty(roleId, field, value)
|
6136eaca
liuzujun
添加好友表
|
248
249
250
|
local tb = {}
tb[field] = value
return CMD.setProperties(roleId, tb)
|
fa565e0c
zhouhaihai
优化结构
|
251
252
253
254
|
end
function CMD.setProperties(roleId, fields)
|
6136eaca
liuzujun
添加好友表
|
255
256
|
local role = require("models.Role").new({key = string.format("%s",roleId), id = roleId})
return role:updateFields(fields)
|
fa565e0c
zhouhaihai
优化结构
|
257
258
259
|
end
function CMD.getProperty(roleId, field)
|
6136eaca
liuzujun
添加好友表
|
260
261
|
local ret = CMD.getProperties(roleId, {field})
return ret[field]
|
fa565e0c
zhouhaihai
优化结构
|
262
263
264
|
end
function CMD.getProperties(roleId, fields)
|
6136eaca
liuzujun
添加好友表
|
265
|
local role = require("models.Role").new({key = string.format("%s",roleId), id = roleId})
|
fa565e0c
zhouhaihai
优化结构
|
266
|
local ret = {}
|
6136eaca
liuzujun
添加好友表
|
267
268
269
270
271
|
local datas = role:loadFields(fields)
if datas then
for index, key in ipairs(fields) do
ret[key] = unpackRoleField(key, datas[key])
end
|
fa565e0c
zhouhaihai
优化结构
|
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
end
return ret
end
function CMD.friendSInfo(roleId)
local info = CMD.getProperties(roleId, {"name", "level", "headId", "ltime", "pvpTBVC", "hangTBV"})
return {
name = info.name,
level = info.level,
headId = info.headId,
ltime = info.ltime,
battleV = info.pvpTBVC ~= 0 and info.pvpTBVC or info.hangTBV,
}
end
function CMD.friendInfo(roleId)
local info = CMD.getProperties(roleId, {"name", "level", "headId", "ltime", "pvpTBVC", "hangTBV", "pvpTSC", "hangTS"})
return {
name = info.name,
level = info.level,
headId = info.headId,
ltime = info.ltime,
battleV = info.pvpTBVC ~= 0 and info.pvpTBVC or info.hangTBV,
|
821e2704
zhouhaihai
heros 增加 supports
|
295
|
team = info.pvpTBVC ~= 0 and info.pvpTSC or info.hangTS
|
fa565e0c
zhouhaihai
优化结构
|
296
297
298
299
300
|
}
end
function CMD.friendBattleInfo(roleId)
local info = CMD.getProperties(roleId, {"pvpTBC", "hangTB"})
|
7420a951
zhouhaihai
好友 无阵容 bug
|
301
|
return (next(info.pvpTBC) and next(info.pvpTBC.heros)) and info.pvpTBC or info.hangTB
|
fa565e0c
zhouhaihai
优化结构
|
302
303
|
end
|
4cf74232
zhouhaihai
pvp
|
304
305
|
function CMD.pvpCInfo(roleId)
local info = CMD.getProperties(roleId, {"name", "level", "headId", "pvpTBVC", "pvpTSC", "pvpTBC"})
|
fa565e0c
zhouhaihai
优化结构
|
306
307
308
309
310
|
return {
name = info.name,
level = info.level,
headId = info.headId,
battleV = info.pvpTBVC,
|
821e2704
zhouhaihai
heros 增加 supports
|
311
|
team = info.pvpTSC,
|
4cf74232
zhouhaihai
pvp
|
312
|
battleInfo = info.pvpTBC
|
fa565e0c
zhouhaihai
优化结构
|
313
314
315
|
}
end
|
4c5d72ab
zhouhaihai
高级pvp
|
316
317
318
319
320
321
322
|
function CMD.pvpHInfo(roleId)
local info = CMD.getProperties(roleId, {"name", "level", "headId", "pvpTBVH", "pvpTSH", "pvpTBH"})
return {
name = info.name,
level = info.level,
headId = info.headId,
battleV = info.pvpTBVH,
|
821e2704
zhouhaihai
heros 增加 supports
|
323
|
team = info.pvpTSH,
|
4c5d72ab
zhouhaihai
高级pvp
|
324
325
326
327
|
battleInfo = info.pvpTBH
}
end
|
cfd68b3a
zhouhaihai
时间重置 新逻辑
|
328
|
-- 高级pvp 排行榜
|
f66cfba4
zhouhaihai
改为点
|
329
|
function CMD.pvpHRankInfo(roleId)
|
cfd68b3a
zhouhaihai
时间重置 新逻辑
|
330
331
332
333
334
335
336
337
338
339
340
|
local info = CMD.getProperties(roleId, {"name", "level", "headId", "pvpTBVH", "ltime"})
local info = {
name = info.name,
level = info.level,
headId = info.headId,
ltime = info.ltime,
battleV = info.pvpTBVH,
}
return info
end
|
9cede2e2
zhouhaihai
主推红点 和冒险次数
|
341
342
343
344
345
346
347
348
349
350
|
-- 记录红点
function CMD.redPTag(roleId, tag, pms)
pms = pms or 1
local redp = CMD.getProperty(roleId, "redp")
if not redp[tag] or redp[tag] ~= pms then
redp[tag] = pms
CMD.setProperty(roleId, "redp", redp)
end
end
|
fa565e0c
zhouhaihai
优化结构
|
351
352
353
354
355
356
357
358
|
RoleCross.handle = function(cmd, roleId, ...)
SRole = SRole or require("models.Role")
if CMD[cmd] then
return CMD[cmd](roleId, ...)
end
end
return RoleCross
|