Commit ac8855277fe33767f9d79a02b1e2086348ab329e
1 parent
0027e33b
联动签到活动
Showing
7 changed files
with
83 additions
and
1 deletions
Show diff stats
src/ProtocolCode.lua
src/actions/ActivityAction.lua
... | ... | @@ -858,4 +858,34 @@ function _M.bossRewardRpc(agent, data) |
858 | 858 | return true |
859 | 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 | 891 | return _M |
862 | 892 | \ No newline at end of file | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -840,6 +840,11 @@ function _M.taskRpc(agent, data) |
840 | 840 | local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}}) |
841 | 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 | 848 | role:changeUpdates({ |
844 | 849 | { type = roleField[taskType], field = {"t", taskId}, value = -1 }, |
845 | 850 | { type = roleField[taskType], field = "a", value = active}, | ... | ... |
src/models/Activity.lua
... | ... | @@ -30,6 +30,8 @@ Activity.ActivityType = { |
30 | 30 | ActShopGoods = 25, -- 活动商品 |
31 | 31 | |
32 | 32 | Crisis = 26, -- 宝藏怪活动 |
33 | + | |
34 | + CommonSignIn = 28, --通用签到 | |
33 | 35 | } |
34 | 36 | |
35 | 37 | local function checkActivityType(activityType) |
... | ... | @@ -73,6 +75,8 @@ Activity.schema = { |
73 | 75 | |
74 | 76 | act24 = {"table", {}, true}, -- 活动卡池 {id=repaynum} |
75 | 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 | 82 | function Activity:data() |
... | ... | @@ -91,7 +95,10 @@ function Activity:data() |
91 | 95 | act18 = self:getProperty("act18"), |
92 | 96 | act19 = self:getProperty("act19"), |
93 | 97 | act20 = self:getProperty("act20"), |
98 | + act24 = self:getProperty("act24"), | |
94 | 99 | act26 = self:getProperty("act26"), |
100 | + | |
101 | + act28 = self:getProperty("act28"), | |
95 | 102 | } |
96 | 103 | end |
97 | 104 | |
... | ... | @@ -780,4 +787,40 @@ activityFunc[Activity.ActivityType.Crisis] = { |
780 | 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 | 826 | return Activity | ... | ... |
src/models/RoleLog.lua
src/models/RoleTask.lua
... | ... | @@ -91,6 +91,7 @@ local TaskType = { |
91 | 91 | SignIn = 901, -- 签到 |
92 | 92 | Pay = 902, -- 充值 |
93 | 93 | ShopAll = 903, -- 在任意商店购买 |
94 | + DailyTask = 904, -- 完成每日活跃任务 | |
94 | 95 | |
95 | 96 | --功能未实现 todo |
96 | 97 | AdvShop = 1002, -- 冒险商城 |
... | ... | @@ -231,6 +232,7 @@ local ActivityListener = { |
231 | 232 | [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}}, |
232 | 233 | [TaskType.AdvMineKill] = {{Activity.ActivityType.Crisis, 1}}, |
233 | 234 | [TaskType.AdvMineLayer] = {{Activity.ActivityType.Crisis, 2}}, |
235 | + [TaskType.DailyTask] = {{Activity.ActivityType.CommonSignIn, f("pre"), f("cur")}}, | |
234 | 236 | } |
235 | 237 | } |
236 | 238 | ... | ... |