Commit 6304b5ad4baa92bc2a87f0cfd418432ca457437d
1 parent
50a0dd50
feat: 一番赏 增加重置扭蛋机指令
reset_capsule typ typ类型: 0=独享 1=公开
Showing
3 changed files
with
60 additions
and
1 deletions
Show diff stats
src/actions/GmAction.lua
... | ... | @@ -9,7 +9,7 @@ function _M.clientRequest(agent, data) |
9 | 9 | SendPacket(actionCodes.Gm_receiveResponse, bin) |
10 | 10 | return true |
11 | 11 | end |
12 | - local ret = action(role, msg) | |
12 | + local ret = action(role, msg, agent.capsule_serv) | |
13 | 13 | bin = MsgPack.pack({ cmd = ret }) |
14 | 14 | SendPacket(actionCodes.Gm_receiveResponse, bin) |
15 | 15 | return true |
... | ... | @@ -1075,4 +1075,15 @@ function _M.clear_sea(role, pms) |
1075 | 1075 | return "成功" |
1076 | 1076 | end |
1077 | 1077 | |
1078 | +table.insert(helpDes, {"重置扭蛋机", "reset_capsule", "typ"}) | |
1079 | +function _M.reset_capsule(role, pms, capsule_serv) | |
1080 | + local typ = tonumber(pms.pm1) | |
1081 | + if typ == 1 then | |
1082 | + skynet.call(capsule_serv, "lua", "reset") | |
1083 | + else | |
1084 | + role:resetCapsule() | |
1085 | + end | |
1086 | + return "成功" | |
1087 | +end | |
1088 | + | |
1078 | 1089 | return _M |
1079 | 1090 | \ No newline at end of file | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -3196,6 +3196,30 @@ function RolePlugin.bind(Role) |
3196 | 3196 | local capsule = self.capsules[capsuleId] or {} |
3197 | 3197 | return capsule:data() |
3198 | 3198 | end |
3199 | + | |
3200 | + function Role:resetCapsule() | |
3201 | + local roleId = self:getProperty("id") | |
3202 | + local res = redisproxy:smembers(CAPSULE_ID_ROLE:format(roleId)) or {} | |
3203 | + for _, key in pairs(res) do | |
3204 | + redisproxy:del(CAPSULE_ROLE:format(roleId, tonumber(key))) | |
3205 | + redisproxy:srem(CAPSULE_ID_ROLE, key) | |
3206 | + end | |
3207 | + | |
3208 | + for _, data in pairs(csvdb["ichibankuji_mainCsv"]) do | |
3209 | + for _, val in pairs(data) do | |
3210 | + if val.typ == 0 then | |
3211 | + local key = val.id..val.room | |
3212 | + if not self.capsules[key] then | |
3213 | + local capsule = require("models.Capsule").new({ key = CAPSULE_ROLE:format(roleId, tonumber(key)), id= val.id, room = val.room, typ = 0, name=val.name}) | |
3214 | + capsule:init() | |
3215 | + capsule:create() | |
3216 | + self.capsules[key] = capsule | |
3217 | + redisproxy.sadd(CAPSULE_ID_ROLE:format(roleId), key) | |
3218 | + end | |
3219 | + end | |
3220 | + end | |
3221 | + end | |
3222 | + end | |
3199 | 3223 | end |
3200 | 3224 | |
3201 | 3225 | return RolePlugin |
3202 | 3226 | \ No newline at end of file | ... | ... |
src/services/capsuled.lua
... | ... | @@ -100,6 +100,30 @@ local function check_capsules() |
100 | 100 | skynet.timeout(60, check_capsules) |
101 | 101 | end |
102 | 102 | |
103 | +function CMD.reset() | |
104 | + local now = skynet.timex() | |
105 | + local res = redisproxy:smembers(CAPSULE_INFO) or {} | |
106 | + for _, key in pairs(res) do | |
107 | + redisproxy:del(CAPSULE_PUBLIC:format(key)) | |
108 | + redisproxy:srem(CAPSULE_INFO, key) | |
109 | + end | |
110 | + | |
111 | + for _, data in pairs(csvdb["ichibankuji_mainCsv"]) do | |
112 | + for _, val in ipairs(data) do | |
113 | + if val.type == 1 then | |
114 | + local key = val.id..val.room | |
115 | + if not capsules[key] then | |
116 | + local capsule = require("models.Capsule").new({ key = CAPSULE_PUBLIC:format(key), id= val.id, room = val.room, typ = 1, name=val.name}) | |
117 | + capsule:init() | |
118 | + capsule:create() | |
119 | + capsules[key] = capsule | |
120 | + redisproxy:sadd(CAPSULE_INFO, key) | |
121 | + end | |
122 | + end | |
123 | + end | |
124 | + end | |
125 | +end | |
126 | + | |
103 | 127 | function CMD.start() |
104 | 128 | local now = skynet.timex() |
105 | 129 | local res = redisproxy:smembers(CAPSULE_INFO) or {} | ... | ... |