Commit a6dc627f8c230cba4460dda2253384f4cd010f10
1 parent
5bc88864
自选箱子协议
Showing
6 changed files
with
30 additions
and
5 deletions
Show diff stats
src/GlobalVar.lua
| @@ -68,6 +68,7 @@ ItemType = { | @@ -68,6 +68,7 @@ ItemType = { | ||
| 68 | AdvItem = 14, -- 冒险道具 | 68 | AdvItem = 14, -- 冒险道具 |
| 69 | FuncOpen = 15, -- 管理功能开放 | 69 | FuncOpen = 15, -- 管理功能开放 |
| 70 | SpeedBox = 16, -- 加速箱子 | 70 | SpeedBox = 16, -- 加速箱子 |
| 71 | + SelectItemBox = 17, -- 自选箱子 | ||
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | --在这个里面的会记录的是功能开放 对应类型open 而不是 ID | 74 | --在这个里面的会记录的是功能开放 对应类型open 而不是 ID |
src/ProtocolCode.lua
| @@ -46,6 +46,7 @@ actionCodes = { | @@ -46,6 +46,7 @@ actionCodes = { | ||
| 46 | Role_goldBuyRpc = 131, | 46 | Role_goldBuyRpc = 131, |
| 47 | Role_getDownloadCvRewardRpc = 132, | 47 | Role_getDownloadCvRewardRpc = 132, |
| 48 | Role_updateFeedbackInfoRpc = 133, | 48 | Role_updateFeedbackInfoRpc = 133, |
| 49 | + Role_useSelectItemRpc = 134, -- 使用多选一礼包 | ||
| 49 | 50 | ||
| 50 | Adv_startAdvRpc = 151, | 51 | Adv_startAdvRpc = 151, |
| 51 | Adv_startHangRpc = 152, | 52 | Adv_startHangRpc = 152, |
src/actions/RoleAction.lua
| @@ -1207,4 +1207,31 @@ function _M.updateFeedbackInfoRpc(agent, data) | @@ -1207,4 +1207,31 @@ function _M.updateFeedbackInfoRpc(agent, data) | ||
| 1207 | return true | 1207 | return true |
| 1208 | end | 1208 | end |
| 1209 | 1209 | ||
| 1210 | +function _M.useSelectItemRpc(agent, data) | ||
| 1211 | + local role = agent.role | ||
| 1212 | + local msg = MsgPack.unpack(data) | ||
| 1213 | + local itemId = msg.itemId | ||
| 1214 | + local index = msg.index | ||
| 1215 | + local count = msg.count | ||
| 1216 | + if math.illegalNum(count, 1, role:getItemCount(itemId)) then return end | ||
| 1217 | + local itemData = csvdb["itemCsv"][itemId] | ||
| 1218 | + if itemData.type ~= ItemType.SelectItemBox then return end | ||
| 1219 | + local itemMap = itemData.use_effect:toNumMap() | ||
| 1220 | + local i = 1 | ||
| 1221 | + local reward, change = {} | ||
| 1222 | + for k, v in pairs(itemMap) do | ||
| 1223 | + if i == index then | ||
| 1224 | + reward[k] = v * count | ||
| 1225 | + break | ||
| 1226 | + end | ||
| 1227 | + i = i + 1 | ||
| 1228 | + end | ||
| 1229 | + | ||
| 1230 | + if next(reward) then | ||
| 1231 | + reward, change = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) | ||
| 1232 | + role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) | ||
| 1233 | + end | ||
| 1234 | + SendPacket(actionCodes.Role_useSelectItemRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 1235 | +end | ||
| 1236 | + | ||
| 1210 | return _M | 1237 | return _M |
| 1211 | \ No newline at end of file | 1238 | \ No newline at end of file |
src/models/Activity.lua
| @@ -260,7 +260,6 @@ activityFunc[Activity.ActivityType.DrawHero] = { | @@ -260,7 +260,6 @@ activityFunc[Activity.ActivityType.DrawHero] = { | ||
| 260 | -- ["close"] = function(self, actType, notify) | 260 | -- ["close"] = function(self, actType, notify) |
| 261 | -- end, | 261 | -- end, |
| 262 | ["crossDay"] = function(self, actType, notify) | 262 | ["crossDay"] = function(self, actType, notify) |
| 263 | - print("cross day draw card") | ||
| 264 | self.owner:sendMail(MailId.ActDrawCard) | 263 | self.owner:sendMail(MailId.ActDrawCard) |
| 265 | end, | 264 | end, |
| 266 | } | 265 | } |
| @@ -278,7 +277,6 @@ activityFunc[Activity.ActivityType.FoodSell] = { | @@ -278,7 +277,6 @@ activityFunc[Activity.ActivityType.FoodSell] = { | ||
| 278 | -- ["close"] = function(self, actType, notify) | 277 | -- ["close"] = function(self, actType, notify) |
| 279 | -- end, | 278 | -- end, |
| 280 | ["crossDay"] = function(self, actType, notify) | 279 | ["crossDay"] = function(self, actType, notify) |
| 281 | - print("cross day sell food") | ||
| 282 | self.owner:sendMail(MailId.ActSellFood) | 280 | self.owner:sendMail(MailId.ActSellFood) |
| 283 | end, | 281 | end, |
| 284 | } | 282 | } |
| @@ -313,7 +311,6 @@ activityFunc[Activity.ActivityType.OpenBox] = { | @@ -313,7 +311,6 @@ activityFunc[Activity.ActivityType.OpenBox] = { | ||
| 313 | -- ["close"] = function(self, actType, notify) | 311 | -- ["close"] = function(self, actType, notify) |
| 314 | -- end, | 312 | -- end, |
| 315 | ["crossDay"] = function(self, actType, notify) | 313 | ["crossDay"] = function(self, actType, notify) |
| 316 | - print("cross day open box") | ||
| 317 | self.owner:sendMail(MailId.ActOpenBox) | 314 | self.owner:sendMail(MailId.ActOpenBox) |
| 318 | end, | 315 | end, |
| 319 | } | 316 | } |
src/models/RoleTimeReset.lua
| @@ -34,7 +34,6 @@ end | @@ -34,7 +34,6 @@ end | ||
| 34 | ResetFunc["CrossMonth"] = function(self, notify, response) | 34 | ResetFunc["CrossMonth"] = function(self, notify, response) |
| 35 | local ltime = self:getProperty("ltime") | 35 | local ltime = self:getProperty("ltime") |
| 36 | if isCrossMonth(ltime, skynet.timex()) then | 36 | if isCrossMonth(ltime, skynet.timex()) then |
| 37 | - print("cross month") | ||
| 38 | self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id | 37 | self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id |
| 39 | end | 38 | end |
| 40 | end | 39 | end |