555f745e
zhangqijia
feat: 一番赏
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
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 _M = {}
function _M.listRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local typ = msg.typ
|
639bbdff
zhangqijia
fix: 一番赏 获取扭蛋机列表,...
|
20
|
local id = msg.id
|
555f745e
zhangqijia
feat: 一番赏
|
21
22
23
|
local capsules = {}
if typ == 1 then
|
639bbdff
zhangqijia
fix: 一番赏 获取扭蛋机列表,...
|
24
|
local ret = skynet.call(agent.capsule_serv, "lua", "list", id)
|
555f745e
zhangqijia
feat: 一番赏
|
25
26
27
28
29
30
|
if next(ret) then
for k, v in pairs(ret) do
capsules[k] = v
end
end
elseif typ == 0 then
|
639bbdff
zhangqijia
fix: 一番赏 获取扭蛋机列表,...
|
31
|
local ret = role:getCapsuleList(id)
|
555f745e
zhangqijia
feat: 一番赏
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
if next(ret) then
for k, v in pairs(ret) do
capsules[k] = v
end
end
end
SendPacket(actionCodes.Capsule_listRpc, MsgPack.pack(capsules))
return true
end
function _M.joinRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local roleId = role:getProperty("id")
local capsuleId = msg.capsule_id --如果刷新则需要传递当前扭蛋机id
local typ = msg.typ or 1
local ret = {}
if typ == 1 then
ret = skynet.call(agent.capsule_serv, "lua", "join", roleId, capsuleId)
elseif typ == 0 then
|
da20e384
zhangqijia
feat: 一番赏 特殊赏 通知
|
54
|
ret = role:joinCapsule(roleId, capsuleId)
|
555f745e
zhangqijia
feat: 一番赏
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
end
SendPacket(actionCodes.Capsule_joinRpc, MsgPack.pack(ret))
return true
end
function _M.exitRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local roleId = role:getProperty("id")
local capsuleId = msg.capsule_id --如果刷新则需要传递当前扭蛋机id
local typ = msg.typ or 1
local ret = {}
if typ == 1 then
ret = skynet.call(agent.capsule_serv, "lua", "exit", roleId, capsuleId)
elseif typ == 0 then
ret = role:exitCapsule()
end
SendPacket(actionCodes.Capsule_exitRpc, MsgPack.pack(ret))
return true
end
function _M.registerRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local roleId = role:getProperty("id")
local capsuleId = msg.capsule_id
local ret = skynet.call(agent.capsule_serv, "lua", "register", roleId, capsuleId)
|
f382b4f2
zhangqijia
fix: 一番赏的抽奖bug
|
85
|
if not ret then return 1 end
|
555f745e
zhangqijia
feat: 一番赏
|
86
87
88
89
90
91
92
93
94
95
|
SendPacket(actionCodes.Capsule_registerRpc, MsgPack.pack(ret))
return true
end
function _M.drawRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local roleId = role:getProperty("id")
local capsuleId = msg.capsule_id
local typ = msg.typ --0=独享,1= 公开
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
96
|
local full = msg.full or 0-- 0=单次,1=十连抽 2=全收
|
555f745e
zhangqijia
feat: 一番赏
|
97
98
|
local cares = msg.cares
|
01ff9b4b
zhangqijia
fix: 一番赏 优化; 抽奖记录...
|
99
|
local ret, token, change, drawReward, capsule
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
100
101
102
103
104
105
106
|
--检查库存
if typ == 1 then
ret, token = skynet.call(agent.capsule_serv, "lua", "goods_stock", capsuleId)
else
ret, token = role:goodStock(capsuleId)
end
|
096de6f7
zhangqijia
fix: 一番赏 抽扭蛋机通知 特...
|
107
|
if ret == 0 then skynet.error("零库存 " .. capsuleId) return 0 end
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
--检查余额
if not next(token) then skynet.error("代币未配置 " .. capsuleId) return 1 end
local cost, drawsNum = {}, 0
if full == 0 then
drawsNum = 1
elseif full == 1 then
if ret < 10 then
drawsNum = ret
else
drawsNum = 10
end
elseif full == 2 then
drawsNum = ret
end
cost[token[1]] = drawsNum * token[2]
|
a997a3b0
zhangqijia
fix: 一番赏 打开消耗票的功能
|
125
126
|
if not role:checkItemEnough(cost) then return 2 end
role:costItems(cost, {log = {desc = "CapsuleCoinCost", int1 = token[1], int2 = cost[token[1]]}})
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
127
128
|
--开始抽奖
|
555f745e
zhangqijia
feat: 一番赏
|
129
|
if typ == 1 then
|
01ff9b4b
zhangqijia
fix: 一番赏 优化; 抽奖记录...
|
130
|
ret, drawReward, capsule = skynet.call(agent.capsule_serv, "lua", "draw_capsule", roleId, capsuleId, full, cares)
|
555f745e
zhangqijia
feat: 一番赏
|
131
|
else
|
01ff9b4b
zhangqijia
fix: 一番赏 优化; 抽奖记录...
|
132
|
ret, drawReward, capsule = role:drawCapsule(capsuleId, full, cares)
|
555f745e
zhangqijia
feat: 一番赏
|
133
|
end
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
134
|
if ret < 5 then
|
f382b4f2
zhangqijia
fix: 一番赏的抽奖bug
|
135
136
137
|
return ret
end
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
138
|
if ret == 5 then
|
01ff9b4b
zhangqijia
fix: 一番赏 优化; 抽奖记录...
|
139
|
SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({change = drawReward, capsule = capsule}))
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
140
|
return true
|
f382b4f2
zhangqijia
fix: 一番赏的抽奖bug
|
141
|
end
|
555f745e
zhangqijia
feat: 一番赏
|
142
|
|
01ff9b4b
zhangqijia
fix: 一番赏 优化; 抽奖记录...
|
143
144
145
|
if drawReward["reward"] and next(drawReward["reward"]) then
_, change = role:award(drawReward["reward"], {log = {desc = "CapsuleReward", int1 = tonumber(capsuleId), int2 = roleId}})
drawReward["capsule"] = capsule
|
01ff9b4b
zhangqijia
fix: 一番赏 优化; 抽奖记录...
|
146
|
SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack(drawReward))
|
cd2a7a67
zhangqijia
fix: 一番赏奖励中加入得奖者的...
|
147
|
else
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
148
|
return ret
|
cd2a7a67
zhangqijia
fix: 一番赏奖励中加入得奖者的...
|
149
|
end
|
555f745e
zhangqijia
feat: 一番赏
|
150
151
152
|
return true
end
|
0a421d34
zhangqijia
fix: 一番赏奖励 刷新协议缺少...
|
153
|
function _M.getDataRpc(agent, data)
|
555f745e
zhangqijia
feat: 一番赏
|
154
155
|
local role = agent.role
local msg = MsgPack.unpack(data)
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
156
157
|
local capsuleId = msg.capsule_id
local typ = msg.typ --0=独享,1= 公开
|
0a421d34
zhangqijia
fix: 一番赏奖励 刷新协议缺少...
|
158
|
local roleId = role:getProperty("id")
|
555f745e
zhangqijia
feat: 一番赏
|
159
|
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
160
161
|
local capsule
if typ == 1 then
|
0a421d34
zhangqijia
fix: 一番赏奖励 刷新协议缺少...
|
162
|
capsule = skynet.call(agent.capsule_serv, "lua", "capsule_data", roleId, capsuleId)
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
163
|
else
|
da20e384
zhangqijia
feat: 一番赏 特殊赏 通知
|
164
|
capsule = role:getCapsuleData(roleId, capsuleId)
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
165
166
167
168
|
end
if not capsule then return 1 end
SendPacket(actionCodes.Capsule_getDataRpc, MsgPack.pack({capsule = capsule}))
|
555f745e
zhangqijia
feat: 一番赏
|
169
|
return true
|
0eb317fb
zhangqijia
fix: 一番赏奖励抽奖的bug与...
|
170
|
|
555f745e
zhangqijia
feat: 一番赏
|
171
172
|
end
|
d4f83f16
zhangqijia
feat: 一番赏 增加抽扭蛋机消...
|
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
function _M.convertCapsuleRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local coin = msg.coin
local count = msg.count or 1
local cost, convert = {}
for k, v in pairs(globalCsv.ichibankuji_buy_cost)do
if k == coin then
convert = v:toArray(true, "=")
break
end
end
cost[convert[1]] = convert[2] * count
if not role:checkItemEnough(cost) then return 1 end
role:costItems(cost, {log = {desc = "CapsuleConvert", int1 = convert[1], int2 = cost[convert[1]]}})
|
a5a46483
zhangqijia
fix: 一番赏 修复消耗票兑换 ...
|
190
191
|
local reward, change = role:award({[coin]= count}, {log = {desc = "CapsuleConvert"}})
|
d4f83f16
zhangqijia
feat: 一番赏 增加抽扭蛋机消...
|
192
193
194
195
|
SendPacket(actionCodes.Capsule_convertCapsuleRpc, MsgPack.pack(role:packReward(reward, change)))
return true
end
|
01ff9b4b
zhangqijia
fix: 一番赏 优化; 抽奖记录...
|
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
function _M.pageRecordRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local idx = msg.idx
local up = msg.up or 0
local capsuleId = msg.capsule_id
local typ = msg.typ --0=独享,1= 公开
local record
if typ == 1 then
record = skynet.call(agent.capsule_serv, "lua", "page_record", capsuleId, up, idx)
else
record = role:pageRecord(capsuleId, up, idx)
end
if not record then return 1 end
SendPacket(actionCodes.Capsule_pageRecordRpc, MsgPack.pack({record = record}))
return true
end
|
da20e384
zhangqijia
feat: 一番赏 特殊赏 通知
|
216
217
218
219
|
function _M.specialRewardRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local capsuleId = msg.capsule_id
|
f66891be
zhangqijia
fix: 一番赏 打开激励奖导致抽...
|
220
|
local typ = msg.typ or 1 --0=独享,1= 公开
|
da20e384
zhangqijia
feat: 一番赏 特殊赏 通知
|
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
local roleId = role:getProperty("id")
local ret
if typ == 1 then
ret = skynet.call(agent.capsule_serv, "lua", "get_special_nty", roleId, capsuleId)
else
ret = role:getSpecialNotify(roleId, capsuleId)
end
if not ret or not next(ret) then return 1 end
SendPacket(actionCodes.Capsule_specialRewardRpc, MsgPack.pack({special= ret}))
return true
end
function _M.clearSpecialNtyRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local capsuleId = msg.capsule_id
local typ = msg.typ --0=独享,1= 公开
local good_ids = msg.good_ids
local roleId = role:getProperty("id")
local ret
if typ == 1 then
ret = skynet.call(agent.capsule_serv, "lua", "clear_special_nty", roleId, capsuleId, good_ids)
end
if not ret or not next(ret) then return 1 end
SendPacket(actionCodes.Capsule_clearSpecialNtyRpc, MsgPack.pack({}))
return true
end
|
555f745e
zhangqijia
feat: 一番赏
|
253
|
return _M
|