Blame view

src/models/Equip.lua 1.18 KB
43cc5f51   gaofengduan   调整 equip 数据结构
1
2
3
4
5
6
7
8
9
10
11
12
13
  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
  
ad484303   gaofengduan   add rune
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  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
  
43cc5f51   gaofengduan   调整 equip 数据结构
32
33
34
35
36
37
38
39
40
  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
ad484303   gaofengduan   add rune
41
  	self:notifyUpdateProperties(self:data())
43cc5f51   gaofengduan   调整 equip 数据结构
42
43
44
45
46
47
48
49
50
51
52
  end
  
  function Equip:data()
  	return {
  		type = self:getProperty("type"),
  		level = self:getProperty("level"),
  		count = self:getProperty("count"),
  	}
  end
  
  return Equip