Daily.lua
4.97 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
-- 日常数据
local Daily = class("Daily", require("shared.ModelBaseMysql"))
local DailyPlugin = import(".DailyPlugin") --宝藏相关
DailyPlugin.bind(Daily)
function Daily:ctor(properties)
Daily.super.ctor(self, properties)
end
Daily.schema = {
id = {"number", 0, "pri"}, -- 角色id
commentHero = {"string", "", "blob"}, -- 单日评论食灵记录 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}} 修改为 {c=0, b=0}
giveFP = {"table", {}}, -- 给谁送过心心
getFP = {"table", {}}, -- 领过谁的心心
pvpFree = {"number", 0}, -- pvp使用免费次数
pvpFreeH = {"number", 0}, -- 高级pvp使用免费次
pvpBought = {"number", 0}, -- 门票购买次数
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}, -- 属性卡池当前索引
drawHeroCnt = {"number", 0}, -- 每日抽卡次数
treasureBase = {"number", 0}, -- 资源值
treasureList = {"table", {}}, --挂机图鉴
treasureListExtra = {"table", {}}, --额外宝藏,挂机图鉴扩展功能
treasureMapCount = {"number", 0}, --宝藏图,消耗一张宝藏图可以发现一次额外宝藏
treasureExtraCount = {"number", 0}, --每日发现额外宝藏使用次数(累计),隔天清零
treasureBaseExtra = {"number", 0}, --额外宝藏资源值
chatTimes = {"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 == "id" then
-- skip
elseif field == "treasureBase" then
dataMap[field] = globalCsv.idle_treasure_base + self.owner:getBnousTreasureBaseMaximum()
elseif field == "treasureList" then
dataMap[field] = self:getTreasureList()
elseif field == "treasureExtraCount" then
dataMap[field] = 0
elseif field == "pvpBought" then
dataMap[field] = 0
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"),
pvpBought = self:getProperty("pvpBought"),
dailySDC = self:getProperty("dailySDC"),
dailySDD = self:getProperty("dailySDD"),
advSupRe = self:getProperty("advSupRe"),
goldBuyT = self:getProperty("goldBuyT"),
unlockPool = self:getProperty("unlockPool"),
curPool = self:getProperty("curPool"),
treasureBase = self:getProperty("treasureBase"),
treasureList = self:getProperty("treasureList"),
treasureListExtra = self:getProperty("treasureListExtra"),
treasureMapCount = self:getProperty("treasureMapCount"),
treasureExtraCount = self:getProperty("treasureExtraCount"),
treasureBaseExtra = self:getProperty("treasureBaseExtra"),
chatTimes = self:getProperty("chatTimes"),
}
end
return Daily