Commit f382b4f2d6c0c26c00e4423bb40e85aed53920c1
1 parent
555f745e
fix: 一番赏的抽奖bug
1. 抽奖,返回值4,返回奖品数量差异 2. 报名协议,返回扭蛋机详情。
Showing
4 changed files
with
44 additions
and
22 deletions
Show diff stats
src/actions/CapsuleAction.lua
@@ -82,6 +82,7 @@ function _M.registerRpc(agent, data) | @@ -82,6 +82,7 @@ function _M.registerRpc(agent, data) | ||
82 | local capsuleId = msg.capsule_id | 82 | local capsuleId = msg.capsule_id |
83 | 83 | ||
84 | local ret = skynet.call(agent.capsule_serv, "lua", "register", roleId, capsuleId) | 84 | local ret = skynet.call(agent.capsule_serv, "lua", "register", roleId, capsuleId) |
85 | + if not ret then return 1 end | ||
85 | SendPacket(actionCodes.Capsule_registerRpc, MsgPack.pack(ret)) | 86 | SendPacket(actionCodes.Capsule_registerRpc, MsgPack.pack(ret)) |
86 | return true | 87 | return true |
87 | end | 88 | end |
@@ -93,16 +94,21 @@ function _M.drawRpc(agent, data) | @@ -93,16 +94,21 @@ function _M.drawRpc(agent, data) | ||
93 | local capsuleId = msg.capsule_id | 94 | local capsuleId = msg.capsule_id |
94 | local typ = msg.typ --0=独享,1= 公开 | 95 | local typ = msg.typ --0=独享,1= 公开 |
95 | local full = msg.full -- 0=单次,1=十连抽 2=全收 | 96 | local full = msg.full -- 0=单次,1=十连抽 2=全收 |
96 | - local continue = msg.continue--确认次数。 | ||
97 | local cares = msg.cares | 97 | local cares = msg.cares |
98 | 98 | ||
99 | local ret, reward, change | 99 | local ret, reward, change |
100 | if typ == 1 then | 100 | if typ == 1 then |
101 | - ret, reward = skynet.call(agent.capsule_serv, "lua", "draw_capsule", roleId, capsuleId, full, continue, cares) | 101 | + ret, reward = skynet.call(agent.capsule_serv, "lua", "draw_capsule", roleId, capsuleId, full, cares) |
102 | else | 102 | else |
103 | ret, reward = role:drawCapsule(capsuleId, full, cares) | 103 | ret, reward = role:drawCapsule(capsuleId, full, cares) |
104 | end | 104 | end |
105 | - if ret <= 4 then return ret end | 105 | + if ret < 4 then |
106 | + return ret | ||
107 | + end | ||
108 | + | ||
109 | + if ret == 4 then | ||
110 | + SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack(reward)) | ||
111 | + end | ||
106 | 112 | ||
107 | reward, change = role:award(reward, {log = {desc = "CapsuleReward", int1 = capsuleId, int2 = roleId}}) | 113 | reward, change = role:award(reward, {log = {desc = "CapsuleReward", int1 = capsuleId, int2 = roleId}}) |
108 | dump(reward) | 114 | dump(reward) |
src/models/Capsule.lua
@@ -188,21 +188,23 @@ function Capsule:join(roleId) | @@ -188,21 +188,23 @@ function Capsule:join(roleId) | ||
188 | local register = self:getProperty("register") or {} | 188 | local register = self:getProperty("register") or {} |
189 | register[roleId] = 0 | 189 | register[roleId] = 0 |
190 | self:setProperty("register", register) | 190 | self:setProperty("register", register) |
191 | - return true | 191 | + return self:data(roleId) |
192 | end | 192 | end |
193 | 193 | ||
194 | -function Capsule:isRegister(roleId) | 194 | +function Capsule:getRegisterByRoleId(roleId) |
195 | local register = self:getProperty("register") or {} | 195 | local register = self:getProperty("register") or {} |
196 | - return register[roleId] == 1 | 196 | + return register[roleId] or 0 |
197 | +end | ||
198 | + | ||
199 | +function Capsule:isRegister(roleId) | ||
200 | + return self:getRegisterByRoleId(roleId) == 1 | ||
197 | end | 201 | end |
198 | 202 | ||
199 | function Capsule:register(roleId) | 203 | function Capsule:register(roleId) |
200 | local register = self:getProperty("register") or {} | 204 | local register = self:getProperty("register") or {} |
201 | - if next(register) then | ||
202 | - register[roleId] = 1 | ||
203 | - return true | ||
204 | - end | ||
205 | - return false | 205 | + register[roleId] = 1 |
206 | + self:setProperty("register", register) | ||
207 | + return self:data(roleId) | ||
206 | end | 208 | end |
207 | 209 | ||
208 | function Capsule:exit(roleId) | 210 | function Capsule:exit(roleId) |
@@ -776,7 +778,7 @@ function Capsule:draw(roleId, full, cares) | @@ -776,7 +778,7 @@ function Capsule:draw(roleId, full, cares) | ||
776 | end | 778 | end |
777 | 779 | ||
778 | 780 | ||
779 | -function Capsule:data() | 781 | +function Capsule:data(roleId) |
780 | return { | 782 | return { |
781 | id = self:getProperty("id"), | 783 | id = self:getProperty("id"), |
782 | room = self:getProperty("room"), | 784 | room = self:getProperty("room"), |
@@ -784,6 +786,7 @@ function Capsule:data() | @@ -784,6 +786,7 @@ function Capsule:data() | ||
784 | name = self:getProperty("name"), | 786 | name = self:getProperty("name"), |
785 | coin = self:getProperty("coin"), | 787 | coin = self:getProperty("coin"), |
786 | onlineCount = self:getOnlineCount(), | 788 | onlineCount = self:getOnlineCount(), |
789 | + playerStatus = self:getRegisterByRoleId(roleId), | ||
787 | record = self:getProperty("record"), | 790 | record = self:getProperty("record"), |
788 | --recordByRole = self:getProperty("recordByRole"), | 791 | --recordByRole = self:getProperty("recordByRole"), |
789 | rank = self:getProperty("rank"), | 792 | rank = self:getProperty("rank"), |
src/models/RolePlugin.lua
@@ -829,11 +829,16 @@ function RolePlugin.bind(Role) | @@ -829,11 +829,16 @@ function RolePlugin.bind(Role) | ||
829 | for _, key in pairs(res) do | 829 | for _, key in pairs(res) do |
830 | local capsule = require("models.Capsule").new({ key = CAPSULE_ROLE:format(roleId,tonumber(key))}) | 830 | local capsule = require("models.Capsule").new({ key = CAPSULE_ROLE:format(roleId,tonumber(key))}) |
831 | capsule:load() | 831 | capsule:load() |
832 | - if capsule:refreshing(now) then | ||
833 | - capsule:init() | ||
834 | - capsule:create() | 832 | + if capsule:isShow() then |
833 | + if capsule:refreshing(now) then | ||
834 | + capsule:init() | ||
835 | + capsule:create() | ||
836 | + end | ||
837 | + self.capsules[key] = capsule | ||
838 | + else | ||
839 | + redisproxy:del(CAPSULE_ROLE:format(roleId, tonumber(key))) | ||
840 | + redisproxy:srem(CAPSULE_ID_ROLE, key) | ||
835 | end | 841 | end |
836 | - self.capsules[key] = capsule | ||
837 | end | 842 | end |
838 | 843 | ||
839 | for _, data in pairs(csvdb["ichibankuji_mainCsv"]) do | 844 | for _, data in pairs(csvdb["ichibankuji_mainCsv"]) do |
src/services/capsuled.lua
@@ -61,7 +61,7 @@ local function add(roleId, capsuleId) | @@ -61,7 +61,7 @@ local function add(roleId, capsuleId) | ||
61 | if next(capsule) then | 61 | if next(capsule) then |
62 | capsule:join(roleId) | 62 | capsule:join(roleId) |
63 | broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.JOIN, roleId = roleId}) | 63 | broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.JOIN, roleId = roleId}) |
64 | - return capsule:data() | 64 | + return capsule:data(roleId) |
65 | end | 65 | end |
66 | print("id 不存在: ".. capsuleId) | 66 | print("id 不存在: ".. capsuleId) |
67 | return nil | 67 | return nil |
@@ -95,8 +95,8 @@ function CMD.start() | @@ -95,8 +95,8 @@ function CMD.start() | ||
95 | end | 95 | end |
96 | capsules[key] = capsule | 96 | capsules[key] = capsule |
97 | else | 97 | else |
98 | - redisproxy.del(CAPSULE_PUBLIC:format(tonumber(key))) | ||
99 | - redisproxy.srem(CAPSULE_INFO, key) | 98 | + redisproxy:del(CAPSULE_PUBLIC:format(tonumber(key))) |
99 | + redisproxy:srem(CAPSULE_INFO, key) | ||
100 | end | 100 | end |
101 | end | 101 | end |
102 | 102 | ||
@@ -109,7 +109,7 @@ function CMD.start() | @@ -109,7 +109,7 @@ function CMD.start() | ||
109 | capsule:init() | 109 | capsule:init() |
110 | capsule:create() | 110 | capsule:create() |
111 | capsules[key] = capsule | 111 | capsules[key] = capsule |
112 | - redisproxy.sadd(CAPSULE_INFO, key) | 112 | + redisproxy:sadd(CAPSULE_INFO, key) |
113 | end | 113 | end |
114 | end | 114 | end |
115 | end | 115 | end |
@@ -145,10 +145,10 @@ function CMD.exit(roleId, capsuleId) | @@ -145,10 +145,10 @@ function CMD.exit(roleId, capsuleId) | ||
145 | end | 145 | end |
146 | end | 146 | end |
147 | 147 | ||
148 | -function CMD.draw_capsule(roleId, capsuleId, typ, cares) | 148 | +function CMD.draw_capsule(roleId, capsuleId, full, cares) |
149 | local capsule = capsules[capsuleId] or {} | 149 | local capsule = capsules[capsuleId] or {} |
150 | if next(capsule) then | 150 | if next(capsule) then |
151 | - local ret, reward, notify = capsule:draw(roleId, typ, cares) | 151 | + local ret, reward, notify = capsule:draw(roleId, full, cares) |
152 | --if ret > 4 then | 152 | --if ret > 4 then |
153 | -- broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.DRAW, roleId = roleId, notify = notify}) | 153 | -- broadCastCapsule(roleId, capsuleId, {changeType = NotifyChangeType.DRAW, roleId = roleId, notify = notify}) |
154 | --end | 154 | --end |
@@ -157,6 +157,14 @@ function CMD.draw_capsule(roleId, capsuleId, typ, cares) | @@ -157,6 +157,14 @@ function CMD.draw_capsule(roleId, capsuleId, typ, cares) | ||
157 | return nil | 157 | return nil |
158 | end | 158 | end |
159 | 159 | ||
160 | +function CMD.register(roleId, capsuleId) | ||
161 | + local capsule = capsules[capsuleId] or {} | ||
162 | + if next(capsule) then | ||
163 | + return capsule:register(roleId) | ||
164 | + end | ||
165 | + return nil | ||
166 | +end | ||
167 | + | ||
160 | skynet.start(function() | 168 | skynet.start(function() |
161 | skynet.dispatch("lua", function(session, address, cmd, ...) | 169 | skynet.dispatch("lua", function(session, address, cmd, ...) |
162 | local f = CMD[string.lower(cmd)] | 170 | local f = CMD[string.lower(cmd)] |