Commit 9ea0c50278fab51eb65e3a184490bd945cdfe712

Authored by liuzujun
1 parent 70aa8660

限时礼包

src/GlobalVar.lua
... ... @@ -290,12 +290,18 @@ MailId = {
290 290 SuperMonthCardEx = 204,
291 291 BattleCardAward = 210,
292 292  
293   - ActDrawCard = 231,
294   - ActOpenBox = 232,
  293 + ActSellFood = 231,
  294 + ActDrawCard = 232,
295 295 ActAdvDraw = 233,
296   - ActSellFood = 234,
297   - ActDrawCardReward = 221,
298   - ActOpenBoxReward = 222,
  296 + ActOpenBox = 234,
  297 + ActSellFoodReward = 221,
  298 + ActDrawCardReward = 222,
299 299 ActAdvDrawReward = 223,
300   - ActSellFoodReward = 224,
  300 + ActOpenBoxReward = 224,
301 301 }
  302 +
  303 +TriggerEventType = {
  304 + HangPass = 1,
  305 + LevelUp = 2,
  306 + TowerPass = 3,
  307 +}
302 308 \ No newline at end of file
... ...
src/ProtocolCode.lua
... ... @@ -44,6 +44,7 @@ actionCodes = {
44 44 Role_guideRpc = 129,
45 45 Role_getRandomNameRpc = 130,
46 46 Role_goldBuyRpc = 131,
  47 + Role_getDownloadCvRewardRpc = 132,
47 48  
48 49 Adv_startAdvRpc = 151,
49 50 Adv_startHangRpc = 152,
... ...
src/actions/RoleAction.lua
... ... @@ -1065,4 +1065,17 @@ function _M.goldBuyRpc(agent, data)
1065 1065 return true
1066 1066 end
1067 1067  
  1068 +function _M.getDownloadCvRewardRpc(agent, data)
  1069 + local role = agent.role
  1070 + local flag = role:getProperty("downCvR") or 0
  1071 + if flag ~= 0 then
  1072 + return 1
  1073 + end
  1074 + local r = globalCsv.role_download_cv_reward
  1075 + local reward, change = role:award(r, {log = {desc = "downloadCv"}})
  1076 + role:updateProperty({field="downCvR", value=1})
  1077 + SendPacket(actionCodes.Role_getDownloadCvRewardRpc, MsgPack.pack(role:packReward(reward, change)))
  1078 + return true
  1079 +end
  1080 +
1068 1081 return _M
1069 1082 \ No newline at end of file
... ...
src/actions/StoreAction.lua
... ... @@ -263,6 +263,13 @@ function _M.shopBuyRpc(agent , data)
263 263 local dataSet = csvdb["shop_normalCsv"][id]
264 264 if not dataSet then return end
265 265  
  266 + if dataSet.unlock ~= "" then
  267 + if not role:checkHangPass(tonumber(config.unlock)) then
  268 + skynet.error(string.format("shopBuyRpc,user do not finish hang pass, user_id:%d", role:getProperty("id")))
  269 + return 1
  270 + end
  271 + end
  272 +
266 273 local buyRecord = role.storeData:getProperty("buyR")
267 274 if math.illegalNum(count, 1, (dataSet.limit == 0 and math.huge or dataSet.limit - (buyRecord[id] or 0))) then
268 275 skynet.error(string.format("shop buy over limit, user_id:%d, goods_id:%d", role:getProperty("id"), id))
... ...
1   -Subproject commit f52151f947b019976eac7ef15ec914bf7d552d64
  1 +Subproject commit 3929031d3194a0403fab720ab39bc40bc79c734d
... ...
src/models/Role.lua
... ... @@ -159,6 +159,8 @@ Role.schema = {
159 159 redp = {"table", {}}, -- 待消除红点 -- 通常打开对应界面就消除的红点 红点消除的方法 在对应的协议中使用 {tag = pms }
160 160  
161 161 chatline = {"table", {}}, -- 奖励发放 id=时间
  162 +
  163 + downCvR = {"number", 0}, -- 下载cv扩展包奖励
162 164 }
163 165  
164 166  
... ...
src/models/RolePlugin.lua
... ... @@ -217,6 +217,7 @@ function RolePlugin.bind(Role)
217 217 if csvdb["player_expCsv"][level + 1] then -- 有下一级
218 218 newExp = newExp - csvdb["player_expCsv"][level].exp
219 219 level = level + 1
  220 + self:checkTaskEnter("RoleLevelUp", {level = level})
220 221 else
221 222 newExp = csvdb["player_expCsv"][level].exp - 1 -- 没有下一级了 经验溢出太多 扣除
222 223 end
... ...
src/models/RoleTask.lua
... ... @@ -76,6 +76,9 @@ local TaskType = {
76 76 AddFriend = 802, -- 加入一个好友 - count
77 77 GetFriendP = 803, -- 获得友情点 - count
78 78  
  79 + -- 角色相关
  80 + RoleLevelUp = 901, -- 角色升级 - curlevel
  81 +
79 82 --功能未实现 todo
80 83 AdvShop = 1002, -- 冒险商城
81 84 UnionBoss = 1004, -- 工会boss
... ... @@ -216,6 +219,15 @@ local ActivityListener = {
216 219 }
217 220 }
218 221  
  222 +local StoreListener = {
  223 + func = "checkStoreTask",
  224 + listen = {
  225 + [TaskType.HangPass] = {{TriggerEventType.HangPass, f("id")}},
  226 + [TaskType.RoleLevelUp] = {{TriggerEventType.LevelUp, f("level")}},
  227 + [TaskType.TowerPass] = {{TriggerEventType.TowerPass, f("level")}},
  228 + }
  229 +}
  230 +
219 231  
220 232 local TaskListeners = {
221 233 StoryListener,
... ... @@ -223,6 +235,7 @@ local TaskListeners = {
223 235 AchievListener,
224 236 SudokuListener,
225 237 ActivityListener,
  238 + StoreListener,
226 239 }
227 240  
228 241 local RoleTask = {}
... ... @@ -533,6 +546,10 @@ function RoleTask.bind(Role)
533 546 self.activity:checkActivity(notNotify, activityType, ...)
534 547 end
535 548  
  549 + function Role:checkStoreTask(notNotify, triggerType, param)
  550 + self.storeData:OnTriggerLimitTimePack(triggerType, param)
  551 + end
  552 +
536 553 end
537 554  
538 555 return RoleTask
539 556 \ No newline at end of file
... ...
src/models/Store.lua
... ... @@ -20,6 +20,7 @@ Store.schema = {
20 20 privCardEx = {"number", 0}, -- 特权卡过期时间戳
21 21 getMailT1 = {"number",0}, -- 上次发送月卡福利邮件的时间
22 22 getMailT2 = {"number",0}, -- 上次发送超级月卡福利邮件的时间
  23 + packTrigger = {"table", {}} -- 礼包触发记录 {关卡难度1={id, 通关关卡数,升级数,爬塔层数}, ...}
23 24 }
24 25  
25 26 function Store:updateProperty(params)
... ... @@ -60,7 +61,7 @@ end
60 61 -- 发送月卡邮件
61 62 function Store:sendMonthCardEmail()
62 63 local timeNow = skynet.timex()
63   - local tabs = {{ex="monthCardEx", t="getMailT1", mail=MailId.MonthCard, alert=MailId.MonthCardEx},
  64 + local tabs = {{ex="monthCardEx", t="getMailT1", mail=MailId.MonthCard, alert=MailId.MonthCardEx},
64 65 {ex="smonthCardEx", t="getMailT2", mail=MailId.SuperMonthCard, alert=MailId.SuperMonthCardEx}}
65 66 for _, v in ipairs(tabs) do
66 67 local ex = self:getProperty(v.ex)
... ... @@ -216,7 +217,7 @@ function Store:onBattleCardReset()
216 217 if config then
217 218 local freeFlag = string.char(string.getbit(battleCardFreeRecord, id))
218 219 local limitFlag = string.char(string.getbit(battleCardLimitRecord, id))
219   -
  220 +
220 221 if battlePoint < config.point then
221 222 break
222 223 end
... ... @@ -227,7 +228,7 @@ function Store:onBattleCardReset()
227 228 concatGift(config.giftLimit)
228 229 end
229 230 end
230   - end
  231 + end
231 232 self.owner:sendMail(MailId.BattleCardAward, nil, gift)
232 233 -- 计算剩余奖励
233 234 self:updateProperty({field = "battleCard", value=0})
... ... @@ -266,6 +267,68 @@ function Store:resetStoreReored(resetId)
266 267 self:updateProperty({field = "buyR", value = buyRecord})
267 268 end
268 269  
  270 +--触发限时礼包
  271 +function Store:OnTriggerLimitTimePack(eventType, param)
  272 + local limitPack = self:getProperty("limitTPack")
  273 + local timeNow = skynet.timex()
  274 + local find = false
  275 + -- 有未过期的限时礼包不再推送
  276 + for k, v in pairs(limitPack) do
  277 + if v > timeNow then
  278 + find = true
  279 + break
  280 + end
  281 + end
  282 + if find == true then
  283 + return
  284 + end
  285 + limitPack = {}
  286 + local hangPass = self.owner:getProperty("hangPass")
  287 + local triggerRecord = self:getProperty("packTrigger")
  288 + local result = {}
  289 + local maxDiff = 0
  290 + -- 取满足限时礼包关卡要求的对应数据
  291 + for diff, maxCarbonId in pairs(hangPass) do
  292 + for id, cfg in pairs(csvdb["shop_packCsv"]) do
  293 + local range = cfg.showRange:toArray(true, "=")
  294 + local beginRange = range[1] or 0
  295 + local endRange = range[2] or 0
  296 + if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then
  297 + result[diff] = cfg
  298 + maxDiff = math.max(maxDiff, diff)
  299 + break
  300 + end
  301 + end
  302 + end
  303 + local shopGoodsId = 0
  304 + for diff, cfg in pairs(result) do
  305 + if diff == maxDiff then
  306 + local record = triggerRecord[diff] or {}
  307 + if (record[0] or 0) ~= cfg.id and next(record) then
  308 + record = {}
  309 + end
  310 + record[0] = cfg.id
  311 + record[eventType] = (record[eventType] or 0) + 1
  312 + if record[eventType] == 1 or record[eventType] % 10 == 0 then
  313 + local pool = cfg.packId:toArray(true, "=")
  314 + local idx = math.random(1, #pool)
  315 + shopGoodsId = pool[idx]
  316 + end
  317 + triggerRecord[diff] = record
  318 + end
  319 + end
  320 + if shopGoodsId ~= 0 then
  321 + local rechargeCfg = csvdb["shop_rechargeCsv"][shopGoodsId]
  322 + if rechargeCfg then
  323 + limitPack[rechargeCfg.id] = timeNow + rechargeCfg.time
  324 + self:updateProperty({field = "limitTPack", value = limitPack})
  325 + end
  326 + end
  327 + if next(result) then
  328 + self:updateProperty({field = "packTrigger", value = triggerRecord})
  329 + end
  330 +end
  331 +
269 332 function Store:data()
270 333 return {
271 334 buyR = self:getProperty("buyR"),
... ...