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
 
  测试
 
双倍掉掉落bug
 | 
22 
 | 
  		return false
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
23
24 
 | 
  	end
  	local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId]
 
 | 
8cd3770f
 
  测试
 
挂机关卡可以选择,经验金币根据最高...
 | 
25 
 | 
  	local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId]
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
26
27 
 | 
  	local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0)
  	local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0)
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
28 
 | 
  
 
 | 
00bf6029
 
  测试
 
限时礼包,抽卡ssr广播
 | 
29
30 
 | 
  	local expCoef, itemCoef = role.storeData:getHangDropCoef()
  
 
 | 
706b517e
 
  测试
 
翻倍掉落活动,商城免费宝箱
 | 
31
32
33 
 | 
  	-- 此次挂机,其中翻倍时长占多少
  	local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime)
  	local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
34 
 | 
  
 
 | 
706b517e
 
  测试
 
翻倍掉落活动,商城免费宝箱
 | 
35
36
37
38 
 | 
  	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
 | 
39 
 | 
  	normalTime = nowItemTime - hangInfo.itemTime
 
 | 
706b517e
 
  测试
 
翻倍掉落活动,商城免费宝箱
 | 
40 
 | 
  	local itemCount = math.max(0, math.floor((normalTime) / globalCsv.idle_item_produce_cd))
 
 | 
706b517e
 
  测试
 
翻倍掉落活动,商城免费宝箱
 | 
41 
 | 
  	hangInfo.itemTime = nowItemTime
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
42
43 
 | 
  
  	local items = role:getProperty("hangBag")
 
 | 
00bf6029
 
  测试
 
限时礼包,抽卡ssr广播
 | 
44 
 | 
  	coinCount = (coinCount + coinDoubleCount) * expCoef
 
 | 
8cd3770f
 
  测试
 
挂机关卡可以选择,经验金币根据最高...
 | 
45
46
47 
 | 
  	items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * expCarbonData.money)
  	items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * expCarbonData.exp)
  	items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp)
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
48
49
50
51
52 
 | 
  
  	local pool = {}
  	for _, temp in pairs(carbonData.item:toArray()) do
  		table.insert(pool, temp:toArray(true, "="))
  	end
 
 | 
64e63ad0
 
  wangyujie
 
完成需求:挂机栏位物品数量上限和钻...
 | 
53
54
55 
 | 
  	local curFC = 0
  	local curIC = 0
  	for id, count in pairs(items) do
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
56 
 | 
  		if id ~= ItemId.Gold and id ~= ItemId.Exp and id ~= ItemId.PlayerExp then
 
 | 
64e63ad0
 
  wangyujie
 
完成需求:挂机栏位物品数量上限和钻...
 | 
57
58 
 | 
  			curFC = curFC + math.ceil(count / globalCsv.idle_field_limit)
  			curIC = curIC + count
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
59
60 
 | 
  		end
  	end
 
 | 
317a46a9
 
  测试
 
添加特权卡
 | 
61
62
63 
 | 
  
  	-- 特权卡挂机额外栏位
  	local privExtraCnt = role.storeData:getHangSlotExtraCount()
 
 | 
460afa6e
 
  测试
 
付费签到改为主动领取,战斗关卡不一...
 | 
64
65 
 | 
  	--local selfFC = role:getProperty("hangBagLimit") + privExtraCnt
  	local selfFC = 50
 
 | 
64e63ad0
 
  wangyujie
 
完成需求:挂机栏位物品数量上限和钻...
 | 
66
67
68
69
70
71
72
73
74 
 | 
  	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
 | 
75 
 | 
  			local cur = clone(pool[idx])
 
 | 
93f6e69b
 
  测试
 
拾荒选择时间,抽卡增加sr保底
 | 
76 
 | 
  			if cur[1] ~= 0 then  -- 轮空 id
 
 | 
024370be
 
  测试
 
双倍掉掉落bug
 | 
77
78 
 | 
  				if cur[1] == ItemId.BreakCost and doubleTime > 0 then
  					cur[2] = cur[2] * 2
 
 | 
64e63ad0
 
  wangyujie
 
完成需求:挂机栏位物品数量上限和钻...
 | 
79 
 | 
  				end
 
 | 
00bf6029
 
  测试
 
限时礼包,抽卡ssr广播
 | 
80 
 | 
  				cur[2] = cur[2] * itemCoef
 
 | 
024370be
 
  测试
 
双倍掉掉落bug
 | 
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 
 | 
  				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
 
完成需求:挂机栏位物品数量上限和钻...
 | 
101 
 | 
  				else
 
 | 
024370be
 
  测试
 
双倍掉掉落bug
 | 
102
103 
 | 
  					items[cur[1]] = items[cur[1]] + cur[2]
  					break
 
 | 
64e63ad0
 
  wangyujie
 
完成需求:挂机栏位物品数量上限和钻...
 | 
104
105 
 | 
  				end
  			else
 
 | 
64e63ad0
 
  wangyujie
 
完成需求:挂机栏位物品数量上限和钻...
 | 
106 
 | 
  				break
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
107 
 | 
  			end
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
108 
 | 
  		end
 
 | 
64e63ad0
 
  wangyujie
 
完成需求:挂机栏位物品数量上限和钻...
 | 
109
110 
 | 
  		curIC = curIC + 1
  	end
 
 | 
024370be
 
  测试
 
双倍掉掉落bug
 | 
111 
 | 
  
 
 | 
64e63ad0
 
  wangyujie
 
完成需求:挂机栏位物品数量上限和钻...
 | 
112
113 
 | 
  	for i = 1, itemCount do
  		randomItem()
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
114
115
116 
 | 
  	end
  
  	if coinCount > 0 or itemCount > 0 then
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
117 
 | 
  		return true
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
118 
 | 
  	end
 
 | 
024370be
 
  测试
 
双倍掉掉落bug
 | 
119
120 
 | 
  
  	return false
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
121
122 
 | 
  end
  
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
123
124
125
126
127
128 
 | 
  --开始一个新的关卡
  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
 
奖励副本
 | 
129 
 | 
  	if not carbonData then return 1 end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
130 
 | 
  
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
131
132
133
134 
 | 
  	if math.floor(carbonId / 10000) ~= 1 then
  		if not role:isFuncUnlock(FuncUnlock.DifficultHang) then return end
  	end
  
 
 | 
5d80aca6
 
  zhouahaihai
 
挂机优化
 | 
135
136 
 | 
  
  	for _, preCarbonId in ipairs(carbonData.prepose:toArray(true, "=")) do
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
137 
 | 
  		if not role:checkHangPass(preCarbonId) then return 2 end
 
 | 
5d80aca6
 
  zhouahaihai
 
挂机优化
 | 
138 
 | 
  	end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
139 
 | 
  
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
140
141
142 
 | 
  	if checkReward(role) then
  		role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")})
  	end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
143
144 
 | 
  
  	local hangInfo = role:getProperty("hangInfo")
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
145 
 | 
  	local isNew = not hangInfo.carbonId
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
146 
 | 
  	hangInfo.carbonId = carbonId
 
 | 
8cd3770f
 
  测试
 
挂机关卡可以选择,经验金币根据最高...
 | 
147 
 | 
  	hangInfo.expCarbonId = isNew and carbonId or hangInfo.expCarbonId
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
148 
 | 
  	local nowTime = skynet.timex()
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
149 
 | 
  	if isNew then
 
 | 
1103490d
 
  zhouhaihai
 
设置 国家时间错误
 | 
150
151 
 | 
  		hangInfo.coinTime = nowTime
  		hangInfo.itemTime = nowTime
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
152
153 
 | 
  		hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max
  		hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max
 
 | 
1103490d
 
  zhouhaihai
 
设置 国家时间错误
 | 
154
155
156 
 | 
  	else
  		hangInfo.coinTime = math.min(nowTime, hangInfo.endCoinTime)
  		hangInfo.itemTime = math.min(nowTime, hangInfo.endItemTime)
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
157 
 | 
  	end
 
 | 
072db127
 
  zhouhaihai
 
推送
 | 
158
159 
 | 
  
  	role:pushMsg({type = "hang", time = math.min(hangInfo.endCoinTime - nowTime, hangInfo.endItemTime - nowTime)})
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
160 
 | 
  	if not role:checkHangPass(carbonId) then
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
161
162
163 
 | 
  		hangInfo.bossTime = nowTime + carbonData.idle_time
  	else
  		hangInfo.bossTime = nil
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
164 
 | 
  	end
 
 | 
072db127
 
  zhouhaihai
 
推送
 | 
165 
 | 
  
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
166
167 
 | 
  	role:updateProperty({field = "hangInfo", value = hangInfo})
  
 
 | 
d02f7904
 
  zhouhaihai
 
遗失的log
 | 
168 
 | 
  	role:mylog("hang_action", {desc = "startHang", int1 = carbonId})
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
169
170
171
172
173
174
175
176 
 | 
  	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
 | 
177
178
179
180 
 | 
  	if checkReward(role) then
  		role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")})
  		role:updateProperty({field = "hangInfo", value = role:getProperty("hangInfo")})
  	end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
181
182
183
184 
 | 
  	SendPacket(actionCodes.Hang_checkRpc, MsgPack.pack({}))
  	return true
  end
  
 
 | 
cc5ca7f3
 
  zhouhaihai
 
缓存battleKey
 | 
185 
 | 
  local _BattleKey = nil
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
186
187
188 
 | 
  function _M.startBattleRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
189
190 
 | 
  	local carbonId = msg.carbonId
  	local curData = csvdb["idle_battleCsv"][carbonId]
 
 | 
a1e08c9c
 
  zhengshouren
 
宝箱关战斗异常
 | 
191
192
193 
 | 
  	if not curData then 
  		return 1
  	end
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
194 
 | 
  
 
 | 
460afa6e
 
  测试
 
付费签到改为主动领取,战斗关卡不一...
 | 
195
196
197
198
199
200 
 | 
  	--local hangInfo = role:getProperty("hangInfo") or {}
  	--if curData.main ~= 1 then
  	--	if carbonId ~= hangInfo.carbonId then 
  	--		return 2
  	--	end
  	--end
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
201 
 | 
  
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
202 
 | 
  	if role:checkHangPass(carbonId) then 
 
 | 
a1e08c9c
 
  zhengshouren
 
宝箱关战斗异常
 | 
203
204 
 | 
  		return 3
  	end
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
205 
 | 
  
 
 | 
cc5ca7f3
 
  zhouhaihai
 
缓存battleKey
 | 
206
207 
 | 
  	_BattleKey = tostring(math.random())
  
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
208 
 | 
  	role:checkTaskEnter("HangBattle", {id = carbonId})
 
 | 
52c87300
 
  zhouhaihai
 
bug
 | 
209 
 | 
  	SendPacket(actionCodes.Hang_startBattleRpc, MsgPack.pack({key = _BattleKey}))
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
210
211
212
213
214
215 
 | 
  	return true
  end
  
  function _M.endBattleRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
8cd3770f
 
  测试
 
挂机关卡可以选择,经验金币根据最高...
 | 
216 
 | 
  	local hangInfo = role:getProperty("hangInfo") or {}
 
 | 
cc5ca7f3
 
  zhouhaihai
 
缓存battleKey
 | 
217 
 | 
  	if not msg.key or msg.key ~= _BattleKey then 
 
 | 
d6a66c74
 
  zhouhaihai
 
校验失败也返回
 | 
218
219 
 | 
  		SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1}))
  		return true
 
 | 
4906ebd2
 
  zhengshouren
 
宝箱关副本结算异常
 | 
220 
 | 
  	end
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
221 
 | 
  	local carbonId = msg.carbonId
 
 | 
d4e9b817
 
  zhouhaihai
 
战斗 日志
 | 
222 
 | 
  	local isWin = msg.starNum and msg.starNum > 0
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
223 
 | 
  	local carbonData = csvdb["idle_battleCsv"][carbonId]
 
 | 
4906ebd2
 
  zhengshouren
 
宝箱关副本结算异常
 | 
224
225
226 
 | 
  	if not carbonData then
  		return 2
  	end
 
 | 
8cd3770f
 
  测试
 
挂机关卡可以选择,经验金币根据最高...
 | 
227 
 | 
  
 
 | 
460afa6e
 
  测试
 
付费签到改为主动领取,战斗关卡不一...
 | 
228
229
230
231
232 
 | 
  	--if carbonData.main ~= 1 then
  	--	if carbonId ~= hangInfo.carbonId then 
  	--		return 3
  	--	end
  	--end
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
233
234 
 | 
  
  	if role:checkHangPass(carbonId) then 
 
 | 
4906ebd2
 
  zhengshouren
 
宝箱关副本结算异常
 | 
235
236 
 | 
  		return 4
  	end
 
 | 
d4e9b817
 
  zhouhaihai
 
战斗 日志
 | 
237 
 | 
  
 
 | 
7bb30dca
 
  zhouhaihai
 
修改发奖
 | 
238 
 | 
  	local reward, change
 
 | 
d4e9b817
 
  zhouhaihai
 
战斗 日志
 | 
239 
 | 
  	if isWin then --win
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
240 
 | 
  		role:hangFinish(carbonId)
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
241
242
243 
 | 
  		if carbonData.main ~= 1 then
  			hangInfo.bossTime = nil
  		end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
244
245 
 | 
  		-- reward
  		reward = {}
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
246
247 
 | 
  		reward[ItemId.Gold] = carbonData.money_clear
  		reward[ItemId.Exp] = carbonData.exp_clear
 
 | 
00115a7a
 
  zhouahaihai
 
奖励发放
 | 
248 
 | 
  		reward[ItemId.PlayerExp] = carbonData.playerExp_clear
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
249 
 | 
  		for itemId, count in pairs(carbonData.item_clear:toNumMap()) do
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
250
251 
 | 
  			reward[itemId] = count
  		end
 
 | 
7bb30dca
 
  zhouhaihai
 
修改发奖
 | 
252 
 | 
  		reward, change = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}})
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
253 
 | 
  
 
 | 
03a6166a
 
  zhouhaihai
 
餐厅优化
 | 
254 
 | 
  		role:checkTaskEnter("HangPass", {id = carbonId})
 
 | 
286c980a
 
  chenyueqi
 
挂机战斗胜利才触发对应的引导
 | 
255
256
257 
 | 
  		
  		-- 引导
  		if carbonId == 10101 then
 
 | 
a5b98c30
 
  chenyueqi
 
引导调整
 | 
258 
 | 
  			role:finishGuide(6)
 
 | 
be0c7a19
 
  chenyueqi
 
挂机打完困难20101才设定完成引导22
 | 
259 
 | 
  		elseif carbonId == 20101 then
 
 | 
286c980a
 
  chenyueqi
 
挂机战斗胜利才触发对应的引导
 | 
260
261
262
263
264
265
266
267 
 | 
  			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
 
挂机
 | 
268 
 | 
  	end
 
 | 
53b4b8bd
 
  测试
 
自动挂机下一关
 | 
269
270 
 | 
  	local nextCarbonId = role:getNextCarbonId(carbonId)
  	-- 设置挂机关卡
 
 | 
87c65a8d
 
  测试
 
挂机经验关卡改为最终通关关卡
 | 
271 
 | 
  	if isWin then --and (hangInfo.carbonId or 0) < nextCarbonId then
 
 | 
98d32f92
 
  测试
 
多编队
 | 
272
273
274
275
276
277
278
279
280 
 | 
  		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
 
  测试
 
挂机经验关卡改为最终通关关卡
 | 
281
282
283
284 
 | 
  		--local cfg = csvdb["idle_battleCsv"][nextCarbonId]
  		--if cfg then
  		--	hangInfo.bossTime = skynet.timex() + cfg.idle_time
  		--end
 
 | 
93f6e69b
 
  测试
 
拾荒选择时间,抽卡增加sr保底
 | 
285 
 | 
  	end
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
286 
 | 
  	role:updateProperty({field = "hangInfo", value = hangInfo})
 
 | 
33be3111
 
  zhouhaihai
 
修改hangPass 结构
 | 
287 
 | 
  	
 
 | 
d4e9b817
 
  zhouhaihai
 
战斗 日志
 | 
288
289
290
291
292
293 
 | 
  	role:checkBattle("hang", {
  		id = carbonId,
  		isWin = isWin,
  		info = msg.info,
  		reward = reward,
  	})
 
 | 
1e9cb217
 
  chenyueqi
 
服务器记录控制引导过程
 | 
294 
 | 
  
 
 | 
d02f7904
 
  zhouhaihai
 
遗失的log
 | 
295
296
297 
 | 
  	local team = role:getProperty("pvpTC")
  	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)})
  
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
298
299
300 
 | 
  	SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({
  		starNum = msg.starNum, 
  		reward = reward,
 
 | 
7bb30dca
 
  zhouhaihai
 
修改发奖
 | 
301 
 | 
  		change = change,
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
302
303
304
305 
 | 
  		}))
  	return true
  end
  
 
 | 
7efe5275
 
  zhouhaihai
 
检查leader
 | 
306
307
308
309
310
311
312 
 | 
  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
 
挂机
 | 
313
314
315 
 | 
  function _M.roleFormatRpc(agent , data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
98d32f92
 
  测试
 
多编队
 | 
316
317 
 | 
  	local index = msg.index	-- 阵容索引
  	local title = msg.title -- 阵容名称
 
 | 
7d662b85
 
  测试
 
编队增加战术字段
 | 
318 
 | 
  	local tactics = msg.tactics	-- 战术
 
 | 
98d32f92
 
  测试
 
多编队
 | 
319 
 | 
  	local team = {}
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
320
321 
 | 
  	for slot, heroId in pairs(msg.heros) do
  		if not role.heros[heroId] then
 
 | 
e6ebee44
 
  zhouhaihai
 
编队bug
 | 
322 
 | 
  			return 1
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
323
324 
 | 
  		end
  	end
 
 | 
f603a60f
 
  zhouhaihai
 
支援技实装
 | 
325
326
327 
 | 
  
  	local supports = {}
  	for slot, support in pairs(msg.supports or {}) do
 
 | 
e6ebee44
 
  zhouhaihai
 
编队bug
 | 
328 
 | 
  		if slot ~= 1 and slot ~= 2 then return 2 end
 
 | 
f603a60f
 
  zhouhaihai
 
支援技实装
 | 
329 
 | 
  		local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
 
 | 
e6ebee44
 
  zhouhaihai
 
编队bug
 | 
330 
 | 
  		if level <= 0 then return 3 end
 
 | 
f603a60f
 
  zhouhaihai
 
支援技实装
 | 
331
332 
 | 
  		supports[slot] = support
  	end
 
 | 
e6ebee44
 
  zhouhaihai
 
编队bug
 | 
333 
 | 
  	if not checkLeader(msg.heros, msg.leader) then return 4 end
 
 | 
f603a60f
 
  zhouhaihai
 
支援技实装
 | 
334 
 | 
  
 
 | 
98d32f92
 
  测试
 
多编队
 | 
335
336
337
338
339
340
341
342
343 
 | 
  	if index > 10 then
  		return 5
  	end
  
  	if #title > 100 then
  		return 6
  	end
  
  	team.heros = {}
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
344 
 | 
  	for slot, heroId in pairs(msg.heros) do
 
 | 
98d32f92
 
  测试
 
多编队
 | 
345
346
347
348
349 
 | 
  		team.heros[slot] = heroId
  	end
  	team.leader = msg.leader
  	team.supports = supports
  	team.title = title
 
 | 
f7f26c15
 
  zhouhaihai
 
编队整理 增加 tactics战术
 | 
350
351
352 
 | 
  	if msg.tactics and globalCsv.tactics_skill_passive_cell[msg.tactics] then
  		team.tactics = msg.tactics
  	end
 
 | 
98d32f92
 
  测试
 
多编队
 | 
353
354 
 | 
  
  	role:setTeamFormat(index, team)
 
 | 
98d32f92
 
  测试
 
多编队
 | 
355 
 | 
  
 
 | 
384bb077
 
  zhouahaihai
 
挂机
 | 
356
357
358
359 
 | 
  	SendPacket(actionCodes.Hang_roleFormatRpc, '')
  	return true
  end
  
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
360
361
362
363
364 
 | 
  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
 
修改发奖
 | 
365 
 | 
  	local reward, change = role:award(items, {log = {desc = "hangReward"}})
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
366
367
368 
 | 
  	table.clear(items)
  	local hangInfo = role:getProperty("hangInfo")
  	local nowTime = skynet.timex()
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
369
370 
 | 
  	hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max
  	hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max
 
 | 
5af8b4aa
 
  zhouahaihai
 
挂机down
 | 
371
372
373
374 
 | 
  	hangInfo.coinTime = nowTime
  	hangInfo.itemTime = nowTime
  	role:updateProperty({field = "hangBag", value = items})
  	role:updateProperty({field = "hangInfo", value = hangInfo})
 
 | 
072db127
 
  zhouhaihai
 
推送
 | 
375
376 
 | 
  	role:pushMsg({type = "hang", time = globalCsv.idle_producetime_max})
  	
 
 | 
190e1415
 
  测试
 
英雄帖活动初始化
 | 
377 
 | 
  	role:checkTaskEnter("HangGet", {reward = reward})
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
378
379 
 | 
  	if reward[ItemId.Gold] then
  		role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
380 
 | 
  	end
 
 | 
d43246b0
 
  zhouhaihai
 
log 增加
 | 
381
382
383
384
385
386
387
388
389
390
391 
 | 
  
  	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"}
  	})
  	
  
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
392 
 | 
  	SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({
 
 | 
7bb30dca
 
  zhouhaihai
 
修改发奖
 | 
393
394 
 | 
  		reward = reward,
  		change = change
 
 | 
bcf5bfbb
 
  zhouahaihai
 
挂机new
 | 
395
396
397
398 
 | 
  	}))
  	return true
  end
  
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
399
400
401
402
403
404 
 | 
  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]
 
 | 
8cd3770f
 
  测试
 
挂机关卡可以选择,经验金币根据最高...
 | 
405 
 | 
  	local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId]
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
406
407
408
409
410
411 
 | 
  
  	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
 
日志
 | 
412 
 | 
  		role:costItems({[ItemId.Diamond] = costs[curCount]}, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
413
414
415
416
417
418
419
420
421 
 | 
  	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)
 
 | 
8cd3770f
 
  测试
 
挂机关卡可以选择,经验金币根据最高...
 | 
422
423
424 
 | 
  	reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * expCarbonData.money)
  	reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * expCarbonData.exp)
  	reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp)
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
425
426
427
428
429
430
431
432
433 
 | 
  
  	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
 
  测试
 
添加特权卡
 | 
434 
 | 
  
 
 | 
9e1a93c2
 
  测试
 
快速挂机掉落浮点数取整
 | 
435 
 | 
  	local doubleCoef = role.activity:isOpen("DoubleDrop") and 2 or 1
 
 | 
317a46a9
 
  测试
 
添加特权卡
 | 
436
437 
 | 
  	-- 特权卡获取加速获得额外道具
  	local coef = role.storeData:getProduceItemSpeedCoef()
 
 | 
accf94c4
 
  测试
 
活动以类型标识,修改双倍活动bug
 | 
438 
 | 
  	if coef > 1 or doubleCoef > 1 then
 
 | 
317a46a9
 
  测试
 
添加特权卡
 | 
439 
 | 
  		for k, cnt in pairs(reward) do
 
 | 
9e1a93c2
 
  测试
 
快速挂机掉落浮点数取整
 | 
440 
 | 
  			reward[k] = math.floor(cnt * coef * doubleCoef)
 
 | 
317a46a9
 
  测试
 
添加特权卡
 | 
441
442
443 
 | 
  		end
  	end
  
 
 | 
7bb30dca
 
  zhouhaihai
 
修改发奖
 | 
444
445 
 | 
  	local change
  	reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
446
447
448 
 | 
  	if reward[ItemId.Gold] then
  		role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
  	end
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
449 
 | 
  	role:checkTaskEnter("HangQuick")
 
 | 
d43246b0
 
  zhouhaihai
 
log 增加
 | 
450
451
452
453
454
455
456
457
458 
 | 
  
  	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"}
  	})
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
459 
 | 
  	SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({
 
 | 
7bb30dca
 
  zhouhaihai
 
修改发奖
 | 
460
461 
 | 
  		reward = reward,
  		change = change
 
 | 
9962b061
 
  zhouahaihai
 
补充 挂机
 | 
462
463
464
465 
 | 
  	}))
  	return true
  end
  
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
466
467
468
469
470
471
472
473 
 | 
  
  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
 
 | 
accf94c4
 
  测试
 
活动以类型标识,修改双倍活动bug
 | 
475
476 
 | 
  	local open, actId = role.activity:isOpen("BonusDouble")
  	local actData = csvdb["activity_ctrlCsv"][actId]
 
 | 
accf94c4
 
  测试
 
活动以类型标识,修改双倍活动bug
 | 
477 
 | 
  
 
 | 
a526f9ef
 
  测试
 
奖励关卡活动未开启导致Bug
 | 
478
479
480
481 
 | 
  	local coef = 1
  	if open and actData then
  		coef= tonumber(actData.condition2)
  	end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
482
483 
 | 
  
  	local bonusC = role.dailyData:getProperty("bonusC")
 
 | 
00bf6029
 
  测试
 
限时礼包,抽卡ssr广播
 | 
484 
 | 
  	local extraCnt = role.storeData:getBonusExtraFightCount()
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
485 
 | 
  	bonusC[btype] = bonusC[btype] or {c = 0, b = 0}
 
 | 
00bf6029
 
  测试
 
限时礼包,抽卡ssr广播
 | 
486 
 | 
  	local lastCount = globalCsv.bonus_daily_buy_count * coef + extraCnt - bonusC[btype]["b"]
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
487
488 
 | 
  	if math.illegalNum(count, 1, lastCount)  then return 1 end
  
 
 | 
3133cb76
 
  zhouhaihai
 
日志
 | 
489 
 | 
  	if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
490 
 | 
  
 
 | 
887c1843
 
  zhouhaihai
 
日志新一批
 | 
491 
 | 
  	role:costItems({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}, {log = {desc = "buyBonusCount", int1 = btype, int2 = count}})
 
 | 
d481965d
 
  zhouhaihai
 
购买次数bug
 | 
492
493 
 | 
  	bonusC[btype]["b"] = bonusC[btype]["b"] + count
  	bonusC[btype]["c"] = bonusC[btype]["c"] - count
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
494
495
496
497
498
499
500 
 | 
  
  	role.dailyData:updateProperty({field = "bonusC", value = bonusC})
  
  	SendPacket(actionCodes.Hang_buyBonusCountRpc, '')
  	return true
  end
  
 
 | 
be24b6ad
 
  zhouhaihai
 
传递 count
 | 
501
502 
 | 
  local function bonusWinReward(role, bonusData, bwin, count)
  	count = count or 1
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
503
504
505
506
507
508
509
510
511
512 
 | 
  	local open, actId = role.activity:isOpen("BonusDouble")
  	local actData = csvdb["activity_ctrlCsv"][actId]
  	local extraCnt = role.storeData:getBonusExtraFightCount()
  
  	local coef = 1
  	if open and actData then
  		coef = tonumber(actData.condition2)
  	end
  	local bonusC = role.dailyData:getProperty("bonusC")
  	bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
 
 | 
be24b6ad
 
  zhouhaihai
 
传递 count
 | 
513
514 
 | 
  	if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] < count then return false, 1 end
  	bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
515
516
517
518 
 | 
  	role.dailyData:updateProperty({field = "bonusC", value = bonusC})
  
  	local reward, change
  	reward = bonusData.reward:toNumMap()
 
 | 
be24b6ad
 
  zhouhaihai
 
传递 count
 | 
519
520 
 | 
  	for itemId, c in pairs(reward) do
  		reward[itemId] = c * count
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
521 
 | 
  	end
 
 | 
be24b6ad
 
  zhouhaihai
 
传递 count
 | 
522
523
524
525
526
527
528 
 | 
  	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
  
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
529
530
531 
 | 
  	for k, v  in pairs(reward) do
  		reward[k] = v * (coef > 1 and actData.condition or 1)
  	end
 
 | 
be24b6ad
 
  zhouhaihai
 
传递 count
 | 
532 
 | 
  	
 
 | 
e4a17692
 
  zhouhaihai
 
奖励关卡 满星奖励
 | 
533
534
535
536
537 
 | 
  	if bwin then -- 满星 额外奖励
  		for k, v in pairs(bonusData.perfect_reward:toNumMap()) do
  			reward[k] = (reward[k] or 0) + v
  		end
  	end
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
538 
 | 
  	reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}})
 
 | 
be24b6ad
 
  zhouhaihai
 
传递 count
 | 
539 
 | 
  	role:checkTaskEnter("BonusPass", {id = id, count = count})
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
540
541
542 
 | 
  	return true, reward, change
  end
  
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
543
544
545
546 
 | 
  function _M.startBonusBattleRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  	local id = msg.id
 
 | 
be24b6ad
 
  zhouhaihai
 
传递 count
 | 
547 
 | 
  	local count = msg.count or 1
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
548 
 | 
  
 
 | 
accf94c4
 
  测试
 
活动以类型标识,修改双倍活动bug
 | 
549
550
551 
 | 
  	local open, actId = role.activity:isOpen("BonusDouble")
  
  	if not role:isFuncUnlock(FuncUnlock.BonusBattle) then return 1 end
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
552 
 | 
  
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
553 
 | 
  	local bonusData = csvdb["bonus_battleCsv"][id]
 
 | 
bc902e2d
 
  zhouhaihai
 
增加开放判断
 | 
554 
 | 
  
 
 | 
accf94c4
 
  测试
 
活动以类型标识,修改双倍活动bug
 | 
555
556
557 
 | 
  	if not open then
  		if not role:isTimeResetOpen(TimeReset["DailyBattle" .. bonusData.type]) then return 2 end
  	end
 
 | 
bc902e2d
 
  zhouhaihai
 
增加开放判断
 | 
558 
 | 
  
 
 | 
accf94c4
 
  测试
 
活动以类型标识,修改双倍活动bug
 | 
559
560 
 | 
  	if not bonusData then return 3 end
  	if not role:checkHangPass(bonusData.unlock) then return 4 end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
561 
 | 
  
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
562
563 
 | 
  	local bonusC = role.dailyData:getProperty("bonusC")
  	bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
 
 | 
accf94c4
 
  测试
 
活动以类型标识,修改双倍活动bug
 | 
564
565 
 | 
  
  	local actData = csvdb["activity_ctrlCsv"][actId]
 
 | 
accf94c4
 
  测试
 
活动以类型标识,修改双倍活动bug
 | 
566 
 | 
  
 
 | 
00bf6029
 
  测试
 
限时礼包,抽卡ssr广播
 | 
567 
 | 
  	local extraCnt = role.storeData:getBonusExtraFightCount()
 
 | 
a526f9ef
 
  测试
 
奖励关卡活动未开启导致Bug
 | 
568
569
570
571 
 | 
  	local coef = 1
  	if open and actData then
  		coef = tonumber(actData.condition2)
  	end
 
 | 
be24b6ad
 
  zhouhaihai
 
传递 count
 | 
572
573 
 | 
  	
  	if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
574 
 | 
  
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
575
576 
 | 
  	local bonusStar = role:getProperty("bonusStar")
  	if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then 
 
 | 
be24b6ad
 
  zhouhaihai
 
传递 count
 | 
577 
 | 
  		local status, reward, change = bonusWinReward(role, bonusData, nil, count)
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
578
579
580
581
582
583
584
585
586
587
588 
 | 
  		if not status then return 10 * (reward or 0) end
  		SendPacket(actionCodes.Hang_startBonusBattleRpc, 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_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
  	end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
589 
 | 
  
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
590
591
592
593
594
595
596
597
598
599 
 | 
  	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
 
奖励副本 完成
 | 
600 
 | 
  	
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
601 
 | 
  
 
 | 
d6a66c74
 
  zhouhaihai
 
校验失败也返回
 | 
602
603
604
605 
 | 
  	if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then 
  		SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1}))
  		return true
  	end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
606
607 
 | 
  	local bonusData = csvdb["bonus_battleCsv"][id]
  
 
 | 
7bb30dca
 
  zhouhaihai
 
修改发奖
 | 
608 
 | 
  	local reward, change
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
609
610
611 
 | 
  
  	local bonusStar = role:getProperty("bonusStar")
  	local curStar = 0
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
612 
 | 
   	if starNum and starNum > 0 then
 
 | 
74a8fdc9
 
  zhouhaihai
 
奖励副本 胜利扣除次数
 | 
613 
 | 
   		-- 胜利扣除次数
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
614 
 | 
   		
 
 | 
ce950b6e
 
  zhouhaihai
 
bug
 | 
615
616 
 | 
   		local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
   		local herosInfo = role:getTeamHerosInfo(bTeam.heros)
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
617
618
619
620
621
622
623
624
625 
 | 
  
   		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
 
挂机
 | 
626 
 | 
  		end
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
627
628
629 
 | 
  		-- 3 全员存活
  		check[3] = function(_)
  			return msg.info.dead and msg.info.dead == 0
 
 | 
accf94c4
 
  测试
 
活动以类型标识,修改双倍活动bug
 | 
630 
 | 
  		end
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666 
 | 
  		-- 4 指定种族 >= N
  		check[4] = function(_, cond)
  			local count = 0
  			for _, one in pairs(herosInfo) do
  				local heroData = csv["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 = csv["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
 
 | 
e4a17692
 
  zhouhaihai
 
奖励关卡 满星奖励
 | 
667
668 
 | 
  		local sweepConds = bonusData.sweep_condition:toTableArray(true)
   		for i, cond in ipairs(sweepConds) do
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
669
670
671
672 
 | 
   			if check[cond[1]] and check[cond[1]](table.unpack(cond)) then
   				curStar = curStar + (1 << (i - 1))
   			end
   		end
 
 | 
e4a17692
 
  zhouhaihai
 
奖励关卡 满星奖励
 | 
673
674
675 
 | 
   		local status
   		status, reward, change = bonusWinReward(role, bonusData, curStar >= (1 << #sweepConds) - 1)
   		if not status then return 10 + (reward or 0) end
 
 | 
3c51e6d4
 
  zhouhaihai
 
奖励副本 完成
 | 
676
677
678
679
680
681 
 | 
   	else
   		curStar = 0
   	end
   	if curStar ~= bonusStar[id] then
   		bonusStar[id] = curStar
   		role:updateProperty({field = "bonusStar", value = bonusStar})
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
682
683 
 | 
   	end
  
 
 | 
d4e9b817
 
  zhouhaihai
 
战斗 日志
 | 
684
685
686
687
688
689 
 | 
   	role:checkBattle("bonus", {
  		id = id,
  		isWin = starNum and starNum > 0,
  		info = msg.info,
  		reward = reward,
  	})
 
 | 
d02f7904
 
  zhouhaihai
 
遗失的log
 | 
690
691 
 | 
  	role:mylog("hang_action", {desc = "bonusBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id})
  
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
692
693 
 | 
  	SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({
  		starNum = starNum, 
 
 | 
7bb30dca
 
  zhouhaihai
 
修改发奖
 | 
694
695
696 
 | 
  		reward = reward,
  		change = change
  	}))
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
697
698
699 
 | 
  	return true
  end
  
 
 | 
a6508219
 
  zhouhaihai
 
挂机奖励
 | 
700
701
702
703
704
705
706
707
708
709
710 
 | 
  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
 
修改发奖
 | 
711 
 | 
  	local reward, change = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}})
 
 | 
a6508219
 
  zhouhaihai
 
挂机奖励
 | 
712
713 
 | 
  
  	role:changeUpdates({{type = "hangGift", field = id, value = 1}})
 
 | 
d02f7904
 
  zhouhaihai
 
遗失的log
 | 
714 
 | 
  	role:mylog("hang_action", {desc = "hangGift",  int1 = id})
 
 | 
a6508219
 
  zhouhaihai
 
挂机奖励
 | 
715 
 | 
  
 
 | 
7bb30dca
 
  zhouhaihai
 
修改发奖
 | 
716 
 | 
  	SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack({reward = reward, change = change}))
 
 | 
a6508219
 
  zhouhaihai
 
挂机奖励
 | 
717
718 
 | 
  	return true
  end
 
 | 
f60b89b1
 
  zhouhaihai
 
奖励副本
 | 
719 
 | 
  
 
 | 
64e63ad0
 
  wangyujie
 
完成需求:挂机栏位物品数量上限和钻...
 | 
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734 
 | 
  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
 
奖励副本
 | 
735 
 | 
  
 
 | 
ed20f277
 
  zhouhaihai
 
chatline 奖励
 | 
736
737
738 
 | 
  function _M.chatLineRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
ed20f277
 
  zhouhaihai
 
chatline 奖励
 | 
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753 
 | 
  	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
 
修改发奖
 | 
754 
 | 
  	local reward, change = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}})
 
 | 
ed20f277
 
  zhouhaihai
 
chatline 奖励
 | 
755 
 | 
  	
 
 | 
7bb30dca
 
  zhouhaihai
 
修改发奖
 | 
756 
 | 
  	SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack({reward = reward, change = change}))
 
 | 
ed20f277
 
  zhouhaihai
 
chatline 奖励
 | 
757
758
759 
 | 
  	return true
  end
  
 
 | 
98d32f92
 
  测试
 
多编队
 | 
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775 
 | 
  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
 
  测试
 
多编队功能
 | 
776
777
778
779
780 
 | 
  	if type == TeamSystemType.Hang then
  		role:finishGuide(5)
  		role:updateHangTeamInfo()
  	end
  
 
 | 
98d32f92
 
  测试
 
多编队
 | 
781
782
783
784 
 | 
  	SendPacket(actionCodes.Hang_selectTeamRpc, '')
  	return true
  end
  
 
 | 
42dcb7da
 
  测试
 
merge code
 | 
785 
 | 
  return _M
 
 |