9c525cf9
gaofengduan
add car smithy
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
local ipairs = ipairs
local table = table
local math = math
local redisproxy = redisproxy
local MsgPack = MsgPack
local _M = {}
function _M.makePotionRpc( agent, data )
local role = agent.role
local msg = MsgPack.unpack(data)
local potionId = msg.id
local count = msg.count
if count < 1 then return 0 end
local potionBag = role:getProperty("potionBag")
|
e6845afa
liuzujun
餐厅食材供应商供应食材条件调整
|
16
17
|
local dishTree = role.dinerData:getProperty("dishTree")
local potionLv = dishTree:getv(potionId, 1)
|
9c525cf9
gaofengduan
add car smithy
|
18
19
|
if potionLv < 1 then return 1 end
|
e6845afa
liuzujun
餐厅食材供应商供应食材条件调整
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
local talentSet = csvdb["diner_talentCsv"][potionId]
if not talentSet then
return 10
end
local talentData = talentSet[potionLv]
if not talentData then
return 11
end
local limit = talentData.pointFront:toNumMap()
for k,v in pairs(limit) do
local lv = dishTree:getv(k, 0)
if lv < v then
return 12
end
end
|
9c525cf9
gaofengduan
add car smithy
|
38
39
40
41
42
43
|
local potionSet = csvdb["adv_potionCsv"][potionId]
if not potionSet then return 2 end
local potionData = potionSet[potionLv]
if not potionData then return 3 end
|
9c525cf9
gaofengduan
add car smithy
|
44
|
local cost = potionData.material:toNumMap()
|
e668f4d0
gaofengduan
fix cost
|
45
46
|
for k, n in pairs(cost) do
cost[k] = n * count
|
9c525cf9
gaofengduan
add car smithy
|
47
48
|
end
if not role:checkItemEnough(cost) then
|
0027e33b
chenyueqi
调理剂生产和使用逻辑优化
|
49
|
return 4
|
9c525cf9
gaofengduan
add car smithy
|
50
|
end
|
3133cb76
zhouhaihai
日志
|
51
|
role:costItems(cost, {log = {desc = "makePotion", int1 = potionId, int2 = count}})
|
0027e33b
chenyueqi
调理剂生产和使用逻辑优化
|
52
|
local own = potionBag[potionId] or 0
|
9c525cf9
gaofengduan
add car smithy
|
53
54
|
potionBag[potionId] = own + count
role:updateProperty({field = "potionBag", value = potionBag})
|
53e8037e
zhouhaihai
任务
|
55
|
role:checkTaskEnter("PotionMake", {count = count, id = potionId})
|
3133cb76
zhouhaihai
日志
|
56
|
|
c59e058b
zhouhaihai
新一批日志记录
|
57
58
59
60
61
|
role:log("carriage_cook", {
item_id = potionId, -- 道具id
item_level = potionLv, -- 道具等级
item_type = 0, -- 道具类型,具体见枚举表中道具类型枚举表
carriage_cook_amount = count, -- 制作总量
|
887c1843
zhouhaihai
日志新一批
|
62
|
carriage_cook_cost = cost, -- 制作消耗道具,json格式记录,{'itemid1':10,'itemid2':5,…………..}
|
c59e058b
zhouhaihai
新一批日志记录
|
63
|
})
|
f22a33af
zhouhaihai
自己的日志
|
64
65
|
role:mylog("role_action", {desc = "makePotion", int1 = potionId, int2 = count})
|
9c525cf9
gaofengduan
add car smithy
|
66
67
68
69
70
71
72
73
74
|
SendPacket(actionCodes.Car_makePotionRpc, MsgPack.pack({potionBag = potionBag}))
return true
end
function _M.equipUpRpc( agent, data )
local role = agent.role
local msg = MsgPack.unpack(data)
local id = msg.id
local count = msg.count
|
056c01a0
zhouhaihai
简化装备
|
75
|
|
9c525cf9
gaofengduan
add car smithy
|
76
77
78
79
80
81
82
83
|
local typ = math.floor((id-7000)/100)
local lv = (id-7000)%100
local dataSet = csvdb["equipCsv"][typ]
if not dataSet then return 1 end
local equipData = dataSet[lv]
if not equipData then return 21 end
if equipData.merge < 1 then return 22 end
|
056c01a0
zhouhaihai
简化装备
|
84
|
|
9c525cf9
gaofengduan
add car smithy
|
85
86
87
88
89
90
91
92
|
local maxLv = 3
local nextLv = lv+1
if nextLv%10 > maxLv then
nextLv = nextLv+10-maxLv
end
local nextEquip = dataSet[nextLv]
if not nextEquip then return 23 end
|
912f7d2c
zhouhaihai
bug
|
93
|
local limit = csvdb["itemCsv"][nextEquip.id].limit ~= 0 and csvdb["itemCsv"][nextEquip.id].limit or math.huge
|
056c01a0
zhouhaihai
简化装备
|
94
95
|
if math.illegalNum(count, 1, limit) then return 0 end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
96
97
|
local own = role:getEquipCount(typ,lv)
|
056c01a0
zhouhaihai
简化装备
|
98
|
local costCount = equipData.merge * count
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
99
|
if own < costCount then
|
9c525cf9
gaofengduan
add car smithy
|
100
101
102
103
|
return 3
end
local cost = equipData.cost:toNumMap()
|
e668f4d0
gaofengduan
fix cost
|
104
105
|
for k, n in pairs(cost) do
cost[k] = n * count
|
9c525cf9
gaofengduan
add car smithy
|
106
107
108
109
110
|
end
if not role:checkItemEnough(cost) then
return 4
end
|
3133cb76
zhouhaihai
日志
|
111
112
113
|
role:costItems(cost, {log = {desc = "equipUp", int1 = id, int2 = count}})
role:addEquip(typ, lv, -costCount, {log = {desc = "equipUp"}})
role:addEquip(typ, nextLv ,count, {log = {desc = "equipUp"}})
|
f60b89b1
zhouhaihai
奖励副本
|
114
|
role:checkTaskEnter("EquipUp", {count = count})
|
3133cb76
zhouhaihai
日志
|
115
|
|
c59e058b
zhouhaihai
新一批日志记录
|
116
117
118
119
120
121
|
role:log("equip_upgrade", {
equip_upgrade_part = typ, -- 升级部位,记录部位ID
equip_id = nextLv, -- 升级后的装备ID
equip_upgrade_amount = count, -- 升级获取的装备数量
equip_upgrade_usedid = lv, -- 升级消耗的装备ID
equip_upgrade_cost = costCount, -- 升级操作消耗装备数量
|
887c1843
zhouhaihai
日志新一批
|
122
|
equip_upgrade_current = cost, -- 升级消耗的货币类型
|
c59e058b
zhouhaihai
新一批日志记录
|
123
|
})
|
f22a33af
zhouhaihai
自己的日志
|
124
|
role:mylog("role_action", {desc = "equipUp", int1 = id, int2 = count})
|
9c525cf9
gaofengduan
add car smithy
|
125
126
127
128
|
SendPacket(actionCodes.Car_equipUpRpc, '')
return true
end
|
fb321075
gaofengduan
add rune up
|
129
130
131
132
133
134
|
function _M.runeUpRpc( agent, data )
local role = agent.role
local msg = MsgPack.unpack(data)
local uid = msg.uid
local ownRune = role.runeBag[uid]
if not ownRune then return 1 end
|
f52efe51
zhouhaihai
符文升级
|
135
|
|
fb321075
gaofengduan
add rune up
|
136
137
138
139
140
141
142
143
144
145
|
local typ = ownRune:getProperty("type")
local id = ownRune:getProperty("id")
local level = ownRune:getProperty("level")
local runeSet = csvdb["runeCsv"][typ]
if not runeSet then return 4 end
local runeData = runeSet[id]
if not runeData then return 5 end
|
1627de1c
liuzujun
铭文升级超过上限bug
|
146
147
|
--local maxLv = #csvdb["rune_buildCsv"]
if level >= runeData.lvLimit then return 6 end
|
04c7448f
gaofengduan
fix rune up
|
148
|
local lvData = csvdb["rune_buildCsv"][level]
|
fb321075
gaofengduan
add rune up
|
149
150
151
152
153
|
local cost = lvData.cost:toNumMap()
if not role:checkItemEnough(cost) then
return 7
end
|
3133cb76
zhouhaihai
日志
|
154
|
role:costItems(cost, {log = {desc = "runeUp", int1 = uid, int2 = level}})
|
fb321075
gaofengduan
add rune up
|
155
|
ownRune:updateProperty({field = "level",value = level+1})
|
53e8037e
zhouhaihai
任务
|
156
|
role:checkTaskEnter("RuneUp")
|
3133cb76
zhouhaihai
日志
|
157
|
|
f52efe51
zhouhaihai
符文升级
|
158
159
160
161
162
163
|
if ownRune:getProperty("refer") ~= 0 then
local hero = role.heros[ownRune:getProperty("refer")]
if hero then
hero:updateProperty({field = "battleV", value = hero:getBattleValue()})
end
end
|
f22a33af
zhouhaihai
自己的日志
|
164
|
ownRune:mylog({desc = "runeUp", int1 = level + 1})
|
3133cb76
zhouhaihai
日志
|
165
|
|
fb321075
gaofengduan
add rune up
|
166
167
168
169
|
SendPacket(actionCodes.Car_runeUpRpc, '')
return true
end
|
912f7d2c
zhouhaihai
bug
|
170
|
function _M.saleEquipRpc(agent, data )
|
056c01a0
zhouhaihai
简化装备
|
171
172
|
local role = agent.role
local msg = MsgPack.unpack(data)
|
9dd0add2
zhouhaihai
批量分解装备
|
173
174
175
|
local backs = msg.backs
if not backs then return end
for id, count in pairs(backs) do
|
2445248d
zhouhaihai
去掉热门料理
|
176
|
if not csvdb["itemCsv"][id] then return end
|
9dd0add2
zhouhaihai
批量分解装备
|
177
178
179
180
181
|
local typ = math.floor((id-7000)/100)
local lv = (id-7000)%100
local own = role:getEquipCount(typ,lv)
if math.illegalNum(count, 1, own) then return end
end
|
7bb30dca
zhouhaihai
修改发奖
|
182
|
local reward, change = {}
|
03a6166a
zhouhaihai
餐厅优化
|
183
|
local allCount = 0
|
9dd0add2
zhouhaihai
批量分解装备
|
184
|
for id, count in pairs(backs) do
|
03a6166a
zhouhaihai
餐厅优化
|
185
|
allCount = allCount + count
|
2445248d
zhouhaihai
去掉热门料理
|
186
|
local itemData = csvdb["itemCsv"][id]
|
9dd0add2
zhouhaihai
批量分解装备
|
187
188
|
local typ = math.floor((id-7000)/100)
local lv = (id-7000)%100
|
3133cb76
zhouhaihai
日志
|
189
|
role:addEquip(typ, lv, -count, {log = {desc = "saleEquip"}}) -- 删掉装备
|
9dd0add2
zhouhaihai
批量分解装备
|
190
191
192
193
194
|
-- 发奖励
local one = itemData.sell_effect:toNumMap()
for k ,v in pairs(one) do
reward[k] = (reward[k] or 0) + v * count
end
|
056c01a0
zhouhaihai
简化装备
|
195
|
end
|
03a6166a
zhouhaihai
餐厅优化
|
196
|
role:checkTaskEnter("SaleEquip", {count = allCount})
|
7bb30dca
zhouhaihai
修改发奖
|
197
|
reward, change = role:award(reward, {log = {desc = "saleEquip"}})
|
f22a33af
zhouhaihai
自己的日志
|
198
199
|
role:mylog("role_action", {desc = "saleEquip", int1 = allCount})
|
7bb30dca
zhouhaihai
修改发奖
|
200
|
SendPacket(actionCodes.Car_saleEquipRpc, MsgPack.pack(role:packReward(reward, change)))
|
056c01a0
zhouhaihai
简化装备
|
201
202
203
|
return true
end
|
497f9a67
zhouhaihai
卖零件
|
204
205
206
207
208
209
|
function _M.saleRuneRpc(agent, data )
local role = agent.role
local msg = MsgPack.unpack(data)
local backs = msg.backs
if not backs then return end
|
7bb30dca
zhouhaihai
修改发奖
|
210
|
local reward, change = {}
|
03a6166a
zhouhaihai
餐厅优化
|
211
|
local count = 0
|
2445248d
zhouhaihai
去掉热门料理
|
212
|
for _, uid in pairs(backs) do
|
03a6166a
zhouhaihai
餐厅优化
|
213
|
count = count + 1
|
497f9a67
zhouhaihai
卖零件
|
214
215
216
|
local rune = role.runeBag[uid]
if not rune then return end
if rune:getProperty("refer") ~= 0 then return end
|
2445248d
zhouhaihai
去掉热门料理
|
217
|
local itemData = csvdb["itemCsv"][rune:getProperty("id")]
|
497f9a67
zhouhaihai
卖零件
|
218
219
220
221
222
223
224
|
if not itemData then return end
local one = itemData.sell_effect:toNumMap()
for k ,v in pairs(one) do
reward[k] = (reward[k] or 0) + v
end
end
|
3133cb76
zhouhaihai
日志
|
225
|
role:delRunes(backs, {log = {desc = "saleRune"}})
|
03a6166a
zhouhaihai
餐厅优化
|
226
|
role:checkTaskEnter("DecoRune", {count = count})
|
7bb30dca
zhouhaihai
修改发奖
|
227
|
reward, change = role:award(reward, {log = {desc = "saleRune"}})
|
3133cb76
zhouhaihai
日志
|
228
|
|
7bb30dca
zhouhaihai
修改发奖
|
229
|
SendPacket(actionCodes.Car_saleRuneRpc, MsgPack.pack(role:packReward(reward, change)))
|
497f9a67
zhouhaihai
卖零件
|
230
231
232
|
return true
end
|
3d8468b2
liuzujun
火花系统
|
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
function _M.sparkQualityUpRpc( agent, data )
local role = agent.role
local msg = MsgPack.unpack(data)
local uid = msg.uid
local ownSpark = role.sparkBag[uid]
if not ownSpark then return 1 end
local cfg_id = ownSpark:getProperty("cfg_id")
local level = ownSpark:getProperty("level")
local sparkSet = csvdb["sparkCsv"][cfg_id]
if not sparkSet then return 4 end
local sparkData = sparkSet[level]
if not sparkData then return 5 end
if sparkData.star_up == 0 then return 6 end
local cost = sparkData.star_item:toNumMap()
if not role:checkItemEnough(cost) then
return 7
end
role:costItems(cost, {log = {desc = "sparkQualityUp", int1 = uid, int2 = level}})
local newSet = csvdb["sparkCsv"][sparkData.star_up]
if not newSet then return 8 end
local newSparkData = newSet[0]
if not newSparkData then return 9 end
local attrs = newSparkData.attr:toNumMap()
ownSpark:addAttr(attrs)
ownSpark:updateProperty({field = "level",value = 0})
ownSpark:updateProperty({field = "cfg_id",value = sparkData.star_up})
--role:checkTaskEnter("SparkQualityUp")
ownSpark:mylog({desc = "sparkQualityUp", int1 = sparkData.id , int2 = sparkData.star_up})
SendPacket(actionCodes.Car_sparkQualityUpRpc, '')
return true
end
function _M.sparkLvlUpRpc( agent, data )
local role = agent.role
local msg = MsgPack.unpack(data)
local uid = msg.uid
local ownSpark = role.sparkBag[uid]
if not ownSpark then return 1 end
local cfg_id = ownSpark:getProperty("cfg_id")
local level = ownSpark:getProperty("level")
local sparkSet = csvdb["sparkCsv"][cfg_id]
if not sparkSet then return 4 end
local sparkData = sparkSet[level]
if not sparkData then return 5 end
if level >= #sparkSet then return 6 end
local cost = sparkData.lv_up_item:toNumMap()
if not role:checkItemEnough(cost) then
return 7
end
local weight = math.random(0, 100)
local addLvl = 1
if weight < sparkData.probability then
addLvl = 2
end
role:costItems(cost, {log = {desc = "sparkLvlUp", int1 = uid, int2 = level}})
local attrs = {}
for i = 1, addLvl do
local cfg = sparkSet[level + i]
if not cfg then break end
for k, v in pairs(cfg.attr:toNumMap()) do
attrs[k] = (attrs[k] or 0) + v
end
end
ownSpark:addAttr(attrs)
ownSpark:updateProperty({field = "level",value = level+addLvl})
--role:checkTaskEnter("SparkLvlUp")
ownSpark:mylog({desc = "sparkLvlUp", int1 = level + addLvl})
SendPacket(actionCodes.Car_sparkLvlUpRpc, MsgPack.pack({big = (addLvl == 2)}))
return true
end
|
9c525cf9
gaofengduan
add car smithy
|
321
|
return _M
|