Blame view

src/models/Hero.lua 3.73 KB
a12bfcce   liuzujun   添加英雄表
1
  local Hero = class("Hero", require("shared.ModelBaseMysql"))
0a07bdd9   zhouahaihai   角色升级 。gm
2
  
8c74292c   zhouahaihai   增加item 以及 角色突破
3
4
5
  local HeroPlugin = import(".HeroPlugin")
  HeroPlugin.bind(Hero)
  
0a07bdd9   zhouahaihai   角色升级 。gm
6
  Hero.schema = {
a12bfcce   liuzujun   添加英雄表
7
8
  	id 			= {"number", 0, "pri"},
  	roleid 		= {"number", 0, "index"},
0a07bdd9   zhouahaihai   角色升级 。gm
9
  	type 		= {"number", 0},
87cc3a35   zhengshouren   餐厅建筑升级逻辑
10
11
  	level		= {"number", 1},		-- 等级
  	breakL		= {"number", 0},		-- 突破等级
b96f8839   gaofengduan   觉醒初始等级为 1
12
  	wakeL		= {"number", 1},		-- 觉醒等级
87cc3a35   zhengshouren   餐厅建筑升级逻辑
13
14
  	talent		= {"string", ""},		-- 0=阶段 1=1 2=1 3=1 4=1 四个天赋当前阶段的等级  阶段默认为1  等级默认为0
  	battleV		= {"number", 0},		-- 保存战斗力
14f1591b   zhouhaihai   删除好感度相关
15
16
  	-- loveExp		= {"number", 0},		--好感度经验
  	-- loveL		= {"number", 0},		--好感度等级
4ea1b5ac   zhouhaihai   穿戴零件
17
18
  	equip       = {"string",""},        --装备 type=level
  	rune       = {"string",""},        --零件 type=id
96d591f7   liuzujun   天赋升级修改,增加英雄信赖
19
  	faith	   = {"number", 0},			-- 信赖
3d8468b2   liuzujun   火花系统
20
  	spark		= {"table", {}},		-- 火花属性
06562145   zhangqijia   英雄模块增加一个字段
21
  	genius	   = {"string", "" }, --天赋点 4=10201 5=10201 6=10203 7=10204
0a07bdd9   zhouahaihai   角色升级 。gm
22
23
  }
  
0a07bdd9   zhouahaihai   角色升级 。gm
24
25
  function Hero:ctor( properties )
  	Hero.super.ctor(self, properties)
0a07bdd9   zhouahaihai   角色升级 。gm
26
27
28
  end
  
  function Hero:notifyUpdateProperty(field, newValue, oldValue)
87cc3a35   zhengshouren   餐厅建筑升级逻辑
29
  	local datas = {
ee999bde   zhouhaihai   零件优化
30
31
32
33
34
35
36
37
  		id = self:getProperty("id"),
  		datas = {
  			{
  				key = field,
  				newValue = newValue,
  				oldValue = oldValue,
  			}
  		}
a43410e1   zhengshouren   整理格式,使用tab替代空格
38
  	}
87cc3a35   zhengshouren   餐厅建筑升级逻辑
39
  	self:notifyUpdateProperties(datas)
0a07bdd9   zhouahaihai   角色升级 。gm
40
41
  end
  
a12bfcce   liuzujun   添加英雄表
42
43
44
45
  function Hero:getSimpleHeroId()
  	return self:getProperty("id") % (self:getProperty("roleid") * MAX_HERO_NUM)
  end
  
0a07bdd9   zhouahaihai   角色升级 。gm
46
  function Hero:notifyUpdateProperties(params)
a43410e1   zhengshouren   整理格式,使用tab替代空格
47
  	local updateData = {
a12bfcce   liuzujun   添加英雄表
48
  		id = self:getSimpleHeroId(),
a43410e1   zhengshouren   整理格式,使用tab替代空格
49
50
  		datas = params
  	}
a43410e1   zhengshouren   整理格式,使用tab替代空格
51
  	SendPacket(actionCodes.Hero_updateProperty, MsgPack.pack(updateData))
0a07bdd9   zhouahaihai   角色升级 。gm
52
53
  end
  
c7ecb87f   zhouhaihai   添加 测试账号 方法
54
55
56
  function Hero:updateProperties(params, notNotify)
  	self:setProperties(params)
  
3d8468b2   liuzujun   火花系统
57
  	local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, equip = true, rune = true, spark = true}
c7ecb87f   zhouhaihai   添加 测试账号 方法
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  	local datas = {}
  	local updateBV = false
  	for k , v in pairs(params) do
  		if check[k] then updateBV = true end
  		table.insert(datas, {key = k, newValue = self:getProperty(k)})
  	end
  	if updateBV then
  		local orginValue = self:getProperty("battleV")
  		local curValue = self:saveBattleValue()
  		if orginValue ~= curValue then
  			table.insert(datas, { key = "battleV", newValue = curValue })
  		end
  	end
  	if not notNotify then
  		self:notifyUpdateProperties(datas)
  	end
  end
  
0a07bdd9   zhouahaihai   角色升级 。gm
76
  function Hero:updateProperty(params)
a43410e1   zhengshouren   整理格式,使用tab替代空格
77
78
79
80
81
82
83
84
85
86
  	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)})
0a07bdd9   zhouahaihai   角色升级 。gm
87
  
3d8468b2   liuzujun   火花系统
88
  	local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, equip = true, rune = true, spark = true}
a43410e1   zhengshouren   整理格式,使用tab替代空格
89
90
91
92
93
94
95
  	if check[params.field] then
  		local orginValue = self:getProperty("battleV")
  		local curValue = self:saveBattleValue()
  		if orginValue ~= curValue then
  			table.insert(datas, { key = "battleV", newValue = curValue })
  		end
  	end
0a07bdd9   zhouahaihai   角色升级 。gm
96
  
a43410e1   zhengshouren   整理格式,使用tab替代空格
97
  	self:notifyUpdateProperties(datas)
0a07bdd9   zhouahaihai   角色升级 。gm
98
99
100
101
102
103
  end
  
  function Hero:data()
  	return {
  		id = self:getProperty("id"),
  		type = self:getProperty("type"),
a43410e1   zhengshouren   整理格式,使用tab替代空格
104
105
106
  		level = self:getProperty("level"),
  		breakL = self:getProperty("breakL"),
  		wakeL = self:getProperty("wakeL"),
a43410e1   zhengshouren   整理格式,使用tab替代空格
107
108
  		talent  = self:getProperty("talent"),
  		battleV = self:getProperty("battleV"),
14f1591b   zhouhaihai   删除好感度相关
109
110
  		-- loveExp = self:getProperty("loveExp"),
  		-- loveL = self:getProperty("loveL"),
24d77701   gaofengduan   fix equip
111
112
  		equip = self:getProperty("equip"),
  		rune = self:getProperty("rune"),
3d8468b2   liuzujun   火花系统
113
114
  		faith = self:getProperty("faith"),
  		spark = self:getProperty("spark"),
06562145   zhangqijia   英雄模块增加一个字段
115
  		genius = self:getProperty("genius"),
0a07bdd9   zhouahaihai   角色升级 。gm
116
117
118
  	}
  end
  
15cba0bf   zhouhaihai   修改天赋升级消耗
119
  function Hero:getCamp()
e3c3a4f5   zhouhaihai   bug
120
      return csvdb["unitCsv"][self:getProperty("type")].camp
1c35c4cf   gaofengduan   fix hero awake
121
122
  end
  
00bf6029   liuzujun   限时礼包,抽卡ssr广播
123
124
125
126
  function Hero:getRare()
      return csvdb["unitCsv"][self:getProperty("type")].rare
  end
  
16634605   liuzujun   多队挂机,天赋道具合成
127
128
129
130
  function Hero:getPosition()
      return csvdb["unitCsv"][self:getProperty("type")].position
  end
  
0a07bdd9   zhouahaihai   角色升级 。gm
131
  return Hero