Blame view

src/models/Hero.lua 2.7 KB
0a07bdd9   zhouahaihai   角色升级 。gm
1
2
  local Hero = class("Hero", require("shared.ModelBase"))
  
8c74292c   zhouahaihai   增加item 以及 角色突破
3
4
5
  local HeroPlugin = import(".HeroPlugin")
  HeroPlugin.bind(Hero)
  
0a07bdd9   zhouahaihai   角色升级 。gm
6
  Hero.schema = {
0a07bdd9   zhouahaihai   角色升级 。gm
7
8
  	id 			= {"number"},
  	type 		= {"number", 0},
87cc3a35   zhengshouren   餐厅建筑升级逻辑
9
10
11
12
13
14
15
16
  	level		= {"number", 1},		-- 等级
  	breakL		= {"number", 0},		-- 突破等级
  	wakeL		= {"number", 0},		-- 觉醒等级
  	skillL		= {"string", ""},		-- 技能等级 1=1 2=1 3=1
  	talent		= {"string", ""},		-- 0=阶段 1=1 2=1 3=1 4=1 四个天赋当前阶段的等级  阶段默认为1  等级默认为0
  	battleV		= {"number", 0},		-- 保存战斗力
  	loveExp		= {"number", 0},		--好感度经验
  	loveL		= {"number", 0},		--好感度等级
9c525cf9   gaofengduan   add car smithy
17
  	skin		= {"number", 0},		--皮肤 0 、 1、 2、 3
43cc5f51   gaofengduan   调整 equip 数据结构
18
  	equip       = {"string","1=0 2=0 3=0 4=0"},        --装备 type=level
24d77701   gaofengduan   fix equip
19
  	rune       = {"string","1=0 2=0 3=0 4=0 5=0 6=0"},        --零件 type=id
0a07bdd9   zhouahaihai   角色升级 。gm
20
21
  }
  
0a07bdd9   zhouahaihai   角色升级 。gm
22
23
  function Hero:ctor( properties )
  	Hero.super.ctor(self, properties)
43cc5f51   gaofengduan   调整 equip 数据结构
24
  	self.runes = {} --符文-零件自增 id
0a07bdd9   zhouahaihai   角色升级 。gm
25
26
27
  end
  
  function Hero:notifyUpdateProperty(field, newValue, oldValue)
87cc3a35   zhengshouren   餐厅建筑升级逻辑
28
29
30
31
  	local datas = {
  		key = field,
  		newValue = newValue,
  		oldValue = oldValue,
a43410e1   zhengshouren   整理格式,使用tab替代空格
32
  	}
87cc3a35   zhengshouren   餐厅建筑升级逻辑
33
  	self:notifyUpdateProperties(datas)
0a07bdd9   zhouahaihai   角色升级 。gm
34
35
36
  end
  
  function Hero:notifyUpdateProperties(params)
a43410e1   zhengshouren   整理格式,使用tab替代空格
37
38
39
40
  	local updateData = {
  		id = self:getProperty("id"),
  		datas = params
  	}
a43410e1   zhengshouren   整理格式,使用tab替代空格
41
  	SendPacket(actionCodes.Hero_updateProperty, MsgPack.pack(updateData))
0a07bdd9   zhouahaihai   角色升级 。gm
42
43
44
  end
  
  function Hero:updateProperty(params)
a43410e1   zhengshouren   整理格式,使用tab替代空格
45
46
47
48
49
50
51
52
53
54
  	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
55
  
a43410e1   zhengshouren   整理格式,使用tab替代空格
56
57
58
59
60
61
62
63
  	local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, skin = true}
  	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
64
  
a43410e1   zhengshouren   整理格式,使用tab替代空格
65
  	self:notifyUpdateProperties(datas)
0a07bdd9   zhouahaihai   角色升级 。gm
66
67
68
69
70
71
  end
  
  function Hero:data()
  	return {
  		id = self:getProperty("id"),
  		type = self:getProperty("type"),
a43410e1   zhengshouren   整理格式,使用tab替代空格
72
73
74
75
76
77
78
79
  		level = self:getProperty("level"),
  		breakL = self:getProperty("breakL"),
  		wakeL = self:getProperty("wakeL"),
  		skillL = self:getProperty("skillL"),
  		talent  = self:getProperty("talent"),
  		battleV = self:getProperty("battleV"),
  		loveExp = self:getProperty("loveExp"),
  		loveL = self:getProperty("loveL"),
6947e382   zhouahaihai   好感度, 皮肤
80
  		skin = self:getProperty("skin"),
24d77701   gaofengduan   fix equip
81
82
  		equip = self:getProperty("equip"),
  		rune = self:getProperty("rune"),
0a07bdd9   zhouahaihai   角色升级 。gm
83
84
85
  	}
  end
  
1c35c4cf   gaofengduan   fix hero awake
86
87
88
89
90
91
92
93
94
  function Hero:getStampId()
      local typs = {
          [1]=50,
          [2]=51,
          [3]=52,
      }
      return typs[csvdb["unitCsv"][self:getProperty("type")].camp]
  end
  
0a07bdd9   zhouahaihai   角色升级 。gm
95
  return Hero