Role.lua
11.7 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
local Role = class("Role", require("shared.ModelBase"))
local RolePlugin = import(".RolePlugin")
local RoleTask = import(".RoleTask")
local RoleActivity = import(".RoleActivity")
local RoleChangeStruct = import(".RoleChangeStruct")
local RolePvp = import(".RolePvp")
local RoleCross = import(".RoleCross")
RolePlugin.bind(Role)
RoleTask.bind(Role)
RoleActivity.bind(Role)
RoleChangeStruct.bind(Role)
RolePvp.bind(Role)
RoleCross.bind(Role)
function Role:ctor( properties )
Role.super.ctor(self, properties)
self.ignoreHeartbeat = false
self.dailyData = nil
self.heros = {}
self.runeBag = {}
self.advData = nil
self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节
self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳
end
Role.schema = {
id = {"number"},
uid = {"string", ""},
name = {"string", ""},
intro = {"string", ""},
headId = {"number", globalCsv.defaultHead},
sid = {"number", 0},
device = {"string", ""},
banTime = {"number", 0},
banType = {"number", 0},
ltime = {"number", 0}, -- 最后登录时间
ctime = {"number", skynet.timex()}, -- 创建时间
ignoreMt = {"number", 0}, -- 忽略维护拦截
sversion = {"number", globalCsv.StructVersion or 0}, -- 重整数据版本
diamond = {"number", 0},
reDiamond = {"number", 0},
setting = {"table", {}}, --设置
codeStr = {"string", ""}, --已经领过的礼包码
-- roleInfo
level = {"number", 1},
exp = {"number", 0},
items = {"string", ""},
funcOpen = {"table", {}}, --功能是否开放
funcLv = {"table", {}}, --功能等级
-- loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL
crown = {"number", 0}, -- 看伴娘
silent = {"number", 0}, --禁言解禁时间
bagLimit = {"table", globalCsv.store_limit_max},
--冒险相关
advPass = {"table", {}}, -- 通关记录 {chapterId = layer}
advItems = {"string", ""}, -- 冒险临时背包
advInfo = {"table", {}}, -- 冒险关卡信息
advTeam = {"table", {}}, -- 冒险玩家队伍信息
advHang = {"table", {}}, -- 挂机信息 -- {chapterId = {format = teaminfo, time = endtime}}
advTask = {"table", {}}, -- 冒险已领取任务完成状态 {id = status} --每层重置
advMTask = {"table", {id = 1, status = 0, lock = true}}, -- 冒险主线任务 -- {id = id, status = status, lock = true} -- 当前主线id 当前主线状态 是否锁定状态
advAchiev = {"table", {}}, -- 冒险成就 {chapterId = {achievId = status, -1 = pt, pts = {}}, }
advL = {"table", {0, 0}}, -- 冒险队等级 {lv, exp}
advElM = {"number", 0}, -- 无尽模式通关的最高层数 endless max layer
advElS = {"number", 0}, -- 无尽模式记录的赛季 endless season
advAFOpen = {"table", {}}, -- 解锁的神器 {[id] = 1}
advAFGet = {"table", {}}, -- 当前拥有的神器 {[id] = 等级}
advAFWear = {"table", {}}, -- 当前拥有的神器 {[slot] = id}
advDrawB = {"table", {}}, -- 冒险抽奖回馈 {[1] = 0, [2] = 100} -- 池子类型 = 点数
advStoryB = {"table", {}}, -- 冒险故事完成记录 (连锁事件绑定的故事) -- {storyId = 1}
advShop = {"table", {}}, -- 冒险內的商店限制购买次数记录 {goodId = count}
advEAchiev = {"table", {}}, -- 冒险无尽冒险手册
advRelay = {"table", {}}, -- 冒险中继点记录 {[chapter] = {[level] = 1}, [-1] = {[level] = 1}} -- -1 无尽 方便重置
advSup = {"table", {}}, -- 冒险支援效果 待选项
--挂机相关
hangPass = {"table", {}}, -- 挂机通过的最大关卡
hangTeam = {"table", {}}, -- 挂机队伍
hangTS = {"table", {}}, -- 挂机队伍他人可读的队伍信息
hangTB = {"table", {}}, -- 挂机队伍他人可用的战斗信息mao
hangTBV = {"number", 0}, -- 挂机队伍他人可用的战斗力
hangInfo = {"table", {}}, -- 当前挂机信息
hangBag = {"table", {}}, -- 背包
hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限
bTeam = {"table", {}}, -- 奖励副本队伍
--引导相关
newerGuide = {"string","1=1"}, -- 新手引导 master=slave
funcGuide = {"string",""}, -- 功能引导 0=0跳过次数(999永久跳过) 1=1功能1触发情况
pvpTC = {"table", {}}, -- pvp 编队普通
pvpTSC = {"table", {}}, -- pvp 他人可读的队伍信息
pvpTBC = {"table", {}}, -- pvp 他人可用的战斗信息
pvpTBVC = {"number", 0}, -- pvp 他人可用的战斗力
pvpMC = {"table", {}}, -- pvp 匹配的对手 普通 {{t = 1, id = roleId}, {t = 2, id = id}, {t = 2, id = id}} -- t 1 玩家 2 机器人
pvpTH = {"table", {}}, -- pvp 编队高级
pvpTSH = {"table", {}}, -- pvp 他人可读的队伍信息
pvpTBH = {"table", {}}, -- pvp 他人可用的战斗信息
pvpTBVH = {"table", {}}, -- pvp 他人可用的战斗力
pvpMH = {"table", {}}, -- pvp 匹配的对手 高级 {{t = 1, id = roleId}, {t = 2, id = id}, {t = 2, id = id}} -- t 1 玩家 2 机器人
potionBag = {"table", {}}, -- 营养剂背包
storyB = {"table", {}}, -- 剧情记录
equips = {"table", {}}, -- 装备简化下, 目前的设计足够支撑 -- {t = {l = c}} -- 接口设计好 底层扩展就重写~
boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}}
towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey}
towerF = {"table", {}}, -- 爬塔阵容
spTask = {"table", {}}, -- 特殊任务 -- {id = status}
dTask = {"table", {}}, -- 每日任务 {t = {id = status}, a = 0, at = {id = status}} t 任务完成情况 a 获得的活跃数值 at 活跃任务完成情况
wTask = {"table", {}}, -- 每周任务 {t = {id = status}, a = 0, at = {id = status}} t 任务完成情况 a 获得的活跃数值 at 活跃任务完成情况
achiveT = {"table", {}}, -- 成就计数统计 achivement_type {id = status}
achiveV = {"table", {}}, -- 成就领奖统计 achivement {id = status}
rechargeF = {"table", {}}, -- 是否首次充值某一项 -- —{[id] = 1} -- 不存在就是没有充值过
dinerS = {"table", {}}, -- 美食币商城 购买记录 {[id] = count}
rmbC = {"number", 0}, -- 人民币重置额
emailSync = {"number", 0}, -- 已经同步到的邮件Id
repayHero = {"number", 0}, -- 超级招募 回馈
floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count}
}
function Role:notifyUpdateProperty(field, newValue, oldValue, extraValue)
local updateData = {
{
key = field,
newValue = newValue,
oldValue = oldValue or "",
extraValue = extraValue,
}
}
SendPacket(actionCodes.Role_updateProperty, MsgPack.pack(updateData))
end
function Role:updateProperty(params)
params = params or {}
if not self.schema[params.field] then return end
local oldValue = self:getProperty(params.field)
local ret = {key = params.field, oldValue = oldValue}
if params.value then
ret.newValue = params.value
self:setProperty(params.field, params.value)
elseif params.delta then
self:incrProperty(params.field, params.delta)
ret.newValue = self:getProperty(params.field)
else
return
end
if not params.notNotify then
SendPacket(actionCodes.Role_updateProperty, MsgPack.pack({ret}))
end
end
function Role:updateProperties(params, notNotify)
self:setProperties(params)
if not notNotify then
SendPacket(actionCodes.Role_updateProperties, MsgPack.pack(params))
end
end
function Role:notifyUpdateProperties(params)
SendPacket(actionCodes.Role_updateProperties, MsgPack.pack(params))
end
-- 某些字段 更新改变量 改变量的定义由字段自身决定 {{type = ""}, }
function Role:changeUpdates(params, notNotify)
local changeUpdateFunc = {
-- ["loveStatus"] = function(info)
-- self:setProperty("loveStatus", self:getProperty("loveStatus"):setv(info["field"], info["value"]))
-- return {type = "loveStatus", field = info["field"], value = info["value"]}
-- end,
--table 类型通用更新
["tableCommon"] = function(fieldType, info)
if self.class.schema[fieldType][1] ~= "table" then
error("[ERROR:] need handler for changeUpdate, field : " .. fieldType)
return
end
--支持多深度单字段
local curValue = self:getProperty(fieldType)
if type(info["field"]) == "table" then
for _idx, _field in ipairs(info["field"]) do
if _idx < #info["field"] then
curValue[_field] = curValue[_field] or {}
curValue = curValue[_field]
else
curValue[_field] = info["value"]
end
end
else
curValue[info["field"]] = info["value"]
end
self:setProperty(fieldType)
return {type = fieldType, field = info["field"], value = info["value"]}
end,
["onlyToC"] = function(info)
return info
end,
}
local updates = {}
for _, one in ipairs(params) do
if changeUpdateFunc[one["type"]] then
table.insert(updates, changeUpdateFunc[one["type"]](one))
elseif one.isOnlyToC then
one.isOnlyToC = nil
table.insert(updates, one)
else
table.insert(updates, changeUpdateFunc["tableCommon"](one["type"], one))
end
end
if not notNotify and next(updates) then
SendPacket(actionCodes.Role_changeUpdate, MsgPack.pack(updates))
end
end
function Role:data()
return {
id = self:getProperty("id"),
name = self:getProperty("name"),
intro = self:getProperty("intro"),
headId = self:getProperty("headId"),
setting = self:getProperty("setting"),
level = self:getProperty("level"),
exp = self:getProperty("exp"),
items = self:getProperty("items"):toNumMap(),
funcOpen = self:getProperty("funcOpen"),
funcLv = self:getProperty("funcLv"),
-- loveStatus = self:getProperty("loveStatus"):toNumMap(),
diamond = self:getAllDiamond(),
bagLimit = self:getProperty("bagLimit"),
silent = self:getProperty("silent"),
advPass = self:getProperty("advPass"),
advInfo = self:getProperty("advInfo"),
advItems = self:getProperty("advItems"):toNumMap(),
advTeam = self:getProperty("advTeam"),
advHang = self:getProperty("advHang"),
advTask = self:getProperty("advTask"),
advMTask = self:getProperty("advMTask"),
advAchiev = self:getProperty("advAchiev"),
advL = self:getProperty("advL"),
advElM = self:getProperty("advElM"),
advElS = self:getProperty("advElS"),
advElChapter = self.advElChapter,
advOverTime = self.advOverTime,
advAFGet = self:getProperty("advAFGet"),
advAFWear = self:getProperty("advAFWear"),
advDrawB = self:getProperty("advDrawB"),
advShop = self:getProperty("advShop"),
advEAchiev = self:getProperty("advEAchiev"),
advSup = self:getProperty("advSup"),
hangPass = self:getProperty("hangPass"),
hangTeam = self:getProperty("hangTeam"),
hangInfo = self:getProperty("hangInfo"),
hangBag = self:getProperty("hangBag"),
hangBagLimit = self:getProperty("hangBagLimit"),
bTeam = self:getProperty("bTeam"),
newerGuide = self:getProperty("newerGuide"),
funcGuide = self:getProperty("funcGuide"),
pvpTC = self:getProperty("pvpTC"),
pvpTH = self:getProperty("pvpTH"),
potionBag = self:getProperty("potionBag"),
storyB = self:getProperty("storyB"),
equips = self:getProperty("equips"),
boxL = self:getProperty("boxL"),
towerInfo = self:getProperty("towerInfo"),
towerF = self:getProperty("towerF"),
spTask = self:getProperty("spTask"),
dTask = self:getProperty("dTask"),
wTask = self:getProperty("wTask"),
achiveT = self:getProperty("achiveT"),
achiveV = self:getProperty("achiveV"),
rechargeF = self:getProperty("rechargeF"),
dinerS = self:getProperty("dinerS"),
rmbC = self:getProperty("rmbC"),
repayHero = self:getProperty("repayHero"),
floorHero = self:getProperty("floorHero"),
}
end
return Role