Commit 6cac3be8579cbb1d1f9d742e2d47ed4642c943b2
1 parent
7f0106d7
将军令批量领取奖励
Showing
3 changed files
with
52 additions
and
24 deletions
Show diff stats
src/actions/ActivityAction.lua
... | ... | @@ -1152,7 +1152,6 @@ function _M.battleCommandRpc(agent, data) |
1152 | 1152 | local actid = msg.actid -- 活动id |
1153 | 1153 | local index = msg.index -- 领取的阶段id |
1154 | 1154 | local pay = msg.pay -- 是否是超级奖励 |
1155 | - print(actid, index, pay) | |
1156 | 1155 | |
1157 | 1156 | if not role.activity:isOpenById(actid, "BattleCommand") then return 1 end |
1158 | 1157 | local actCtrlData = csvdb["activity_ctrlCsv"][actid] |
... | ... | @@ -1165,32 +1164,62 @@ function _M.battleCommandRpc(agent, data) |
1165 | 1164 | local bpCfg = csvdb["activity_battlepass_rewardCsv"][actid] |
1166 | 1165 | if not bpCfg then return 3 end |
1167 | 1166 | |
1168 | - bpCfg = bpCfg[index] | |
1169 | - if not bpCfg then return 4 end | |
1170 | - | |
1171 | - if (actData["lvl"] or 0) < bpCfg["type"] then return 5 end | |
1167 | + local award = {} | |
1168 | + if not index then -- 一键领取 | |
1169 | + for i = 1, #bpCfg do | |
1170 | + local cfg = bpCfg[i] | |
1171 | + if not cfg then return 4 end | |
1172 | + | |
1173 | + if (actData["lvl"] or 0) < cfg["type"] then break end | |
1174 | + local records = {{"freeR", "rewardNormal"}, {"payR", "rewardHigh"}} | |
1175 | + | |
1176 | + for _, info in ipairs(records) do | |
1177 | + local typeKey, rewardKey = info[1], info[2] | |
1178 | + local record = actData[typeKey] or "" | |
1179 | + local flag = string.char(string.getbit(record, i)) | |
1180 | + if flag == "0" then | |
1181 | + record = string.setbit(record, i) | |
1182 | + end | |
1183 | + record = string.setbit(record, i) | |
1184 | + actData[typeKey] = record | |
1172 | 1185 | |
1173 | - local record = "" | |
1174 | - if pay then | |
1175 | - record = actData["payR"] or "" | |
1186 | + local awd = cfg[rewardKey] | |
1187 | + for k, v in pairs(awd:toNumMap()) do | |
1188 | + award[k] = (award[k] or 0) + v | |
1189 | + end | |
1190 | + end | |
1191 | + end | |
1176 | 1192 | else |
1177 | - record = actData["freeR"] or "" | |
1178 | - end | |
1193 | + bpCfg = bpCfg[index] | |
1194 | + if not bpCfg then return 4 end | |
1179 | 1195 | |
1180 | - local flag = string.char(string.getbit(record, index)) | |
1196 | + if (actData["lvl"] or 0) < bpCfg["type"] then return 5 end | |
1181 | 1197 | |
1182 | - if flag == "1" then | |
1183 | - return 6 | |
1184 | - end | |
1198 | + local record = "" | |
1199 | + if pay then | |
1200 | + record = actData["payR"] or "" | |
1201 | + else | |
1202 | + record = actData["freeR"] or "" | |
1203 | + end | |
1185 | 1204 | |
1186 | - record = string.setbit(record, index) | |
1187 | - local award = "" | |
1188 | - if pay then | |
1189 | - actData["payR"] = record | |
1190 | - award = bpCfg["rewardNormal"] | |
1191 | - else | |
1192 | - actData["freeR"] = record | |
1193 | - award = bpCfg["rewardHigh"] | |
1205 | + local flag = string.char(string.getbit(record, index)) | |
1206 | + | |
1207 | + if flag == "1" then | |
1208 | + return 6 | |
1209 | + end | |
1210 | + | |
1211 | + record = string.setbit(record, index) | |
1212 | + local awd = "" | |
1213 | + if pay then | |
1214 | + actData["payR"] = record | |
1215 | + awd = bpCfg["rewardNormal"] | |
1216 | + else | |
1217 | + actData["freeR"] = record | |
1218 | + awd = bpCfg["rewardHigh"] | |
1219 | + end | |
1220 | + for k, v in pairs(awd:toNumMap()) do | |
1221 | + award[k] = (award[k] or 0) + v | |
1222 | + end | |
1194 | 1223 | end |
1195 | 1224 | |
1196 | 1225 | role.activity:updateActData("BattleCommand", actData) | ... | ... |
src/models/Activity.lua
... | ... | @@ -979,7 +979,6 @@ activityFunc[Activity.ActivityType.BattleCommand] = { |
979 | 979 | self:updateActData(actType, data, not notify) |
980 | 980 | end, |
981 | 981 | ["check"] = function(self, actType, notify, id, count) -- 检查 itemid, count |
982 | - print("babababa", id, count) | |
983 | 982 | local isOpen, actId = self:isOpen(actType) |
984 | 983 | local actData = self:getActData(actType) or {} |
985 | 984 | local actCfg = csvdb["activity_ctrlCsv"][actId] | ... | ... |