87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
1
2
3
4
5
6
7
8
9
10
11 
 | 
  local ipairs = ipairs
  local table = table
  local math = math
  local redisproxy = redisproxy
  local MsgPack = MsgPack
  
  local _M = {}
  
  function _M.addSellRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
12
13 
 | 
  	for _,sellData in pairs(msg) do
  		local slot = sellData.slot
 
 | 
5a307eb6
 
  gaofengduan
 
fix diner
 | 
14
15
16 
 | 
  		local sells = json.decode(role.dinerData:getProperty("sells"))
  		if sells[slot] and sells[slot].count and sells[slot].count ~= 0 then
  			return 0
 
 | 
289a4927
 
  gaofengduan
 
fix diner talent
 | 
17 
 | 
  		end
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
18
19
20
21 
 | 
  		if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then
  			return 1
  		end
  		slot = tostring(slot)
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
22 
 | 
  
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
23
24
25
26
27
28
29
30
31
32
33
34
35 
 | 
  		local dish = sellData.dish
  		local dishSet = csvdb["diner_dishCsv"][dish]
  		if not dishSet then
  			return 2
  		end
  		local dishLevel = role.dinerData:getProperty("dishTree"):getv(dish, 0)
  		if dishLevel == 0 then
  			return 3
  		end
  		local dishData = dishSet[dishLevel]
  		if not dishData then
  			return 4
  		end
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
36 
 | 
  
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
37
38
39
40
41
42
43
44
45
46 
 | 
  		local calSell = role.dinerData:updateSell(slot, true) or {
  			deltaCount = 0,
  			deltaTime = 0,
  			lastCount = 0,
  		}
  		local count = sellData.count
  		local maxDishCount = role.dinerData:getMaxDishs()
  		if math.illegalNum(count + calSell.lastCount, 1, maxDishCount) then
  			return 5
  		end
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
47 
 | 
  
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
48 
 | 
  		local cost = dishData.material:toNumMap()
 
 | 
687835fc
 
  gaofengduan
 
fix bug cost
 | 
49
50 
 | 
  		for k, n in pairs(cost) do
  			cost[k] = n * count
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
51
52
53
54 
 | 
  		end
  		if not role:checkItemEnough(cost) then
  			return 6
  		end
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
55 
 | 
  
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
56
57 
 | 
  		role:costItems(cost)
  		role.dinerData:updateSell(slot)
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
58 
 | 
  
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
59
60
61
62
63
64
65 
 | 
  		local dirty = false
  		for id, value in pairs(cost) do
  			if role.dinerData:checkDinerTask(DinerTask.UseMaterial, value, id, nil, true) then
  				dirty = true
  			end
  		end
  		if role.dinerData:checkDinerTask(DinerTask.AddDish, count, dish, nil, true) then
 
 | 
cc796aaf
 
  zhengshouren
 
增加餐厅任务计数逻辑
 | 
66
67 
 | 
  			dirty = true
  		end
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
68
69
70 
 | 
  		if dirty then
  			role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order"))
  		end
 
 | 
cc796aaf
 
  zhengshouren
 
增加餐厅任务计数逻辑
 | 
71 
 | 
  
 
 | 
5a307eb6
 
  gaofengduan
 
fix diner
 | 
72 
 | 
  		sells = json.decode(role.dinerData:getProperty("sells"))
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
73
74 
 | 
  		if not sells[slot] then
  			sells[slot] = {
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
75 
 | 
  				reward = "",
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
76
77 
 | 
  			}
  		end
 
 | 
5a307eb6
 
  gaofengduan
 
fix diner
 | 
78
79
80
81
82 
 | 
  		sells[slot].dish = dish
  		sells[slot].level = dishLevel
  		sells[slot].count = count
  		sells[slot].time = skynet.timex() - calSell.deltaTime
  		sells[slot].hot = role.dinerData:getProperty("hot"):getv(sells[slot].dish, 0)
 
 | 
448dee6b
 
  gaofengduan
 
fix 餐车快速制作
 | 
83 
 | 
  		role.dinerData:updateProperty({field = "sells", value = json.encode(sells)})
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
84 
 | 
  	end
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
85 
 | 
  	SendPacket(actionCodes.Diner_addSellRpc, "")
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
86 
 | 
  	return true
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
87
88 
 | 
  end
  
 
 | 
1ab9458f
 
  gaofengduan
 
add 下菜操作
 | 
89
90
91
92
93
94
95
96
97
98
99
100
101
102 
 | 
  function _M.removeSellRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  
  	local slot = msg.slot
  	if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then
  		return 1
  	end
  	slot = tostring(slot)
  	local sells = json.decode(role.dinerData:getProperty("sells"))
  	local sell = sells[slot]
  	if not sell then
  		return 2
  	end
 
 | 
1ab9458f
 
  gaofengduan
 
add 下菜操作
 | 
103
104
105
106
107
108
109
110
111
112
113
114
115
116 
 | 
  	local dish = sell.dish
  	local dishSet = csvdb["diner_dishCsv"][dish]
  	if not dishSet then
  		return 3
  	end
  	local dishLevel = role.dinerData:getProperty("dishTree"):getv(dish, 0)
  	if dishLevel == 0 then
  		return 4
  	end
  	local dishData = dishSet[dishLevel]
  	if not dishData then
  		return 5
  	end
  
 
 | 
6991df1b
 
  gaofengduan
 
fix bug
 | 
117 
 | 
  	role.dinerData:updateSell(slot)
 
 | 
1ab9458f
 
  gaofengduan
 
add 下菜操作
 | 
118
119
120
121
122
123
124 
 | 
  	local reward = {}
  	local cost = dishData.material:toNumMap()
  	for k, n in pairs(cost) do
  		local sum = n*sell.count
  		role:addItem({itemId = k,count = sum})
  		reward[k] = sum
  	end
 
 | 
5a307eb6
 
  gaofengduan
 
fix diner
 | 
125 
 | 
  	sells[slot].count = 0
 
 | 
1ab9458f
 
  gaofengduan
 
add 下菜操作
 | 
126
127
128
129
130 
 | 
  	role.dinerData:updateProperty({field = "sells", value = json.encode(sells)})
  	SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward}))
  	return true
  end
  
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
131 
 | 
  function _M.getSellRewardRpc( agent, data )
 
 | 
5d57bd79
 
  gaofengduan
 
add 餐车 getSellRew...
 | 
132 
 | 
  	local role = agent.role
 
 | 
cc796aaf
 
  zhengshouren
 
增加餐厅任务计数逻辑
 | 
133 
 | 
  	local dirty = false
 
 | 
f5c07b1b
 
  gaofengduan
 
fix diner
 | 
134 
 | 
  	local reward = ""
 
 | 
5d57bd79
 
  gaofengduan
 
add 餐车 getSellRew...
 | 
135 
 | 
  	local sells = json.decode(role.dinerData:getProperty("sells"))
 
 | 
32161569
 
  gaofengduan
 
fix diner
 | 
136 
 | 
  	for slot, _ in pairs(sells) do
 
 | 
0c0b161d
 
  gaofengduan
 
fix getSellRewardRpc
 | 
137 
 | 
  		role.dinerData:updateSell(slot)
 
 | 
32161569
 
  gaofengduan
 
fix diner
 | 
138
139
140 
 | 
  	end
  	sells = json.decode(role.dinerData:getProperty("sells"))
  	for slot, sell in pairs(sells) do
 
 | 
cc796aaf
 
  zhengshouren
 
增加餐厅任务计数逻辑
 | 
141
142 
 | 
  		local rewards = sell.reward:toNumMap()
  		for k,v in pairs(rewards) do
 
 | 
f5c07b1b
 
  gaofengduan
 
fix diner
 | 
143 
 | 
  			reward = reward:incrv(k, v)
 
 | 
5d57bd79
 
  gaofengduan
 
add 餐车 getSellRew...
 | 
144 
 | 
  		end
 
 | 
cc796aaf
 
  zhengshouren
 
增加餐厅任务计数逻辑
 | 
145
146 
 | 
  
  		if rewards[ItemId.Gold] and rewards[ItemId.Gold] > 0 then
 
 | 
da6362db
 
  gaofengduan
 
fix dinerData
 | 
147 
 | 
  			if role.dinerData:checkDinerTask(DinerTask.DishWithGold, rewards[ItemId.Gold], sell.dish, nil, true) then
 
 | 
cc796aaf
 
  zhengshouren
 
增加餐厅任务计数逻辑
 | 
148
149
150 
 | 
  				dirty = true
  			end
  		end
 
 | 
32161569
 
  gaofengduan
 
fix diner
 | 
151 
 | 
  		sells[slot].reward = ""
 
 | 
5d57bd79
 
  gaofengduan
 
add 餐车 getSellRew...
 | 
152 
 | 
  	end
 
 | 
f5c07b1b
 
  gaofengduan
 
fix diner
 | 
153
154 
 | 
  	role.dinerData:updateProperty({field = "sells", value = json.encode(sells)})
  	for k, v in pairs(reward:toNumMap()) do
 
 | 
0c0b161d
 
  gaofengduan
 
fix getSellRewardRpc
 | 
155 
 | 
  		role:addItem({itemId = k,count = v})
 
 | 
5d57bd79
 
  gaofengduan
 
add 餐车 getSellRew...
 | 
156 
 | 
  	end
 
 | 
32161569
 
  gaofengduan
 
fix diner
 | 
157 
 | 
  
 
 | 
cc796aaf
 
  zhengshouren
 
增加餐厅任务计数逻辑
 | 
158 
 | 
  	if dirty then
 
 | 
da6362db
 
  gaofengduan
 
fix dinerData
 | 
159 
 | 
  		role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order"))
 
 | 
cc796aaf
 
  zhengshouren
 
增加餐厅任务计数逻辑
 | 
160
161 
 | 
  	end
  
 
 | 
0c0b161d
 
  gaofengduan
 
fix getSellRewardRpc
 | 
162 
 | 
  	SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward}))
 
 | 
5d57bd79
 
  gaofengduan
 
add 餐车 getSellRew...
 | 
163 
 | 
  	return true
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
164
165 
 | 
  end
  
 
 | 
2050d40d
 
  gaofengduan
 
add diner expedit...
 | 
166
167 
 | 
  function _M.expediteSellRpc( agent, data )
  	local role = agent.role
 
 | 
020fc7ed
 
  gaofengduan
 
fix diner expedit...
 | 
168
169 
 | 
  	local count = role.dinerData:getProperty("expedite")
  	local max = #globalCsv.diner_sell_quick_cost
 
 | 
cb3aaefb
 
  gaofengduan
 
fix diner
 | 
170 
 | 
  	if count >= max then
 
 | 
020fc7ed
 
  gaofengduan
 
fix diner expedit...
 | 
171
172 
 | 
  		return 1
  	end
 
 | 
cb3aaefb
 
  gaofengduan
 
fix diner
 | 
173 
 | 
  	local cost = {[ItemId.Diamond] = globalCsv.diner_sell_quick_cost[count+1]}
 
 | 
020fc7ed
 
  gaofengduan
 
fix diner expedit...
 | 
174
175
176
177
178 
 | 
  	if not role:checkItemEnough(cost) then
  		return 2
  	end
  	role:costItems(cost)
  
 
 | 
2050d40d
 
  gaofengduan
 
add diner expedit...
 | 
179 
 | 
  	local dirty = false
 
 | 
020fc7ed
 
  gaofengduan
 
fix diner expedit...
 | 
180 
 | 
  	local reward,popular = "",0
 
 | 
2050d40d
 
  gaofengduan
 
add diner expedit...
 | 
181
182
183
184
185
186 
 | 
  	local sells = json.decode(role.dinerData:getProperty("sells"))
  	for slot, _ in pairs(sells) do
  		role.dinerData:updateSell(slot)
  	end
  	sells = json.decode(role.dinerData:getProperty("sells"))
  	for slot, sell in pairs(sells) do
 
 | 
020fc7ed
 
  gaofengduan
 
fix diner expedit...
 | 
187 
 | 
  		local result = role.dinerData:expediteSell(slot)
 
 | 
6991df1b
 
  gaofengduan
 
fix bug
 | 
188
189
190
191
192
193 
 | 
  		if result then
  			local rewards = result.reward:toNumMap()
  			for k,v in pairs(result.reward:toNumMap()) do
  				reward = reward:incrv(k,v)
  			end
  			popular = popular + result.popular
 
 | 
2050d40d
 
  gaofengduan
 
add diner expedit...
 | 
194 
 | 
  
 
 | 
6991df1b
 
  gaofengduan
 
fix bug
 | 
195
196
197
198 
 | 
  			if rewards[ItemId.Gold] and rewards[ItemId.Gold] > 0 then
  				if role.dinerData:checkDinerTask(DinerTask.DishWithGold, rewards[ItemId.Gold], sell.dish, nil, true) then
  					dirty = true
  				end
 
 | 
2050d40d
 
  gaofengduan
 
add diner expedit...
 | 
199
200
201
202 
 | 
  			end
  		end
  	end
  
 
 | 
020fc7ed
 
  gaofengduan
 
fix diner expedit...
 | 
203
204
205 
 | 
  	role.dinerData:notifyUpdateProperty("sells", role.dinerData:getProperty("sells"))
  	role.dinerData:setProperty("expedite",count+1)
  	role.dinerData:notifyUpdateProperty("expedite", count+1)
 
 | 
2050d40d
 
  gaofengduan
 
add diner expedit...
 | 
206
207
208
209
210
211
212 
 | 
  	for k, v in pairs(reward:toNumMap()) do
  		role:addItem({itemId = k,count = v})
  	end
  
  	if dirty then
  		role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order"))
  	end
 
 | 
020fc7ed
 
  gaofengduan
 
fix diner expedit...
 | 
213 
 | 
  	SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward,popular = popular}))
 
 | 
2050d40d
 
  gaofengduan
 
add diner expedit...
 | 
214
215
216 
 | 
  	return true
  end
  
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
217
218
219
220
221 
 | 
  function _M.levelUpRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  
  	local index = msg.index
 
 | 
f9c6cac9
 
  zhengshouren
 
建筑升级增加 其他建筑物等级限制
 | 
222
223 
 | 
  	local buildingSet = csvdb["diner_buildingCsv"][index]
  	if not buildingSet then
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
224
225
226
227
228 
 | 
  		return
  	end
  
  	local buildL = role.dinerData:getProperty("buildL")
  	local curLevel = buildL:getv(index, 1)
 
 | 
f9c6cac9
 
  zhengshouren
 
建筑升级增加 其他建筑物等级限制
 | 
229 
 | 
  	if curLevel >= #buildingSet then
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
230
231 
 | 
  		return
  	end
 
 | 
f9c6cac9
 
  zhengshouren
 
建筑升级增加 其他建筑物等级限制
 | 
232
233
234
235
236 
 | 
  	local buildingData = buildingSet[curLevel]
  	if not buildingData then
  		return
  	end
  	if buildingData.upLimit ~= "" then
 
 | 
4a969fc5
 
  gaofengduan
 
fix diner levelUpRpc
 | 
237 
 | 
  		local id, level = buildingData.upLimit:match("(%d+)=(%d+)")
 
 | 
f9c6cac9
 
  zhengshouren
 
建筑升级增加 其他建筑物等级限制
 | 
238
239
240
241 
 | 
  		if buildL:getv(tonumber(id), 1) < tonumber(level) then
  			return
  		end
  	end
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
242 
 | 
  
 
 | 
f9c6cac9
 
  zhengshouren
 
建筑升级增加 其他建筑物等级限制
 | 
243 
 | 
  	local cost = buildingData.starCost:toNumMap()
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
244 
 | 
  	if not role:checkItemEnough(cost) then
 
 | 
289a4927
 
  gaofengduan
 
fix diner talent
 | 
245 
 | 
  		return
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
246
247 
 | 
  	end
  
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
248 
 | 
  	role:costItems(cost)
 
 | 
d96fae59
 
  gaofengduan
 
fix diner levelUpRpc
 | 
249 
 | 
  	role.dinerData:updateProperty({field = "buildL", value = buildL:setv(index, curLevel + 1)})
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
250
251
252
253
254 
 | 
  
  	SendPacket(actionCodes.Diner_levelUpRpc, '')
  	return true
  end
  
 
 | 
b67180e8
 
  zhengshouren
 
餐厅天赋升级
 | 
255
256
257 
 | 
  function _M.talentUpRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
b67180e8
 
  zhengshouren
 
餐厅天赋升级
 | 
258 
 | 
  	local dish = msg.dish
 
 | 
b67180e8
 
  zhengshouren
 
餐厅天赋升级
 | 
259
260 
 | 
  	local dishTree = role.dinerData:getProperty("dishTree")
  	local dishLevel = dishTree:getv(dish, 0)
 
 | 
289a4927
 
  gaofengduan
 
fix diner talent
 | 
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291 
 | 
  
  	local talentSet = csvdb["diner_talentCsv"][dish]
  	if not talentSet then
  		return 1
  	end
  
  	local talentData = talentSet[dishLevel]
  	if not talentData then
  		return 2
  	end
  
  	if not talentSet[dishLevel+1] then
  		return 21
  	end
  
  	local typ = math.floor(dish/100 + 1)
  	local treeSet = csvdb["diner_treeCsv"][typ]
  	if not treeSet then
  		return 3
  	end
  
  	local treeData = treeSet[dish]
  	if not treeData then
  		return 4
  	end
  
  	local limit = treeData.pointFront:toNumMap()
  	for k,v in pairs(limit) do
  		local lv = dishTree:getv(k, 0)
  		if lv < v then
  			return 5
 
 | 
b67180e8
 
  zhengshouren
 
餐厅天赋升级
 | 
292 
 | 
  		end
 
 | 
b67180e8
 
  zhengshouren
 
餐厅天赋升级
 | 
293 
 | 
  	end
 
 | 
289a4927
 
  gaofengduan
 
fix diner talent
 | 
294
295 
 | 
  
  	local cost = talentData.cost:toNumMap()
 
 | 
b67180e8
 
  zhengshouren
 
餐厅天赋升级
 | 
296 
 | 
  	if not role:checkItemEnough(cost) then
 
 | 
289a4927
 
  gaofengduan
 
fix diner talent
 | 
297
298
299 
 | 
  		return 6
  	end
  
 
 | 
dbd0ca58
 
  gaofengduan
 
car  营养剂制作
 | 
300 
 | 
  	-- 正在贩卖不能升级料理天赋
 
 | 
289a4927
 
  gaofengduan
 
fix diner talent
 | 
301
302
303
304
305
306 
 | 
  	local sells = json.decode(role.dinerData:getProperty("sells"))
  	for slot, _ in pairs(sells) do
  		role.dinerData:updateSell(slot)
  	end
  	sells = json.decode(role.dinerData:getProperty("sells"))
  	for _, sell in pairs(sells) do
 
 | 
6991df1b
 
  gaofengduan
 
fix bug
 | 
307 
 | 
  		if sell.dish == msg.dish and sell.count > 0 then
 
 | 
289a4927
 
  gaofengduan
 
fix diner talent
 | 
308
309 
 | 
  			return 7
  		end
 
 | 
b67180e8
 
  zhengshouren
 
餐厅天赋升级
 | 
310
311 
 | 
  	end
  
 
 | 
dbd0ca58
 
  gaofengduan
 
car  营养剂制作
 | 
312 
 | 
  	-- 正在冒险不能升级营养剂天赋
 
 | 
69d686f8
 
  gaofengduan
 
暂时取消营养剂天赋升级限制
 | 
313
314
315 
 | 
  	-- if talentData.effect:toArray(true,"=")[1] == 2 then
  	-- 	if next(role:getProperty("advTeam")) then return 8 end
  	-- end
 
 | 
dbd0ca58
 
  gaofengduan
 
car  营养剂制作
 | 
316 
 | 
  
 
 | 
b67180e8
 
  zhengshouren
 
餐厅天赋升级
 | 
317
318 
 | 
  	role:costItems(cost)
  	role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)})
 
 | 
289a4927
 
  gaofengduan
 
fix diner talent
 | 
319 
 | 
  	local treePoint = talentData.tree_point:toNumMap()
 
 | 
b67180e8
 
  zhengshouren
 
餐厅天赋升级
 | 
320
321
322
323
324
325
326
327 
 | 
  	if next(treePoint) then
  		role:award(treePoint)
  	end
  
  	SendPacket(actionCodes.Diner_talentUpRpc, '')
  	return true
  end
  
 
 | 
7d44dca2
 
  zhengshouren
 
支援技能升级逻辑
 | 
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361 
 | 
  function _M.skillUpRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  
  	local skill = msg.skill
  	local skillSet = csvdb["diner_skillCsv"][skill]
  	if not skillSet then
  		return
  	end
  
  	local skillTree = role.dinerData:getProperty("skillTree")
  	local skillLevel = skillTree:getv(skill, 1)
  	local skillData = skillSet[skillLevel]
  	if not skillData then
  		return
  	end
  	if skillData.unlock ~= "" then
  		local id, level = skillData.unlock:math("(%d+)=(%d+)")
  		if skillTree:getv(tonumber(id), 1) < tonumber(level) then
  			return
  		end
  	end
  	local cost = skillData.cost:toNumMap()
  	if not role:checkItemEnough(cost) then
  		return
  	end
  
  	role:costItems(cost)
  	role.dinerData:updateProperty({field = "skillTree", value = skillTree:setv(skill, skillLevel + 1)})
  
  	SendPacket(actionCodes.Diner_skillUpRpc, '')
  	return true
  end
  
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
362
363
364
365
366
367
368
369
370
371
372
373
374 
 | 
  function _M.lockTaskRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  	local index = msg.index
  
  	if math.illegalNum(index, 1, 7) then
  		return 1
  	end
  	local orders = json.decode(role.dinerData:getProperty("order"))
  	local order = orders[index]
  	if not order then
  		return 2
  	end
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
375
376
377
378 
 | 
  	if order.lock == 0 then
  		order.lock = 1
  	else
  		order.lock = 0
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
379 
 | 
  	end
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
380 
 | 
  	role.dinerData:updateProperty({field = "order", value = json.encode(orders)})
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
381 
 | 
  	SendPacket(actionCodes.Diner_lockTaskRpc, MsgPack.pack({lock = order.lock}))
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
382
383
384 
 | 
  	return true
  end
  
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
385 
 | 
  function _M.updateTaskRpc( agent, data )
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
386
387 
 | 
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
388 
 | 
  	local index = msg.index
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
389
390 
 | 
  	-- 0 放弃已接受任务,1 接受任务,2 完成已接受任务
  	local cmd = msg.cmd
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
391
392
393
394
395
396
397
398
399 
 | 
  
  	if math.illegalNum(index, 1, 7) then
  		return 1
  	end
  	local orders = json.decode(role.dinerData:getProperty("order"))
  	local order = orders[index]
  	if not order then
  		return 2
  	end
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
400
401
402
403
404
405
406
407 
 | 
  	local taskSet = csvdb["diner_questCsv"][order.lv]
  	if not taskSet then
  		return 4
  	end
  	local taskData = taskSet[order.id]
  	if not taskData then
  		return 5
  	end
 
 | 
289a4927
 
  gaofengduan
 
fix diner talent
 | 
408 
 | 
  
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
409 
 | 
  
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
410
411
412
413
414
415
416
417
418
419
420
421
422 
 | 
  	if cmd == 0 then
  		if order.status ~= 0 then
  			return 30
  		end
  		orders[index].status = 1
  		orders[index].lock = 1
  	elseif cmd == 1 then
  		if order.status ~= 1 then
  			return 31
  		end
  		orders[index].status = 0
  		orders[index].lock = 0
  	elseif cmd == 2 then
 
 | 
452d6146
 
  gaofengduan
 
fix diner task
 | 
423 
 | 
  		if order.status ~= 1 then
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
424
425 
 | 
  			return 32
  		end
 
 | 
452d6146
 
  gaofengduan
 
fix diner task
 | 
426 
 | 
  		if order.n < taskData.value then
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
427
428
429
430
431 
 | 
  			return 6
  		end
  		for typ, count in pairs(taskData.reward:toNumMap()) do
  			role:addItem({itemId = typ, count = count})
  		end
 
 | 
452d6146
 
  gaofengduan
 
fix diner task
 | 
432 
 | 
  		table.remove(orders,index)
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
433
434 
 | 
  	else
  		return 33
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
435
436 
 | 
  	end
  
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
437
438 
 | 
  	role.dinerData:updateProperty({field = "order", value = json.encode(orders)})
  	SendPacket(actionCodes.Diner_updateTaskRpc, '')
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
439
440
441 
 | 
  	return true
  end
  
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
442 
 | 
  function _M.refreshTaskRpc( agent, data )
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
443
444
445 
 | 
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  
 
 | 
fdb86cad
 
  gaofengduan
 
fix diner task
 | 
446 
 | 
  	local cost = {[ItemId.Diamond] = 40}
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
447
448
449
450
451
452
453
454
455
456
457
458
459
460 
 | 
  	if not role:checkItemEnough(cost) then
  		return 1
  	end
  
  	local orders = json.decode(role.dinerData:getProperty("order"))
  	if #orders > 6 then
  		return 2
  	end
  
  	local taskLevel = role.dinerData:getProperty("buildL"):getv(5, 1)
  	local taskData = csvdb["diner_questCsv"][taskLevel]
  	if not taskData then
  		return 3
  	end
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
461
462
463 
 | 
  
  	role:costItems(cost)
  
 
 | 
ca232abd
 
  gaofengduan
 
fix diner task re...
 | 
464
465
466
467
468
469
470 
 | 
  	for k,v in pairs(orders) do
  		if v.lock == 0 then
  			local index = math.randWeight(taskData, "chance")
  			local t = taskData[index]
  			orders[k] = {lv = taskLevel, id = t.id, n = 0, lock = 0,status = 0}
  		end
  	end
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
471 
 | 
  	role.dinerData:updateProperty({field = "order", value = json.encode(orders)})
 
 | 
289a4927
 
  gaofengduan
 
fix diner talent
 | 
472
473 
 | 
  
  	SendPacket(actionCodes.Diner_refreshTaskRpc, '')
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
474
475
476 
 | 
  	return true
  end
  
 
 | 
4288160b
 
  gaofengduan
 
add Diner_getGree...
 | 
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506 
 | 
  function _M.getGreenhouseRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  
  	local buildType = 6
  	local level = role.dinerData:getProperty("buildL"):getv(buildType, 1)
  	local buildingData = csvdb["diner_buildingCsv"][buildType][level]
  	if not buildingData then
  		return 1
  	end
  	if buildingData.speed <= 0 then
  		return 2
  	end
  
  	local reward = ""
  	local now = skynet.timex()
  	local timePass = now - role.dinerData:getProperty("gTime")
  	role.dinerData:setProperty("gTime",now)
  	role.dinerData:notifyUpdateProperty("gTime",now)
  	local count = math.floor(timePass/buildingData.speed)
  	count = math.min(count,buildingData.storage)
  	for _=1,count do
  		reward = reward:incrv(string.randWeight(buildingData.gift_normal), 1)
  	end
  	for k, v in pairs(reward:toNumMap()) do
  		role:addItem({itemId = k,count = v})
  	end
  	SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward}))
  	return true
  end
 
 | 
4864d579
 
  zhengshouren
 
领取任务,锁定任务,获得特殊任务
 | 
507 
 | 
  
 
 | 
87cc3a35
 
  zhengshouren
 
餐厅建筑升级逻辑
 | 
508 
 | 
  return _M
 
 |