Blame view

src/models/Daily.lua 2.2 KB
be9c9ca6   zhouahaihai   角色评论
1
2
3
4
5
  -- 日常数据
  
  local Daily = class("Daily", require("shared.ModelBase"))
  
  function Daily:ctor(properties)
a43410e1   zhengshouren   整理格式,使用tab替代空格
6
  	Daily.super.ctor(self, properties)
be9c9ca6   zhouahaihai   角色评论
7
8
9
  end
  
  Daily.schema = {
87cc3a35   zhengshouren   餐厅建筑升级逻辑
10
11
12
  	commentHero		= {"string", ""},		-- 单日评论食灵记录 type=1
  	hangQC			= {"number", 0},		-- 挂机快速次数
  	dinerQC			= {"number", 0},		-- 贩卖加速次数
09be9059   zhouhaihai   冒险接口
13
  	advC			= {"number", 0},		-- 冒险次数(消耗体力)
e38b9c49   zhouhaihai   无尽次数
14
  	advElC			= {"number", 0},		-- 无尽次数(消耗体力)
09be9059   zhouhaihai   冒险接口
15
  	advBC			= {"number", 0},		-- 冒险次数购买次数(冒险体力购买次数)
e38b9c49   zhouhaihai   无尽次数
16
  	advElBC			= {"number", 0},		-- 无尽次数购买次数(冒险体力购买次数)
f60b89b1   zhouhaihai   奖励副本
17
  	advWs			= {"table", {}}, 		-- 冒险队工坊
c384626d   zhouhaihai   好友
18
19
20
  	bonusC			= {"table", {}}, 		-- 奖励副本 次数 {[type] = {c = 0, b = 0}}
  	giveFP			= {"table", {}},		-- 给谁送过心心
  	getFP			= {"table", {}},		-- 领过谁的心心
4cf74232   zhouhaihai   pvp
21
  	pvpFree			= {"number", 0},		-- pvp使用免费次数
be9c9ca6   zhouahaihai   角色评论
22
23
  }
  
be9c9ca6   zhouahaihai   角色评论
24
  function Daily:updateProperty(params)
a43410e1   zhengshouren   整理格式,使用tab替代空格
25
26
27
  	local type, default = table.unpack(self.schema[params.field])
  
  	if params.delta then
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
28
  		self:incrProperty(params.field, params.delta)
440aa055   zhouhaihai   聊天
29
30
31
  		if not params.notNotify then
  			self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
  		end
a43410e1   zhengshouren   整理格式,使用tab替代空格
32
33
34
35
  		return true
  	end
  	if params.value then
  		self:setProperty(params.field, params.value)
440aa055   zhouhaihai   聊天
36
37
38
  		if not params.notNotify then
  			self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
  		end
a43410e1   zhengshouren   整理格式,使用tab替代空格
39
40
41
  		return true
  	end
  	return false
be9c9ca6   zhouahaihai   角色评论
42
43
44
  end
  
  function Daily:refreshDailyData(notify)
c384626d   zhouhaihai   好友
45
  	redisproxy:del(FRIEND_POINT:format(self.owner:getProperty("id")))
a43410e1   zhengshouren   整理格式,使用tab替代空格
46
47
48
49
50
51
52
53
54
  	for field, schema in pairs(self.schema) do
  		if field ~= "key" then
  			local typ, def = table.unpack(schema)
  			self:setProperty(field, def)
  		end
  	end
  	if notify then
  		self.owner:notifyUpdateProperties(self:data())
  	end
be9c9ca6   zhouahaihai   角色评论
55
56
57
  end
  
  function Daily:data()
a43410e1   zhengshouren   整理格式,使用tab替代空格
58
  	return {
a43410e1   zhengshouren   整理格式,使用tab替代空格
59
  		hangQC = self:getProperty("hangQC"),
87cc3a35   zhengshouren   餐厅建筑升级逻辑
60
  		dinerQC = self:getProperty("dinerQC"),
09be9059   zhouhaihai   冒险接口
61
62
  		advC = self:getProperty("advC"),
  		advBC = self:getProperty("advBC"),
e38b9c49   zhouhaihai   无尽次数
63
64
  		advElC = self:getProperty("advElC"),
  		advElBC = self:getProperty("advElBC"),
bab30666   zhouhaihai   增加通用功能等级 字段
65
  		advWs = self:getProperty("advWs"),
f60b89b1   zhouhaihai   奖励副本
66
  		bonusC = self:getProperty("bonusC"),
c384626d   zhouhaihai   好友
67
68
  		giveFP = self:getProperty("giveFP"),
  		getFP = self:getProperty("getFP"),
4cf74232   zhouhaihai   pvp
69
  		pvpFree = self:getProperty("pvpFree"),
a43410e1   zhengshouren   整理格式,使用tab替代空格
70
  	}
be9c9ca6   zhouahaihai   角色评论
71
72
73
  end
  
  return Daily