Commit ac8855277fe33767f9d79a02b1e2086348ab329e

Authored by liuzujun
1 parent 0027e33b

联动签到活动

src/ProtocolCode.lua
@@ -229,6 +229,7 @@ actionCodes = { @@ -229,6 +229,7 @@ actionCodes = {
229 Activity_battleMilestoneRpc = 663, 229 Activity_battleMilestoneRpc = 663,
230 Activity_bossRewardRpc = 664, 230 Activity_bossRewardRpc = 664,
231 Activity_crisisMilestoneRpc = 665, 231 Activity_crisisMilestoneRpc = 665,
  232 + Activity_commonSignRpc = 666,
232 233
233 Radio_startQuestRpc = 700, 234 Radio_startQuestRpc = 700,
234 Radio_finishQuestRpc = 701, 235 Radio_finishQuestRpc = 701,
src/actions/ActivityAction.lua
@@ -858,4 +858,34 @@ function _M.bossRewardRpc(agent, data) @@ -858,4 +858,34 @@ function _M.bossRewardRpc(agent, data)
858 return true 858 return true
859 end 859 end
860 860
  861 +function _M.commonSignRpc(agent, data)
  862 + local role = agent.role
  863 + local msg = MsgPack.unpack(data)
  864 + local actid = msg.actid
  865 + local index = msg.index
  866 +
  867 + if not role.activity:isOpenById(actid, "CommonSignIn") then return 1 end
  868 +
  869 + local actData = role.activity:getActData("CommonSignIn")
  870 + if (actData[0] or 0) < index then
  871 + return 2
  872 + end
  873 + if (actData[index] or 0) == 1 then
  874 + return 3
  875 + end
  876 +
  877 + local actCfg = csvdb["activity_signInCsv"][actid]
  878 + if not actCfg then return 4 end
  879 + actCfg = actCfg[index]
  880 + if not actCfg then return 5 end
  881 +
  882 + actData[index] = 1
  883 + role.activity:updateActData("CommonSignIn", actData)
  884 +
  885 + local award = actCfg.reward:toNumMap()
  886 + local reward, change = role:award(award, {log = {desc = "commonSign", int1 = actid, int2 = index}})
  887 + SendPacket(actionCodes.Activity_commonSignRpc, MsgPack.pack(role:packReward(reward, change)))
  888 + return true
  889 +end
  890 +
861 return _M 891 return _M
862 \ No newline at end of file 892 \ No newline at end of file
src/actions/RoleAction.lua
@@ -840,6 +840,11 @@ function _M.taskRpc(agent, data) @@ -840,6 +840,11 @@ function _M.taskRpc(agent, data)
840 local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}}) 840 local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}})
841 local active = (taskStatus["a"] or 0) + taskData.active 841 local active = (taskStatus["a"] or 0) + taskData.active
842 842
  843 + -- 日常活动完成
  844 + if taskType == 1 then
  845 + role:checkTaskEnter("DailyTask", {pre = (taskStatus["a"] or 0), cur = active})
  846 + end
  847 +
843 role:changeUpdates({ 848 role:changeUpdates({
844 { type = roleField[taskType], field = {"t", taskId}, value = -1 }, 849 { type = roleField[taskType], field = {"t", taskId}, value = -1 },
845 { type = roleField[taskType], field = "a", value = active}, 850 { type = roleField[taskType], field = "a", value = active},
1 -Subproject commit f6a626350c1f4039f0f677a1baf262f3493757d2 1 +Subproject commit fcf0c6c46ae54862a6b68b77f87ce0cf8a729da5
src/models/Activity.lua
@@ -30,6 +30,8 @@ Activity.ActivityType = { @@ -30,6 +30,8 @@ Activity.ActivityType = {
30 ActShopGoods = 25, -- 活动商品 30 ActShopGoods = 25, -- 活动商品
31 31
32 Crisis = 26, -- 宝藏怪活动 32 Crisis = 26, -- 宝藏怪活动
  33 +
  34 + CommonSignIn = 28, --通用签到
33 } 35 }
34 36
35 local function checkActivityType(activityType) 37 local function checkActivityType(activityType)
@@ -73,6 +75,8 @@ Activity.schema = { @@ -73,6 +75,8 @@ Activity.schema = {
73 75
74 act24 = {"table", {}, true}, -- 活动卡池 {id=repaynum} 76 act24 = {"table", {}, true}, -- 活动卡池 {id=repaynum}
75 act26 = {"table", {}}, -- {task = {id = count}, socre = {id = status}} 77 act26 = {"table", {}}, -- {task = {id = count}, socre = {id = status}}
  78 +
  79 + act28 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1}
76 } 80 }
77 81
78 function Activity:data() 82 function Activity:data()
@@ -91,7 +95,10 @@ function Activity:data() @@ -91,7 +95,10 @@ function Activity:data()
91 act18 = self:getProperty("act18"), 95 act18 = self:getProperty("act18"),
92 act19 = self:getProperty("act19"), 96 act19 = self:getProperty("act19"),
93 act20 = self:getProperty("act20"), 97 act20 = self:getProperty("act20"),
  98 + act24 = self:getProperty("act24"),
94 act26 = self:getProperty("act26"), 99 act26 = self:getProperty("act26"),
  100 +
  101 + act28 = self:getProperty("act28"),
95 } 102 }
96 end 103 end
97 104
@@ -780,4 +787,40 @@ activityFunc[Activity.ActivityType.Crisis] = { @@ -780,4 +787,40 @@ activityFunc[Activity.ActivityType.Crisis] = {
780 end, 787 end,
781 } 788 }
782 789
  790 +activityFunc[Activity.ActivityType.CommonSignIn] = {
  791 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  792 + if not isCrossDay then
  793 + activityFunc[Activity.ActivityType.CommonSignIn]["crossDay"](self, actType, notify, actId)
  794 + end
  795 + end,
  796 + ["crossDay"] = function(self, actType, notify, actId)
  797 + local actCfg = csvdb["activity_ctrlCsv"][actId]
  798 + if not actCfg then return end
  799 + local conArr = actCfg.condition2:toArray("true", "=")
  800 + -- 0 登录即可, 1 达到指定活跃度
  801 + if conArr[1] ~= 0 then
  802 + return
  803 + end
  804 + local curData = self:getActData(actType) or {}
  805 + curData[0] = (curData[0] or 0) + 1
  806 + self:updateActData(actType, curData, not notify)
  807 + end,
  808 + ["check"] = function(self, actType, notify, pre, cur) -- 检查
  809 + local isOpen, actId = self:isOpen(actType)
  810 + local actData = self:getActData(actType) or {}
  811 + local actCfg = csvdb["activity_ctrlCsv"][actId]
  812 + if not actCfg then return end
  813 + local conArr = actCfg.condition2:toArray("true", "=")
  814 + -- 0 登录即可, 1 达到指定活跃度
  815 + if conArr[1] ~= 1 then
  816 + return
  817 + end
  818 + local val = conArr[2] or 0
  819 + if pre < val and cur >= val then
  820 + actData[0] = (actData[0] or 0) + 1
  821 + self:updateActData(actType, actData, not notify)
  822 + end
  823 + end,
  824 +}
  825 +
783 return Activity 826 return Activity
src/models/RoleLog.lua
@@ -51,6 +51,7 @@ local ItemReason = { @@ -51,6 +51,7 @@ local ItemReason = {
51 actBattle = 135, -- 活动关卡 51 actBattle = 135, -- 活动关卡
52 actMilestone = 136, -- 活动关卡boss伤害里程碑 52 actMilestone = 136, -- 活动关卡boss伤害里程碑
53 worldBossReward = 137, -- 世界boss翻牌奖励 53 worldBossReward = 137, -- 世界boss翻牌奖励
  54 + commonSign = 138, -- 每日活跃签到
54 55
55 56
56 advHang = 301, -- 拾荒挂机 57 advHang = 301, -- 拾荒挂机
src/models/RoleTask.lua
@@ -91,6 +91,7 @@ local TaskType = { @@ -91,6 +91,7 @@ local TaskType = {
91 SignIn = 901, -- 签到 91 SignIn = 901, -- 签到
92 Pay = 902, -- 充值 92 Pay = 902, -- 充值
93 ShopAll = 903, -- 在任意商店购买 93 ShopAll = 903, -- 在任意商店购买
  94 + DailyTask = 904, -- 完成每日活跃任务
94 95
95 --功能未实现 todo 96 --功能未实现 todo
96 AdvShop = 1002, -- 冒险商城 97 AdvShop = 1002, -- 冒险商城
@@ -231,6 +232,7 @@ local ActivityListener = { @@ -231,6 +232,7 @@ local ActivityListener = {
231 [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}}, 232 [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}},
232 [TaskType.AdvMineKill] = {{Activity.ActivityType.Crisis, 1}}, 233 [TaskType.AdvMineKill] = {{Activity.ActivityType.Crisis, 1}},
233 [TaskType.AdvMineLayer] = {{Activity.ActivityType.Crisis, 2}}, 234 [TaskType.AdvMineLayer] = {{Activity.ActivityType.Crisis, 2}},
  235 + [TaskType.DailyTask] = {{Activity.ActivityType.CommonSignIn, f("pre"), f("cur")}},
234 } 236 }
235 } 237 }
236 238