Equip.lua
1.18 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
local Equip = class("Equip", require("shared.ModelBase"))
Equip.schema = {
type = {"number"}, -- 类型
level = {"number"}, -- 等级
count = {"number", 0}, -- 数量
refer = {"number", 0}, -- 已装备英雄数
}
function Equip:ctor( properties )
Equip.super.ctor(self, properties)
end
function Equip:notifyUpdateProperty(field, newValue, oldValue)
local datas = {
key = field,
newValue = newValue,
oldValue = oldValue,
}
self:notifyUpdateProperties(datas)
end
function Equip:notifyUpdateProperties(params)
local updateData = {
type = self:getProperty("type"),
level = self:getProperty("level"),
datas = params
}
SendPacket(actionCodes.Role_updateEquip, MsgPack.pack(updateData))
end
function Equip: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
self:notifyUpdateProperties(self:data())
end
function Equip:data()
return {
type = self:getProperty("type"),
level = self:getProperty("level"),
count = self:getProperty("count"),
}
end
return Equip