be9c9ca6
zhouahaihai
角色评论
|
1
2
|
-- 日常数据
|
fa992c94
liuzujun
添加daily,diner,act...
|
3
|
local Daily = class("Daily", require("shared.ModelBaseMysql"))
|
be9c9ca6
zhouahaihai
角色评论
|
4
|
|
a85b344f
zhangqijia
feat: 挂机图鉴
|
5
6
|
oneDay = 60*60*24
|
be9c9ca6
zhouahaihai
角色评论
|
7
|
function Daily:ctor(properties)
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
8
|
Daily.super.ctor(self, properties)
|
be9c9ca6
zhouahaihai
角色评论
|
9
10
11
|
end
Daily.schema = {
|
fa992c94
liuzujun
添加daily,diner,act...
|
12
13
|
id = {"number", 0, "pri"}, -- 角色id
commentHero = {"string", "", "blob"}, -- 单日评论食灵记录 type=1
|
87cc3a35
zhengshouren
餐厅建筑升级逻辑
|
14
15
|
hangQC = {"number", 0}, -- 挂机快速次数
dinerQC = {"number", 0}, -- 贩卖加速次数
|
e38b9c49
zhouhaihai
无尽次数
|
16
|
advElC = {"number", 0}, -- 无尽次数(消耗体力)
|
09be9059
zhouhaihai
冒险接口
|
17
|
advBC = {"number", 0}, -- 冒险次数购买次数(冒险体力购买次数)
|
e38b9c49
zhouhaihai
无尽次数
|
18
|
advElBC = {"number", 0}, -- 无尽次数购买次数(冒险体力购买次数)
|
f60b89b1
zhouhaihai
奖励副本
|
19
|
advWs = {"table", {}}, -- 冒险队工坊
|
c384626d
zhouhaihai
好友
|
20
21
22
|
bonusC = {"table", {}}, -- 奖励副本 次数 {[type] = {c = 0, b = 0}}
giveFP = {"table", {}}, -- 给谁送过心心
getFP = {"table", {}}, -- 领过谁的心心
|
4cf74232
zhouhaihai
pvp
|
23
|
pvpFree = {"number", 0}, -- pvp使用免费次数
|
4c5d72ab
zhouhaihai
高级pvp
|
24
|
pvpFreeH = {"number", 0}, -- 高级pvp使用免费次数
|
cccc9c70
zhouhaihai
商城
|
25
26
27
|
dailySDC = {"table", {}}, -- daily shop diamond count {[id] = count} -- 每日商城购买次数统计
dailySDD = {"table", {}}, -- daily shop diamond disount {[id] = 1} -- 每日商城折扣统计
|
9ced5432
zhouhaihai
冒险支援效果 保底事件
|
28
|
|
d51114bd
wangyujie
完成需求:每日金币购买
|
29
30
|
advSupRe = {"number", 0}, -- 冒险支援效果刷新次数
goldBuyT = {"number", 0}, -- 金币购买次数
|
317a46a9
liuzujun
添加特权卡
|
31
|
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
32
33
|
unlockPool = {"table", {}}, -- 解锁的属性卡池
curPool = {"number", 0}, -- 属性卡池当前索引
|
7113ad0c
liuzujun
每日抽卡次数触发礼包
|
34
|
drawHeroCnt = {"number", 0}, -- 每日抽卡次数
|
a85b344f
zhangqijia
feat: 挂机图鉴
|
35
36
|
treasureList = {"table", {}}, --挂机图鉴
|
be9c9ca6
zhouahaihai
角色评论
|
37
38
|
}
|
be9c9ca6
zhouahaihai
角色评论
|
39
|
function Daily:updateProperty(params)
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
40
41
42
|
local type, default = table.unpack(self.schema[params.field])
if params.delta then
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
43
|
self:incrProperty(params.field, params.delta)
|
440aa055
zhouhaihai
聊天
|
44
45
46
|
if not params.notNotify then
self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
end
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
47
48
49
50
|
return true
end
if params.value then
self:setProperty(params.field, params.value)
|
440aa055
zhouhaihai
聊天
|
51
52
53
|
if not params.notNotify then
self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
end
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
54
55
56
|
return true
end
return false
|
be9c9ca6
zhouahaihai
角色评论
|
57
58
59
|
end
function Daily:refreshDailyData(notify)
|
c384626d
zhouhaihai
好友
|
60
|
redisproxy:del(FRIEND_POINT:format(self.owner:getProperty("id")))
|
cccc9c70
zhouhaihai
商城
|
61
|
local dataMap = {}
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
62
|
for field, schema in pairs(self.schema) do
|
fc316d1f
zhouhaihai
冒险体力优化
|
63
|
if field == "advElC" then
|
6f3959ce
zhouhaihai
bug
|
64
|
if self:getProperty(field) > 0 then
|
0e3ab88d
zhouhaihai
中继层
|
65
66
|
dataMap[field] = 0
end
|
a85b344f
zhangqijia
feat: 挂机图鉴
|
67
68
|
elseif field == "treasureList" then
dataMap[field] = self:getTreasrueList()
|
0e3ab88d
zhouhaihai
中继层
|
69
|
elseif field ~= "key" then
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
70
|
local typ, def = table.unpack(schema)
|
cccc9c70
zhouhaihai
商城
|
71
72
73
74
75
76
|
dataMap[field] = def
end
end
-- 每日折扣搞一下
local dailySDD = {}
local sddPool = {}
|
c5825110
saicom
新增用户商城相关数据
|
77
78
|
for id, data in pairs(csvdb["shop_normalCsv"]) do
if data.shop == 1 and data.disount ~= 0 then
|
cccc9c70
zhouhaihai
商城
|
79
|
table.insert(sddPool, id)
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
80
81
|
end
end
|
cccc9c70
zhouhaihai
商城
|
82
83
84
85
86
87
88
|
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)
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
89
90
91
|
if notify then
self.owner:notifyUpdateProperties(self:data())
end
|
be9c9ca6
zhouahaihai
角色评论
|
92
93
|
end
|
a85b344f
zhangqijia
feat: 挂机图鉴
|
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
--解锁
function Daily:checkUnlock(treaval)
local role = self.owner
local treasureC = treaval.unlock:toArray(true, "=")
local show = false
if treasureC[1] == 1 then --通关关卡
if not self.owner:checkHangPass(treasureC[2]) then show = true end
elseif treasureC[1] == 2 then --通关拾荒章节=x层
local chapterId = treasureC[2]
local layer = 1
local advCsv = csvdb["adv_chapterCsv"][chapterId]
if not advCsv then return false end --不存在的章节
if math.floor(chapterId / 100) ~= 2 then
layer = math.min(layer, advCsv.limitlevel)
end
local advPass = role:getProperty("advPass")
if (advPass[chapterId] or 0) < layer then
show = false
else
show = true
end
elseif treasureC[1] == 3 then --拥有指定id的角色时
local hero = role:getHeroByID(treasureC[2])
if hero then show = true end
else
show = true
end
return show
end
--CD
function Daily:checkTreasureExpired(treasureAttr, treasureList)
local curInfo = treasureList[treasureAttr.id]
if curInfo then
-- check finish
if curInfo["expire_time"] then
if curInfo.cool_time > 1 then
if skynet.timex() > curInfo["expire_time"] then --已过期
treasureList[treasureAttr.id] = nil
elseif skynet.timex() > curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却
curInfo = nil
end
else
if skynet.timex() > curInfo["expire_time"] then
treasureList[treasureAttr.id] = nil
end
end
end
else
curInfo = clone(treasureAttr)
end
return curInfo
end
--资源
function Daily:checkTreasureBase(treasureList, treasureBase, removeId)
local tmptreasure = {}
for k, val in pairs(treasureList) do
if removeId and val.id == removeId then
table.remove(treasureList, k)
else
if treasureBase >= val.treasure_value then
treasureBase = treasureBase - val.treasure_value
tmptreasure[val.id] = val
end
end
end
return tmptreasure
end
--权重
function Daily:checkTreasureWeight(treasureList, tmptreasure, treasureBase)
local removeId
while next(tmptreasure) do
local tmp = self:checkTreasureBase(tmptreasure, treasureBase, removeId)
print(treasureBase)
local id = math.randWeight(tmp, "weight") --宝藏id
if not id then
break
end
local treasure = tmp[id]
if treasureBase >= treasure.treasure_value then
--扣除资源值
treasureBase = treasureBase - treasure.treasure_value
else
break
end
local chapterId = math.randWeight(csvdb["idle_battleCsv"], "treasure_weight") --关卡id
if not chapterId then
break
end
treasure.chapter_id = chapterId
treasureList[id] = treasure
removeId = id
end
end
--chapterId
function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
local treasure = nil
if not curInfo then
print("curInfo is nil")
return treasure
end
if chapterId == curInfo.chapter_id then --开始挖宝关卡ID=挂机关卡ID
if not curInfo["expire_time"] then
if curInfo.cool_time > 1 then
curInfo["expire_time"] = skynet.timex() + curInfo.working_time + curInfo.cool_time * oneDay
else
curInfo["expire_time"] = skynet.timex() + curInfo.working_time
end
else
if skynet.timex() > curInfo["expire_time"] then --已过期
treasure = table.remove(treasureList, curInfo.id)
elseif skynet.timex() > curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却
treasure = curInfo
end
end
else
if curInfo["expire_time"] then
if skynet.timex() > curInfo["expire_time"] then --已过期
treasure = table.remove(treasureList, curInfo.id)
elseif skynet.timex() > curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却
treasure = curInfo
else
curInfo["expire_time"] = nil
end
end
end
return treasure
end
function Daily:buyTreasure(treasureList)
local boughtTreasurer = {}
local treasureBase = globalCsv.idle_treasure_base
for id, val in pairs(treasureList) do
treasureBase = treasureBase - val.treasure_value
if treasureBase < 0 then
treasureBase = treasureBase + val.treasure_value
print("资源余额不足")
return
else
boughtTreasurer[id] = val
end
end
self:updateProperty({field = "treasureBase", value = treasureBase})
return boughtTreasurer
end
--重置宝藏图鉴
function Daily:resetTreasureList()
self:updateProperty({field = "treasureList", value = {}})
end
--宝藏图鉴
function Daily:getTreasrueList()
print("宝藏图鉴...")
local tmpcsv = csvdb["idle_treasureCsv"]
local treasureList = self:getProperty("treasureList") --挖宝列表 过期删除 领取奖励删除 跨天更新
local tmptreasure = {}
local treasureBase = globalCsv.idle_treasure_base
for id, val in pairs(tmpcsv) do
if self:checkUnlock(val) == true then
local treasure = self:checkTreasureExpired(val, treasureList)
if treasure then
table.insert(tmptreasure, treasure)
end
end
end
table.sort(tmptreasure, function (a,b) return a.treasure_value > b.treasure_value end)
self:checkTreasureWeight(treasureList, tmptreasure, treasureBase)
self:updateProperty({field = "treasureList", value = treasureList})
return treasureList
end
--检索挖宝列表
function Daily:checkTreasureList(chapterId)
print("检索挖宝列表")
local treasureList = self:getProperty("treasureList")
local tmptreasure = {}
for id, val in pairs(treasureList) do
local treasure = self:checkTreasureChapterId(val, treasureList, chapterId)
if treasure ~= nil then
tmptreasure[id] = treasure
end
end
if next(tmptreasure) == nil then
print("宝藏列表为空")
return nil
end
local boughtTreasurer = self:buyTreasure(tmptreasure)
self:updateProperty({field = "treasureList", value = treasureList})
return boughtTreasurer
end
|
be9c9ca6
zhouahaihai
角色评论
|
299
|
function Daily:data()
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
300
|
return {
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
301
|
hangQC = self:getProperty("hangQC"),
|
87cc3a35
zhengshouren
餐厅建筑升级逻辑
|
302
|
dinerQC = self:getProperty("dinerQC"),
|
09be9059
zhouhaihai
冒险接口
|
303
|
advBC = self:getProperty("advBC"),
|
e38b9c49
zhouhaihai
无尽次数
|
304
305
|
advElC = self:getProperty("advElC"),
advElBC = self:getProperty("advElBC"),
|
bab30666
zhouhaihai
增加通用功能等级 字段
|
306
|
advWs = self:getProperty("advWs"),
|
f60b89b1
zhouhaihai
奖励副本
|
307
|
bonusC = self:getProperty("bonusC"),
|
c384626d
zhouhaihai
好友
|
308
309
|
giveFP = self:getProperty("giveFP"),
getFP = self:getProperty("getFP"),
|
4cf74232
zhouhaihai
pvp
|
310
|
pvpFree = self:getProperty("pvpFree"),
|
4c5d72ab
zhouhaihai
高级pvp
|
311
|
pvpFreeH = self:getProperty("pvpFreeH"),
|
cccc9c70
zhouhaihai
商城
|
312
313
|
dailySDC = self:getProperty("dailySDC"),
dailySDD = self:getProperty("dailySDD"),
|
9ced5432
zhouhaihai
冒险支援效果 保底事件
|
314
|
advSupRe = self:getProperty("advSupRe"),
|
d51114bd
wangyujie
完成需求:每日金币购买
|
315
|
goldBuyT = self:getProperty("goldBuyT"),
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
316
317
|
unlockPool = self:getProperty("unlockPool"),
curPool = self:getProperty("curPool"),
|
a85b344f
zhangqijia
feat: 挂机图鉴
|
318
|
treasureList = self:getProperty("treasureList"),
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
319
|
}
|
be9c9ca6
zhouahaihai
角色评论
|
320
321
322
|
end
return Daily
|