384bb077
zhouahaihai
挂机
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
local ipairs = ipairs
local table = table
local math = math
local next = next
local string = string
local redisproxy = redisproxy
local MsgPack = MsgPack
local getRandomName = getRandomName
local mcast_util = mcast_util
local string_format = string.format
local tonumber = tonumber
local require = require
local table_insert = table.insert
local tconcat = table.concat
local table_unpack = table.unpack
local _M = {}
local function checkReward(role)
local hangInfo = role:getProperty("hangInfo")
if not hangInfo.carbonId or not hangInfo.coinTime or not hangInfo.itemTime then
|
024370be
liuzujun
双倍掉掉落bug
|
22
|
return false
|
384bb077
zhouahaihai
挂机
|
23
24
|
end
local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId]
|
bcf5bfbb
zhouahaihai
挂机new
|
25
26
|
local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0)
local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0)
|
384bb077
zhouahaihai
挂机
|
27
|
|
706b517e
liuzujun
翻倍掉落活动,商城免费宝箱
|
28
29
30
|
-- 此次挂机,其中翻倍时长占多少
local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime)
local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime
|
384bb077
zhouahaihai
挂机
|
31
|
|
706b517e
liuzujun
翻倍掉落活动,商城免费宝箱
|
32
33
34
35
|
local coinCount = math.max(0, math.floor((normalTime) / globalCsv.idle_money_produce_cd))
local coinDoubleCount = math.max(0, math.floor((doubleTime) / globalCsv.idle_money_produce_cd)) * 2
hangInfo.coinTime = nowCoinTime
|
024370be
liuzujun
双倍掉掉落bug
|
36
|
normalTime = nowItemTime - hangInfo.itemTime
|
706b517e
liuzujun
翻倍掉落活动,商城免费宝箱
|
37
|
local itemCount = math.max(0, math.floor((normalTime) / globalCsv.idle_item_produce_cd))
|
706b517e
liuzujun
翻倍掉落活动,商城免费宝箱
|
38
|
hangInfo.itemTime = nowItemTime
|
384bb077
zhouahaihai
挂机
|
39
40
|
local items = role:getProperty("hangBag")
|
706b517e
liuzujun
翻倍掉落活动,商城免费宝箱
|
41
|
coinCount = coinCount + coinDoubleCount
|
384bb077
zhouahaihai
挂机
|
42
43
|
items[ItemId.Gold] = (items[ItemId.Gold] or 0) + coinCount * carbonData.money
items[ItemId.Exp] = (items[ItemId.Exp] or 0) + coinCount * carbonData.exp
|
4b7c7c96
zhouahaihai
增加 清空 挂机 冒险gm 角色经验
|
44
|
items[ItemId.PlayerExp] = (items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp
|
384bb077
zhouahaihai
挂机
|
45
46
47
48
49
|
local pool = {}
for _, temp in pairs(carbonData.item:toArray()) do
table.insert(pool, temp:toArray(true, "="))
end
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
50
51
52
|
local curFC = 0
local curIC = 0
for id, count in pairs(items) do
|
bcf5bfbb
zhouahaihai
挂机new
|
53
|
if id ~= ItemId.Gold and id ~= ItemId.Exp and id ~= ItemId.PlayerExp then
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
54
55
|
curFC = curFC + math.ceil(count / globalCsv.idle_field_limit)
curIC = curIC + count
|
9962b061
zhouahaihai
补充 挂机
|
56
57
|
end
end
|
317a46a9
liuzujun
添加特权卡
|
58
59
60
61
|
-- 特权卡挂机额外栏位
local privExtraCnt = role.storeData:getHangSlotExtraCount()
local selfFC = role:getProperty("hangBagLimit") + privExtraCnt
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
62
63
64
65
66
67
68
69
70
|
local selfIC = selfFC * globalCsv.idle_field_limit
local function randomItem()
if curIC >= selfIC then
return
end
local tempPool = clone(pool)
while #tempPool > 0 do
local idx = math.randWeight(tempPool, 3)
|
024370be
liuzujun
双倍掉掉落bug
|
71
72
73
74
|
local cur = clone(pool[idx])
if cur[1] ~= 1 then -- 轮空 id
if cur[1] == ItemId.BreakCost and doubleTime > 0 then
cur[2] = cur[2] * 2
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
75
|
end
|
024370be
liuzujun
双倍掉掉落bug
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
if (items[cur[1]] and math.ceil((items[cur[1]] + cur[2]) / globalCsv.idle_field_limit) > math.ceil(items[cur[1]] / globalCsv.idle_field_limit))
or not items[cur[1]] then --要占用新栏位的情况
local addFC
if not items[cur[1]] then
addFC = math.ceil(cur[2] / globalCsv.idle_field_limit)
else
local frontC = items[cur[1]] % globalCsv.idle_field_limit
if frontC == 0 then
frontC = globalCsv.idle_field_limit
end
addFC = math.ceil((cur[2] - (globalCsv.idle_field_limit - frontC)) / globalCsv.idle_field_limit)
end
if curFC + addFC <= selfFC then
curFC = curFC + addFC
items[cur[1]] = (items[cur[1]] or 0) + cur[2]
break
else
--加不了,换别的东西
table.remove(tempPool, idx)
end
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
96
|
else
|
024370be
liuzujun
双倍掉掉落bug
|
97
98
|
items[cur[1]] = items[cur[1]] + cur[2]
break
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
99
100
|
end
else
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
101
|
break
|
9962b061
zhouahaihai
补充 挂机
|
102
|
end
|
9962b061
zhouahaihai
补充 挂机
|
103
|
end
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
104
105
|
curIC = curIC + 1
end
|
024370be
liuzujun
双倍掉掉落bug
|
106
|
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
107
108
|
for i = 1, itemCount do
randomItem()
|
384bb077
zhouahaihai
挂机
|
109
110
111
|
end
if coinCount > 0 or itemCount > 0 then
|
5af8b4aa
zhouahaihai
挂机down
|
112
|
return true
|
384bb077
zhouahaihai
挂机
|
113
|
end
|
024370be
liuzujun
双倍掉掉落bug
|
114
115
|
return false
|
384bb077
zhouahaihai
挂机
|
116
117
|
end
|
384bb077
zhouahaihai
挂机
|
118
119
120
121
122
123
|
--开始一个新的关卡
function _M.startRpc( agent, data )
local role = agent.role
local msg = MsgPack.unpack(data)
local carbonId = msg.carbonId
local carbonData = csvdb["idle_battleCsv"][carbonId]
|
f60b89b1
zhouhaihai
奖励副本
|
124
|
if not carbonData then return 1 end
|
384bb077
zhouahaihai
挂机
|
125
|
|
d232676a
zhouhaihai
功能解锁 冒险返回
|
126
127
128
129
|
if math.floor(carbonId / 10000) ~= 1 then
if not role:isFuncUnlock(FuncUnlock.DifficultHang) then return end
end
|
5d80aca6
zhouahaihai
挂机优化
|
130
131
|
for _, preCarbonId in ipairs(carbonData.prepose:toArray(true, "=")) do
|
33be3111
zhouhaihai
修改hangPass 结构
|
132
|
if not role:checkHangPass(preCarbonId) then return 2 end
|
5d80aca6
zhouahaihai
挂机优化
|
133
|
end
|
384bb077
zhouahaihai
挂机
|
134
|
|
5af8b4aa
zhouahaihai
挂机down
|
135
136
137
|
if checkReward(role) then
role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")})
end
|
384bb077
zhouahaihai
挂机
|
138
139
|
local hangInfo = role:getProperty("hangInfo")
|
5af8b4aa
zhouahaihai
挂机down
|
140
|
local isNew = not hangInfo.carbonId
|
384bb077
zhouahaihai
挂机
|
141
142
|
hangInfo.carbonId = carbonId
local nowTime = skynet.timex()
|
5af8b4aa
zhouahaihai
挂机down
|
143
|
if isNew then
|
1103490d
zhouhaihai
设置 国家时间错误
|
144
145
|
hangInfo.coinTime = nowTime
hangInfo.itemTime = nowTime
|
bcf5bfbb
zhouahaihai
挂机new
|
146
147
|
hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max
hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max
|
1103490d
zhouhaihai
设置 国家时间错误
|
148
149
150
|
else
hangInfo.coinTime = math.min(nowTime, hangInfo.endCoinTime)
hangInfo.itemTime = math.min(nowTime, hangInfo.endItemTime)
|
5af8b4aa
zhouahaihai
挂机down
|
151
|
end
|
33be3111
zhouhaihai
修改hangPass 结构
|
152
|
if not role:checkHangPass(carbonId) then
|
5af8b4aa
zhouahaihai
挂机down
|
153
154
155
|
hangInfo.bossTime = nowTime + carbonData.idle_time
else
hangInfo.bossTime = nil
|
384bb077
zhouahaihai
挂机
|
156
157
158
|
end
role:updateProperty({field = "hangInfo", value = hangInfo})
|
3133cb76
zhouhaihai
日志
|
159
160
|
role:log("hang_action", {desc = "startHang", int1 = carbonId})
|
384bb077
zhouahaihai
挂机
|
161
162
163
164
165
166
167
168
|
SendPacket(actionCodes.Hang_startRpc, '')
return true
end
-- 每隔1分钟检查一次
function _M.checkRpc(agent, data)
local role = agent.role
-- local msg = MsgPack.unpack(data)
|
5af8b4aa
zhouahaihai
挂机down
|
169
170
171
172
|
if checkReward(role) then
role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")})
role:updateProperty({field = "hangInfo", value = role:getProperty("hangInfo")})
end
|
384bb077
zhouahaihai
挂机
|
173
174
175
176
|
SendPacket(actionCodes.Hang_checkRpc, MsgPack.pack({}))
return true
end
|
cc5ca7f3
zhouhaihai
缓存battleKey
|
177
|
local _BattleKey = nil
|
384bb077
zhouahaihai
挂机
|
178
179
180
|
function _M.startBattleRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
bcf5bfbb
zhouahaihai
挂机new
|
181
182
|
local carbonId = msg.carbonId
local curData = csvdb["idle_battleCsv"][carbonId]
|
a1e08c9c
zhengshouren
宝箱关战斗异常
|
183
184
185
|
if not curData then
return 1
end
|
bcf5bfbb
zhouahaihai
挂机new
|
186
|
|
384bb077
zhouahaihai
挂机
|
187
|
local hangInfo = role:getProperty("hangInfo")
|
bcf5bfbb
zhouahaihai
挂机new
|
188
|
if curData.main ~= 1 then
|
a1e08c9c
zhengshouren
宝箱关战斗异常
|
189
190
191
|
if carbonId ~= hangInfo.carbonId then
return 2
end
|
bcf5bfbb
zhouahaihai
挂机new
|
192
193
|
end
|
33be3111
zhouhaihai
修改hangPass 结构
|
194
|
if role:checkHangPass(carbonId) then
|
a1e08c9c
zhengshouren
宝箱关战斗异常
|
195
196
|
return 3
end
|
bcf5bfbb
zhouahaihai
挂机new
|
197
|
|
cc5ca7f3
zhouhaihai
缓存battleKey
|
198
199
|
_BattleKey = tostring(math.random())
|
53e8037e
zhouhaihai
任务
|
200
|
role:checkTaskEnter("HangBattle", {id = carbonId})
|
52c87300
zhouhaihai
bug
|
201
|
SendPacket(actionCodes.Hang_startBattleRpc, MsgPack.pack({key = _BattleKey}))
|
384bb077
zhouahaihai
挂机
|
202
203
204
205
206
207
208
|
return true
end
function _M.endBattleRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local hangInfo = role:getProperty("hangInfo")
|
cc5ca7f3
zhouhaihai
缓存battleKey
|
209
|
if not msg.key or msg.key ~= _BattleKey then
|
d6a66c74
zhouhaihai
校验失败也返回
|
210
211
|
SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1}))
return true
|
4906ebd2
zhengshouren
宝箱关副本结算异常
|
212
|
end
|
bcf5bfbb
zhouahaihai
挂机new
|
213
214
|
local carbonId = msg.carbonId
local carbonData = csvdb["idle_battleCsv"][carbonId]
|
4906ebd2
zhengshouren
宝箱关副本结算异常
|
215
216
217
|
if not carbonData then
return 2
end
|
bcf5bfbb
zhouahaihai
挂机new
|
218
|
if carbonData.main ~= 1 then
|
4906ebd2
zhengshouren
宝箱关副本结算异常
|
219
220
221
|
if carbonId ~= hangInfo.carbonId then
return 3
end
|
bcf5bfbb
zhouahaihai
挂机new
|
222
|
end
|
33be3111
zhouhaihai
修改hangPass 结构
|
223
224
|
if role:checkHangPass(carbonId) then
|
4906ebd2
zhengshouren
宝箱关副本结算异常
|
225
226
|
return 4
end
|
7bb30dca
zhouhaihai
修改发奖
|
227
|
local reward, change
|
384bb077
zhouahaihai
挂机
|
228
|
if msg.starNum and msg.starNum > 0 then --win
|
33be3111
zhouhaihai
修改hangPass 结构
|
229
|
role:hangFinish(carbonId)
|
bcf5bfbb
zhouahaihai
挂机new
|
230
231
232
|
if carbonData.main ~= 1 then
hangInfo.bossTime = nil
end
|
384bb077
zhouahaihai
挂机
|
233
234
|
-- reward
reward = {}
|
384bb077
zhouahaihai
挂机
|
235
236
|
reward[ItemId.Gold] = carbonData.money_clear
reward[ItemId.Exp] = carbonData.exp_clear
|
00115a7a
zhouahaihai
奖励发放
|
237
|
reward[ItemId.PlayerExp] = carbonData.playerExp_clear
|
384bb077
zhouahaihai
挂机
|
238
|
for itemId, count in pairs(carbonData.item_clear:toNumMap()) do
|
384bb077
zhouahaihai
挂机
|
239
240
|
reward[itemId] = count
end
|
7bb30dca
zhouhaihai
修改发奖
|
241
|
reward, change = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}})
|
00e663bd
zhouhaihai
剧情相关
|
242
|
|
03a6166a
zhouhaihai
餐厅优化
|
243
|
role:checkTaskEnter("HangPass", {id = carbonId})
|
384bb077
zhouahaihai
挂机
|
244
|
end
|
384bb077
zhouahaihai
挂机
|
245
|
role:updateProperty({field = "hangInfo", value = hangInfo})
|
33be3111
zhouhaihai
修改hangPass 结构
|
246
247
248
|
local team = role:getProperty("pvpTC")
role:log("hang_action", {desc = "hangBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = carbonId, int2 = role:getProperty("hangTBV"), cint1 = role:getHerosCamp(team.heros)})
|
3133cb76
zhouhaihai
日志
|
249
|
|
384bb077
zhouahaihai
挂机
|
250
251
252
|
SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({
starNum = msg.starNum,
reward = reward,
|
7bb30dca
zhouhaihai
修改发奖
|
253
|
change = change,
|
384bb077
zhouahaihai
挂机
|
254
255
256
257
|
}))
return true
end
|
7efe5275
zhouhaihai
检查leader
|
258
259
260
261
262
263
264
|
local function checkLeader(heros, leader)
if not leader then return end
for slot, heroId in pairs(heros) do
if heroId == leader then return true end
end
end
|
384bb077
zhouahaihai
挂机
|
265
266
267
|
function _M.roleFormatRpc(agent , data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
384bb077
zhouahaihai
挂机
|
268
269
270
|
local hangTeam = role:getProperty("hangTeam")
for slot, heroId in pairs(msg.heros) do
if not role.heros[heroId] then
|
e6ebee44
zhouhaihai
编队bug
|
271
|
return 1
|
384bb077
zhouahaihai
挂机
|
272
273
|
end
end
|
f603a60f
zhouhaihai
支援技实装
|
274
275
276
|
local supports = {}
for slot, support in pairs(msg.supports or {}) do
|
e6ebee44
zhouhaihai
编队bug
|
277
|
if slot ~= 1 and slot ~= 2 then return 2 end
|
f603a60f
zhouhaihai
支援技实装
|
278
|
local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
|
e6ebee44
zhouhaihai
编队bug
|
279
|
if level <= 0 then return 3 end
|
f603a60f
zhouhaihai
支援技实装
|
280
281
|
supports[slot] = support
end
|
e6ebee44
zhouhaihai
编队bug
|
282
|
if not checkLeader(msg.heros, msg.leader) then return 4 end
|
f603a60f
zhouhaihai
支援技实装
|
283
|
|
384bb077
zhouahaihai
挂机
|
284
285
286
287
288
289
|
table.clear(hangTeam)
hangTeam.heros = {}
for slot, heroId in pairs(msg.heros) do
hangTeam.heros[slot] = heroId
end
hangTeam.leader = msg.leader
|
f603a60f
zhouhaihai
支援技实装
|
290
|
hangTeam.supports = supports
|
fa565e0c
zhouhaihai
优化结构
|
291
|
role:saveHangTeam(hangTeam)
|
384bb077
zhouahaihai
挂机
|
292
293
294
295
|
SendPacket(actionCodes.Hang_roleFormatRpc, '')
return true
end
|
5af8b4aa
zhouahaihai
挂机down
|
296
297
298
299
300
|
function _M.getRewardRpc(agent , data)
local role = agent.role
checkReward(role)
local items = role:getProperty("hangBag")
if not next(items) then return end
|
7bb30dca
zhouhaihai
修改发奖
|
301
|
local reward, change = role:award(items, {log = {desc = "hangReward"}})
|
5af8b4aa
zhouahaihai
挂机down
|
302
303
304
|
table.clear(items)
local hangInfo = role:getProperty("hangInfo")
local nowTime = skynet.timex()
|
bcf5bfbb
zhouahaihai
挂机new
|
305
306
|
hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max
hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max
|
5af8b4aa
zhouahaihai
挂机down
|
307
308
309
310
|
hangInfo.coinTime = nowTime
hangInfo.itemTime = nowTime
role:updateProperty({field = "hangBag", value = items})
role:updateProperty({field = "hangInfo", value = hangInfo})
|
03a6166a
zhouhaihai
餐厅优化
|
311
|
role:checkTaskEnter("HangGet")
|
53e8037e
zhouhaihai
任务
|
312
313
|
if reward[ItemId.Gold] then
role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
|
bcf5bfbb
zhouahaihai
挂机new
|
314
|
end
|
53e8037e
zhouhaihai
任务
|
315
|
SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({
|
7bb30dca
zhouhaihai
修改发奖
|
316
317
|
reward = reward,
change = change
|
bcf5bfbb
zhouahaihai
挂机new
|
318
319
320
321
|
}))
return true
end
|
53e8037e
zhouhaihai
任务
|
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
-- function _M.getRewardItemRpc(agent , data)
-- local role = agent.role
-- checkReward(role)
-- local items = role:getProperty("hangBag")
-- if not next(items) then return end
-- local notNeed = {[ItemId.Gold] = 1, [ItemId.Exp] = 1, [ItemId.PlayerExp] = 1}
-- local reward = {}
-- for itemId , count in pairs(items) do
-- if not notNeed[itemId] then
-- reward[itemId] = count
-- items[itemId] = nil
-- end
-- end
-- if not next(reward) then return end
-- local reward = role:award(reward)
-- local hangInfo = role:getProperty("hangInfo")
-- local nowTime = skynet.timex()
-- hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max
-- hangInfo.itemTime = nowTime
-- role:updateProperty({field = "hangBag", value = items})
-- role:updateProperty({field = "hangInfo", value = hangInfo})
-- SendPacket(actionCodes.Hang_getRewardItemRpc, MsgPack.pack({
-- reward = reward
-- }))
-- return true
-- end
-- function _M.getRewardCoinRpc(agent , data)
-- local role = agent.role
-- checkReward(role)
-- local items = role:getProperty("hangBag")
-- if not next(items) then return end
-- local need = {[ItemId.Gold] = 1, [ItemId.Exp] = 1, [ItemId.PlayerExp] = 1}
-- local reward = {}
-- for itemId , count in pairs(items) do
-- if need[itemId] then
-- reward[itemId] = count
-- items[itemId] = nil
-- end
-- end
-- local reward = role:award(reward)
|
bcf5bfbb
zhouahaihai
挂机new
|
367
|
|
53e8037e
zhouhaihai
任务
|
368
369
370
371
372
373
374
375
376
377
378
379
|
-- local hangInfo = role:getProperty("hangInfo")
-- local nowTime = skynet.timex()
-- hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max
-- hangInfo.coinTime = nowTime
-- role:updateProperty({field = "hangBag", value = items})
-- role:updateProperty({field = "hangInfo", value = hangInfo})
-- SendPacket(actionCodes.Hang_getRewardCoinRpc, MsgPack.pack({
-- reward = reward
-- }))
-- return true
-- end
|
9962b061
zhouahaihai
补充 挂机
|
380
381
382
383
384
385
386
387
388
389
390
391
392
|
function _M.quickRpc(agent , data)
local role = agent.role
local hangInfo = role:getProperty("hangInfo")
if not hangInfo.carbonId then return end
local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId]
local curCount = role.dailyData:getProperty("hangQC") + 1
local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=")
if not costs[curCount] then return end
if costs[curCount] > 0 then
if not role:checkItemEnough({[ItemId.Diamond] = costs[curCount]}) then return end
|
3133cb76
zhouhaihai
日志
|
393
|
role:costItems({[ItemId.Diamond] = costs[curCount]}, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
|
9962b061
zhouahaihai
补充 挂机
|
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
end
role.dailyData:updateProperty({field = "hangQC", value = curCount})
local time = globalCsv.idle_quickproduce_time
local reward = {}
local coinCount = math.floor(time / globalCsv.idle_money_produce_cd)
local itemCount = math.floor(time / globalCsv.idle_item_produce_cd)
reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + coinCount * carbonData.money
reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + coinCount * carbonData.exp
local pool = {}
for _, temp in pairs(carbonData.item:toArray()) do
table.insert(pool, temp:toArray(true, "="))
end
for i = 1, itemCount do
local cur = pool[math.randWeight(pool, 3)]
reward[cur[1]] = (reward[cur[1]] or 0) + cur[2]
end
|
317a46a9
liuzujun
添加特权卡
|
414
415
416
417
418
419
420
421
422
|
-- 特权卡获取加速获得额外道具
local coef = role.storeData:getProduceItemSpeedCoef()
if coef > 1 then
for k, cnt in pairs(reward) do
reward[k] = math.floor(cnt * coef)
end
end
|
7bb30dca
zhouhaihai
修改发奖
|
423
424
|
local change
reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
|
f60b89b1
zhouhaihai
奖励副本
|
425
426
427
|
if reward[ItemId.Gold] then
role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
end
|
53e8037e
zhouhaihai
任务
|
428
|
role:checkTaskEnter("HangQuick")
|
9962b061
zhouahaihai
补充 挂机
|
429
|
SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({
|
7bb30dca
zhouhaihai
修改发奖
|
430
431
|
reward = reward,
change = change
|
9962b061
zhouahaihai
补充 挂机
|
432
433
434
435
|
}))
return true
end
|
f60b89b1
zhouhaihai
奖励副本
|
436
437
438
439
440
441
442
443
444
|
function _M.bonusFormatRpc(agent , data)
local role = agent.role
local msg = MsgPack.unpack(data)
local bTeam = role:getProperty("bTeam")
for slot, heroId in pairs(msg.heros) do
if not role.heros[heroId] then
return
end
end
|
f603a60f
zhouhaihai
支援技实装
|
445
446
447
448
449
450
451
|
local supports = {}
for slot, support in pairs(msg.supports) do
if slot ~= 1 and slot ~= 2 then return end
local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
if level <= 0 then return end
supports[slot] = support
end
|
7efe5275
zhouhaihai
检查leader
|
452
453
|
if not checkLeader(msg.heros, msg.leader) then return end
|
f60b89b1
zhouhaihai
奖励副本
|
454
455
456
457
458
459
|
table.clear(bTeam)
bTeam.heros = {}
for slot, heroId in pairs(msg.heros) do
bTeam.heros[slot] = heroId
end
bTeam.leader = msg.leader
|
f603a60f
zhouhaihai
支援技实装
|
460
|
bTeam.supports = supports
|
f60b89b1
zhouhaihai
奖励副本
|
461
462
463
464
465
466
467
468
469
470
471
472
473
|
role:updateProperty({field = "bTeam", value = bTeam})
SendPacket(actionCodes.Hang_bonusFormatRpc, '')
return true
end
function _M.buyBonusCountRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local count = msg.count
local btype = msg.type
|
3133cb76
zhouhaihai
日志
|
474
|
if not TimeReset["DailyBattle" .. btype] then return end
|
f60b89b1
zhouhaihai
奖励副本
|
475
476
477
478
479
480
|
local bonusC = role.dailyData:getProperty("bonusC")
bonusC[btype] = bonusC[btype] or {c = 0, b = 0}
local lastCount = globalCsv.bonus_daily_buy_count - bonusC[btype]["b"]
if math.illegalNum(count, 1, lastCount) then return 1 end
|
3133cb76
zhouhaihai
日志
|
481
|
if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end
|
f60b89b1
zhouhaihai
奖励副本
|
482
|
|
3133cb76
zhouhaihai
日志
|
483
|
role:costItems({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}, {log = {desc = "buyBonusCount", short1 = btype, int1 = count}})
|
d481965d
zhouhaihai
购买次数bug
|
484
485
|
bonusC[btype]["b"] = bonusC[btype]["b"] + count
bonusC[btype]["c"] = bonusC[btype]["c"] - count
|
f60b89b1
zhouhaihai
奖励副本
|
486
487
488
489
490
491
492
493
494
495
496
497
|
role.dailyData:updateProperty({field = "bonusC", value = bonusC})
SendPacket(actionCodes.Hang_buyBonusCountRpc, '')
return true
end
function _M.startBonusBattleRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local id = msg.id
|
d232676a
zhouhaihai
功能解锁 冒险返回
|
498
499
|
if not role:isFuncUnlock(FuncUnlock.BonusBattle) then return end
|
f60b89b1
zhouhaihai
奖励副本
|
500
|
local bonusData = csvdb["bonus_battleCsv"][id]
|
bc902e2d
zhouhaihai
增加开放判断
|
501
502
503
|
if not role:isTimeResetOpen(TimeReset["DailyBattle" .. bonusData.type]) then return end
|
f60b89b1
zhouhaihai
奖励副本
|
504
|
if not bonusData then return 1 end
|
33be3111
zhouhaihai
修改hangPass 结构
|
505
|
if not role:checkHangPass(bonusData.unlock) then return 2 end
|
f60b89b1
zhouhaihai
奖励副本
|
506
507
508
509
510
511
|
if not next(role:getProperty("bTeam")) then return 3 end
local bonusC = role.dailyData:getProperty("bonusC")
bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
if globalCsv.bonus_daily_count - bonusC[bonusData.type]["c"] <= 0 then return 4 end
|
f60b89b1
zhouhaihai
奖励副本
|
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
|
role.__bonusBattleCache = {
key = tostring(math.random()),
id = id,
}
SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
return true
end
function _M.endBonusBattleRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local id = msg.id
local key = msg.key
local starNum = msg.starNum
if not role.__bonusBattleCache then return 1 end
|
d6a66c74
zhouhaihai
校验失败也返回
|
530
531
532
533
|
if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then
SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1}))
return true
end
|
f60b89b1
zhouhaihai
奖励副本
|
534
535
|
local bonusData = csvdb["bonus_battleCsv"][id]
|
7bb30dca
zhouhaihai
修改发奖
|
536
|
local reward, change
|
f60b89b1
zhouhaihai
奖励副本
|
537
|
if starNum and starNum > 0 then
|
74a8fdc9
zhouhaihai
奖励副本 胜利扣除次数
|
538
539
540
541
542
543
544
|
-- 胜利扣除次数
local bonusC = role.dailyData:getProperty("bonusC")
bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
if globalCsv.bonus_daily_count - bonusC[bonusData.type]["c"] <= 0 then return 3 end
bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1
role.dailyData:updateProperty({field = "bonusC", value = bonusC})
|
b2747fbc
zhouhaihai
挂机
|
545
546
547
548
549
|
reward = bonusData.reward:toNumMap()
local chance = bonusData.chance:randWeight(true)
if chance[1] ~= 0 then
reward[chance[1]] = (reward[chance[1]] or 0) + chance[2]
end
|
7bb30dca
zhouhaihai
修改发奖
|
550
|
reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}})
|
f60b89b1
zhouhaihai
奖励副本
|
551
552
553
|
role:checkTaskEnter("BonusPass", {id = id})
end
|
3133cb76
zhouhaihai
日志
|
554
555
|
role:log("hang_action", {desc = "bonusBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id})
|
f60b89b1
zhouhaihai
奖励副本
|
556
557
|
SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({
starNum = starNum,
|
7bb30dca
zhouhaihai
修改发奖
|
558
559
560
|
reward = reward,
change = change
}))
|
f60b89b1
zhouhaihai
奖励副本
|
561
562
563
|
return true
end
|
a6508219
zhouhaihai
挂机奖励
|
564
565
566
567
568
569
570
571
572
573
574
|
function _M.hangGiftRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local id = msg.id
local carbonData = csvdb["idle_battleCsv"][id]
if not carbonData or carbonData.item_clear_special == "" then return 1 end
local hangGift = role:getProperty("hangGift")
if hangGift[id] then return 2 end
|
7bb30dca
zhouhaihai
修改发奖
|
575
|
local reward, change = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}})
|
a6508219
zhouhaihai
挂机奖励
|
576
577
578
579
|
role:log("hang_action", {desc = "hangGift", int1 = id})
role:changeUpdates({{type = "hangGift", field = id, value = 1}})
|
7bb30dca
zhouhaihai
修改发奖
|
580
|
SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack({reward = reward, change = change}))
|
a6508219
zhouhaihai
挂机奖励
|
581
582
|
return true
end
|
f60b89b1
zhouhaihai
奖励副本
|
583
|
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
|
function _M.bagFieldRpc(agent, data)
local role = agent.role
local curBL = role:getProperty("hangBagLimit")
local costD = globalCsv.idle_field_cost[curBL - globalCsv.idle_field_origin]
if not costD then
return 1
end
if costD ~= 0 and not role:checkItemEnough({[ItemId.Diamond] = costD}) then
return 2
end
role:updateProperty({field = "hangBagLimit", value = curBL + 1})
role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "bagField"}})
SendPacket(actionCodes.Hang_bagFieldRpc, '')
return true
end
|
f60b89b1
zhouhaihai
奖励副本
|
599
|
|
ed20f277
zhouhaihai
chatline 奖励
|
600
601
602
|
function _M.chatLineRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
ed20f277
zhouhaihai
chatline 奖励
|
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
|
local id = msg.id
local idleData = csvdb["idle_battleCsv"][id]
if not idleData or idleData.chatline == 0 then
return
end
local chatline = role:getProperty("chatline")
if chatline[id] then return end
if not role:checkHangPass(id) then return end
chatline[id] = skynet.timex()
role:updateProperty({field = "chatline", value = chatline})
|
7bb30dca
zhouhaihai
修改发奖
|
618
|
local reward, change = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}})
|
ed20f277
zhouhaihai
chatline 奖励
|
619
|
|
7bb30dca
zhouhaihai
修改发奖
|
620
|
SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack({reward = reward, change = change}))
|
ed20f277
zhouhaihai
chatline 奖励
|
621
622
623
|
return true
end
|
384bb077
zhouahaihai
挂机
|
624
|
return _M
|