Commit 44537ca2293cb4e09d09c83fd740365167d552f2
Merge branch 'cn/develop' into cn/player
Showing
2 changed files
with
80 additions
and
32 deletions
Show diff stats
src/actions/RoleAction.lua
| ... | ... | @@ -890,25 +890,14 @@ function _M.unLockStoryBookRpc(agent, data) |
| 890 | 890 | return true |
| 891 | 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 | 896 | local taskStatus = role:getProperty(roleField[taskType]) |
| 908 | 897 | local tStatus = taskStatus["t"] or {} |
| 909 | 898 | |
| 910 | 899 | if (tStatus[taskId] or 0) < taskData.condition1 then |
| 911 | - return 3 | |
| 900 | + return nil | |
| 912 | 901 | end |
| 913 | 902 | |
| 914 | 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 | 925 | task_reward_type = taskType, --任务奖励类型,见 任务奖励类型枚举表 |
| 937 | 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 | 929 | end |
| 943 | 930 | |
| 944 | -function _M.taskActiveRpc(agent, data) | |
| 931 | +function _M.taskRpc(agent, data) | |
| 945 | 932 | local role = agent.role |
| 946 | 933 | local msg = MsgPack.unpack(data) |
| 947 | 934 | |
| 948 | 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 | 938 | local taskId = msg.id --任务id |
| 952 | 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 | 966 | local taskStatus = role:getProperty(roleField[taskType]) |
| 959 | 967 | local tStatus = taskStatus["at"] or {} |
| 960 | 968 | |
| 961 | 969 | if tStatus[taskId] == -1 or (taskStatus["a"] or 0) < taskData.active then |
| 962 | - return | |
| 970 | + return nil | |
| 963 | 971 | end |
| 964 | 972 | |
| 965 | 973 | local needReward = taskData.reward:toNumMap() |
| ... | ... | @@ -974,12 +982,42 @@ function _M.taskActiveRpc(agent, data) |
| 974 | 982 | role:changeUpdates({ |
| 975 | 983 | { type = roleField[taskType], field = {"at", taskId}, value = -1 } |
| 976 | 984 | }) |
| 977 | - | |
| 985 | + | |
| 978 | 986 | role:log("task_reward", { |
| 979 | 987 | task_reward_id = taskId * 100 + taskType, --任务奖励ID |
| 980 | 988 | task_reward_type = 3, --任务奖励类型,见 任务奖励类型枚举表 |
| 981 | 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 | 1022 | SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change))) |
| 985 | 1023 | return true | ... | ... |
src/models/RolePlugin.lua
| ... | ... | @@ -2787,8 +2787,8 @@ function RolePlugin.bind(Role) |
| 2787 | 2787 | return self:getDeltaValue(result, value) + self:getDeltaValue(levelReault, value) |
| 2788 | 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 | 2792 | for time, set in pairs(srcBnous) do |
| 2793 | 2793 | if not dstBnous[time] then |
| 2794 | 2794 | dstBnous[time] = {} |
| ... | ... | @@ -2798,12 +2798,20 @@ function RolePlugin.bind(Role) |
| 2798 | 2798 | end |
| 2799 | 2799 | end |
| 2800 | 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 | 2808 | function Role:getBnousAdv() |
| 2802 | 2809 | local towerBnous = self:getTowerBnousActive() |
| 2803 | 2810 | local levelBnous = self:getLevelBnous() |
| 2804 | 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 | 2815 | end |
| 2808 | 2816 | |
| 2809 | 2817 | function Role:getBnousHangTime() |
| ... | ... | @@ -2817,16 +2825,18 @@ function RolePlugin.bind(Role) |
| 2817 | 2825 | local towerBnous = self:getTowerBnousActive() |
| 2818 | 2826 | local levelBnous = self:getLevelBnous() |
| 2819 | 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 | 2831 | end |
| 2823 | 2832 | |
| 2824 | 2833 | function Role:getBnousSweep() |
| 2825 | 2834 | local towerBnous = self:getTowerBnousActive() |
| 2826 | 2835 | local levelBnous = self:getLevelBnous() |
| 2827 | 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 | 2840 | end |
| 2831 | 2841 | |
| 2832 | 2842 | function Role:getBnousDismantlingMaximum() | ... | ... |