Commit 7f9f002db73f666e35f7e196ec94526ed721ec2f

Authored by liuzujun
1 parent d9d51454

循环周活动

@@ -129,6 +129,7 @@ ItemId = { @@ -129,6 +129,7 @@ ItemId = {
129 TimeReset = { 129 TimeReset = {
130 CrossDay = 1, --通用跨天 130 CrossDay = 1, --通用跨天
131 CrossWeek = 2, --通用跨周 131 CrossWeek = 2, --通用跨周
  132 + CrossMonth = 1, --通用跨月 索引使用跨天,在回调方法中判断是否跨越 跨月的前置条件是跨天
132 DinerRank = 1, -- 餐厅排行榜 133 DinerRank = 1, -- 餐厅排行榜
133 PvpRank = 2, -- pvp排行榜 134 PvpRank = 2, -- pvp排行榜
134 PvpHight = 11, --高级竞技场 135 PvpHight = 11, --高级竞技场
@@ -288,4 +289,13 @@ MailId = { @@ -288,4 +289,13 @@ MailId = {
288 MonthCardEx = 203, 289 MonthCardEx = 203,
289 SuperMonthCardEx = 204, 290 SuperMonthCardEx = 204,
290 BattleCardAward = 210, 291 BattleCardAward = 210,
  292 +
  293 + ActDrawCard = 231,
  294 + ActOpenBox = 232,
  295 + ActAdvDraw = 233,
  296 + ActSellFood = 234,
  297 + ActDrawCardReward = 221,
  298 + ActOpenBoxReward = 222,
  299 + ActAdvDrawReward = 223,
  300 + ActSellFoodReward = 224,
291 } 301 }
src/actions/RoleAction.lua
@@ -130,6 +130,8 @@ function _M.loginRpc( agent, data ) @@ -130,6 +130,8 @@ function _M.loginRpc( agent, data )
130 130
131 for _, name in ipairs({"dailyData", "dinerData", "activity", "storeData"}) do 131 for _, name in ipairs({"dailyData", "dinerData", "activity", "storeData"}) do
132 response[name] = role[name]:data() 132 response[name] = role[name]:data()
  133 + --print("["..name.."]")
  134 + --dump(response[name])
133 end 135 end
134 136
135 response.role = role:data() 137 response.role = role:data()
@@ -516,7 +518,7 @@ function _M.openTimeBoxRpc(agent, data) @@ -516,7 +518,7 @@ function _M.openTimeBoxRpc(agent, data)
516 518
517 boxL[slot] = nil 519 boxL[slot] = nil
518 reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}}) 520 reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}})
519 - role:checkTaskEnter("OpenBox", {id = boxId}) 521 + role:checkTaskEnter("OpenBox", {id = boxId, count=1})
520 else 522 else
521 return 523 return
522 end 524 end
@@ -1059,7 +1061,7 @@ function _M.goldBuyRpc(agent, data) @@ -1059,7 +1061,7 @@ function _M.goldBuyRpc(agent, data)
1059 goldC = goldC * coef 1061 goldC = goldC * coef
1060 role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) 1062 role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1})
1061 role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "goldBuy"}}) 1063 role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "goldBuy"}})
1062 - local reward, change = role:award({[ItemId.Gold] = goldC}, {log = {desc = "goldBuy"}}) 1064 + local reward, change = role:award({[ItemId.Gold] = math.floor(goldC)}, {log = {desc = "goldBuy"}})
1063 SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack(role:packReward(reward, change))) 1065 SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack(role:packReward(reward, change)))
1064 return true 1066 return true
1065 end 1067 end
src/actions/StoreAction.lua
@@ -298,6 +298,9 @@ function _M.shopBuyRpc(agent , data) @@ -298,6 +298,9 @@ function _M.shopBuyRpc(agent , data)
298 end 298 end
299 local reward = role:award(gift, {log = {desc = desc, int1 = id, int2 = count}}) 299 local reward = role:award(gift, {log = {desc = desc, int1 = id, int2 = count}})
300 300
  301 + if dataSet.shop == 1 then
  302 + role:checkTaskEnter("ShopAll", {count = count})
  303 + end
301 role:log("role_action", {desc = desc, int1 = id, int2 = count}) 304 role:log("role_action", {desc = desc, int1 = id, int2 = count})
302 305
303 SendPacket(actionCodes.Store_shopBuyRpc, MsgPack.pack({reward = reward})) 306 SendPacket(actionCodes.Store_shopBuyRpc, MsgPack.pack({reward = reward}))
1 -Subproject commit 060b3335605687579bbd930e3a9919561ef75acb 1 +Subproject commit 802d38498d671d29d4d7702a5c1c7b0941183bd1
src/models/Activity.lua
@@ -4,6 +4,10 @@ local string_format = string.format @@ -4,6 +4,10 @@ local string_format = string.format
4 Activity.ActivityType = { 4 Activity.ActivityType = {
5 Sign = 1, -- 签到 5 Sign = 1, -- 签到
6 DoubleDrop = 2, -- 双倍掉落 6 DoubleDrop = 2, -- 双倍掉落
  7 + DrawHero = 3, --抽卡周
  8 + FoodSell = 4, --贩卖周
  9 + OpenBox = 5, --拆解周
  10 + AdvDraw = 6, --拾荒抽周
7 } 11 }
8 12
9 13
@@ -24,13 +28,23 @@ end @@ -24,13 +28,23 @@ end
24 28
25 Activity.schema = { 29 Activity.schema = {
26 actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} 30 actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time}
  31 + round = {"table", {}}, -- 记录活动到了第几轮 {id = roundnum}
27 act1 = {"table", {}}, -- {0 = day, 1= -1, 2 = -1} == 签到活动 32 act1 = {"table", {}}, -- {0 = day, 1= -1, 2 = -1} == 签到活动
  33 + act3 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励
  34 + act4 = {"table", {}}, -- {0 = 贩卖数量, 1=1, 2=1} 贩卖周活动 1表示领取过该档位的奖励
  35 + act5 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励
  36 + act6 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励
28 } 37 }
29 38
30 function Activity:data() 39 function Activity:data()
31 return { 40 return {
32 actime = self:getProperty("actime"), 41 actime = self:getProperty("actime"),
  42 + round = self:getProperty("round"),
33 act1 = self:getProperty("act1"), 43 act1 = self:getProperty("act1"),
  44 + act3 = self:getProperty("act3"),
  45 + act4 = self:getProperty("act4"),
  46 + act5 = self:getProperty("act5"),
  47 + act6 = self:getProperty("act6"),
34 } 48 }
35 end 49 end
36 50
@@ -163,6 +177,133 @@ activityFunc[Activity.ActivityType.Sign] = { @@ -163,6 +177,133 @@ activityFunc[Activity.ActivityType.Sign] = {
163 end, 177 end,
164 } 178 }
165 179
  180 +--loop1:累计料理贩卖N次
  181 +--loop2:累计招募N次
  182 +--loop3:累计资助N次
  183 +--loop4:时钟箱拆解N个
  184 +function Activity:checkWeeklyAct(actType, notify, count)
  185 + local actInfoMap = {
  186 + [Activity.ActivityType.DrawHero] = {mailId = MailId.ActDrawCardReward, table = "activity_loop2Csv"},
  187 + [Activity.ActivityType.AdvDraw] = {mailId = MailId.ActAdvDrawReward, table = "activity_loop3Csv"},
  188 + [Activity.ActivityType.OpenBox] = {mailId = MailId.ActOpenBoxReward, table = "activity_loop4Csv"},
  189 + [Activity.ActivityType.FoodSell] = {mailId = MailId.ActSellFoodReward, table = "activity_loop1Csv"}
  190 + }
  191 + local info = actInfoMap[actType]
  192 + if not info then return end
  193 +
  194 + local curData = self:getActData(actType)
  195 + local roundData = self:getProperty("round")
  196 + local curRound = roundData[actType] or 0
  197 + local ctrlData = csvdb["activity_ctrlCsv"][actType]
  198 + if not ctrlData then return end
  199 + if curRound >= ctrlData.condition then
  200 + return
  201 + end
  202 + curData[0] = (curData[0] or 0) + count
  203 + local totalCnt = 0
  204 + local finishCnt = 0
  205 + local maxCondition = 0
  206 + for k, cfg in pairs(csvdb[info.table] or {}) do
  207 + totalCnt = totalCnt + 1
  208 + if maxCondition < cfg.condition1 then
  209 + maxCondition = cfg.condition1
  210 + end
  211 + if not curData[cfg.id] and curData[0] >= cfg.condition1 then
  212 + if info.mailId then
  213 + self.owner:sendMail(info.mailId, nil, cfg.reward, {cfg.condition1})
  214 + curData[cfg.id] = 1
  215 + end
  216 + end
  217 + if curData[cfg.id] then
  218 + finishCnt = finishCnt + 1
  219 + end
  220 + end
  221 + if totalCnt == finishCnt then
  222 + roundData[actType] = curRound + 1
  223 + for k,v in pairs(curData) do
  224 + if k == 0 then
  225 + curData[k] = curData[0] >= maxCondition and curData[0] - maxCondition or 0
  226 + else
  227 + curData[k] = nil
  228 + end
  229 + end
  230 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  231 + end
  232 + self:updateActData(actType, curData, not notify)
  233 +end
  234 +
  235 +-- 抽卡周
  236 +activityFunc[Activity.ActivityType.DrawHero] = {
  237 + ["check"] = function(self, actType, notify, count) -- 检查
  238 + self:checkWeeklyAct(actType, notify, count)
  239 + end,
  240 + ["init"] = function(self, actType, isCrossDay, notify)
  241 + local roundData = self:getProperty("round")
  242 + roundData[actType] = 0
  243 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  244 + end,
  245 + -- ["close"] = function(self, actType, notify)
  246 + -- end,
  247 + ["crossDay"] = function(self, actType, notify)
  248 + print("cross day draw card")
  249 + self.owner:sendMail(MailId.ActDrawCard)
  250 + end,
  251 +}
  252 +
  253 +-- 售卖周
  254 +activityFunc[Activity.ActivityType.FoodSell] = {
  255 + ["check"] = function(self, actType, notify, count) -- 检查
  256 + self:checkWeeklyAct(actType, notify, count)
  257 + end,
  258 + ["init"] = function(self, actType, isCrossDay, notify)
  259 + local roundData = self:getProperty("round")
  260 + roundData[actType] = 0
  261 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  262 + end,
  263 + -- ["close"] = function(self, actType, notify)
  264 + -- end,
  265 + ["crossDay"] = function(self, actType, notify)
  266 + print("cross day sell food")
  267 + self.owner:sendMail(MailId.ActSellFood)
  268 + end,
  269 +}
  270 +
  271 +-- 拾荒周
  272 +activityFunc[Activity.ActivityType.AdvDraw] = {
  273 + ["check"] = function(self, actType, notify, count) -- 检查
  274 + self:checkWeeklyAct(actType, notify, count)
  275 + end,
  276 + ["init"] = function(self, actType, isCrossDay, notify)
  277 + local roundData = self:getProperty("round")
  278 + roundData[actType] = 0
  279 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  280 + end,
  281 + -- ["close"] = function(self, actType, notify)
  282 + -- end,
  283 + ["crossDay"] = function(self, actType, notify)
  284 + print("cross day act adv cost")
  285 + self.owner:sendMail(MailId.ActAdvDraw)
  286 + end,
  287 +}
  288 +
  289 +-- 拆解周
  290 +activityFunc[Activity.ActivityType.OpenBox] = {
  291 + ["check"] = function(self, actType, notify, count) -- 检查
  292 + self:checkWeeklyAct(actType, notify, count)
  293 + end,
  294 + ["init"] = function(self, actType, isCrossDay, notify)
  295 + local roundData = self:getProperty("round")
  296 + roundData[actType] = 0
  297 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  298 + end,
  299 + -- ["close"] = function(self, actType, notify)
  300 + -- end,
  301 + ["crossDay"] = function(self, actType, notify)
  302 + print("cross day open box")
  303 + self.owner:sendMail(MailId.ActOpenBox)
  304 + end,
  305 +}
  306 +
166 function Activity:initActivity(actType, isCrossDay, notify) 307 function Activity:initActivity(actType, isCrossDay, notify)
167 if activityFunc[actType] and activityFunc[actType]['close'] then 308 if activityFunc[actType] and activityFunc[actType]['close'] then
168 activityFunc[actType]["init"](self, actType, isCrossDay, notify) 309 activityFunc[actType]["init"](self, actType, isCrossDay, notify)
@@ -173,7 +314,9 @@ function Activity:closeActivity(actType, notify, notUpdateAct) @@ -173,7 +314,9 @@ function Activity:closeActivity(actType, notify, notUpdateAct)
173 if activityFunc[actType] and activityFunc[actType]['close'] then 314 if activityFunc[actType] and activityFunc[actType]['close'] then
174 activityFunc[actType]["close"](self, actType, notify) 315 activityFunc[actType]["close"](self, actType, notify)
175 end 316 end
176 - self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) 317 + if Activity.schema["act".. actType] then
  318 + self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct)
  319 + end
177 end 320 end
178 321
179 function Activity:refreshDailyData(notify) 322 function Activity:refreshDailyData(notify)
src/models/RolePlugin.lua
@@ -1583,7 +1583,7 @@ function RolePlugin.bind(Role) @@ -1583,7 +1583,7 @@ function RolePlugin.bind(Role)
1583 end 1583 end
1584 1584
1585 --直接给玩家发送邮件,立即推送小红点 1585 --直接给玩家发送邮件,立即推送小红点
1586 - function Role:sendMail(mailId, createTime, reward) 1586 + function Role:sendMail(mailId, createTime, reward, contentPms)
1587 local tgift = {} 1587 local tgift = {}
1588 if type(reward) == "string" then 1588 if type(reward) == "string" then
1589 for _, one in pairs(reward:toTableArray(true)) do 1589 for _, one in pairs(reward:toTableArray(true)) do
@@ -1596,7 +1596,7 @@ function RolePlugin.bind(Role) @@ -1596,7 +1596,7 @@ function RolePlugin.bind(Role)
1596 for k, v in pairs(tgift) do 1596 for k, v in pairs(tgift) do
1597 gift = gift .. k.."="..v.." " 1597 gift = gift .. k.."="..v.." "
1598 end 1598 end
1599 - redisproxy:insertEmail({roleId = self:getProperty("id"), emailId = mailId, createtime = createTime, attachments = gift}) 1599 + redisproxy:insertEmail({roleId = self:getProperty("id"), emailId = mailId, createtime = createTime, attachments = gift, contentPms = contentPms})
1600 self.sendMailFlag = true 1600 self.sendMailFlag = true
1601 end 1601 end
1602 1602
src/models/RoleTask.lua
@@ -205,10 +205,14 @@ local SudokuListener = { @@ -205,10 +205,14 @@ local SudokuListener = {
205 } 205 }
206 } 206 }
207 207
  208 +local Activity = require("models.Activity")
208 local ActivityListener = { 209 local ActivityListener = {
209 func = "checkActivityTask", 210 func = "checkActivityTask",
210 - listener = {  
211 - 211 + listen = {
  212 + [TaskType.DrawHero] = {{Activity.ActivityType.DrawHero, f("count")}},
  213 + [TaskType.FoodSell] = {{Activity.ActivityType.FoodSell, f("count")}},
  214 + [TaskType.AdvDraw] = {{Activity.ActivityType.AdvDraw, f("count")}},
  215 + [TaskType.OpenBox] = {{Activity.ActivityType.OpenBox, f("count")}},
212 } 216 }
213 } 217 }
214 218
src/models/RoleTimeReset.lua
@@ -30,6 +30,14 @@ ResetFunc[&quot;CrossWeek&quot;] = function(self, notify, response) @@ -30,6 +30,14 @@ ResetFunc[&quot;CrossWeek&quot;] = function(self, notify, response)
30 response.dinerS = {} 30 response.dinerS = {}
31 end 31 end
32 32
  33 +ResetFunc["CrossMonth"] = function(self, notify, response)
  34 + local ltime = self:getProperty("ltime")
  35 + if isCrossMonth(ltime, skynet.timex()) then
  36 + print("cross month")
  37 + self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id
  38 + end
  39 +end
  40 +
33 41
34 ResetFunc["DinerRank"] = function(self, notify, response) 42 ResetFunc["DinerRank"] = function(self, notify, response)
35 self.dinerData:rankResetData(notify) 43 self.dinerData:rankResetData(notify)
@@ -52,9 +60,11 @@ function Role:updateTimeReset(now, notify) @@ -52,9 +60,11 @@ function Role:updateTimeReset(now, notify)
52 60
53 local needResetId = {} 61 local needResetId = {}
54 for resetId, resetData in pairs(csvdb["time_resetCsv"]) do 62 for resetId, resetData in pairs(csvdb["time_resetCsv"]) do
55 - local curRound = math.floor((passTime - resetData.start) / resetData.interval)  
56 - if not timeReset[resetId] or curRound ~= timeReset[resetId] then  
57 - needResetId[resetId] = curRound 63 + if resetData.interval > 0 then
  64 + local curRound = math.floor((passTime - resetData.start) / resetData.interval)
  65 + if not timeReset[resetId] or curRound ~= timeReset[resetId] then
  66 + needResetId[resetId] = curRound
  67 + end
58 end 68 end
59 end 69 end
60 if not next(needResetId) then return end 70 if not next(needResetId) then return end
src/models/Store.lua
@@ -144,7 +144,7 @@ function Store:getGearExchangeCoef() @@ -144,7 +144,7 @@ function Store:getGearExchangeCoef()
144 return 1 144 return 1
145 end 145 end
146 146
147 - local coef = (globalCsv.shop_priv_card_produce_coef or 50)/ 100 147 + local coef = (globalCsv.shop_priv_exchange_gear_coef or 50)/ 100
148 return 1 + coef 148 return 1 + coef
149 end 149 end
150 150