Daily.lua
3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
-- 日常数据
local Daily = class("Daily", require("shared.ModelBase"))
function Daily:ctor(properties)
Daily.super.ctor(self, properties)
end
Daily.schema = {
commentHero = {"string", ""}, -- 单日评论食灵记录 type=1
hangQC = {"number", 0}, -- 挂机快速次数
dinerQC = {"number", 0}, -- 贩卖加速次数
advElC = {"number", 0}, -- 无尽次数(消耗体力)
advBC = {"number", 0}, -- 冒险次数购买次数(冒险体力购买次数)
advElBC = {"number", 0}, -- 无尽次数购买次数(冒险体力购买次数)
advWs = {"table", {}}, -- 冒险队工坊
bonusC = {"table", {}}, -- 奖励副本 次数 {[type] = {c = 0, b = 0}}
giveFP = {"table", {}}, -- 给谁送过心心
getFP = {"table", {}}, -- 领过谁的心心
pvpFree = {"number", 0}, -- pvp使用免费次数
pvpFreeH = {"number", 0}, -- 高级pvp使用免费次数
dailySDC = {"table", {}}, -- daily shop diamond count {[id] = count} -- 每日商城购买次数统计
dailySDD = {"table", {}}, -- daily shop diamond disount {[id] = 1} -- 每日商城折扣统计
advSupRe = {"number", 0}, -- 冒险支援效果刷新次数
goldBuyT = {"number", 0}, -- 金币购买次数
unlockPool = {"table", {}}, -- 解锁的属性卡池
curPool = {"number", 0}, -- 属性卡池当前索引
}
function Daily:updateProperty(params)
local type, default = table.unpack(self.schema[params.field])
if params.delta then
self:incrProperty(params.field, params.delta)
if not params.notNotify then
self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
end
return true
end
if params.value then
self:setProperty(params.field, params.value)
if not params.notNotify then
self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
end
return true
end
return false
end
function Daily:refreshDailyData(notify)
redisproxy:del(FRIEND_POINT:format(self.owner:getProperty("id")))
local dataMap = {}
for field, schema in pairs(self.schema) do
if field == "advElC" then
if self:getProperty(field) > 0 then
dataMap[field] = 0
end
elseif field ~= "key" then
local typ, def = table.unpack(schema)
dataMap[field] = def
end
end
-- 每日折扣搞一下
local dailySDD = {}
local sddPool = {}
for id, data in pairs(csvdb["shop_normalCsv"]) do
if data.shop == 1 and data.disount ~= 0 then
table.insert(sddPool, id)
end
end
for i = 1, math.min(#sddPool, globalCsv.shop_diamond_disount_count) do
local idx = math.randomInt(1, #sddPool)
dailySDD[sddPool[idx]] = 1
table.remove(sddPool, idx)
end
dataMap["dailySDD"] = dailySDD
self:setProperties(dataMap)
if notify then
self.owner:notifyUpdateProperties(self:data())
end
end
function Daily:data()
return {
hangQC = self:getProperty("hangQC"),
dinerQC = self:getProperty("dinerQC"),
advBC = self:getProperty("advBC"),
advElC = self:getProperty("advElC"),
advElBC = self:getProperty("advElBC"),
advWs = self:getProperty("advWs"),
bonusC = self:getProperty("bonusC"),
giveFP = self:getProperty("giveFP"),
getFP = self:getProperty("getFP"),
pvpFree = self:getProperty("pvpFree"),
pvpFreeH = self:getProperty("pvpFreeH"),
dailySDC = self:getProperty("dailySDC"),
dailySDD = self:getProperty("dailySDD"),
advSupRe = self:getProperty("advSupRe"),
goldBuyT = self:getProperty("goldBuyT"),
unlockPool = self:getProperty("unlockPool"),
curPool = self:getProperty("curPool"),
}
end
return Daily