384bb077
 
  zhouahaihai
 
挂机
 | 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 
 | 
  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
  		return
  	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 
 | 
  
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
28 
 | 
  	local coinCount = math.max(0, math.floor((nowCoinTime - hangInfo.coinTime) / globalCsv.idle_money_produce_cd))
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
29 
 | 
  	hangInfo.coinTime = hangInfo.coinTime + coinCount * globalCsv.idle_money_produce_cd
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
30 
 | 
  
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
31 
 | 
  	local itemCount = math.max(0, math.floor((nowItemTime - hangInfo.itemTime) / globalCsv.idle_item_produce_cd))
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
32 
 | 
  	hangInfo.itemTime = hangInfo.itemTime + itemCount * globalCsv.idle_item_produce_cd
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
33
34
35
36 
 | 
  
  	local items = role:getProperty("hangBag")
  	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  角色经验
 | 
37 
 | 
  	items[ItemId.PlayerExp] = (items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
38
39
40
41
42 
 | 
  
  	local pool = {}
  	for _, temp in pairs(carbonData.item:toArray()) do
  		table.insert(pool, temp:toArray(true, "="))
  	end
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
43
44 
 | 
  	local curTypeCount = 0
  	for id, _ in pairs(items) do
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
45 
 | 
  		if id ~= ItemId.Gold and id ~= ItemId.Exp and id ~= ItemId.PlayerExp then
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
46
47
48 
 | 
  			curTypeCount = curTypeCount + 1
  		end
  	end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
49
50 
 | 
  	for i = 1, itemCount do
  		local cur = pool[math.randWeight(pool, 3)]
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
51
52
53
54
55
56 
 | 
  		if items[cur[1]] or curTypeCount < role:getProperty("hangBagLimit") then
  			if not items[cur[1]] then
  				curTypeCount = curTypeCount + 1
  			end
  			items[cur[1]] = (items[cur[1]] or 0) + cur[2]
  		end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
57
58
59 
 | 
  	end
  
  	if coinCount > 0 or itemCount > 0 then
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
60 
 | 
  		return true
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
61
62
63
64
65
66
67
68
69
70
71 
 | 
  	end
  end
  
  
  
  --开始一个新的关卡
  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
 
奖励副本
 | 
72 
 | 
  	if not carbonData then return 1 end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
73 
 | 
  
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
74
75
76
77 
 | 
  	if math.floor(carbonId / 10000) ~= 1 then
  		if not role:isFuncUnlock(FuncUnlock.DifficultHang) then return end
  	end
  
 
 | 
5d80aca6
 
  zhouahaihai
 
挂机优化
 | 
78
79 
 | 
  
  	for _, preCarbonId in ipairs(carbonData.prepose:toArray(true, "=")) do
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
80 
 | 
  		if not role:checkHangPass(preCarbonId) then return 2 end
 
 | 
5d80aca6
 
  zhouahaihai
 
挂机优化
 | 
81 
 | 
  	end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
82 
 | 
  
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
83
84
85 
 | 
  	if checkReward(role) then
  		role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")})
  	end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
86
87 
 | 
  
  	local hangInfo = role:getProperty("hangInfo")
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
88 
 | 
  	local isNew = not hangInfo.carbonId
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
89
90 
 | 
  	hangInfo.carbonId = carbonId
  	local nowTime = skynet.timex()
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
91 
 | 
  	if isNew then
 
 | 
1103490d
 
  zhouhaihai
 
设置 国家时间错误
 | 
92
93 
 | 
  		hangInfo.coinTime = nowTime
  		hangInfo.itemTime = nowTime
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
94
95 
 | 
  		hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max
  		hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max
 
 | 
1103490d
 
  zhouhaihai
 
设置 国家时间错误
 | 
96
97
98 
 | 
  	else
  		hangInfo.coinTime = math.min(nowTime, hangInfo.endCoinTime)
  		hangInfo.itemTime = math.min(nowTime, hangInfo.endItemTime)
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
99 
 | 
  	end
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
100 
 | 
  	if not role:checkHangPass(carbonId) then
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
101
102
103 
 | 
  		hangInfo.bossTime = nowTime + carbonData.idle_time
  	else
  		hangInfo.bossTime = nil
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
104
105
106 
 | 
  	end
  	role:updateProperty({field = "hangInfo", value = hangInfo})
  
 
 | 
3133cb76
 
  zhouhaihai
 
日志
 | 
107
108 
 | 
  	role:log("hang_action", {desc = "startHang", int1 = carbonId})
  
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
109
110
111
112
113
114
115
116 
 | 
  	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
 | 
117
118
119
120 
 | 
  	if checkReward(role) then
  		role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")})
  		role:updateProperty({field = "hangInfo", value = role:getProperty("hangInfo")})
  	end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
121
122
123
124 
 | 
  	SendPacket(actionCodes.Hang_checkRpc, MsgPack.pack({}))
  	return true
  end
  
 
 | 
cc5ca7f3
 
  zhouhaihai
 
缓存battleKey
 | 
125 
 | 
  local _BattleKey = nil
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
126
127
128 
 | 
  function _M.startBattleRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
129
130 
 | 
  	local carbonId = msg.carbonId
  	local curData = csvdb["idle_battleCsv"][carbonId]
 
 | 
a1e08c9c
 
  zhengshouren
 
宝箱关战斗异常
 | 
131
132
133 
 | 
  	if not curData then 
  		return 1
  	end
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
134 
 | 
  
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
135 
 | 
  	local hangInfo = role:getProperty("hangInfo")
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
136 
 | 
  	if curData.main ~= 1 then
 
 | 
a1e08c9c
 
  zhengshouren
 
宝箱关战斗异常
 | 
137
138
139 
 | 
  		if carbonId ~= hangInfo.carbonId then 
  			return 2
  		end
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
140
141 
 | 
  	end
  
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
142 
 | 
  	if role:checkHangPass(carbonId) then 
 
 | 
a1e08c9c
 
  zhengshouren
 
宝箱关战斗异常
 | 
143
144 
 | 
  		return 3
  	end
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
145 
 | 
  
 
 | 
cc5ca7f3
 
  zhouhaihai
 
缓存battleKey
 | 
146
147 
 | 
  	_BattleKey = tostring(math.random())
  
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
148 
 | 
  	role:checkTaskEnter("HangBattle", {id = carbonId})
 
 | 
52c87300
 
  zhouhaihai
 
bug
 | 
149 
 | 
  	SendPacket(actionCodes.Hang_startBattleRpc, MsgPack.pack({key = _BattleKey}))
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
150
151
152
153
154
155
156 
 | 
  	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
 | 
157 
 | 
  	if not msg.key or msg.key ~= _BattleKey then 
 
 | 
4906ebd2
 
  zhengshouren
 
宝箱关副本结算异常
 | 
158
159 
 | 
  		return 1
  	end
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
160
161 
 | 
  	local carbonId = msg.carbonId
  	local carbonData = csvdb["idle_battleCsv"][carbonId]
 
 | 
4906ebd2
 
  zhengshouren
 
宝箱关副本结算异常
 | 
162
163
164 
 | 
  	if not carbonData then
  		return 2
  	end
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
165 
 | 
  	if carbonData.main ~= 1 then
 
 | 
4906ebd2
 
  zhengshouren
 
宝箱关副本结算异常
 | 
166
167
168 
 | 
  		if carbonId ~= hangInfo.carbonId then 
  			return 3
  		end
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
169 
 | 
  	end
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
170
171 
 | 
  
  	if role:checkHangPass(carbonId) then 
 
 | 
4906ebd2
 
  zhengshouren
 
宝箱关副本结算异常
 | 
172
173 
 | 
  		return 4
  	end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
174
175 
 | 
  	local reward
  	if msg.starNum and msg.starNum > 0 then --win
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
176 
 | 
  		role:hangFinish(carbonId)
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
177
178
179 
 | 
  		if carbonData.main ~= 1 then
  			hangInfo.bossTime = nil
  		end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
180
181 
 | 
  		-- reward
  		reward = {}
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
182
183 
 | 
  		reward[ItemId.Gold] = carbonData.money_clear
  		reward[ItemId.Exp] = carbonData.exp_clear
 
 | 
00115a7a
 
  zhouahaihai
 
奖励发放
 | 
184 
 | 
  		reward[ItemId.PlayerExp] = carbonData.playerExp_clear
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
185 
 | 
  		for itemId, count in pairs(carbonData.item_clear:toNumMap()) do
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
186
187 
 | 
  			reward[itemId] = count
  		end
 
 | 
3133cb76
 
  zhouhaihai
 
日志
 | 
188 
 | 
  		reward = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}})
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
189 
 | 
  
 
 | 
03a6166a
 
  zhouhaihai
 
餐厅优化
 | 
190 
 | 
  		role:checkTaskEnter("HangPass", {id = carbonId})
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
191 
 | 
  	end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
192 
 | 
  	role:updateProperty({field = "hangInfo", value = hangInfo})
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
193
194
195 
 | 
  	
  	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
 
日志
 | 
196 
 | 
  
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
197
198
199
200
201
202
203 
 | 
  	SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({
  		starNum = msg.starNum, 
  		reward = reward,
  		}))
  	return true
  end
  
 
 | 
7efe5275
 
  zhouhaihai
 
检查leader
 | 
204
205
206
207
208
209
210 
 | 
  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
 
挂机
 | 
211
212
213 
 | 
  function _M.roleFormatRpc(agent , data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
214
215
216 
 | 
  	local hangTeam = role:getProperty("hangTeam")
  	for slot, heroId in pairs(msg.heros) do
  		if not role.heros[heroId] then
 
 | 
e6ebee44
 
  zhouhaihai
 
编队bug
 | 
217 
 | 
  			return 1
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
218
219 
 | 
  		end
  	end
 
 | 
f603a60f
 
  zhouhaihai
 
支援技实装
 | 
220
221
222 
 | 
  
  	local supports = {}
  	for slot, support in pairs(msg.supports or {}) do
 
 | 
e6ebee44
 
  zhouhaihai
 
编队bug
 | 
223 
 | 
  		if slot ~= 1 and slot ~= 2 then return 2 end
 
 | 
f603a60f
 
  zhouhaihai
 
支援技实装
 | 
224 
 | 
  		local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
 
 | 
e6ebee44
 
  zhouhaihai
 
编队bug
 | 
225 
 | 
  		if level <= 0 then return 3 end
 
 | 
f603a60f
 
  zhouhaihai
 
支援技实装
 | 
226
227 
 | 
  		supports[slot] = support
  	end
 
 | 
e6ebee44
 
  zhouhaihai
 
编队bug
 | 
228 
 | 
  	if not checkLeader(msg.heros, msg.leader) then return 4 end
 
 | 
f603a60f
 
  zhouhaihai
 
支援技实装
 | 
229 
 | 
  
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
230
231
232
233
234
235 
 | 
  	table.clear(hangTeam)
  	hangTeam.heros = {}
  	for slot, heroId in pairs(msg.heros) do
  		hangTeam.heros[slot] = heroId
  	end
  	hangTeam.leader = msg.leader
 
 | 
f603a60f
 
  zhouhaihai
 
支援技实装
 | 
236 
 | 
  	hangTeam.supports = supports
 
 | 
fa565e0c
 
  zhouhaihai
 
优化结构
 | 
237 
 | 
  	role:saveHangTeam(hangTeam)
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
238
239
240
241 
 | 
  	SendPacket(actionCodes.Hang_roleFormatRpc, '')
  	return true
  end
  
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
242
243
244
245
246 
 | 
  function _M.getRewardRpc(agent , data)
  	local role = agent.role
  	checkReward(role)
  	local items = role:getProperty("hangBag")
  	if not next(items) then return end
 
 | 
3133cb76
 
  zhouhaihai
 
日志
 | 
247 
 | 
  	local reward = role:award(items, {log = {desc = "hangReward"}})
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
248
249
250 
 | 
  	table.clear(items)
  	local hangInfo = role:getProperty("hangInfo")
  	local nowTime = skynet.timex()
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
251
252 
 | 
  	hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max
  	hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
253
254
255
256 
 | 
  	hangInfo.coinTime = nowTime
  	hangInfo.itemTime = nowTime
  	role:updateProperty({field = "hangBag", value = items})
  	role:updateProperty({field = "hangInfo", value = hangInfo})
 
 | 
03a6166a
 
  zhouhaihai
 
餐厅优化
 | 
257 
 | 
  	role:checkTaskEnter("HangGet")
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
258
259 
 | 
  	if reward[ItemId.Gold] then
  		role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
260 
 | 
  	end
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
261 
 | 
  	SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
262
263
264
265
266 
 | 
  		reward = reward
  	}))
  	return true
  end
  
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
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
299
300
301
302
303
304
305
306
307
308
309
310
311 
 | 
  -- 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
 | 
312 
 | 
  	
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
313
314
315
316
317
318
319
320
321
322
323
324 
 | 
  -- 	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
 
补充 挂机
 | 
325
326
327
328
329
330
331
332
333
334
335
336
337 
 | 
  
  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
 
日志
 | 
338 
 | 
  		role:costItems({[ItemId.Diamond] = costs[curCount]}, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359 
 | 
  	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
  
 
 | 
3133cb76
 
  zhouhaihai
 
日志
 | 
360 
 | 
  	reward = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
361
362
363 
 | 
  	if reward[ItemId.Gold] then
  		role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
  	end
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
364 
 | 
  	role:checkTaskEnter("HangQuick")
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
365
366
367
368
369
370 
 | 
  	SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({
  		reward = reward
  	}))
  	return true
  end
  
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
371
372
373
374
375
376
377
378
379 
 | 
  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
 
支援技实装
 | 
380
381
382
383
384
385
386 
 | 
  	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
 | 
387
388 
 | 
  	if not checkLeader(msg.heros, msg.leader) then return end
  	
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
389
390
391
392
393
394 
 | 
  	table.clear(bTeam)
  	bTeam.heros = {}
  	for slot, heroId in pairs(msg.heros) do
  		bTeam.heros[slot] = heroId
  	end
  	bTeam.leader = msg.leader
 
 | 
f603a60f
 
  zhouhaihai
 
支援技实装
 | 
395 
 | 
  	bTeam.supports = supports
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
396
397
398
399
400
401
402
403
404
405
406
407
408 
 | 
  
  	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
 
日志
 | 
409 
 | 
  	if not TimeReset["DailyBattle" .. btype] then return end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
410
411
412
413
414
415 
 | 
  
  	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
 
日志
 | 
416 
 | 
  	if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
417 
 | 
  
 
 | 
3133cb76
 
  zhouhaihai
 
日志
 | 
418 
 | 
  	role:costItems({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}, {log = {desc = "buyBonusCount", short1 = btype, int1 = count}})
 
 | 
d481965d
 
  zhouhaihai
 
购买次数bug
 | 
419
420 
 | 
  	bonusC[btype]["b"] = bonusC[btype]["b"] + count
  	bonusC[btype]["c"] = bonusC[btype]["c"] - count
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
421
422
423
424
425
426
427
428
429
430
431
432 
 | 
  
  	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
 
功能解锁  冒险返回
 | 
433
434 
 | 
  	if not role:isFuncUnlock(FuncUnlock.BonusBattle) then return end
  
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
435 
 | 
  	local bonusData = csvdb["bonus_battleCsv"][id]
 
 | 
bc902e2d
 
  zhouhaihai
 
增加开放判断
 | 
436
437
438 
 | 
  
  	if not role:isTimeResetOpen(TimeReset["DailyBattle" .. bonusData.type]) then return end
  
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
439 
 | 
  	if not bonusData then return 1 end
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
440 
 | 
  	if not role:checkHangPass(bonusData.unlock) then return 2 end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
441
442
443
444
445
446 
 | 
  
  	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
 
奖励副本
 | 
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469 
 | 
  
  
  	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
  
  	if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then return 2 end
  	local bonusData = csvdb["bonus_battleCsv"][id]
  
  	local reward
   	if starNum and starNum > 0 then
 
 | 
74a8fdc9
 
  zhouhaihai
 
奖励副本 胜利扣除次数
 | 
470
471
472
473
474
475
476 
 | 
   		-- 胜利扣除次数
   		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})
  
 
 | 
3133cb76
 
  zhouhaihai
 
日志
 | 
477 
 | 
   		reward = role:award(bonusData.reward, {log = {desc = "bonusBattle", int1 = id}})
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
478
479
480 
 | 
   		role:checkTaskEnter("BonusPass", {id = id})
   	end
  
 
 | 
3133cb76
 
  zhouhaihai
 
日志
 | 
481
482 
 | 
  	role:log("hang_action", {desc = "bonusBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id})
  
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
483
484
485
486
487
488 
 | 
  	SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({
  		starNum = starNum, 
  		reward = reward}))
  	return true
  end
  
 
 | 
a6508219
 
  zhouhaihai
 
挂机奖励
 | 
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507 
 | 
  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
  
  	local reward = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}})
  	role:log("hang_action", {desc = "hangGift",  int1 = id})
  
  	role:changeUpdates({{type = "hangGift", field = id, value = 1}})
  
  	SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack(reward))
  	return true
  end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
508
509 
 | 
  
  
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
510 
 | 
  return _M
 
 |