314bc5df
zhengshouren
提交服务器初始代码
|
1
2
|
local Role = class("Role", require("shared.ModelBase"))
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
3
4
|
local RolePlugin = import(".RolePlugin")
local RoleTask = import(".RoleTask")
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
5
6
7
8
|
local RoleActivity = import(".RoleActivity")
local RoleChangeStruct = import(".RoleChangeStruct")
RolePlugin.bind(Role)
RoleTask.bind(Role)
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
9
10
11
|
RoleActivity.bind(Role)
RoleChangeStruct.bind(Role)
|
314bc5df
zhengshouren
提交服务器初始代码
|
12
13
|
function Role:ctor( properties )
Role.super.ctor(self, properties)
|
314bc5df
zhengshouren
提交服务器初始代码
|
14
|
self.ignoreHeartbeat = false
|
09be9059
zhouhaihai
冒险接口
|
15
|
self.dailyData = nil
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
16
|
self.heros = {}
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
17
|
self.runeBag = {}
|
46fac6f1
zhouahaihai
酱料
|
18
|
self.advData = nil
|
314bc5df
zhengshouren
提交服务器初始代码
|
19
20
21
|
end
Role.schema = {
|
314bc5df
zhengshouren
提交服务器初始代码
|
22
23
|
id = {"number"},
uid = {"string", ""},
|
314bc5df
zhengshouren
提交服务器初始代码
|
24
|
name = {"string", ""},
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
25
26
27
28
|
sid = {"number", 0},
device = {"string", ""},
banTime = {"number", 0},
banType = {"number", 0},
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
29
30
31
32
|
ltime = {"number", 0}, -- 最后登录时间
ctime = {"number", skynet.timex()}, -- 创建时间
ignoreMt = {"number", 0}, -- 忽略维护拦截
sversion = {"number", globalCsv.StructVersion or 0}, -- 重整数据版本
|
312b9db5
zhouahaihai
背包
|
33
34
|
diamond = {"number", 0},
reDiamond = {"number", 0},
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
35
|
-- roleInfo
|
4b7c7c96
zhouahaihai
增加 清空 挂机 冒险gm 角色经验
|
36
37
|
level = {"number", 1},
exp = {"number", 0},
|
6947e382
zhouahaihai
好感度, 皮肤
|
38
|
items = {"string", ""},
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
39
|
funcOpen = {"table", {}}, --功能是否开放
|
bab30666
zhouhaihai
增加通用功能等级 字段
|
40
|
funcLv = {"table", {}}, --功能等级
|
6947e382
zhouahaihai
好感度, 皮肤
|
41
|
loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL
|
37037eeb
zhengshouren
计算奖励
|
42
|
crown = {"number", 0}, -- 看伴娘
|
314bc5df
zhengshouren
提交服务器初始代码
|
43
|
|
312b9db5
zhouahaihai
背包
|
44
45
|
bagLimit = {"table", globalCsv.store_limit_max},
|
23d89d13
zhouahaihai
冒险 结构
|
46
|
--冒险相关
|
3aa11fb9
zhouhaihai
字段类型
|
47
|
advPass = {"table", {}}, -- 通关记录 {chapterId = layer}
|
46fac6f1
zhouahaihai
酱料
|
48
|
advItems = {"string", ""}, -- 冒险临时背包
|
09be9059
zhouhaihai
冒险接口
|
49
|
advInfo = {"table", {}}, -- 冒险关卡信息
|
46fac6f1
zhouahaihai
酱料
|
50
|
advTeam = {"table", {}}, -- 冒险玩家队伍信息
|
3aa11fb9
zhouhaihai
字段类型
|
51
|
advHang = {"table", {}}, -- 挂机信息 -- {chapterId = {format = teaminfo, time = endtime}}
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
52
53
|
advTask = {"table", {}}, -- 冒险已领取任务完成状态 {id = status} --每层重置
advMTask = {"table", {id = 1, status = 0, lock = true}}, -- 冒险主线任务 -- {id = id, status = status, lock = true} -- 当前主线id 当前主线状态 是否锁定状态
|
09be9059
zhouhaihai
冒险接口
|
54
|
advAchiev = {"table", {}}, -- 冒险成就 {chapterId = {achievId = status}}
|
bab30666
zhouhaihai
增加通用功能等级 字段
|
55
|
advL = {"number", 1}, -- 冒险队等级
|
8da953a7
zhouhaihai
无尽模式
|
56
57
|
advElM = {"number", 0}, -- 无尽模式通关的最高层数 endless max layer
advElS = {"number", globalCsv.adv_endless_season}, -- 无尽模式记录的赛季 endless season
|
bab30666
zhouhaihai
增加通用功能等级 字段
|
58
|
|
384bb077
zhouahaihai
挂机
|
59
60
61
62
63
|
--挂机相关
hangPass = {"table", {}}, -- 挂机通过的最大关卡
hangTeam = {"table", {}}, -- 挂机队伍
hangInfo = {"table", {}}, -- 当前挂机信息
hangBag = {"table", {}}, -- 背包
|
9962b061
zhouahaihai
补充 挂机
|
64
|
hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限
|
384bb077
zhouahaihai
挂机
|
65
|
|
dbd0ca58
gaofengduan
car 营养剂制作
|
66
|
potionBag = {"table", {}}, -- 营养剂背包
|
00e663bd
zhouhaihai
剧情相关
|
67
68
|
storyB = {"table", {}}, -- 剧情记录
|
056c01a0
zhouhaihai
简化装备
|
69
70
|
equips = {"table", {}}, -- 装备简化下, 目前的设计足够支撑 -- {t = {l = c}} -- 接口设计好 底层扩展就重写~
|
9b35bf6e
zhouhaihai
开启时间箱
|
71
72
|
boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}}
|
276b1da9
zhouhaihai
爬塔接口
|
73
|
|
ea357636
zhouhaihai
爬塔初始层数
|
74
|
towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey}
|
276b1da9
zhouhaihai
爬塔接口
|
75
|
towerF = {"table", {}}, -- 爬塔阵容
|
314bc5df
zhengshouren
提交服务器初始代码
|
76
77
|
}
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
78
|
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
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 {}
|
23d89d13
zhouahaihai
冒险 结构
|
94
|
if not self.schema[params.field] then return end
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
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
|
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)
for field, value in pairs(params) do
self:setProperty(field, value)
end
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
|
23d89d13
zhouahaihai
冒险 结构
|
124
|
-- 某些字段 更新改变量 改变量的定义由字段自身决定 {{type = ""}, }
|
6947e382
zhouahaihai
好感度, 皮肤
|
125
126
127
128
129
130
|
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,
|
23d89d13
zhouahaihai
冒险 结构
|
131
132
133
134
135
136
|
--table 类型通用更新
["tableCommon"] = function(fieldType, info)
if self.class.schema[fieldType][1] ~= "table" then
error("[ERROR:] need handler for changeUpdate, field : " .. fieldType)
return
end
|
dbd0ca58
gaofengduan
car 营养剂制作
|
137
|
--支持多深度单字段
|
23d89d13
zhouahaihai
冒险 结构
|
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
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,
|
00e663bd
zhouhaihai
剧情相关
|
154
155
156
|
["onlyToC"] = function(info)
return info
end,
|
6947e382
zhouahaihai
好感度, 皮肤
|
157
|
}
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
158
|
|
6947e382
zhouahaihai
好感度, 皮肤
|
159
160
161
162
|
local updates = {}
for _, one in ipairs(params) do
if changeUpdateFunc[one["type"]] then
table.insert(updates, changeUpdateFunc[one["type"]](one))
|
00e663bd
zhouhaihai
剧情相关
|
163
164
165
|
elseif one.isOnlyToC then
one.isOnlyToC = nil
table.insert(updates, one)
|
6947e382
zhouahaihai
好感度, 皮肤
|
166
|
else
|
23d89d13
zhouahaihai
冒险 结构
|
167
|
table.insert(updates, changeUpdateFunc["tableCommon"](one["type"], one))
|
6947e382
zhouahaihai
好感度, 皮肤
|
168
169
170
171
172
173
|
end
end
if not notNotify and next(updates) then
SendPacket(actionCodes.Role_changeUpdate, MsgPack.pack(updates))
end
end
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
174
|
|
314bc5df
zhengshouren
提交服务器初始代码
|
175
176
177
|
function Role:data()
return {
id = self:getProperty("id"),
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
178
179
|
name = self:getProperty("name"),
level = self:getProperty("level"),
|
4b7c7c96
zhouahaihai
增加 清空 挂机 冒险gm 角色经验
|
180
|
exp = self:getProperty("exp"),
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
181
|
items = self:getProperty("items"):toNumMap(),
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
182
|
funcOpen = self:getProperty("funcOpen"),
|
bab30666
zhouhaihai
增加通用功能等级 字段
|
183
|
funcLv = self:getProperty("funcLv"),
|
6947e382
zhouahaihai
好感度, 皮肤
|
184
|
loveStatus = self:getProperty("loveStatus"):toNumMap(),
|
312b9db5
zhouahaihai
背包
|
185
186
|
diamond = self:getAllDiamond(),
bagLimit = self:getProperty("bagLimit"),
|
dbd0ca58
gaofengduan
car 营养剂制作
|
187
|
|
23d89d13
zhouahaihai
冒险 结构
|
188
189
|
advPass = self:getProperty("advPass"),
advInfo = self:getProperty("advInfo"),
|
46fac6f1
zhouahaihai
酱料
|
190
|
advItems = self:getProperty("advItems"):toNumMap(),
|
36c30c5c
zhouahaihai
冒险
|
191
|
advTeam = self:getProperty("advTeam"),
|
09be9059
zhouhaihai
冒险接口
|
192
193
|
advHang = self:getProperty("advHang"),
advTask = self:getProperty("advTask"),
|
f99f48df
zhouhaihai
冒险任务
|
194
|
advMTask = self:getProperty("advMTask"),
|
bab30666
zhouhaihai
增加通用功能等级 字段
|
195
196
|
advAchiev = self:getProperty("advAchiev"),
advL = self:getProperty("advL"),
|
8da953a7
zhouhaihai
无尽模式
|
197
|
advElM = self:getProperty("advElM"),
|
384bb077
zhouahaihai
挂机
|
198
199
200
201
202
203
|
hangPass = self:getProperty("hangPass"),
hangTeam = self:getProperty("hangTeam"),
hangInfo = self:getProperty("hangInfo"),
hangBag = self:getProperty("hangBag"),
hangBagLimit = self:getProperty("hangBagLimit"),
|
dbd0ca58
gaofengduan
car 营养剂制作
|
204
205
|
potionBag = self:getProperty("potionBag"),
|
1c3053c3
zhouhaihai
返回数据
|
206
|
storyB = self:getProperty("storyB"),
|
056c01a0
zhouhaihai
简化装备
|
207
|
equips = self:getProperty("equips"),
|
9b35bf6e
zhouhaihai
开启时间箱
|
208
|
boxL = self:getProperty("boxL"),
|
276b1da9
zhouhaihai
爬塔接口
|
209
210
|
towerInfo = self:getProperty("towerInfo"),
towerF = self:getProperty("towerF"),
|
056c01a0
zhouhaihai
简化装备
|
211
|
|
314bc5df
zhengshouren
提交服务器初始代码
|
212
213
214
215
|
}
end
return Role
|