384bb077
zhouahaihai
挂机
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
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 = {}
|
70fb62d1
测试
服务器数据打点
|
19
20
21
22
23
24
25
26
27
28
29
|
local function getHangTime(role)
local hangInfo = role:getProperty("hangInfo")
if not hangInfo.carbonId or not hangInfo.coinTime or not hangInfo.itemTime then
return 0
end
local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId]
local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0)
return nowCoinTime - hangInfo.coinTime
end
|
251d8e5e
zhangqijia
fix: 挂机宝鉴,宝藏CD的bug
|
30
|
local function checkReward(role, isTreasure, carbonId)
|
384bb077
zhouahaihai
挂机
|
31
32
|
local hangInfo = role:getProperty("hangInfo")
if not hangInfo.carbonId or not hangInfo.coinTime or not hangInfo.itemTime then
|
024370be
测试
双倍掉掉落bug
|
33
|
return false
|
384bb077
zhouahaihai
挂机
|
34
35
|
end
local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId]
|
2a542865
测试
齿轮、经验 奖励投放逻辑调整
|
36
37
|
--local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId]
local expCarbonData = hangInfo.expData or {}
|
bcf5bfbb
zhouahaihai
挂机new
|
38
39
|
local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0)
local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0)
|
384bb077
zhouahaihai
挂机
|
40
|
|
00bf6029
测试
限时礼包,抽卡ssr广播
|
41
42
|
local expCoef, itemCoef = role.storeData:getHangDropCoef()
|
706b517e
测试
翻倍掉落活动,商城免费宝箱
|
43
44
45
|
-- 此次挂机,其中翻倍时长占多少
local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime)
local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime
|
384bb077
zhouahaihai
挂机
|
46
|
|
706b517e
测试
翻倍掉落活动,商城免费宝箱
|
47
48
49
50
|
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
测试
双倍掉掉落bug
|
51
|
normalTime = nowItemTime - hangInfo.itemTime
|
706b517e
测试
翻倍掉落活动,商城免费宝箱
|
52
|
local itemCount = math.max(0, math.floor((normalTime) / globalCsv.idle_item_produce_cd))
|
706b517e
测试
翻倍掉落活动,商城免费宝箱
|
53
|
hangInfo.itemTime = nowItemTime
|
384bb077
zhouahaihai
挂机
|
54
55
|
local items = role:getProperty("hangBag")
|
00bf6029
测试
限时礼包,抽卡ssr广播
|
56
|
coinCount = (coinCount + coinDoubleCount) * expCoef
|
2a542865
测试
齿轮、经验 奖励投放逻辑调整
|
57
58
|
items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * (expCarbonData.money or 0))
items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * (expCarbonData.exp or 0))
|
251d8e5e
zhangqijia
fix: 挂机宝鉴,宝藏CD的bug
|
59
|
items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * (expCarbonData.playerExp or 0))
|
384bb077
zhouahaihai
挂机
|
60
61
62
63
64
|
local pool = {}
for _, temp in pairs(carbonData.item:toArray()) do
table.insert(pool, temp:toArray(true, "="))
end
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
65
66
67
|
local curFC = 0
local curIC = 0
for id, count in pairs(items) do
|
bcf5bfbb
zhouahaihai
挂机new
|
68
|
if id ~= ItemId.Gold and id ~= ItemId.Exp and id ~= ItemId.PlayerExp then
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
69
70
|
curFC = curFC + math.ceil(count / globalCsv.idle_field_limit)
curIC = curIC + count
|
9962b061
zhouahaihai
补充 挂机
|
71
72
|
end
end
|
317a46a9
测试
添加特权卡
|
73
74
75
|
-- 特权卡挂机额外栏位
local privExtraCnt = role.storeData:getHangSlotExtraCount()
|
460afa6e
测试
付费签到改为主动领取,战斗关卡不一...
|
76
77
|
--local selfFC = role:getProperty("hangBagLimit") + privExtraCnt
local selfFC = 50
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
78
79
80
81
82
83
84
85
86
|
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
测试
双倍掉掉落bug
|
87
|
local cur = clone(pool[idx])
|
93f6e69b
测试
拾荒选择时间,抽卡增加sr保底
|
88
|
if cur[1] ~= 0 then -- 轮空 id
|
024370be
测试
双倍掉掉落bug
|
89
90
|
if cur[1] == ItemId.BreakCost and doubleTime > 0 then
cur[2] = cur[2] * 2
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
91
|
end
|
00bf6029
测试
限时礼包,抽卡ssr广播
|
92
|
cur[2] = cur[2] * itemCoef
|
024370be
测试
双倍掉掉落bug
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
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
完成需求:挂机栏位物品数量上限和钻...
|
113
|
else
|
024370be
测试
双倍掉掉落bug
|
114
115
|
items[cur[1]] = items[cur[1]] + cur[2]
break
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
116
117
|
end
else
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
118
|
break
|
9962b061
zhouahaihai
补充 挂机
|
119
|
end
|
9962b061
zhouahaihai
补充 挂机
|
120
|
end
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
121
122
|
curIC = curIC + 1
end
|
024370be
测试
双倍掉掉落bug
|
123
|
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
124
125
|
for i = 1, itemCount do
randomItem()
|
384bb077
zhouahaihai
挂机
|
126
127
|
end
|
a85b344f
zhangqijia
feat: 挂机图鉴
|
128
|
--挂机得到的宝藏加入到挂机奖励
|
1199daf9
zhangqijia
fix: 挂机图鉴, 增加宝藏CD检查
|
129
|
if isTreasure or false == true then
|
09a115e9
zhangqijia
fix: 挂机图鉴, 切换挂机关卡...
|
130
131
|
carbonId = carbonId or hangInfo.carbonId
local treasureList= role.dailyData:checkTreasureList(carbonId) or {}
|
1199daf9
zhangqijia
fix: 挂机图鉴, 增加宝藏CD检查
|
132
|
if next(treasureList) ~= nil then
|
1199daf9
zhangqijia
fix: 挂机图鉴, 增加宝藏CD检查
|
133
134
135
136
137
138
|
for id, val in pairs(treasureList) do
local award = val.award:toNumMap()
for k,v in pairs(award) do
items[k] = (award[k] or 0) + v
end
end
|
a85b344f
zhangqijia
feat: 挂机图鉴
|
139
140
141
|
end
end
|
384bb077
zhouahaihai
挂机
|
142
|
if coinCount > 0 or itemCount > 0 then
|
5af8b4aa
zhouahaihai
挂机down
|
143
|
return true
|
384bb077
zhouahaihai
挂机
|
144
|
end
|
024370be
测试
双倍掉掉落bug
|
145
146
|
return false
|
384bb077
zhouahaihai
挂机
|
147
148
|
end
|
384bb077
zhouahaihai
挂机
|
149
150
151
152
153
154
|
--开始一个新的关卡
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
奖励副本
|
155
|
if not carbonData then return 1 end
|
384bb077
zhouahaihai
挂机
|
156
|
|
d232676a
zhouhaihai
功能解锁 冒险返回
|
157
158
159
160
|
if math.floor(carbonId / 10000) ~= 1 then
if not role:isFuncUnlock(FuncUnlock.DifficultHang) then return end
end
|
5d80aca6
zhouahaihai
挂机优化
|
161
162
|
for _, preCarbonId in ipairs(carbonData.prepose:toArray(true, "=")) do
|
33be3111
zhouhaihai
修改hangPass 结构
|
163
|
if not role:checkHangPass(preCarbonId) then return 2 end
|
5d80aca6
zhouahaihai
挂机优化
|
164
|
end
|
384bb077
zhouahaihai
挂机
|
165
|
|
ba33bcac
测试
挂机章节解锁
|
166
167
168
169
170
171
172
173
174
|
local carbonId = msg.carbonId -- 解锁章节id
local condition = globalCsv.idle_chapter_unlock[carbonId]
if condition then
local unlockChapter = role:getProperty("unlockChap")
if not unlockChapter[carbonId] then
return 3
end
end
|
251d8e5e
zhangqijia
fix: 挂机宝鉴,宝藏CD的bug
|
175
|
if checkReward(role, true, carbonId) then
|
5af8b4aa
zhouahaihai
挂机down
|
176
177
|
role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")})
end
|
384bb077
zhouahaihai
挂机
|
178
179
|
local hangInfo = role:getProperty("hangInfo")
|
5af8b4aa
zhouahaihai
挂机down
|
180
|
local isNew = not hangInfo.carbonId
|
384bb077
zhouahaihai
挂机
|
181
|
hangInfo.carbonId = carbonId
|
2a542865
测试
齿轮、经验 奖励投放逻辑调整
|
182
|
--hangInfo.expCarbonId = isNew and carbonId or hangInfo.expCarbonId
|
384bb077
zhouahaihai
挂机
|
183
|
local nowTime = skynet.timex()
|
5af8b4aa
zhouahaihai
挂机down
|
184
|
if isNew then
|
1103490d
zhouhaihai
设置 国家时间错误
|
185
186
|
hangInfo.coinTime = nowTime
hangInfo.itemTime = nowTime
|
bcf5bfbb
zhouahaihai
挂机new
|
187
188
|
hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max
hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max
|
1103490d
zhouhaihai
设置 国家时间错误
|
189
190
191
|
else
hangInfo.coinTime = math.min(nowTime, hangInfo.endCoinTime)
hangInfo.itemTime = math.min(nowTime, hangInfo.endItemTime)
|
5af8b4aa
zhouahaihai
挂机down
|
192
|
end
|
072db127
zhouhaihai
推送
|
193
194
|
role:pushMsg({type = "hang", time = math.min(hangInfo.endCoinTime - nowTime, hangInfo.endItemTime - nowTime)})
|
33be3111
zhouhaihai
修改hangPass 结构
|
195
|
if not role:checkHangPass(carbonId) then
|
5af8b4aa
zhouahaihai
挂机down
|
196
197
198
|
hangInfo.bossTime = nowTime + carbonData.idle_time
else
hangInfo.bossTime = nil
|
384bb077
zhouahaihai
挂机
|
199
|
end
|
072db127
zhouhaihai
推送
|
200
|
|
384bb077
zhouahaihai
挂机
|
201
202
|
role:updateProperty({field = "hangInfo", value = hangInfo})
|
d02f7904
zhouhaihai
遗失的log
|
203
|
role:mylog("hang_action", {desc = "startHang", int1 = carbonId})
|
384bb077
zhouahaihai
挂机
|
204
205
206
207
208
209
210
211
|
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
|
212
213
214
215
|
if checkReward(role) then
role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")})
role:updateProperty({field = "hangInfo", value = role:getProperty("hangInfo")})
end
|
384bb077
zhouahaihai
挂机
|
216
217
218
219
|
SendPacket(actionCodes.Hang_checkRpc, MsgPack.pack({}))
return true
end
|
cc5ca7f3
zhouhaihai
缓存battleKey
|
220
|
local _BattleKey = nil
|
384bb077
zhouahaihai
挂机
|
221
222
223
|
function _M.startBattleRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
bcf5bfbb
zhouahaihai
挂机new
|
224
225
|
local carbonId = msg.carbonId
local curData = csvdb["idle_battleCsv"][carbonId]
|
a1e08c9c
zhengshouren
宝箱关战斗异常
|
226
227
228
|
if not curData then
return 1
end
|
bcf5bfbb
zhouahaihai
挂机new
|
229
|
|
460afa6e
测试
付费签到改为主动领取,战斗关卡不一...
|
230
231
232
233
234
235
|
--local hangInfo = role:getProperty("hangInfo") or {}
--if curData.main ~= 1 then
-- if carbonId ~= hangInfo.carbonId then
-- return 2
-- end
--end
|
bcf5bfbb
zhouahaihai
挂机new
|
236
|
|
33be3111
zhouhaihai
修改hangPass 结构
|
237
|
if role:checkHangPass(carbonId) then
|
a1e08c9c
zhengshouren
宝箱关战斗异常
|
238
239
|
return 3
end
|
bcf5bfbb
zhouahaihai
挂机new
|
240
|
|
cc5ca7f3
zhouhaihai
缓存battleKey
|
241
|
_BattleKey = tostring(math.random())
|
70fb62d1
测试
服务器数据打点
|
242
|
role._StartBattleTs = skynet.timex()
|
cc5ca7f3
zhouhaihai
缓存battleKey
|
243
|
|
53e8037e
zhouhaihai
任务
|
244
|
role:checkTaskEnter("HangBattle", {id = carbonId})
|
52c87300
zhouhaihai
bug
|
245
|
SendPacket(actionCodes.Hang_startBattleRpc, MsgPack.pack({key = _BattleKey}))
|
384bb077
zhouahaihai
挂机
|
246
247
248
249
250
251
|
return true
end
function _M.endBattleRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
8cd3770f
测试
挂机关卡可以选择,经验金币根据最高...
|
252
|
local hangInfo = role:getProperty("hangInfo") or {}
|
cc5ca7f3
zhouhaihai
缓存battleKey
|
253
|
if not msg.key or msg.key ~= _BattleKey then
|
d6a66c74
zhouhaihai
校验失败也返回
|
254
255
|
SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1}))
return true
|
4906ebd2
zhengshouren
宝箱关副本结算异常
|
256
|
end
|
bcf5bfbb
zhouahaihai
挂机new
|
257
|
local carbonId = msg.carbonId
|
d4e9b817
zhouhaihai
战斗 日志
|
258
|
local isWin = msg.starNum and msg.starNum > 0
|
bcf5bfbb
zhouahaihai
挂机new
|
259
|
local carbonData = csvdb["idle_battleCsv"][carbonId]
|
4906ebd2
zhengshouren
宝箱关副本结算异常
|
260
261
262
|
if not carbonData then
return 2
end
|
8cd3770f
测试
挂机关卡可以选择,经验金币根据最高...
|
263
|
|
460afa6e
测试
付费签到改为主动领取,战斗关卡不一...
|
264
265
266
267
268
|
--if carbonData.main ~= 1 then
-- if carbonId ~= hangInfo.carbonId then
-- return 3
-- end
--end
|
33be3111
zhouhaihai
修改hangPass 结构
|
269
|
|
e639a6b9
zhangqijia
fix: 挂机图鉴-绑定关卡
|
270
|
if role:checkHangPass(carbonId) then
|
4906ebd2
zhengshouren
宝箱关副本结算异常
|
271
272
|
return 4
end
|
d4e9b817
zhouhaihai
战斗 日志
|
273
|
|
edf2ee12
zhouhaihai
防作弊
|
274
275
276
277
278
279
280
281
282
283
|
-- 防作弊
if not role:checkBattleCheat("hang", {
id = carbonId,
isWin = isWin,
info = msg.info
}) then
SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1}))
return true
end
|
7bb30dca
zhouhaihai
修改发奖
|
284
|
local reward, change
|
d4e9b817
zhouhaihai
战斗 日志
|
285
|
if isWin then --win
|
33be3111
zhouhaihai
修改hangPass 结构
|
286
|
role:hangFinish(carbonId)
|
bcf5bfbb
zhouahaihai
挂机new
|
287
288
289
|
if carbonData.main ~= 1 then
hangInfo.bossTime = nil
end
|
384bb077
zhouahaihai
挂机
|
290
291
|
-- reward
reward = {}
|
384bb077
zhouahaihai
挂机
|
292
293
|
reward[ItemId.Gold] = carbonData.money_clear
reward[ItemId.Exp] = carbonData.exp_clear
|
00115a7a
zhouahaihai
奖励发放
|
294
|
reward[ItemId.PlayerExp] = carbonData.playerExp_clear
|
384bb077
zhouahaihai
挂机
|
295
|
for itemId, count in pairs(carbonData.item_clear:toNumMap()) do
|
384bb077
zhouahaihai
挂机
|
296
297
|
reward[itemId] = count
end
|
7bb30dca
zhouhaihai
修改发奖
|
298
|
reward, change = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}})
|
00e663bd
zhouhaihai
剧情相关
|
299
|
|
03a6166a
zhouhaihai
餐厅优化
|
300
|
role:checkTaskEnter("HangPass", {id = carbonId})
|
286c980a
chenyueqi
挂机战斗胜利才触发对应的引导
|
301
302
303
|
-- 引导
if carbonId == 10101 then
|
a5b98c30
chenyueqi
引导调整
|
304
|
role:finishGuide(6)
|
be0c7a19
chenyueqi
挂机打完困难20101才设定完成引导22
|
305
|
elseif carbonId == 20101 then
|
286c980a
chenyueqi
挂机战斗胜利才触发对应的引导
|
306
307
308
309
310
311
312
313
|
role:finishGuide(22)
end
for _, guideData in pairs(csvdb["guide_unlockCsv"]) do
if guideData.type == 3 and guideData.carbonId == carbonId then
role:saveGuide(guideData.guideId,1,true)
break
end
end
|
384bb077
zhouahaihai
挂机
|
314
|
end
|
53b4b8bd
测试
自动挂机下一关
|
315
316
|
local nextCarbonId = role:getNextCarbonId(carbonId)
-- 设置挂机关卡
|
87c65a8d
测试
挂机经验关卡改为最终通关关卡
|
317
|
if isWin then --and (hangInfo.carbonId or 0) < nextCarbonId then
|
2a542865
测试
齿轮、经验 奖励投放逻辑调整
|
318
319
320
321
322
323
324
|
local newCarbonData = csvdb["idle_battleCsv"][carbonId]
if newCarbonData then
local expData = hangInfo.expData or {}
expData.exp = (expData.exp or 0) + newCarbonData.exp
expData.money = (expData.money or 0) + newCarbonData.money
expData.playerExp = (expData.playerExp or 0) + newCarbonData.playerExp
hangInfo.expData = expData
|
98d32f92
测试
多编队
|
325
|
end
|
2a542865
测试
齿轮、经验 奖励投放逻辑调整
|
326
327
328
329
330
331
332
333
334
335
336
|
--if not hangInfo.expCarbonId then
-- hangInfo.expCarbonId = carbonId
--else
-- local oldCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId]
-- local newCarbonData = csvdb["idle_battleCsv"][carbonId]
-- if oldCarbonData.money < newCarbonData.money then
-- hangInfo.expCarbonId = carbonId
-- end
--end
|
87c65a8d
测试
挂机经验关卡改为最终通关关卡
|
337
338
339
340
|
--local cfg = csvdb["idle_battleCsv"][nextCarbonId]
--if cfg then
-- hangInfo.bossTime = skynet.timex() + cfg.idle_time
--end
|
93f6e69b
测试
拾荒选择时间,抽卡增加sr保底
|
341
|
end
|
e639a6b9
zhangqijia
fix: 挂机图鉴-绑定关卡
|
342
343
344
345
346
347
|
--刷新宝藏图鉴
if isWin and globalCsv.idle_treasure_point and globalCsv.idle_treasure_point == carbonId then
role.dailyData:getTreasrueList()
end
|
384bb077
zhouahaihai
挂机
|
348
|
role:updateProperty({field = "hangInfo", value = hangInfo})
|
33be3111
zhouhaihai
修改hangPass 结构
|
349
|
|
d4e9b817
zhouhaihai
战斗 日志
|
350
351
352
353
354
355
|
role:checkBattle("hang", {
id = carbonId,
isWin = isWin,
info = msg.info,
reward = reward,
})
|
1e9cb217
chenyueqi
服务器记录控制引导过程
|
356
|
|
d02f7904
zhouhaihai
遗失的log
|
357
|
local team = role:getProperty("pvpTC")
|
70fb62d1
测试
服务器数据打点
|
358
359
360
|
local battleTime = skynet.timex() - role._StartBattleTs
role:mylog("hang_action", {desc = "hangBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = carbonId, int2 = role:getProperty("hangTBV"), cint1 = role:getHerosCamp(team.heros), cint2 = battleTime})
|
d02f7904
zhouhaihai
遗失的log
|
361
|
|
384bb077
zhouahaihai
挂机
|
362
363
364
|
SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({
starNum = msg.starNum,
reward = reward,
|
7bb30dca
zhouhaihai
修改发奖
|
365
|
change = change,
|
384bb077
zhouahaihai
挂机
|
366
367
368
369
|
}))
return true
end
|
7efe5275
zhouhaihai
检查leader
|
370
371
372
373
374
375
376
|
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
挂机
|
377
378
379
|
function _M.roleFormatRpc(agent , data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
98d32f92
测试
多编队
|
380
381
|
local index = msg.index -- 阵容索引
local title = msg.title -- 阵容名称
|
7d662b85
测试
编队增加战术字段
|
382
|
local tactics = msg.tactics -- 战术
|
761b3ea8
chenyueqi
再改一波电波塔整容相关信息
|
383
|
local tower = msg.tower
|
98d32f92
测试
多编队
|
384
|
local team = {}
|
384bb077
zhouahaihai
挂机
|
385
386
|
for slot, heroId in pairs(msg.heros) do
if not role.heros[heroId] then
|
e6ebee44
zhouhaihai
编队bug
|
387
|
return 1
|
384bb077
zhouahaihai
挂机
|
388
389
|
end
end
|
f603a60f
zhouhaihai
支援技实装
|
390
391
392
|
local supports = {}
for slot, support in pairs(msg.supports or {}) do
|
e6ebee44
zhouhaihai
编队bug
|
393
|
if slot ~= 1 and slot ~= 2 then return 2 end
|
f603a60f
zhouhaihai
支援技实装
|
394
|
local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
|
e6ebee44
zhouhaihai
编队bug
|
395
|
if level <= 0 then return 3 end
|
f603a60f
zhouhaihai
支援技实装
|
396
397
|
supports[slot] = support
end
|
e6ebee44
zhouhaihai
编队bug
|
398
|
if not checkLeader(msg.heros, msg.leader) then return 4 end
|
f603a60f
zhouhaihai
支援技实装
|
399
|
|
98d32f92
测试
多编队
|
400
401
402
403
404
405
406
407
408
|
if index > 10 then
return 5
end
if #title > 100 then
return 6
end
team.heros = {}
|
384bb077
zhouahaihai
挂机
|
409
|
for slot, heroId in pairs(msg.heros) do
|
98d32f92
测试
多编队
|
410
411
412
413
414
|
team.heros[slot] = heroId
end
team.leader = msg.leader
team.supports = supports
team.title = title
|
f7f26c15
zhouhaihai
编队整理 增加 tactics战术
|
415
416
417
|
if msg.tactics and globalCsv.tactics_skill_passive_cell[msg.tactics] then
team.tactics = msg.tactics
end
|
98d32f92
测试
多编队
|
418
|
|
761b3ea8
chenyueqi
再改一波电波塔整容相关信息
|
419
420
421
422
423
|
if tower then
role:setTowerTeamFormat(index, team)
else
role:setTeamFormat(index, team)
end
|
98d32f92
测试
多编队
|
424
|
|
384bb077
zhouahaihai
挂机
|
425
426
427
428
|
SendPacket(actionCodes.Hang_roleFormatRpc, '')
return true
end
|
5af8b4aa
zhouahaihai
挂机down
|
429
430
|
function _M.getRewardRpc(agent , data)
local role = agent.role
|
70fb62d1
测试
服务器数据打点
|
431
|
local hangTime = getHangTime(role)
|
1199daf9
zhangqijia
fix: 挂机图鉴, 增加宝藏CD检查
|
432
|
checkReward(role, true)
|
5af8b4aa
zhouahaihai
挂机down
|
433
434
|
local items = role:getProperty("hangBag")
if not next(items) then return end
|
7bb30dca
zhouhaihai
修改发奖
|
435
|
local reward, change = role:award(items, {log = {desc = "hangReward"}})
|
5af8b4aa
zhouahaihai
挂机down
|
436
437
438
|
table.clear(items)
local hangInfo = role:getProperty("hangInfo")
local nowTime = skynet.timex()
|
a42130ee
chenyueqi
电波塔加成错误
|
439
440
441
|
local timeAdd = role:getBnousHangTime()
hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max + timeAdd
hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max + timeAdd
|
5af8b4aa
zhouahaihai
挂机down
|
442
443
444
445
|
hangInfo.coinTime = nowTime
hangInfo.itemTime = nowTime
role:updateProperty({field = "hangBag", value = items})
role:updateProperty({field = "hangInfo", value = hangInfo})
|
072db127
zhouhaihai
推送
|
446
447
|
role:pushMsg({type = "hang", time = globalCsv.idle_producetime_max})
|
190e1415
测试
英雄帖活动初始化
|
448
|
role:checkTaskEnter("HangGet", {reward = reward})
|
53e8037e
zhouhaihai
任务
|
449
450
|
if reward[ItemId.Gold] then
role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
|
bcf5bfbb
zhouahaihai
挂机new
|
451
|
end
|
d43246b0
zhouhaihai
log 增加
|
452
453
454
455
456
457
458
459
460
461
|
role:log("residence_reward", {
mission_threadid = math.floor(hangInfo.carbonId / 10000), --大关卡ID
mission_id = hangInfo.carbonId, --关卡ID
mission_type = 100, --关卡类型,见关卡类型枚举表
residence_reward_type = 0, --领取奖励方式,快速(超前领取)记录为1,正常领取记录为0
residence_time = 0, --挂机或排名时长
residence_reward = reward, --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
})
|
70fb62d1
测试
服务器数据打点
|
462
|
role:mylog("hang_action", {desc = "hangReward", int1 = hangTime})
|
d43246b0
zhouhaihai
log 增加
|
463
|
|
53e8037e
zhouhaihai
任务
|
464
|
SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({
|
7bb30dca
zhouhaihai
修改发奖
|
465
466
|
reward = reward,
change = change
|
bcf5bfbb
zhouahaihai
挂机new
|
467
468
469
470
|
}))
return true
end
|
9962b061
zhouahaihai
补充 挂机
|
471
472
473
474
475
476
|
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]
|
2a542865
测试
齿轮、经验 奖励投放逻辑调整
|
477
478
|
--local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId]
local expCarbonData = hangInfo.expData or {}
|
9962b061
zhouahaihai
补充 挂机
|
479
480
481
482
483
|
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
|
3d8050ef
测试
钻石3改成虹光玉8
|
484
485
|
if not role:checkItemEnough({[ItemId.Jade] = costs[curCount]}) then return end
role:costItems({[ItemId.Jade] = costs[curCount]}, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
|
9962b061
zhouahaihai
补充 挂机
|
486
487
488
489
490
491
492
493
494
|
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)
|
2a542865
测试
齿轮、经验 奖励投放逻辑调整
|
495
496
497
|
reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * (expCarbonData.money or 0))
reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * (expCarbonData.exp or 0))
reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * (expCarbonData.playerExp or 0))
|
9962b061
zhouahaihai
补充 挂机
|
498
499
500
501
502
503
504
505
506
|
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
测试
添加特权卡
|
507
|
|
9e1a93c2
测试
快速挂机掉落浮点数取整
|
508
|
local doubleCoef = role.activity:isOpen("DoubleDrop") and 2 or 1
|
317a46a9
测试
添加特权卡
|
509
510
|
-- 特权卡获取加速获得额外道具
local coef = role.storeData:getProduceItemSpeedCoef()
|
accf94c4
测试
活动以类型标识,修改双倍活动bug
|
511
|
if coef > 1 or doubleCoef > 1 then
|
317a46a9
测试
添加特权卡
|
512
|
for k, cnt in pairs(reward) do
|
9e1a93c2
测试
快速挂机掉落浮点数取整
|
513
|
reward[k] = math.floor(cnt * coef * doubleCoef)
|
317a46a9
测试
添加特权卡
|
514
515
516
|
end
end
|
7bb30dca
zhouhaihai
修改发奖
|
517
518
|
local change
reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
|
f60b89b1
zhouhaihai
奖励副本
|
519
520
521
|
if reward[ItemId.Gold] then
role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
end
|
53e8037e
zhouhaihai
任务
|
522
|
role:checkTaskEnter("HangQuick")
|
d43246b0
zhouhaihai
log 增加
|
523
524
525
526
527
528
529
530
531
|
role:log("residence_reward", {
mission_threadid = math.floor(hangInfo.carbonId / 10000), --大关卡ID
mission_id = hangInfo.carbonId, --关卡ID
mission_type = 100, --关卡类型,见关卡类型枚举表
residence_reward_type = 1, --领取奖励方式,快速(超前领取)记录为1,正常领取记录为0
residence_time = time, --挂机或排名时长
residence_reward = reward, --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
})
|
70fb62d1
测试
服务器数据打点
|
532
533
|
role:mylog("hang_action", {desc = "quick", short1 = curCount})
|
9962b061
zhouahaihai
补充 挂机
|
534
|
SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({
|
7bb30dca
zhouhaihai
修改发奖
|
535
536
|
reward = reward,
change = change
|
9962b061
zhouahaihai
补充 挂机
|
537
538
539
540
|
}))
return true
end
|
f60b89b1
zhouhaihai
奖励副本
|
541
542
543
544
545
546
547
548
|
function _M.buyBonusCountRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local count = msg.count
local btype = msg.type
|
3133cb76
zhouhaihai
日志
|
549
|
if not TimeReset["DailyBattle" .. btype] then return end
|
accf94c4
测试
活动以类型标识,修改双倍活动bug
|
550
551
|
local open, actId = role.activity:isOpen("BonusDouble")
local actData = csvdb["activity_ctrlCsv"][actId]
|
accf94c4
测试
活动以类型标识,修改双倍活动bug
|
552
|
|
a526f9ef
测试
奖励关卡活动未开启导致Bug
|
553
554
555
556
|
local coef = 1
if open and actData then
coef= tonumber(actData.condition2)
end
|
f60b89b1
zhouhaihai
奖励副本
|
557
558
|
local bonusC = role.dailyData:getProperty("bonusC")
|
00bf6029
测试
限时礼包,抽卡ssr广播
|
559
|
local extraCnt = role.storeData:getBonusExtraFightCount()
|
f60b89b1
zhouhaihai
奖励副本
|
560
|
bonusC[btype] = bonusC[btype] or {c = 0, b = 0}
|
00bf6029
测试
限时礼包,抽卡ssr广播
|
561
|
local lastCount = globalCsv.bonus_daily_buy_count * coef + extraCnt - bonusC[btype]["b"]
|
f60b89b1
zhouhaihai
奖励副本
|
562
563
|
if math.illegalNum(count, 1, lastCount) then return 1 end
|
3d8050ef
测试
钻石3改成虹光玉8
|
564
|
if not role:checkItemEnough({[ItemId.Jade] = globalCsv.bonus_buy_cost * count}) then return 2 end
|
f60b89b1
zhouhaihai
奖励副本
|
565
|
|
3d8050ef
测试
钻石3改成虹光玉8
|
566
|
role:costItems({[ItemId.Jade] = globalCsv.bonus_buy_cost * count}, {log = {desc = "buyBonusCount", int1 = btype, int2 = count}})
|
d481965d
zhouhaihai
购买次数bug
|
567
568
|
bonusC[btype]["b"] = bonusC[btype]["b"] + count
bonusC[btype]["c"] = bonusC[btype]["c"] - count
|
f60b89b1
zhouhaihai
奖励副本
|
569
570
571
572
573
574
575
|
role.dailyData:updateProperty({field = "bonusC", value = bonusC})
SendPacket(actionCodes.Hang_buyBonusCountRpc, '')
return true
end
|
40b19300
chenyueqi
电波塔激活加成效果后对各个系统的加成
|
576
|
local function bonusWinReward(role, bonusData, rewardType, count, sweep)
|
be24b6ad
zhouhaihai
传递 count
|
577
|
count = count or 1
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
578
|
|
55c7c172
zhouhaihai
奖励副本 新机制
|
579
580
581
582
|
local reward, change = {}
if rewardType == 1 or rewardType == 4 then
for k, v in pairs(bonusData.clear_reward:toNumMap()) do
reward[k] = (reward[k] or 0) + v
|
be24b6ad
zhouhaihai
传递 count
|
583
584
585
|
end
end
|
55c7c172
zhouhaihai
奖励副本 新机制
|
586
|
if rewardType == 2 or rewardType == 4 then
|
e4a17692
zhouhaihai
奖励关卡 满星奖励
|
587
588
589
590
|
for k, v in pairs(bonusData.perfect_reward:toNumMap()) do
reward[k] = (reward[k] or 0) + v
end
end
|
55c7c172
zhouhaihai
奖励副本 新机制
|
591
592
593
|
if rewardType == 3 then
local open, actId = role.activity:isOpen("BonusDouble")
|
1ce3adac
zhouhaihai
充值
|
594
595
596
597
|
local actData
if open then
actData = csvdb["activity_ctrlCsv"][actId]
end
|
55c7c172
zhouhaihai
奖励副本 新机制
|
598
599
600
601
602
603
604
605
606
607
608
|
reward = bonusData.reward:toNumMap()
for itemId, c in pairs(reward) do
reward[itemId] = c * count
end
for i = 1, count do
local chance = bonusData.chance:randWeight(true)
if chance[1] ~= 0 then
reward[chance[1]] = (reward[chance[1]] or 0) + chance[2]
end
end
|
1ce3adac
zhouhaihai
充值
|
609
610
611
612
|
if open and actData then
for k, v in pairs(reward) do
reward[k] = v * (actData.condition > 1 and actData.condition or 1)
end
|
55c7c172
zhouhaihai
奖励副本 新机制
|
613
614
615
|
end
end
|
40b19300
chenyueqi
电波塔激活加成效果后对各个系统的加成
|
616
617
618
619
620
621
622
|
if sweep then
local bnousReward = role:getBnousSweep()
for key, value in pairs(bnousReward) do
reward[key] = (reward[key] or 0) + value * count
end
end
|
55c7c172
zhouhaihai
奖励副本 新机制
|
623
624
625
|
reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = bonusData.id}})
role:checkTaskEnter("BonusPass", {id = bonusData.id, count = count})
return reward, change
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
626
627
|
end
|
f60b89b1
zhouhaihai
奖励副本
|
628
629
630
631
|
function _M.startBonusBattleRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local id = msg.id
|
be24b6ad
zhouhaihai
传递 count
|
632
|
local count = msg.count or 1
|
f60b89b1
zhouhaihai
奖励副本
|
633
|
|
accf94c4
测试
活动以类型标识,修改双倍活动bug
|
634
635
636
|
local open, actId = role.activity:isOpen("BonusDouble")
if not role:isFuncUnlock(FuncUnlock.BonusBattle) then return 1 end
|
d232676a
zhouhaihai
功能解锁 冒险返回
|
637
|
|
f60b89b1
zhouhaihai
奖励副本
|
638
|
local bonusData = csvdb["bonus_battleCsv"][id]
|
bc902e2d
zhouhaihai
增加开放判断
|
639
|
|
accf94c4
测试
活动以类型标识,修改双倍活动bug
|
640
641
642
|
if not open then
if not role:isTimeResetOpen(TimeReset["DailyBattle" .. bonusData.type]) then return 2 end
end
|
bc902e2d
zhouhaihai
增加开放判断
|
643
|
|
accf94c4
测试
活动以类型标识,修改双倍活动bug
|
644
|
if not bonusData then return 3 end
|
c5e11ffc
zhouhaihai
解锁条件修改
|
645
|
local bonusStar = role:getProperty("bonusStar")
|
f60b89b1
zhouhaihai
奖励副本
|
646
|
|
4591e219
zhouhaihai
bug
|
647
|
if bonusData.unlock ~= 0 and (not bonusStar[bonusData.unlock] or bonusStar[bonusData.unlock] == 0) then return 4 end
|
f60b89b1
zhouhaihai
奖励副本
|
648
|
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
649
|
if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then
|
55c7c172
zhouhaihai
奖励副本 新机制
|
650
651
652
653
654
655
656
657
658
659
660
661
662
663
|
local bonusC = role.dailyData:getProperty("bonusC")
bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
local actData = csvdb["activity_ctrlCsv"][actId]
local extraCnt = role.storeData:getBonusExtraFightCount()
local coef = 1
if open and actData then
coef = tonumber(actData.condition2)
end
if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end
bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count
role.dailyData:updateProperty({field = "bonusC", value = bonusC})
|
40b19300
chenyueqi
电波塔激活加成效果后对各个系统的加成
|
664
|
local reward, change = bonusWinReward(role, bonusData, 3, count, true)
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
665
|
SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change}))
|
f76d63e1
测试
联动任务活动
|
666
667
|
role:checkTaskEnter("BonusQuick", {count = count})
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
668
669
670
671
672
673
674
675
676
|
else
local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
if not next(bTeam) then return 5 end
role.__bonusBattleCache = {
key = tostring(math.random()),
id = id,
}
SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
end
|
f60b89b1
zhouhaihai
奖励副本
|
677
|
|
f60b89b1
zhouhaihai
奖励副本
|
678
679
680
681
682
683
684
685
686
687
|
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
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
688
|
|
f60b89b1
zhouhaihai
奖励副本
|
689
|
|
d6a66c74
zhouhaihai
校验失败也返回
|
690
691
692
693
|
if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then
SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1}))
return true
end
|
edf2ee12
zhouhaihai
防作弊
|
694
695
696
697
698
699
700
701
702
703
704
705
|
role.__bonusBattleCache = nil
-- 防作弊
if not role:checkBattleCheat("bonus", {
id = id,
isWin = starNum and starNum > 0,
info = msg.info
}) then
SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1}))
return true
end
|
f60b89b1
zhouhaihai
奖励副本
|
706
707
|
local bonusData = csvdb["bonus_battleCsv"][id]
|
1ce3adac
zhouhaihai
充值
|
708
|
local reward, change = {}
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
709
710
|
local bonusStar = role:getProperty("bonusStar")
|
55c7c172
zhouhaihai
奖励副本 新机制
|
711
|
local oldStar = bonusStar[id] or 0
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
712
|
local curStar = 0
|
f60b89b1
zhouhaihai
奖励副本
|
713
|
if starNum and starNum > 0 then
|
74a8fdc9
zhouhaihai
奖励副本 胜利扣除次数
|
714
|
-- 胜利扣除次数
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
715
|
|
ce950b6e
zhouhaihai
bug
|
716
|
local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
|
821e2704
zhouhaihai
heros 增加 supports
|
717
|
local herosInfo = role:getTeamHerosInfo(bTeam).heros
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
718
719
720
721
722
723
724
725
726
|
local check = {}
-- 1 通关
check[1] = function(_)
return true
end
-- 2 阵亡人数 <= N
check[2] = function(_, cond)
return msg.info.dead and msg.info.dead <= cond
|
b2747fbc
zhouhaihai
挂机
|
727
|
end
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
728
729
730
|
-- 3 全员存活
check[3] = function(_)
return msg.info.dead and msg.info.dead == 0
|
accf94c4
测试
活动以类型标识,修改双倍活动bug
|
731
|
end
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
732
733
734
735
|
-- 4 指定种族 >= N
check[4] = function(_, cond)
local count = 0
for _, one in pairs(herosInfo) do
|
66fe093a
测试
元旦关卡活动
|
736
|
local heroData = csvdb["unitCsv"][one.type]
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
737
738
739
740
741
742
743
744
745
746
|
if heroData.camp == cond then
count = count + 1
end
end
return count >= cond
end
-- 5 指定职业 >= N
check[5] = function(_, cond)
local count = 0
for _, one in pairs(herosInfo) do
|
66fe093a
测试
元旦关卡活动
|
747
|
local heroData = csvdb["unitCsv"][one.type]
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
|
if heroData.job == cond then
count = count + 1
end
end
return count >= cond
end
-- 6 含有指定角色
check[6] = function(_, cond)
for _, one in pairs(herosInfo) do
if one.type == cond then
return true
end
end
return false
end
-- 7 通关耗时 <= X 秒 msg.info.atime
check[7] = function(_, cond)
return msg.info.atime and msg.info.atime <= cond
end
curStar = 0
|
e4a17692
zhouhaihai
奖励关卡 满星奖励
|
768
769
|
local sweepConds = bonusData.sweep_condition:toTableArray(true)
for i, cond in ipairs(sweepConds) do
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
770
771
772
773
|
if check[cond[1]] and check[cond[1]](table.unpack(cond)) then
curStar = curStar + (1 << (i - 1))
end
end
|
e4a17692
zhouhaihai
奖励关卡 满星奖励
|
774
|
local status
|
55c7c172
zhouhaihai
奖励副本 新机制
|
775
776
777
778
779
780
781
782
783
784
785
786
787
|
local rewardType = 0
if curStar >= (1 << #sweepConds) - 1 then -- 满星
rewardType = 2
if oldStar == 0 then --通关
rewardType = 4
end
elseif oldStar == 0 then --通关
rewardType = 1
end
if rewardType ~= 0 then
reward, change = bonusWinReward(role, bonusData, rewardType)
end
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
788
|
else
|
55c7c172
zhouhaihai
奖励副本 新机制
|
789
|
curStar = oldStar
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
790
|
end
|
55c7c172
zhouhaihai
奖励副本 新机制
|
791
|
if curStar ~= oldStar then
|
3c51e6d4
zhouhaihai
奖励副本 完成
|
792
793
|
bonusStar[id] = curStar
role:updateProperty({field = "bonusStar", value = bonusStar})
|
f60b89b1
zhouhaihai
奖励副本
|
794
795
|
end
|
d4e9b817
zhouhaihai
战斗 日志
|
796
797
798
799
800
801
|
role:checkBattle("bonus", {
id = id,
isWin = starNum and starNum > 0,
info = msg.info,
reward = reward,
})
|
d02f7904
zhouhaihai
遗失的log
|
802
803
|
role:mylog("hang_action", {desc = "bonusBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id})
|
f60b89b1
zhouhaihai
奖励副本
|
804
805
|
SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({
starNum = starNum,
|
7bb30dca
zhouhaihai
修改发奖
|
806
807
808
|
reward = reward,
change = change
}))
|
f60b89b1
zhouhaihai
奖励副本
|
809
810
811
|
return true
end
|
29fbbc10
zhouhaihai
夜间打工
|
812
813
814
815
816
|
local function workWinReward(role, bonusData, rewardType, count, sweep)
count = count or 1
local reward, change = {}
|
7a4c9ac8
liguanghui
bug修复:扫荡会多给一次奖励
|
817
818
819
820
821
822
|
reward = bonusData.reward:toNumMap()
for itemId, c in pairs(reward) do
reward[itemId] = c * count
end
|
29fbbc10
zhouhaihai
夜间打工
|
823
824
825
826
827
|
if rewardType == 2 or rewardType == 4 then
for k, v in pairs(bonusData.perfect_reward:toNumMap()) do
reward[k] = (reward[k] or 0) + v
end
end
|
5de5479e
liguanghui
工作日玩法奖励结算bug修复
|
828
829
|
for i = 1, count do
local chance = bonusData.chance:randWeight(true)
|
5de5479e
liguanghui
工作日玩法奖励结算bug修复
|
830
831
|
if chance[1] ~= 0 then
reward[chance[1]] = (reward[chance[1]] or 0) + chance[2]
|
29fbbc10
zhouhaihai
夜间打工
|
832
833
|
end
end
|
29fbbc10
zhouhaihai
夜间打工
|
834
|
reward, change = role:award(reward, {log = {desc = "workBattle", int1 = bonusData.id}})
|
29fbbc10
zhouhaihai
夜间打工
|
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
|
return reward, change
end
function _M.workBattleInfoRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local workMainCsv = csvdb["work_mainCsv"][msg.type]
if not workMainCsv then return 1 end
if not role:isTimeResetOpen(TimeReset["WorkBattle" .. msg.type]) then return 2 end
SendPacket(actionCodes.Hang_workBattleInfoRpc, MsgPack.pack({count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. msg.type]) * 10 + msg.type))}))
return true
end
function _M.getWorkRewardRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local workMainCsv = csvdb["work_mainCsv"][msg.type]
if not workMainCsv then return 1 end
if not role:isTimeResetOpen(TimeReset["WorkBattle" .. msg.type]) then return 2 end
local count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. msg.type]) * 10 + msg.type))
if count < workMainCsv.target_num then return 3 end
local workBattle = role:getProperty("workBattle")
if workBattle[msg.type] ~= 1 then
return 4
end
workBattle[msg.type] = -1
role:updateProperty({field = "workBattle", value = workBattle})
local reward, change = role:award(workMainCsv.phase_award, {log = {desc = "workReward"}})
SendPacket(actionCodes.Hang_getWorkRewardRpc, MsgPack.pack({reward = reward, change = change}))
return true
end
function _M.startWorkBattleRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local id = msg.id
local count = msg.count or 1
if not role:isFuncUnlock(FuncUnlock.BonusBattle) then return 1 end
local bonusData = csvdb["work_battleCsv"][id]
if not bonusData then return 3 end
if not role:isTimeResetOpen(TimeReset["WorkBattle" .. bonusData.type]) then return 2 end
local ticketId = csvdb["work_mainCsv"][bonusData.type].ticket
local workStar = role:getProperty("workStar")
if bonusData.unlock ~= 0 and (not workStar[bonusData.unlock] or workStar[bonusData.unlock] == 0) then return 4 end
local workBattle = role:getProperty("workBattle")
workBattle[bonusData.type] = workBattle[bonusData.type] or 0
local needCount = count - (workBattle[bonusData.type] == 0 and 1 or 0)
if needCount ~= 0 and not role:checkItemEnough({[ticketId] = needCount}) then return 11 end
if workStar[id] and workStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then
if workBattle[bonusData.type] == 0 then
workBattle[bonusData.type] = 1
role:updateProperty({field = "workBattle", value = workBattle})
end
if needCount > 0 then
role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}})
end
|
007e3c41
zhouhaihai
增加的分数不同
|
899
|
redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, count * bonusData.target_add)
|
29fbbc10
zhouhaihai
夜间打工
|
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
|
local reward, change = workWinReward(role, bonusData, 3, count, true)
SendPacket(actionCodes.Hang_startWorkBattleRpc, MsgPack.pack({reward = reward, change = change}))
else
local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
if not next(bTeam) then return 5 end
role.__bonusBattleCache = {
key = tostring(math.random()),
id = id,
}
SendPacket(actionCodes.Hang_startWorkBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
end
return true
end
function _M.endWorkBattleRpc(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
if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then
SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({errorCode = 1}))
return true
end
role.__bonusBattleCache = nil
-- 防作弊
if not role:checkBattleCheat("work", {
id = id,
isWin = starNum and starNum > 0,
info = msg.info
}) then
SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({errorCode = 1}))
return true
end
local bonusData = csvdb["work_battleCsv"][id]
local ticketId = csvdb["work_mainCsv"][bonusData.type].ticket
local reward, change = {}
local workStar = role:getProperty("workStar")
local oldStar = workStar[id] or 0
local curStar = 0
if starNum and starNum > 0 then
-- 胜利扣除次数
local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
local herosInfo = role:getTeamHerosInfo(bTeam).heros
local check = {}
-- 1 通关
check[1] = function(_)
return true
end
-- 2 阵亡人数 <= N
check[2] = function(_, cond)
return msg.info.dead and msg.info.dead <= cond
end
-- 3 全员存活
check[3] = function(_)
return msg.info.dead and msg.info.dead == 0
end
-- 4 指定种族 >= N
check[4] = function(_, cond)
local count = 0
for _, one in pairs(herosInfo) do
local heroData = csvdb["unitCsv"][one.type]
if heroData.camp == cond then
count = count + 1
end
end
return count >= cond
end
-- 5 指定职业 >= N
check[5] = function(_, cond)
local count = 0
for _, one in pairs(herosInfo) do
local heroData = csvdb["unitCsv"][one.type]
if heroData.job == cond then
count = count + 1
end
end
return count >= cond
end
-- 6 含有指定角色
check[6] = function(_, cond)
for _, one in pairs(herosInfo) do
if one.type == cond then
return true
end
end
return false
end
-- 7 通关耗时 <= X 秒 msg.info.atime
check[7] = function(_, cond)
return msg.info.atime and msg.info.atime <= cond
end
curStar = 0
local sweepConds = bonusData.sweep_condition:toTableArray(true)
for i, cond in ipairs(sweepConds) do
if check[cond[1]] and check[cond[1]](table.unpack(cond)) then
curStar = curStar + (1 << (i - 1))
end
end
local status
local rewardType = 0
if curStar >= (1 << #sweepConds) - 1 then -- 满星
rewardType = 2
if oldStar == 0 then --通关
rewardType = 4
end
elseif oldStar == 0 then --通关
rewardType = 1
end
if rewardType ~= 0 then
local workBattle = role:getProperty("workBattle")
workBattle[bonusData.type] = workBattle[bonusData.type] or 0
local needCount = 1 - (workBattle[bonusData.type] == 0 and 1 or 0)
|
ffb897e9
zhouhaihai
免费次数记录错误
|
1023
1024
|
if workBattle[bonusData.type] == 0 then
workBattle[bonusData.type] = 1
|
29fbbc10
zhouhaihai
夜间打工
|
1025
1026
1027
1028
1029
|
role:updateProperty({field = "workBattle", value = workBattle})
end
if needCount > 0 then
role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}})
end
|
007e3c41
zhouhaihai
增加的分数不同
|
1030
|
redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, bonusData.target_add)
|
29fbbc10
zhouhaihai
夜间打工
|
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
|
reward, change = workWinReward(role, bonusData, rewardType)
end
else
curStar = oldStar
end
if curStar ~= oldStar then
workStar[id] = curStar
role:updateProperty({field = "workStar", value = workStar})
end
role:checkBattle("work", {
id = id,
isWin = starNum and starNum > 0,
info = msg.info,
reward = reward,
})
role:mylog("hang_action", {desc = "workBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id})
SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({
starNum = starNum,
reward = reward,
change = change
}))
return true
end
|
a6508219
zhouhaihai
挂机奖励
|
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
|
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
修改发奖
|
1068
|
local reward, change = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}})
|
a6508219
zhouhaihai
挂机奖励
|
1069
1070
|
role:changeUpdates({{type = "hangGift", field = id, value = 1}})
|
d02f7904
zhouhaihai
遗失的log
|
1071
|
role:mylog("hang_action", {desc = "hangGift", int1 = id})
|
a6508219
zhouhaihai
挂机奖励
|
1072
|
|
7bb30dca
zhouhaihai
修改发奖
|
1073
|
SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack({reward = reward, change = change}))
|
a6508219
zhouhaihai
挂机奖励
|
1074
1075
|
return true
end
|
f60b89b1
zhouhaihai
奖励副本
|
1076
|
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
1077
1078
1079
1080
1081
1082
1083
|
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
|
3d8050ef
测试
钻石3改成虹光玉8
|
1084
|
if costD ~= 0 and not role:checkItemEnough({[ItemId.Jade] = costD}) then
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
1085
1086
1087
|
return 2
end
role:updateProperty({field = "hangBagLimit", value = curBL + 1})
|
3d8050ef
测试
钻石3改成虹光玉8
|
1088
|
role:costItems({[ItemId.Jade] = costD}, {log = {desc = "bagField"}})
|
64e63ad0
wangyujie
完成需求:挂机栏位物品数量上限和钻...
|
1089
1090
1091
|
SendPacket(actionCodes.Hang_bagFieldRpc, '')
return true
end
|
f60b89b1
zhouhaihai
奖励副本
|
1092
|
|
ed20f277
zhouhaihai
chatline 奖励
|
1093
1094
1095
|
function _M.chatLineRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
ed20f277
zhouhaihai
chatline 奖励
|
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
|
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
修改发奖
|
1111
|
local reward, change = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}})
|
ed20f277
zhouhaihai
chatline 奖励
|
1112
|
|
7bb30dca
zhouhaihai
修改发奖
|
1113
|
SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack({reward = reward, change = change}))
|
ed20f277
zhouhaihai
chatline 奖励
|
1114
1115
1116
|
return true
end
|
98d32f92
测试
多编队
|
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
|
function _M.selectTeamRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local index = msg.index -- 阵容索引
local type = msg.type -- 系统类型
if index > 10 then
return 1
end
local team = role:getTeamFormat(index)
if not next(team) then return 2 end
local teamIndex = role:getProperty("teamIndex") or {}
teamIndex[type] = index
role:updateProperty({field = "teamIndex", value = teamIndex})
|
782ee57d
测试
多编队功能
|
1133
1134
1135
1136
1137
|
if type == TeamSystemType.Hang then
role:finishGuide(5)
role:updateHangTeamInfo()
end
|
98d32f92
测试
多编队
|
1138
1139
1140
1141
|
SendPacket(actionCodes.Hang_selectTeamRpc, '')
return true
end
|
ba33bcac
测试
挂机章节解锁
|
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
|
function _M.unlockChapterRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local carbonId = msg.carbonId -- 解锁章节id
local condition = globalCsv.idle_chapter_unlock[carbonId]
if not condition then return 1 end
local conditionMap = condition:toArray(true, "=")
local count, level = conditionMap[1],conditionMap[2]
local cnt = 0
for _, hero in pairs(role.heros) do
if hero:getProperty("level") >= level then
cnt = cnt + 1
end
end
if cnt < count then return 2 end
local unlockChapter = role:getProperty("unlockChap")
unlockChapter[carbonId] = 1
role:updateProperty({field="unlockChap", value = unlockChapter})
SendPacket(actionCodes.Hang_unlockChapterRpc, '')
return true
end
|
42dcb7da
测试
merge code
|
1166
|
return _M
|