43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
1
2 
 | 
  local Rune = class("Rune", require("shared.ModelBase"))
  Rune.schema = {
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
3
4 
 | 
  	uid 		= {"number"},      		-- 唯一自增id
  	type 		= {"number"},      		-- 装备位置
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
5
6 
 | 
  	id 			= {"number"},
  	level		= {"number", 0},		-- 等级
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
7 
 | 
  	refer		= {"number", 0},		-- 已装备英雄id
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
8 
 | 
  	attrs       = {"string",""}         -- 基础属性值 id=value
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
9
10
11
12
13
14
15
16 
 | 
  }
  
  function Rune:ctor( properties )
  	Rune.super.ctor(self, properties)
  end
  
  function Rune:notifyUpdateProperty(field, newValue, oldValue)
  	local datas = {
 
 | 
ee999bde
 
  zhouhaihai
 
零件优化
 | 
17
18
19
20
21
22
23
24 
 | 
  		uid = self:getProperty("uid"),
  		datas = {
  			{
  				key = field,
  				newValue = newValue,
  				oldValue = oldValue,
  			}
  		}
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
25
26
27
28 
 | 
  	}
  	self:notifyUpdateProperties(datas)
  end
  
 
 | 
3133cb76
 
  zhouhaihai
 
日志
 | 
29
30
31
32
33
34
35
36
37
38
39
40 
 | 
  function Rune:log(contents)
  	contents = contents or {}
  	if contents["cint1"] or contents["cint2"] or contents["cint3"] then
  		print("heroLog error log have cint1 or cint2 or cint3 ", debug.traceback())
  	end
  	contents["cint1"] = self:getProperty("uid")
  	contents["cint2"] = self:getProperty("type")
  	contents["cint3"] = self:getProperty("id")
  
  	self.owner:log("rune_action", contents)
  end
  
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
41
42 
 | 
  function Rune:notifyUpdateProperties(params)
  	local updateData = {
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
43 
 | 
  		uid = self:getProperty("uid"),
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
44
45
46
47
48
49
50
51
52
53
54
55
56
57 
 | 
  		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
 
 | 
ee999bde
 
  zhouhaihai
 
零件优化
 | 
58
59
60
61 
 | 
  	local datas = {}
  	table.insert(datas, {key = params.field, newValue = self:getProperty(params.field)})
  
  	self:notifyUpdateProperties(datas)
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
62
63
64
65
66
67 
 | 
  end
  
  -- types 类型=权重"2=100 3=100 4=100"  value最大值=最小值 "50=100 50=100 100=200"
  local function getRandomValue(types,values)
  	local typeMap = types:toNumMap()
  	local valueArry = values:toArray()
 
 | 
b58b5b49
 
  zhouhaihai
 
零件bug
 | 
68 
 | 
  
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
69 
 | 
  	if table.nums(typeMap) ~= #valueArry then return nil end
 
 | 
b58b5b49
 
  zhouhaihai
 
零件bug
 | 
70
71 
 | 
  	local typ, value
  	local typTab = {}
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
72 
 | 
  	for t,w in pairs(typeMap) do
 
 | 
b58b5b49
 
  zhouhaihai
 
零件bug
 | 
73 
 | 
  		table.insert(typTab,{t=t,w=w})
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
74
75 
 | 
  	end
  
 
 | 
b58b5b49
 
  zhouhaihai
 
零件bug
 | 
76
77 
 | 
  	local tk = math.randWeight(typTab, "w")
  	typ =  typTab[tk]["t"]
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
78
79 
 | 
  
  	local range = valueArry[tk]:toArray(true,"=")
 
 | 
b58b5b49
 
  zhouhaihai
 
零件bug
 | 
80
81 
 | 
  	value = math.randomInt(range[1],range[2])
  	return typ, value
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
82
83
84
85 
 | 
  end
  
  function Rune:generateAttrs()
  	local runeData  = csvdb["runeCsv"][self:getProperty("type")][self:getProperty("id")]
 
 | 
e3c5cc5e
 
  zhouhaihai
 
跨服竞技场over
 | 
86
87
88 
 | 
  	if not runeData then
  		print(self:getProperty("type"), self:getProperty("id"))
  	end
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
89 
 | 
  	local attrs = ""
 
 | 
b58b5b49
 
  zhouhaihai
 
零件bug
 | 
90
91
92
93 
 | 
  	local typ, value = getRandomValue(runeData.attr1,runeData.range1)
  	attrs = attrs:setv(typ, value)
  	local typ, value = getRandomValue(runeData.attr1,runeData.range1)
  	attrs = attrs:setv(typ, value)
 
 | 
ee3ac0b5
 
  gaofengduan
 
fix magic
 | 
94 
 | 
  	self:setProperty("attrs",attrs)
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
95
96
97
98 
 | 
  end
  
  function Rune:data()
  	return {
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
99
100 
 | 
  		uid = self:getProperty("uid"),
  		type = self:getProperty("type"),
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
101 
 | 
  		id = self:getProperty("id"),
 
 | 
ad484303
 
  gaofengduan
 
add rune
 | 
102
103 
 | 
  		refer = self:getProperty("refer"),
  		attrs = self:getProperty("attrs"),
 
 | 
37ad731e
 
  gaofengduan
 
fix rune
 | 
104 
 | 
  		level = self:getProperty("level"),
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
105
106
107
108 
 | 
  	}
  end
  
  return Rune
 
 |