Commit e6e49b456b64470425bd7ffc5090e3fde11a1728
1 parent
464ccbd2
一键领取成就奖励
Showing
3 changed files
with
79 additions
and
44 deletions
Show diff stats
src/actions/RoleAction.lua
| ... | ... | @@ -912,62 +912,96 @@ function _M.achiveRpc(agent, data) |
| 912 | 912 | local taskId = msg.id --任务id |
| 913 | 913 | |
| 914 | 914 | if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end |
| 915 | - | |
| 916 | - local achiveTask = csvdb["achievementCsv"][taskId] | |
| 917 | - if not achiveTask then return 1 end | |
| 918 | - | |
| 919 | 915 | local achiveT = role:getProperty("achiveT") |
| 920 | 916 | local achiveV = role:getProperty("achiveV") |
| 917 | + local fuxRecord = role:getProperty("fuxR") or 0 | |
| 918 | + | |
| 919 | + local groups = {} | |
| 920 | + | |
| 921 | + if not taskId then | |
| 922 | + local awards = {} | |
| 923 | + for id, cfg in pairs(csvdb["achievementCsv"]) do | |
| 924 | + -- 没领过 | |
| 925 | + if not achiveV[id] then | |
| 926 | + if (achiveT[cfg.type] or 0) >= cfg.condition1 then | |
| 927 | + local award = cfg.reward:toNumMap() | |
| 928 | + for k, v in pairs(award) do | |
| 929 | + awards[k] = (awards[k] or 0) + v | |
| 930 | + end | |
| 931 | + achiveV[id] = skynet.timex() | |
| 932 | + groups[cfg.group] = 1 | |
| 933 | + | |
| 934 | + role:log("achievement", { | |
| 935 | + achievement_id = cfg.id, -- 成就id | |
| 936 | + achievement_type = cfg.type, -- 成就类型,具体枚举表中成就类型枚举表 | |
| 937 | + achievement_reward = award, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} | |
| 938 | + }) | |
| 939 | + end | |
| 940 | + end | |
| 941 | + end | |
| 942 | + if not next(awards) then | |
| 943 | + return 5 | |
| 944 | + end | |
| 945 | + local reward, change = role:award(awards, {log = {desc = "finishAchive", int1 = 0}}) | |
| 946 | + role:updateProperty({field = "achiveV", value = achiveV}) | |
| 921 | 947 | |
| 922 | - if achiveV[taskId] then return 2 end | |
| 948 | + SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change))) | |
| 949 | + else | |
| 950 | + local achiveTask = csvdb["achievementCsv"][taskId] | |
| 951 | + if not achiveTask then return 1 end | |
| 923 | 952 | |
| 924 | - local curStatus = achiveT[achiveTask.type] or 0 | |
| 925 | - local maxc = achiveTask.condition1 | |
| 953 | + if achiveV[taskId] then return 2 end | |
| 926 | 954 | |
| 927 | - if maxc > curStatus then | |
| 928 | - return 3 | |
| 929 | - end | |
| 955 | + local curStatus = achiveT[achiveTask.type] or 0 | |
| 956 | + local maxc = achiveTask.condition1 | |
| 930 | 957 | |
| 931 | - local reward, change = role:award(achiveTask.reward, {log = {desc = "finishAchive", int1 = taskId}}) | |
| 932 | - role:changeUpdates({ | |
| 933 | - { type = "achiveV", field = taskId, value = skynet.timex() } | |
| 934 | - }) | |
| 958 | + if maxc > curStatus then | |
| 959 | + return 3 | |
| 960 | + end | |
| 935 | 961 | |
| 936 | - -- 复兴奖励 | |
| 937 | - if csvdb["achievement_groupCsv"][achiveTask.group].bookmark == 3 then | |
| 938 | - local overCount = 0 | |
| 939 | - for tId, status in pairs(achiveV) do | |
| 940 | - local tData = csvdb["achievementCsv"][tId] | |
| 941 | - if tData then | |
| 942 | - local groupData = csvdb["achievement_groupCsv"][tData.group] | |
| 943 | - if groupData.bookmark == 3 then | |
| 944 | - overCount = overCount + 1 | |
| 962 | + local reward, change = role:award(achiveTask.reward, {log = {desc = "finishAchive", int1 = taskId}}) | |
| 963 | + role:changeUpdates({ | |
| 964 | + { type = "achiveV", field = taskId, value = skynet.timex() } | |
| 965 | + }) | |
| 966 | + groups[achiveTask.group] = 1 | |
| 967 | + | |
| 968 | + role:log("achievement", { | |
| 969 | + achievement_id = taskId, -- 成就id | |
| 970 | + achievement_type = achiveTask.type, -- 成就类型,具体枚举表中成就类型枚举表 | |
| 971 | + achievement_reward = reward, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} | |
| 972 | + }) | |
| 973 | + | |
| 974 | + SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change))) | |
| 975 | + end | |
| 976 | + | |
| 977 | + for group, _ in pairs(groups) do | |
| 978 | + -- 复兴奖励 | |
| 979 | + if csvdb["achievement_groupCsv"][group].bookmark == 3 then | |
| 980 | + local overCount = 0 | |
| 981 | + local preMaxCount = fuxRecord or 0 | |
| 982 | + for tId, status in pairs(achiveV) do | |
| 983 | + local tData = csvdb["achievementCsv"][tId] | |
| 984 | + if tData then | |
| 985 | + local groupData = csvdb["achievement_groupCsv"][tData.group] | |
| 986 | + if groupData.bookmark == 3 then | |
| 987 | + overCount = overCount + 1 | |
| 988 | + end | |
| 945 | 989 | end |
| 946 | 990 | end |
| 947 | - end | |
| 948 | - | |
| 949 | - for level, pData in pairs(csvdb["achievement_rewardCsv"]) do | |
| 950 | - if pData.request == overCount then | |
| 951 | - -- 发放奖励 | |
| 952 | - redisproxy:insertEmail({ | |
| 953 | - roleId = role:getProperty("id"), | |
| 954 | - emailId = 101, | |
| 955 | - attachments = pData.reward, | |
| 956 | - contentPms = {pData.level}, | |
| 957 | - }) | |
| 958 | - elseif pData.request > overCount then | |
| 959 | - break | |
| 991 | + local flag = false | |
| 992 | + for level, pData in pairs(csvdb["achievement_rewardCsv"]) do | |
| 993 | + if preMaxCount < pData.request and overCount >= pData.request then | |
| 994 | + role:sendMail(101, skynet.timex(), pData.reward, {pData.level}) | |
| 995 | + flag = true | |
| 996 | + end | |
| 997 | + end | |
| 998 | + if flag then | |
| 999 | + role:updateProperty({field = "fuxR", value = overCount, notNotify = true}) | |
| 960 | 1000 | end |
| 1001 | + break | |
| 961 | 1002 | end |
| 962 | 1003 | end |
| 963 | - | |
| 964 | - role:log("achievement", { | |
| 965 | - achievement_id = taskId, -- 成就id | |
| 966 | - achievement_type = achiveTask.type, -- 成就类型,具体枚举表中成就类型枚举表 | |
| 967 | - achievement_reward = reward, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} | |
| 968 | - }) | |
| 969 | 1004 | |
| 970 | - SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change))) | |
| 971 | 1005 | return true |
| 972 | 1006 | end |
| 973 | 1007 | ... | ... |
src/models/Role.lua
| ... | ... | @@ -154,6 +154,7 @@ Role.schema = { |
| 154 | 154 | |
| 155 | 155 | achiveT = {"table", {}}, -- 成就计数统计 achivement_type {id = status} |
| 156 | 156 | achiveV = {"table", {}}, -- 成就领奖统计 achivement {id = status} |
| 157 | + fuxR = {"number", 0}, -- 复兴成就最大完成数量 | |
| 157 | 158 | |
| 158 | 159 | rechargeF = {"table", {}}, -- 是否首次充值某一项 -- —{[id] = 1} -- 不存在就是没有充值过 |
| 159 | 160 | dinerS = {"table", {}}, -- 美食币商城 购买记录 {[id] = count} | ... | ... |
src/models/RoleTask.lua
| ... | ... | @@ -720,7 +720,7 @@ function RoleTask.bind(Role) |
| 720 | 720 | elseif cfg.type == 24 then -- 代理拾荒出勤人数 |
| 721 | 721 | calTask[id] = (calTask[id] or 0) + (param1 or 0) |
| 722 | 722 | elseif cfg.type == 28 then -- 完成指定任务 |
| 723 | - print(actId,param2, cfg.condition2, param1) | |
| 723 | + --print(actId,param2, cfg.condition2, param1) | |
| 724 | 724 | if actId == param2 and cfg.condition2 == param1 then |
| 725 | 725 | calTask[id] = (calTask[id] or 0) + 1 |
| 726 | 726 | end | ... | ... |