fa565e0c
zhouhaihai
优化结构
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
-- 跨越 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"),
|
e9bfa7a2
liuzujun
其他玩家展示界面数据支持, 更新s...
|
14
15
16
|
battleV = self.getProperty("friendTeam").v or 0,
--battleV = self:getProperty("pvpTBVC") ~= 0 and self:getProperty("pvpTBVC") or self:getProperty("hangTBV")
|
fa565e0c
zhouhaihai
优化结构
|
17
18
19
20
21
22
23
|
}
return info
end
-- 好友详细队伍信息
function Role:friendInfo()
local info = self:friendSInfo()
|
e9bfa7a2
liuzujun
其他玩家展示界面数据支持, 更新s...
|
24
25
26
27
28
29
30
|
--local team = self:getProperty("pvpTBVC") ~= 0 and self:getProperty("pvpTSC") or self:getProperty("hangTS")
--info.team = team
info.team = self:getProperty("friendTeam").team or {}
info.heroCnt = self:getProperty("heroCnt")
info.achieveCnt = table.numbers(self:getProperty("achiveV"))
info.bgId = self:getProperty("bgId")
info.hangPass = self:getProperty("hangPass")
|
fa565e0c
zhouhaihai
优化结构
|
31
32
33
|
return info
end
|
6136eaca
liuzujun
添加好友表
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
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
优化结构
|
48
49
50
51
52
|
-- 好友队伍战斗信息
function Role:friendBattleInfo()
return self:getProperty("pvpTBVC") ~= 0 and self:getProperty("pvpTBC") or self:getProperty("hangTB")
end
|
4cf74232
zhouhaihai
pvp
|
53
54
|
-- pvp 数据
function Role:pvpCInfo()
|
fa565e0c
zhouhaihai
优化结构
|
55
56
57
58
|
local info = {
name = self:getProperty("name"),
level = self:getProperty("level"),
headId = self:getProperty("headId"),
|
fa565e0c
zhouhaihai
优化结构
|
59
|
battleV = self:getProperty("pvpTBVC"),
|
821e2704
zhouhaihai
heros 增加 supports
|
60
|
team = self:getProperty("pvpTSC"),
|
4cf74232
zhouhaihai
pvp
|
61
|
battleInfo = self:getProperty("pvpTBC")
|
fa565e0c
zhouhaihai
优化结构
|
62
63
64
65
|
}
return info
end
|
4c5d72ab
zhouhaihai
高级pvp
|
66
67
68
69
70
71
72
|
-- 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
|
73
|
team = self:getProperty("pvpTSH"),
|
4c5d72ab
zhouhaihai
高级pvp
|
74
75
76
77
78
|
battleInfo = self:getProperty("pvpTBH")
}
return info
end
|
cfd68b3a
zhouhaihai
时间重置 新逻辑
|
79
80
81
82
83
84
85
86
87
88
89
90
|
-- 高级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
主推红点 和冒险次数
|
91
92
93
94
95
96
97
98
99
|
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
添加 测试账号 方法
|
100
101
102
103
104
105
|
function Role:accountInit(initData)
-- 道具
local reward = {}
for k , v in pairs(initData.items or {}) do
reward[tonumber(k)] = v
end
|
3133cb76
zhouhaihai
日志
|
106
|
self:award(reward, {log = {desc = "gm"}})
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
-- 英雄
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
日志
|
128
|
status, hero = self:addHero({type = heroId, log = {desc = "gm"}})
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
129
130
131
132
133
134
135
|
else
status = true
end
if status then
local rune = ""
for slot , runeId in pairs(initData.heros.rune) do
slot = tonumber(slot)
|
3133cb76
zhouhaihai
日志
|
136
|
local status, rune_ = self:addRune({type = slot, id = runeId, log = {desc = "gm"}})
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
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
|
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
添加 测试账号 方法
|
177
178
179
180
|
local addPre
addPre = function(carbonId)
local carbonData = csvdb["idle_battleCsv"][carbonId]
for _, pre in ipairs(carbonData.prepose:toArray(true, "=")) do
|
33be3111
zhouhaihai
修改hangPass 结构
|
181
|
self:checkHangPass(pre)
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
182
183
184
185
|
self:checkTaskEnter("HangPass", {id = pre})
addPre(pre)
end
end
|
33be3111
zhouhaihai
修改hangPass 结构
|
186
|
self:checkHangPass(carbonId)
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
187
|
addPre(carbonId)
|
c7ecb87f
zhouhaihai
添加 测试账号 方法
|
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
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
优化结构
|
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
|
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
添加好友表
|
255
256
257
|
local tb = {}
tb[field] = value
return CMD.setProperties(roleId, tb)
|
fa565e0c
zhouhaihai
优化结构
|
258
259
260
261
|
end
function CMD.setProperties(roleId, fields)
|
6136eaca
liuzujun
添加好友表
|
262
263
|
local role = require("models.Role").new({key = string.format("%s",roleId), id = roleId})
return role:updateFields(fields)
|
fa565e0c
zhouhaihai
优化结构
|
264
265
266
|
end
function CMD.getProperty(roleId, field)
|
6136eaca
liuzujun
添加好友表
|
267
268
|
local ret = CMD.getProperties(roleId, {field})
return ret[field]
|
fa565e0c
zhouhaihai
优化结构
|
269
270
271
|
end
function CMD.getProperties(roleId, fields)
|
6136eaca
liuzujun
添加好友表
|
272
|
local role = require("models.Role").new({key = string.format("%s",roleId), id = roleId})
|
fa565e0c
zhouhaihai
优化结构
|
273
|
local ret = {}
|
6136eaca
liuzujun
添加好友表
|
274
275
276
277
278
|
local datas = role:loadFields(fields)
if datas then
for index, key in ipairs(fields) do
ret[key] = unpackRoleField(key, datas[key])
end
|
fa565e0c
zhouhaihai
优化结构
|
279
280
281
282
283
|
end
return ret
end
function CMD.friendSInfo(roleId)
|
e9bfa7a2
liuzujun
其他玩家展示界面数据支持, 更新s...
|
284
285
|
--local info = CMD.getProperties(roleId, {"name", "level", "headId", "ltime", "pvpTBVC", "hangTBV"})
local info = CMD.getProperties(roleId, {"name", "level", "headId", "ltime", "friendTeam"})
|
fa565e0c
zhouhaihai
优化结构
|
286
287
288
289
290
|
return {
name = info.name,
level = info.level,
headId = info.headId,
ltime = info.ltime,
|
e9bfa7a2
liuzujun
其他玩家展示界面数据支持, 更新s...
|
291
292
|
--battleV = info.pvpTBVC ~= 0 and info.pvpTBVC or info.hangTBV,
battleV = info.friendTeam.v or 0,
|
fa565e0c
zhouhaihai
优化结构
|
293
294
295
296
|
}
end
function CMD.friendInfo(roleId)
|
e9bfa7a2
liuzujun
其他玩家展示界面数据支持, 更新s...
|
297
298
|
--local info = CMD.getProperties(roleId, {"name", "level", "headId", "ltime", "pvpTBVC", "hangTBV", "pvpTSC", "hangTS"})
local info = CMD.getProperties(roleId, {"name", "level", "headId", "ltime", "friendTeam", "heroCnt", "achiveV", "bgId", "hangPass"})
|
fa565e0c
zhouhaihai
优化结构
|
299
300
301
302
303
|
return {
name = info.name,
level = info.level,
headId = info.headId,
ltime = info.ltime,
|
e9bfa7a2
liuzujun
其他玩家展示界面数据支持, 更新s...
|
304
305
306
307
308
309
310
311
|
--battleV = info.pvpTBVC ~= 0 and info.pvpTBVC or info.hangTBV,
--team = info.pvpTBVC ~= 0 and info.pvpTSC or info.hangTS
battleV = info.friendTeam.v or 0,
team = info.friendTeam.team or {},
heroCnt = info.heroCnt,
achieveCnt = table.numbers(info.achiveV),
bgId = info.bgId,
hangPass = info.hangPass,
|
fa565e0c
zhouhaihai
优化结构
|
312
313
314
315
|
}
end
function CMD.friendBattleInfo(roleId)
|
e9bfa7a2
liuzujun
其他玩家展示界面数据支持, 更新s...
|
316
317
318
319
|
--local info = CMD.getProperties(roleId, {"pvpTBC", "hangTB"})
local info = CMD.getProperties(roleId, {"friendTeam"})
--return (next(info.pvpTBC) and next(info.pvpTBC.heros)) and info.pvpTBC or info.hangTB
return info.friendTeam.bInfo or {}
|
fa565e0c
zhouhaihai
优化结构
|
320
321
|
end
|
4cf74232
zhouhaihai
pvp
|
322
323
|
function CMD.pvpCInfo(roleId)
local info = CMD.getProperties(roleId, {"name", "level", "headId", "pvpTBVC", "pvpTSC", "pvpTBC"})
|
fa565e0c
zhouhaihai
优化结构
|
324
325
326
327
328
|
return {
name = info.name,
level = info.level,
headId = info.headId,
battleV = info.pvpTBVC,
|
821e2704
zhouhaihai
heros 增加 supports
|
329
|
team = info.pvpTSC,
|
4cf74232
zhouhaihai
pvp
|
330
|
battleInfo = info.pvpTBC
|
fa565e0c
zhouhaihai
优化结构
|
331
332
333
|
}
end
|
4c5d72ab
zhouhaihai
高级pvp
|
334
335
336
337
338
339
340
|
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
|
341
|
team = info.pvpTSH,
|
4c5d72ab
zhouhaihai
高级pvp
|
342
343
344
345
|
battleInfo = info.pvpTBH
}
end
|
cfd68b3a
zhouhaihai
时间重置 新逻辑
|
346
|
-- 高级pvp 排行榜
|
f66cfba4
zhouhaihai
改为点
|
347
|
function CMD.pvpHRankInfo(roleId)
|
cfd68b3a
zhouhaihai
时间重置 新逻辑
|
348
349
350
351
352
353
354
355
356
357
358
|
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
主推红点 和冒险次数
|
359
360
361
362
363
364
365
366
367
368
|
-- 记录红点
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
优化结构
|
369
370
371
372
373
374
375
376
|
RoleCross.handle = function(cmd, roleId, ...)
SRole = SRole or require("models.Role")
if CMD[cmd] then
return CMD[cmd](roleId, ...)
end
end
return RoleCross
|