Blame view

src/models/Daily.lua 1.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},		-- 贩卖加速次数
be9c9ca6   zhouahaihai   角色评论
13
14
  }
  
be9c9ca6   zhouahaihai   角色评论
15
  function Daily:updateProperty(params)
a43410e1   zhengshouren   整理格式,使用tab替代空格
16
17
18
19
20
21
22
23
24
25
26
27
28
  	local type, default = table.unpack(self.schema[params.field])
  
  	if params.delta then
  		self:setProperty(params.field, self:getProperty(paramsfield) + params.delta)
  		self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
  		return true
  	end
  	if params.value then
  		self:setProperty(params.field, params.value)
  		self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
  		return true
  	end
  	return false
be9c9ca6   zhouahaihai   角色评论
29
30
31
  end
  
  function Daily:refreshDailyData(notify)
a43410e1   zhengshouren   整理格式,使用tab替代空格
32
33
34
35
36
37
38
39
40
  	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   角色评论
41
42
43
  end
  
  function Daily:data()
a43410e1   zhengshouren   整理格式,使用tab替代空格
44
  	return {
a43410e1   zhengshouren   整理格式,使用tab替代空格
45
  		hangQC = self:getProperty("hangQC"),
87cc3a35   zhengshouren   餐厅建筑升级逻辑
46
  		dinerQC = self:getProperty("dinerQC"),
a43410e1   zhengshouren   整理格式,使用tab替代空格
47
  	}
be9c9ca6   zhouahaihai   角色评论
48
49
50
  end
  
  return Daily