43cc5f51
gaofengduan
调整 equip 数据结构
|
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
|
local Rune = class("Rune", require("shared.ModelBase"))
Rune.schema = {
id = {"number"},
level = {"number", 0}, -- 等级
count = {"number", 0}, -- 数量
refer = {"number", 0}, -- 已装备英雄id
}
function Rune:ctor( properties )
Rune.super.ctor(self, properties)
end
function Rune:notifyUpdateProperty(field, newValue, oldValue)
local datas = {
key = field,
newValue = newValue,
oldValue = oldValue,
}
self:notifyUpdateProperties(datas)
end
function Rune:notifyUpdateProperties(params)
local updateData = {
id = self:getProperty("id"),
datas = params
}
SendPacket(actionCodes.Role_updateRune, MsgPack.pack(updateData))
end
function Rune:updateProperty(params)
if not params.field or (not params.delta and not params.value) then
return
end
if params.delta then
self:incrProperty(params.field, params.delta)
elseif params.value then
self:setProperty(params.field, params.value)
end
local datas = {}
table.insert(datas, {key = params.field, newValue = self:getProperty(params.field)})
self:notifyUpdateProperties(datas)
end
function Rune:data()
return {
id = self:getProperty("id"),
level = self:getProperty("level"),
count = self:getProperty("count"),
}
end
return Rune
|