Compare View
Commits (3)
Showing
2 changed files
Show diff stats
src/actions/RoleAction.lua
@@ -890,25 +890,14 @@ function _M.unLockStoryBookRpc(agent, data) | @@ -890,25 +890,14 @@ function _M.unLockStoryBookRpc(agent, data) | ||
890 | return true | 890 | return true |
891 | end | 891 | end |
892 | 892 | ||
893 | -function _M.taskRpc(agent, data) | ||
894 | - local role = agent.role | ||
895 | - local msg = MsgPack.unpack(data) | ||
896 | - | ||
897 | - if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end | ||
898 | - | ||
899 | - local taskType = msg.type -- 1 日常 2 周常 | ||
900 | - local taskId = msg.id --任务id | ||
901 | - local roleField = {"dTask", "wTask"} | ||
902 | - if not roleField[taskType] then return 1 end | ||
903 | - | ||
904 | - local taskData = csvdb["task_loopCsv"][taskType][taskId] | ||
905 | - if not taskData then return 2 end | 893 | +local function getTaskReward(role, taskId, roleField, taskType, taskData) |
894 | + if not taskData then return nil end | ||
906 | 895 | ||
907 | local taskStatus = role:getProperty(roleField[taskType]) | 896 | local taskStatus = role:getProperty(roleField[taskType]) |
908 | local tStatus = taskStatus["t"] or {} | 897 | local tStatus = taskStatus["t"] or {} |
909 | 898 | ||
910 | if (tStatus[taskId] or 0) < taskData.condition1 then | 899 | if (tStatus[taskId] or 0) < taskData.condition1 then |
911 | - return 3 | 900 | + return nil |
912 | end | 901 | end |
913 | 902 | ||
914 | local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}}) | 903 | local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}}) |
@@ -936,30 +925,49 @@ function _M.taskRpc(agent, data) | @@ -936,30 +925,49 @@ function _M.taskRpc(agent, data) | ||
936 | task_reward_type = taskType, --任务奖励类型,见 任务奖励类型枚举表 | 925 | task_reward_type = taskType, --任务奖励类型,见 任务奖励类型枚举表 |
937 | task_reward_detail = reward, --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | 926 | task_reward_detail = reward, --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} |
938 | }) | 927 | }) |
939 | - | ||
940 | - SendPacket(actionCodes.Role_taskRpc, MsgPack.pack(role:packReward(reward, change))) | ||
941 | - return true | 928 | + return reward, change |
942 | end | 929 | end |
943 | 930 | ||
944 | -function _M.taskActiveRpc(agent, data) | 931 | +function _M.taskRpc(agent, data) |
945 | local role = agent.role | 932 | local role = agent.role |
946 | local msg = MsgPack.unpack(data) | 933 | local msg = MsgPack.unpack(data) |
947 | 934 | ||
948 | if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end | 935 | if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end |
949 | 936 | ||
950 | - local taskType = msg.type -- 1 日常 2 周长 | 937 | + local taskType = msg.type -- 1 日常 2 周常 |
951 | local taskId = msg.id --任务id | 938 | local taskId = msg.id --任务id |
952 | local roleField = {"dTask", "wTask"} | 939 | local roleField = {"dTask", "wTask"} |
953 | - if not roleField[taskType] then return end | 940 | + if not roleField[taskType] then return 1 end |
954 | 941 | ||
955 | - local taskData = csvdb["task_activeCsv"][taskType][taskId] | ||
956 | - if not taskData then return end | 942 | + local reward, change = {}, {} |
943 | + if not taskId then | ||
944 | + | ||
945 | + for id, taskData in pairs(csvdb["task_loopCsv"][taskType]) do | ||
946 | + local tmpreward, tmpchange = getTaskReward(role, id, roleField, taskType, taskData) | ||
947 | + if tmpreward then | ||
948 | + for k, v in pairs(tmpreward) do | ||
949 | + reward[k] = (reward[k] or 0) + v | ||
950 | + end | ||
951 | + if tmpchange then table.insert(change, tmpchange) end | ||
952 | + end | ||
953 | + end | ||
954 | + else | ||
955 | + local taskData = csvdb["task_loopCsv"][taskType][taskId] | ||
956 | + if not taskData then return 2 end | ||
957 | + reward, change= getTaskReward(role, taskId, roleField, taskType, taskData) | ||
958 | + end | ||
957 | 959 | ||
960 | + SendPacket(actionCodes.Role_taskRpc, MsgPack.pack(role:packReward(reward, change))) | ||
961 | + return true | ||
962 | +end | ||
963 | + | ||
964 | + | ||
965 | +local function getTaskActiveReward(role, taskId, roleField, taskType, taskData) | ||
958 | local taskStatus = role:getProperty(roleField[taskType]) | 966 | local taskStatus = role:getProperty(roleField[taskType]) |
959 | local tStatus = taskStatus["at"] or {} | 967 | local tStatus = taskStatus["at"] or {} |
960 | 968 | ||
961 | if tStatus[taskId] == -1 or (taskStatus["a"] or 0) < taskData.active then | 969 | if tStatus[taskId] == -1 or (taskStatus["a"] or 0) < taskData.active then |
962 | - return | 970 | + return nil |
963 | end | 971 | end |
964 | 972 | ||
965 | local needReward = taskData.reward:toNumMap() | 973 | local needReward = taskData.reward:toNumMap() |
@@ -974,12 +982,42 @@ function _M.taskActiveRpc(agent, data) | @@ -974,12 +982,42 @@ function _M.taskActiveRpc(agent, data) | ||
974 | role:changeUpdates({ | 982 | role:changeUpdates({ |
975 | { type = roleField[taskType], field = {"at", taskId}, value = -1 } | 983 | { type = roleField[taskType], field = {"at", taskId}, value = -1 } |
976 | }) | 984 | }) |
977 | - | 985 | + |
978 | role:log("task_reward", { | 986 | role:log("task_reward", { |
979 | task_reward_id = taskId * 100 + taskType, --任务奖励ID | 987 | task_reward_id = taskId * 100 + taskType, --任务奖励ID |
980 | task_reward_type = 3, --任务奖励类型,见 任务奖励类型枚举表 | 988 | task_reward_type = 3, --任务奖励类型,见 任务奖励类型枚举表 |
981 | task_reward_detail = reward, --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | 989 | task_reward_detail = reward, --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} |
982 | }) | 990 | }) |
991 | + return reward, change | ||
992 | +end | ||
993 | + | ||
994 | +function _M.taskActiveRpc(agent, data) | ||
995 | + local role = agent.role | ||
996 | + local msg = MsgPack.unpack(data) | ||
997 | + | ||
998 | + if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end | ||
999 | + | ||
1000 | + local taskType = msg.type -- 1 日常 2 周长 | ||
1001 | + local taskId = msg.id --任务id | ||
1002 | + local roleField = {"dTask", "wTask"} | ||
1003 | + if not roleField[taskType] then return end | ||
1004 | + | ||
1005 | + local reward, change = {}, {} | ||
1006 | + if not taskId then | ||
1007 | + for id, taskData in pairs(csvdb["task_activeCsv"][taskType]) do | ||
1008 | + local tmpreward, tmpchange = getTaskActiveReward(role, id, roleField, taskType, taskData) | ||
1009 | + if tmpreward then | ||
1010 | + for k, v in pairs(tmpreward) do | ||
1011 | + reward[k] = (reward[k] or 0) + v | ||
1012 | + end | ||
1013 | + if tmpchange then table.insert(change, tmpchange) end | ||
1014 | + end | ||
1015 | + end | ||
1016 | + else | ||
1017 | + local taskData = csvdb["task_activeCsv"][taskType][taskId] | ||
1018 | + if not taskData then return end | ||
1019 | + reward, change= getTaskActiveReward(role, taskId, roleField, taskType, taskData) | ||
1020 | + end | ||
983 | 1021 | ||
984 | SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change))) | 1022 | SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change))) |
985 | return true | 1023 | return true |
src/models/RolePlugin.lua
@@ -2787,8 +2787,8 @@ function RolePlugin.bind(Role) | @@ -2787,8 +2787,8 @@ function RolePlugin.bind(Role) | ||
2787 | return self:getDeltaValue(result, value) + self:getDeltaValue(levelReault, value) | 2787 | return self:getDeltaValue(result, value) + self:getDeltaValue(levelReault, value) |
2788 | end | 2788 | end |
2789 | 2789 | ||
2790 | - local function appendBnous(dstBnous, srcBnous) | ||
2791 | - if not dstBnous or not srcBnous then return end | 2790 | + local function appendAdvBnous(dstBnous, srcBnous) |
2791 | + if not dstBnous and not srcBnous then return end | ||
2792 | for time, set in pairs(srcBnous) do | 2792 | for time, set in pairs(srcBnous) do |
2793 | if not dstBnous[time] then | 2793 | if not dstBnous[time] then |
2794 | dstBnous[time] = {} | 2794 | dstBnous[time] = {} |
@@ -2798,12 +2798,20 @@ function RolePlugin.bind(Role) | @@ -2798,12 +2798,20 @@ function RolePlugin.bind(Role) | ||
2798 | end | 2798 | end |
2799 | end | 2799 | end |
2800 | end | 2800 | end |
2801 | + | ||
2802 | + local function appendTableBnous(dstBnous, srcBnous) | ||
2803 | + if not dstBnous and not srcBnous then return end | ||
2804 | + for k, v in pairs(srcBnous) do | ||
2805 | + dstBnous[k] = (dstBnous[k] or 0) + v | ||
2806 | + end | ||
2807 | + end | ||
2801 | function Role:getBnousAdv() | 2808 | function Role:getBnousAdv() |
2802 | local towerBnous = self:getTowerBnousActive() | 2809 | local towerBnous = self:getTowerBnousActive() |
2803 | local levelBnous = self:getLevelBnous() | 2810 | local levelBnous = self:getLevelBnous() |
2804 | local adv = levelBnous[SystemBnousType.Adv] or {} | 2811 | local adv = levelBnous[SystemBnousType.Adv] or {} |
2805 | - appendBnous(towerBnous[SystemBnousType.Adv], adv) | ||
2806 | - return towerBnous[SystemBnousType.Adv] or {} | 2812 | + towerBnous[SystemBnousType.Adv] = towerBnous[SystemBnousType.Adv] or {} |
2813 | + appendAdvBnous(towerBnous[SystemBnousType.Adv], adv) | ||
2814 | + return towerBnous[SystemBnousType.Adv] | ||
2807 | end | 2815 | end |
2808 | 2816 | ||
2809 | function Role:getBnousHangTime() | 2817 | function Role:getBnousHangTime() |
@@ -2817,16 +2825,18 @@ function RolePlugin.bind(Role) | @@ -2817,16 +2825,18 @@ function RolePlugin.bind(Role) | ||
2817 | local towerBnous = self:getTowerBnousActive() | 2825 | local towerBnous = self:getTowerBnousActive() |
2818 | local levelBnous = self:getLevelBnous() | 2826 | local levelBnous = self:getLevelBnous() |
2819 | local pvpTicket = levelBnous[SystemBnousType.PvpTicket] or {} | 2827 | local pvpTicket = levelBnous[SystemBnousType.PvpTicket] or {} |
2820 | - appendBnous(towerBnous[SystemBnousType.PvpTicket], pvpTicket) | ||
2821 | - return towerBnous[SystemBnousType.PvpTicket] or {} | 2828 | + towerBnous[SystemBnousType.PvpTicket] = towerBnous[SystemBnousType.PvpTicket] or {} |
2829 | + appendTableBnous(towerBnous[SystemBnousType.PvpTicket], pvpTicket) | ||
2830 | + return towerBnous[SystemBnousType.PvpTicket] | ||
2822 | end | 2831 | end |
2823 | 2832 | ||
2824 | function Role:getBnousSweep() | 2833 | function Role:getBnousSweep() |
2825 | local towerBnous = self:getTowerBnousActive() | 2834 | local towerBnous = self:getTowerBnousActive() |
2826 | local levelBnous = self:getLevelBnous() | 2835 | local levelBnous = self:getLevelBnous() |
2827 | local sweepReward = levelBnous[SystemBnousType.SweepReward] or {} | 2836 | local sweepReward = levelBnous[SystemBnousType.SweepReward] or {} |
2828 | - appendBnous(towerBnous[SystemBnousType.SweepReward], sweepReward) | ||
2829 | - return towerBnous[SystemBnousType.SweepReward] or {} | 2837 | + towerBnous[SystemBnousType.SweepReward] = towerBnous[SystemBnousType.SweepReward] or {} |
2838 | + appendTableBnous(towerBnous[SystemBnousType.SweepReward], sweepReward) | ||
2839 | + return towerBnous[SystemBnousType.SweepReward] | ||
2830 | end | 2840 | end |
2831 | 2841 | ||
2832 | function Role:getBnousDismantlingMaximum() | 2842 | function Role:getBnousDismantlingMaximum() |