Commit 7fe1158cfe67bc499d65a4c61215dfecc837bb4b
Merge branch 'cn/develop' of 120.26.43.151:wasteland/server into cn/develop
Showing
3 changed files
with
85 additions
and
38 deletions
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,23 +2787,33 @@ function RolePlugin.bind(Role) | @@ -2787,23 +2787,33 @@ 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 | + local result = clone(dstBnous or {}) | ||
| 2792 | for time, set in pairs(srcBnous) do | 2793 | for time, set in pairs(srcBnous) do |
| 2793 | - if not dstBnous[time] then | ||
| 2794 | - dstBnous[time] = {} | 2794 | + if not result[time] then |
| 2795 | + result[time] = {} | ||
| 2795 | end | 2796 | end |
| 2796 | for key, value in pairs(set) do | 2797 | for key, value in pairs(set) do |
| 2797 | - dstBnous[time][key] = (dstBnous[time][key] or 0) + value | 2798 | + result[time][key] = (result[time][key] or 0) + value |
| 2798 | end | 2799 | end |
| 2799 | end | 2800 | end |
| 2801 | + return result | ||
| 2802 | + end | ||
| 2803 | + | ||
| 2804 | + local function appendTableBnous(dstBnous, srcBnous) | ||
| 2805 | + if not dstBnous and not srcBnous then return {} end | ||
| 2806 | + local result = clone(dstBnous or {}) | ||
| 2807 | + for k, v in pairs(srcBnous) do | ||
| 2808 | + result[k] = (result[k] or 0) + v | ||
| 2809 | + end | ||
| 2810 | + return result | ||
| 2800 | end | 2811 | end |
| 2801 | function Role:getBnousAdv() | 2812 | function Role:getBnousAdv() |
| 2802 | local towerBnous = self:getTowerBnousActive() | 2813 | local towerBnous = self:getTowerBnousActive() |
| 2803 | local levelBnous = self:getLevelBnous() | 2814 | local levelBnous = self:getLevelBnous() |
| 2804 | local adv = levelBnous[SystemBnousType.Adv] or {} | 2815 | local adv = levelBnous[SystemBnousType.Adv] or {} |
| 2805 | - appendBnous(towerBnous[SystemBnousType.Adv], adv) | ||
| 2806 | - return towerBnous[SystemBnousType.Adv] or {} | 2816 | + return appendAdvBnous(towerBnous[SystemBnousType.Adv], adv) |
| 2807 | end | 2817 | end |
| 2808 | 2818 | ||
| 2809 | function Role:getBnousHangTime() | 2819 | function Role:getBnousHangTime() |
| @@ -2817,16 +2827,14 @@ function RolePlugin.bind(Role) | @@ -2817,16 +2827,14 @@ function RolePlugin.bind(Role) | ||
| 2817 | local towerBnous = self:getTowerBnousActive() | 2827 | local towerBnous = self:getTowerBnousActive() |
| 2818 | local levelBnous = self:getLevelBnous() | 2828 | local levelBnous = self:getLevelBnous() |
| 2819 | local pvpTicket = levelBnous[SystemBnousType.PvpTicket] or {} | 2829 | local pvpTicket = levelBnous[SystemBnousType.PvpTicket] or {} |
| 2820 | - appendBnous(towerBnous[SystemBnousType.PvpTicket], pvpTicket) | ||
| 2821 | - return towerBnous[SystemBnousType.PvpTicket] or {} | 2830 | + return appendTableBnous(towerBnous[SystemBnousType.PvpTicket], 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 | + return appendTableBnous(towerBnous[SystemBnousType.SweepReward], sweepReward) |
| 2830 | end | 2838 | end |
| 2831 | 2839 | ||
| 2832 | function Role:getBnousDismantlingMaximum() | 2840 | function Role:getBnousDismantlingMaximum() |
| @@ -2995,7 +3003,7 @@ function RolePlugin.bind(Role) | @@ -2995,7 +3003,7 @@ function RolePlugin.bind(Role) | ||
| 2995 | -- 把溢出的铭文奖励通过邮件发送 | 3003 | -- 把溢出的铭文奖励通过邮件发送 |
| 2996 | function Role:checkRuneCount(reward) | 3004 | function Role:checkRuneCount(reward) |
| 2997 | local firstMore = false | 3005 | local firstMore = false |
| 2998 | - local count = self:getRuneBatCount() | 3006 | + local count = self:getRuneBagCount() |
| 2999 | local page = globalCsv.store_type[ItemType.Rune] | 3007 | local page = globalCsv.store_type[ItemType.Rune] |
| 3000 | local limit = self:getProperty("bagLimit")[page] | 3008 | local limit = self:getProperty("bagLimit")[page] |
| 3001 | if count >= limit then | 3009 | if count >= limit then |
src/models/Rune.lua
| @@ -92,8 +92,9 @@ function Rune:generateAttrs() | @@ -92,8 +92,9 @@ function Rune:generateAttrs() | ||
| 92 | local attrs = "" | 92 | local attrs = "" |
| 93 | local typ, value = getRandomValue(runeData.attr1,runeData.range1) | 93 | local typ, value = getRandomValue(runeData.attr1,runeData.range1) |
| 94 | attrs = attrs:setv(typ, value) | 94 | attrs = attrs:setv(typ, value) |
| 95 | - local typ, value = getRandomValue(runeData.attr2,runeData.range2) | ||
| 96 | - attrs = attrs:setv(typ, value) | 95 | + local typ, value = getRandomValue(runeData.attr2,runeData.range2) |
| 96 | + attrs = string.format("%s %d=%d", attrs, typ, value) | ||
| 97 | + --attrs = attrs:setv(typ, value) | ||
| 97 | self:setProperty("attrs",attrs) | 98 | self:setProperty("attrs",attrs) |
| 98 | end | 99 | end |
| 99 | 100 |