Commit 9a1c54b249ed7da4959775636a5fcbae4f405215

Authored by zhouhaihai
1 parent 9104a922

活动

docs/日志说明.xlsx
No preview for this file type
src/models/RoleActivity.lua renamed to src/models/Activity.lua
... ... @@ -2,9 +2,10 @@ local Activity = class("Activity", require("shared.ModelBase"))
2 2  
3 3  
4 4 Activity.ActivityType = {
5   -
  5 + DoubleDrop = 1, -- 双倍掉落
6 6 }
7 7  
  8 +
8 9 local function checkActivityType(activityType)
9 10 if type(activityType) == "string" then
10 11 activityType = Activity.ActivityType[activityType]
... ... @@ -16,12 +17,12 @@ end
16 17 function Activity:ctor(properties)
17 18 Activity.super.ctor(self, properties)
18 19  
19   - self.open = {}
20   -
  20 + self._isOpen = {}
21 21 end
22 22  
23 23  
24 24 Activity.schema = {
  25 + ctime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time}
25 26 _1 = {"table", {}},
26 27 }
27 28  
... ... @@ -32,5 +33,49 @@ function Activity:data()
32 33 end
33 34  
34 35  
  36 +function Activity:updateProperty(params)
  37 + local type, default = table.unpack(self.schema[params.field])
  38 +
  39 + if params.delta then
  40 + self:incrProperty(params.field, params.delta)
  41 + if not params.notNotify then
  42 + self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
  43 + end
  44 + return true
  45 + end
  46 + if params.value then
  47 + self:setProperty(params.field, params.value)
  48 + if not params.notNotify then
  49 + self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
  50 + end
  51 + return true
  52 + end
  53 + return false
  54 +end
  55 +
  56 +
  57 +function Activity:isOpen(activityType)
  58 + activityType = checkActivityType(activityType)
  59 +
  60 +end
  61 +
  62 +-- 跨天刷新 --登录刷新
  63 +function Activity:checkActivityStatus(ltime, now, notify)
  64 +
  65 +end
  66 +
  67 +local checkActivityFunc = {}
  68 +
  69 +checkActivityFunc[Activity.ActivityType.DoubleDrop] = function(self, notNotify, activityType, ...)
  70 +
  71 +end
  72 +
  73 +function Activity:checkActivityEnter(notNotify, activityType, ...)
  74 + if not activityType then return end
  75 + if checkActivityFunc[activityType] then
  76 + checkActivityFunc[activityType](self, notNotify, activityType, ...)
  77 + end
  78 +end
  79 +
35 80  
36 81 return Activity
37 82 \ No newline at end of file
... ...
src/models/Role.lua
... ... @@ -23,7 +23,7 @@ function Role:ctor( properties )
23 23 self.heros = {}
24 24 self.runeBag = {}
25 25 self.advData = nil
26   -
  26 + self.activity = nil
27 27 self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节
28 28 self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳
29 29 end
... ...
src/models/RolePlugin.lua
... ... @@ -10,6 +10,7 @@ function RolePlugin.bind(Role)
10 10 self:loadRunes()
11 11 self:loadHeros()
12 12 self:loadDiner()
  13 + self:loadActivity()
13 14 end
14 15  
15 16 function Role:reloadWhenLogin()
... ... @@ -507,6 +508,18 @@ function RolePlugin.bind(Role)
507 508 end
508 509 end
509 510  
  511 + function Role:loadActivity()
  512 + local roleId = self:getProperty("id")
  513 + local dataKey = string.format(R_ACTIVITY, roleId)
  514 + self.activity = require("models.Activity").new({key = dataKey})
  515 + self.activity.owner = self
  516 + if not redisproxy:exists(dataKey) then
  517 + self.activity:create()
  518 + else
  519 + self.activity:load()
  520 + end
  521 + end
  522 +
510 523 function Role:loadDiner()
511 524 local roleId = self:getProperty("id")
512 525 local dataKey = string.format(R_DINER, roleId)
... ...
src/models/RoleTask.lua
... ... @@ -184,7 +184,7 @@ local AchievListener = {
184 184 }
185 185 }
186 186  
187   -local SudokuListerer = {
  187 +local SudokuListener = {
188 188 func = "checkSudokuTask",
189 189 listen = {
190 190 [TaskType.HangPass] = {{1, 1, f("id")}},
... ... @@ -205,12 +205,20 @@ local SudokuListerer = {
205 205 }
206 206 }
207 207  
  208 +local ActivityListener = {
  209 + func = "checkActivityTask",
  210 + listener = {
  211 +
  212 + }
  213 +}
  214 +
208 215  
209 216 local TaskListeners = {
210 217 StoryListener,
211 218 CommonListener,
212 219 AchievListener,
213   - SudokuListerer,
  220 + SudokuListener,
  221 + ActivityListener,
214 222 }
215 223  
216 224 local RoleTask = {}
... ... @@ -517,6 +525,10 @@ function RoleTask.bind(Role)
517 525 end
518 526 end
519 527  
  528 + function Role:checkActivityTask(notNotify, activityType, ...)
  529 + self.activity:checkActivityEnter(notNotify, activityType, ...)
  530 + end
  531 +
520 532 end
521 533  
522 534 return RoleTask
523 535 \ No newline at end of file
... ...