Commit b620581ab7c5050d585a7566aeaa70c7608eb6b1
1 parent
c756d4df
战令活动,战令相关的任务活动
Showing
8 changed files
with
377 additions
and
5 deletions
Show diff stats
src/ProtocolCode.lua
@@ -231,6 +231,8 @@ actionCodes = { | @@ -231,6 +231,8 @@ actionCodes = { | ||
231 | Activity_crisisMilestoneRpc = 665, | 231 | Activity_crisisMilestoneRpc = 665, |
232 | Activity_commonSignRpc = 666, | 232 | Activity_commonSignRpc = 666, |
233 | Activity_friendHelpRpc = 667, | 233 | Activity_friendHelpRpc = 667, |
234 | + Activity_battleCommandRpc = 668, | ||
235 | + Activity_actCalendaTmpTaskRpc = 659, | ||
234 | 236 | ||
235 | Radio_startQuestRpc = 700, | 237 | Radio_startQuestRpc = 700, |
236 | Radio_finishQuestRpc = 701, | 238 | Radio_finishQuestRpc = 701, |
src/actions/ActivityAction.lua
@@ -266,6 +266,47 @@ function _M.actCalendaTaskRpc(agent, data) | @@ -266,6 +266,47 @@ function _M.actCalendaTaskRpc(agent, data) | ||
266 | return true | 266 | return true |
267 | end | 267 | end |
268 | 268 | ||
269 | +function _M.actCalendaTmpTaskRpc(agent, data) | ||
270 | + local role = agent.role | ||
271 | + local msg = MsgPack.unpack(data) | ||
272 | + local taskId = msg.id | ||
273 | + local calTask = role:getProperty("calTask1") or {} | ||
274 | + local record = calTask["r"] or {} | ||
275 | + local flag = record[taskId] or 0 | ||
276 | + if flag == 1 then return 1 end | ||
277 | + local open, actId = role.activity:isOpen("CalendaTaskTmp") | ||
278 | + local actData = csvdb["activity_ctrlCsv"][actId] | ||
279 | + if not open then return 2 end | ||
280 | + if not actData then return 3 end | ||
281 | + | ||
282 | + local taskList = csvdb["activity_taskCsv"][actData.condition] | ||
283 | + if not taskList then return 4 end | ||
284 | + local taskCfg = taskList[taskId] | ||
285 | + if not taskCfg then return 5 end | ||
286 | + if taskCfg.key ~= actData.condition then return 6 end | ||
287 | + | ||
288 | + if (calTask[taskId] or 0) < taskCfg.condition1 then return 7 end | ||
289 | + | ||
290 | + record[taskId] = 1 | ||
291 | + calTask["r"] = record | ||
292 | + | ||
293 | + role:updateProperty({field = "calTask", value = calTask}) | ||
294 | + | ||
295 | + local reward, change = role:award(taskCfg.reward, {log = {desc = "calendaTask"}}) | ||
296 | + | ||
297 | + role:log("activity", { | ||
298 | + activity_id = taskId, -- 活动ID(或活动指定任务的ID) | ||
299 | + activity_type = role.activity.ActivityType.CalendaTaskTmp, -- 活动类型,见活动类型枚举表 | ||
300 | + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | ||
301 | + }) | ||
302 | + | ||
303 | + role:checkTaskEnter("FinishSpeTask", {taskId = taskId, actId = actId}) | ||
304 | + | ||
305 | + SendPacket(actionCodes.Activity_actCalendaTmpTaskRpc, MsgPack.pack(role:packReward(reward, change))) | ||
306 | + | ||
307 | + return true | ||
308 | +end | ||
309 | + | ||
269 | function _M.exchangeRpc(agent, data) | 310 | function _M.exchangeRpc(agent, data) |
270 | local role = agent.role | 311 | local role = agent.role |
271 | local msg = MsgPack.unpack(data) | 312 | local msg = MsgPack.unpack(data) |
@@ -1097,11 +1138,103 @@ function _M.friendHelpRpc(agent, data) | @@ -1097,11 +1138,103 @@ function _M.friendHelpRpc(agent, data) | ||
1097 | 1138 | ||
1098 | local reward, change | 1139 | local reward, change |
1099 | if next(award) then | 1140 | if next(award) then |
1100 | - reward, change = role:award(award, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) | 1141 | + reward, change = role:award(award, {log = {desc = "actFriendHelp", int1 = actid}}) |
1101 | end | 1142 | end |
1102 | role.activity:updateActData("FriendEnergy", actData) | 1143 | role.activity:updateActData("FriendEnergy", actData) |
1103 | SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = result, reward = reward})) | 1144 | SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = result, reward = reward})) |
1104 | return true | 1145 | return true |
1105 | end | 1146 | end |
1106 | 1147 | ||
1148 | +-- 战令活动奖励 | ||
1149 | +function _M.battleCommandRpc(agent, data) | ||
1150 | + local role = agent.role | ||
1151 | + local msg = MsgPack.unpack(data) | ||
1152 | + local actid = msg.actid -- 活动id | ||
1153 | + local index = msg.index -- 领取的阶段id | ||
1154 | + local pay = msg.pay -- 是否是超级奖励 | ||
1155 | + | ||
1156 | + if not role.activity:isOpenById(actid, "BattleCommand") then return 1 end | ||
1157 | + local actCtrlData = csvdb["activity_ctrlCsv"][actid] | ||
1158 | + | ||
1159 | + if not actCtrlData then return end | ||
1160 | + | ||
1161 | + local actData = role.activity:getActData("BattleCommand") or {} | ||
1162 | + if pay and not actData["unlock"] then return 2 end | ||
1163 | + | ||
1164 | + local bpCfg = csvdb["activity_battlepass_rewardCsv"][actid] | ||
1165 | + if not bpCfg then return 3 end | ||
1166 | + | ||
1167 | + bpCfg = bpCfg[index] | ||
1168 | + if not bpCfg then return 4 end | ||
1169 | + | ||
1170 | + if (actData["lvl"] or 0) < bpCfg["typeId"] then return 5 end | ||
1171 | + | ||
1172 | + local record = "" | ||
1173 | + if pay then | ||
1174 | + record = actData["payR"] or "" | ||
1175 | + else | ||
1176 | + record = actData["freeR"] or "" | ||
1177 | + end | ||
1178 | + | ||
1179 | + local flag = string.char(string.getbit(record, index)) | ||
1180 | + | ||
1181 | + if flag == "1" then | ||
1182 | + return 4 | ||
1183 | + end | ||
1184 | + | ||
1185 | + record = string.setbit(record, index) | ||
1186 | + local award = "" | ||
1187 | + if pay then | ||
1188 | + actData["payR"] = record | ||
1189 | + award = bpCfg["rewardNormal"] | ||
1190 | + else | ||
1191 | + actData["freeR"] = record | ||
1192 | + award = bpCfg["rewardHigh"] | ||
1193 | + end | ||
1194 | + | ||
1195 | + role.activity:updateActData("BattleCommand", actData) | ||
1196 | + | ||
1197 | + local reward, change = role:award(award, {log = {desc = "actBattleCommand", int1 = actid, int2 = index}}) | ||
1198 | + | ||
1199 | + SendPacket(actionCodes.Activity_battleCommandRpc, MsgPack.pack(role:packReward(reward, change))) | ||
1200 | + return true | ||
1201 | +end | ||
1202 | + | ||
1203 | +function _M.buyBattleCommandLvlRpc(agent, data) | ||
1204 | + local role = agent.role | ||
1205 | + local msg = MsgPack.unpack(data) | ||
1206 | + local actid = msg.actid -- 活动id | ||
1207 | + | ||
1208 | + if not role.activity:isOpenById(actid, "BattleCommand") then return 1 end | ||
1209 | + local actCtrlData = csvdb["activity_ctrlCsv"][actid] | ||
1210 | + | ||
1211 | + if not actCtrlData then return 2 end | ||
1212 | + | ||
1213 | + local bpCfg = csvdb["activity_battlepass_rewardCsv"][actid] | ||
1214 | + if not bpCfg then return 3 end | ||
1215 | + | ||
1216 | + local actData = role.activity:getActData("BattleCommand") or {} | ||
1217 | + | ||
1218 | + local curLvl = actData["lvl"] or 0 | ||
1219 | + local nextLvl = curLvl + 1 | ||
1220 | + if curLvl >= bpCfg[#bpCfg]["type"] then return 4 end | ||
1221 | + local cost = 0 | ||
1222 | + for i = 1, #bpCfg do | ||
1223 | + local cfg = bpCfg[i] | ||
1224 | + if cfg["type"] == curLvl then | ||
1225 | + cost = cfg["cost"] | ||
1226 | + break | ||
1227 | + end | ||
1228 | + end | ||
1229 | + if cost == 0 then return 5 end | ||
1230 | + | ||
1231 | + if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return 6 end | ||
1232 | + role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}}) | ||
1233 | + actData["lvl"] = nextLvl | ||
1234 | + role.activity:updateActData("BattleCommand", actData) | ||
1235 | + | ||
1236 | + SendPacket(actionCodes.Activity_buyBattleCommandLvlRpc, MsgPack.pack({})) | ||
1237 | + return true | ||
1238 | +end | ||
1239 | + | ||
1107 | return _M | 1240 | return _M |
1108 | \ No newline at end of file | 1241 | \ No newline at end of file |
src/models/Activity.lua
@@ -35,6 +35,8 @@ Activity.ActivityType = { | @@ -35,6 +35,8 @@ Activity.ActivityType = { | ||
35 | FriendEnergy = 30, -- 好友互赠能量活动 | 35 | FriendEnergy = 30, -- 好友互赠能量活动 |
36 | AdvLevel = 33, -- 拾荒关卡 | 36 | AdvLevel = 33, -- 拾荒关卡 |
37 | BattleCommand = 34, -- 战令活动 | 37 | BattleCommand = 34, -- 战令活动 |
38 | + | ||
39 | + CalendaTaskTmp = 38, -- 新春任务活动 | ||
38 | } | 40 | } |
39 | 41 | ||
40 | local function checkActivityType(activityType) | 42 | local function checkActivityType(activityType) |
@@ -486,11 +488,78 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | @@ -486,11 +488,78 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | ||
486 | role:checkTaskEnter("RuneQualityCollect", {}) | 488 | role:checkTaskEnter("RuneQualityCollect", {}) |
487 | 489 | ||
488 | end, | 490 | end, |
491 | + ["crossDay"] = function(self, actType, notify, actId) | ||
492 | + local actData = self.owner:getProperty("CalTask") or {} | ||
493 | + local record = actData["r"] or {} | ||
494 | + local actCfg = csvdb["activity_taskCsv"][actId] | ||
495 | + if not actCfg then return end | ||
496 | + local change = false | ||
497 | + for taskId, cfg in pairs(actCfg) do | ||
498 | + if cfg["resetType"] == 1 then -- 每日充值 | ||
499 | + record[taskId] = nil | ||
500 | + actData[taskId] = nil | ||
501 | + change = true | ||
502 | + end | ||
503 | + end | ||
504 | + if change then | ||
505 | + self.owner:updateProperty({field="CalTask", value=actData}) | ||
506 | + end | ||
507 | + end, | ||
489 | ["close"] = function(self, actType, notify) | 508 | ["close"] = function(self, actType, notify) |
490 | self.owner:updateProperty({field="CalTask", value={}}) | 509 | self.owner:updateProperty({field="CalTask", value={}}) |
491 | end, | 510 | end, |
492 | } | 511 | } |
493 | 512 | ||
513 | +-- 活动任务 仅供春节活动使用 防冲突 | ||
514 | +activityFunc[Activity.ActivityType.CalendaTaskTmp] = { | ||
515 | + ["init"] = function(self, actType, isCrossDay, notify) | ||
516 | + local calTask = self.owner:getProperty("CalTask1") | ||
517 | + calTask = {} | ||
518 | + local role = self.owner | ||
519 | + local buildL = role.dinerData:getProperty("buildL") | ||
520 | + local curLevel = buildL:getv(1, 1) | ||
521 | + role:checkTaskEnter("DinerLevelUp", {level = curLevel}) | ||
522 | + | ||
523 | + role:checkTaskEnter("HeroLvlCollect", {}) | ||
524 | + role:checkTaskEnter("HeroQualityCollect", {}) | ||
525 | + | ||
526 | + local curPopular = role.dinerData:getProperty("popular") | ||
527 | + role:checkTaskEnter("DinerPopular", {count = curPopular}) | ||
528 | + | ||
529 | + local rLevel = role:getProperty("level") | ||
530 | + role:checkTaskEnter("RoleLevelUp", {level = rLevel}) | ||
531 | + | ||
532 | + local towerInfo = role:getProperty("towerInfo") | ||
533 | + role:checkTaskEnter("TowerPass", {level = towerInfo.l}) | ||
534 | + --"PvpWin" | ||
535 | + --role:checkTaskEnter("HangPass", {id = 0}) | ||
536 | + role:checkCalendaTask(true, 15, 3) | ||
537 | + role:checkTaskEnter("HeroStarCollect", {}) | ||
538 | + role:checkTaskEnter("RuneQualityCollect", {}) | ||
539 | + | ||
540 | + end, | ||
541 | + ["crossDay"] = function(self, actType, notify, actId) | ||
542 | + local actData = self.owner:getProperty("CalTask1") or {} | ||
543 | + local record = actData["r"] or {} | ||
544 | + local actCfg = csvdb["activity_taskCsv"][actId] | ||
545 | + if not actCfg then return end | ||
546 | + local change = false | ||
547 | + for taskId, cfg in pairs(actCfg) do | ||
548 | + if cfg["resetType"] == 1 then -- 每日充值 | ||
549 | + record[taskId] = nil | ||
550 | + actData[taskId] = nil | ||
551 | + change = true | ||
552 | + end | ||
553 | + end | ||
554 | + if change then | ||
555 | + self.owner:updateProperty({field="CalTask1", value=actData}) | ||
556 | + end | ||
557 | + end, | ||
558 | + ["close"] = function(self, actType, notify) | ||
559 | + self.owner:updateProperty({field="CalTask1", value={}}) | ||
560 | + end, | ||
561 | +} | ||
562 | + | ||
494 | -- 兑换 | 563 | -- 兑换 |
495 | activityFunc[Activity.ActivityType.Exchange] = { | 564 | activityFunc[Activity.ActivityType.Exchange] = { |
496 | ["init"] = function(self, actType, isCrossDay, notify, actId) | 565 | ["init"] = function(self, actType, isCrossDay, notify, actId) |
@@ -901,7 +970,7 @@ activityFunc[Activity.ActivityType.BattleCommand] = { | @@ -901,7 +970,7 @@ activityFunc[Activity.ActivityType.BattleCommand] = { | ||
901 | local data = {unlock = 0, freeR = "", payR = "", lvl = 0, sum = 0} | 970 | local data = {unlock = 0, freeR = "", payR = "", lvl = 0, sum = 0} |
902 | self:updateActData(actType, data, not notify) | 971 | self:updateActData(actType, data, not notify) |
903 | end, | 972 | end, |
904 | - ["check"] = function(self, actType, notify, id, count) -- 检查 | 973 | + ["check"] = function(self, actType, notify, id, count) -- 检查 itemid, count |
905 | local isOpen, actId = self:isOpen(actType) | 974 | local isOpen, actId = self:isOpen(actType) |
906 | local actData = self:getActData(actType) or {} | 975 | local actData = self:getActData(actType) or {} |
907 | local actCfg = csvdb["activity_ctrlCsv"][actId] | 976 | local actCfg = csvdb["activity_ctrlCsv"][actId] |
@@ -909,7 +978,23 @@ activityFunc[Activity.ActivityType.BattleCommand] = { | @@ -909,7 +978,23 @@ activityFunc[Activity.ActivityType.BattleCommand] = { | ||
909 | if actCfg.condition1 == "" then return end | 978 | if actCfg.condition1 == "" then return end |
910 | local itemId = tonumber(actCfg.condition2) | 979 | local itemId = tonumber(actCfg.condition2) |
911 | if itemId == id and count > 0 then | 980 | if itemId == id and count > 0 then |
912 | - actData["sum"] = actData["sum"] + count | 981 | + local total = actData["sum"] + count |
982 | + local curLvl = actData["lvl"] or 0 | ||
983 | + if actCfg.condition == 1 then -- 代表sum需要转换为等级 | ||
984 | + local bpCfg = csvdb["activity_battlepass_rewardCsv"][actId] | ||
985 | + if not bpCfg then return end | ||
986 | + for i = 1, #bpCfg do | ||
987 | + local cfg = bpCfg[i] | ||
988 | + if cfg["type"] > curLvl then | ||
989 | + if total < cfg["condition"] then break end | ||
990 | + total = total - cfg["condition"] | ||
991 | + curLvl = curLvl + 1 | ||
992 | + end | ||
993 | + end | ||
994 | + actData["lvl"] = curLvl | ||
995 | + actData["sum"] = total | ||
996 | + end | ||
997 | + | ||
913 | self:updateActData(actType, actData) | 998 | self:updateActData(actType, actData) |
914 | end | 999 | end |
915 | end, | 1000 | end, |
src/models/Role.lua
@@ -183,6 +183,7 @@ Role.schema = { | @@ -183,6 +183,7 @@ Role.schema = { | ||
183 | feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 | 183 | feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 |
184 | 184 | ||
185 | calTask = {"table", {}}, -- 英雄令活动 日历任务活动 | 185 | calTask = {"table", {}}, -- 英雄令活动 日历任务活动 |
186 | + calTask1 = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用 | ||
186 | radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv | 187 | radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv |
187 | } | 188 | } |
188 | 189 | ||
@@ -409,6 +410,7 @@ function Role:data() | @@ -409,6 +410,7 @@ function Role:data() | ||
409 | feedback = self:getProperty("feedback"), | 410 | feedback = self:getProperty("feedback"), |
410 | ctime = self:getProperty("ctime"), | 411 | ctime = self:getProperty("ctime"), |
411 | calTask = self:getProperty("calTask"), | 412 | calTask = self:getProperty("calTask"), |
413 | + calTask1 = self:getProperty("calTask1"), | ||
412 | radioTask = self:getProperty("radioTask"), | 414 | radioTask = self:getProperty("radioTask"), |
413 | } | 415 | } |
414 | end | 416 | end |
src/models/RoleLog.lua
@@ -53,6 +53,8 @@ local ItemReason = { | @@ -53,6 +53,8 @@ local ItemReason = { | ||
53 | worldBossReward = 137, -- 世界boss翻牌奖励 | 53 | worldBossReward = 137, -- 世界boss翻牌奖励 |
54 | commonSign = 138, -- 每日活跃签到 | 54 | commonSign = 138, -- 每日活跃签到 |
55 | actFriendHelp = 139,-- 好友能量互助活动 | 55 | actFriendHelp = 139,-- 好友能量互助活动 |
56 | + actBattleCommand = 140, -- 活动战令 | ||
57 | + actBuyBpLevel = 141, -- 购买活动战令等级 | ||
56 | 58 | ||
57 | 59 | ||
58 | advHang = 301, -- 拾荒挂机 | 60 | advHang = 301, -- 拾荒挂机 |
src/models/RolePlugin.lua
@@ -1809,7 +1809,7 @@ function RolePlugin.bind(Role) | @@ -1809,7 +1809,7 @@ function RolePlugin.bind(Role) | ||
1809 | self:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}}) | 1809 | self:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}}) |
1810 | elseif rechargeData.shop == 2 then --通行证商店 | 1810 | elseif rechargeData.shop == 2 then --通行证商店 |
1811 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 1811 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) |
1812 | - self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id) | 1812 | + self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) |
1813 | elseif rechargeData.shop == 3 then -- 礼包商店 | 1813 | elseif rechargeData.shop == 3 then -- 礼包商店 |
1814 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 1814 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) |
1815 | else | 1815 | else |
src/models/RoleTask.lua
@@ -288,6 +288,40 @@ local CalendaTaskListener = { | @@ -288,6 +288,40 @@ local CalendaTaskListener = { | ||
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | +local CalendaTaskTmpListener = { | ||
292 | + func = "checkCalendaTaskTmp", | ||
293 | + listen = { | ||
294 | + [TaskType.DrawHero] = {{1, 1, f("count")}}, | ||
295 | + [TaskType.BonusPass]= {{2, 1, f("count")}}, | ||
296 | + [TaskType.AdvStart]= {{3, 1}}, | ||
297 | + [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, | ||
298 | + [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 | ||
299 | + [TaskType.AdvHang]= {{6, 1}}, ---- | ||
300 | + [TaskType.HeroQualityCollect]= {{7, 3}}, | ||
301 | + [TaskType.OverOderTask]= {{8, 1}}, | ||
302 | + [TaskType.VillageApply]= {{9, 1}}, | ||
303 | + [TaskType.PvpWin]= {{10, 2, f("score")}}, | ||
304 | + [TaskType.DinerPopular]= {{11, 2, f("count")}}, | ||
305 | + [TaskType.RoleLevelUp]= {{12, 2, f("level")}}, | ||
306 | + [TaskType.TowerPass]= {{13, 2, f("level")}}, | ||
307 | + [TaskType.HeroTalent]= {{14, 1}}, | ||
308 | + [TaskType.HangPass]= {{15, 3}}, | ||
309 | + [TaskType.HeroStarCollect]= {{16, 3}}, | ||
310 | + [TaskType.FoodSell]= {{17, 1, f("count")}}, | ||
311 | + [TaskType.HangGet]= {{18, 3, f("reward")}}, | ||
312 | + [TaskType.RuneQualityCollect]= {{19, 3}}, | ||
313 | + [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, | ||
314 | + [TaskType.RadioTaskStart] = {{21, 1}, {22, 3, f("heroCnt")}}, | ||
315 | + [TaskType.BonusQuick] = {{23, 1, f("count")}}, | ||
316 | + [TaskType.AdvHangHeroCnt] = {{24, 3, f("HeroCnt")}}, | ||
317 | + [TaskType.AdvKillBoss] = {{25, 1}}, | ||
318 | + [TaskType.AdvMineKill] = {{26, 1}}, | ||
319 | + [TaskType.PvpBattle] = {{27, 1}}, | ||
320 | + [TaskType.FinishSpeTask] = {{28, 3, f("taskId"), f("actId")}}, | ||
321 | + | ||
322 | + } | ||
323 | +} | ||
324 | + | ||
291 | local TaskListeners = { | 325 | local TaskListeners = { |
292 | StoryListener, | 326 | StoryListener, |
293 | CommonListener, | 327 | CommonListener, |
@@ -296,6 +330,7 @@ local TaskListeners = { | @@ -296,6 +330,7 @@ local TaskListeners = { | ||
296 | ActivityListener, | 330 | ActivityListener, |
297 | StoreListener, | 331 | StoreListener, |
298 | CalendaTaskListener, | 332 | CalendaTaskListener, |
333 | + CalendaTaskTmpListener, | ||
299 | } | 334 | } |
300 | 335 | ||
301 | local RoleTask = {} | 336 | local RoleTask = {} |
@@ -736,6 +771,119 @@ function RoleTask.bind(Role) | @@ -736,6 +771,119 @@ function RoleTask.bind(Role) | ||
736 | --dump(calTask) | 771 | --dump(calTask) |
737 | end | 772 | end |
738 | 773 | ||
774 | + function Role:checkCalendaTaskTmp(notNotify, mainType, subType, param1, param2) | ||
775 | + --print("check calenda taskl", mainType, subType, param1, param2) | ||
776 | + if not self.activity then return end | ||
777 | + local open, actId = self.activity:isOpen("CalendaTaskTmp") | ||
778 | + local actData = csvdb["activity_ctrlCsv"][actId] | ||
779 | + if not actData then return end | ||
780 | + if not open then return end | ||
781 | + | ||
782 | + local change = false | ||
783 | + local calTask = self:getProperty("calTask1") or {} | ||
784 | + param1 = param1 or 1 | ||
785 | + | ||
786 | + local cid = actData.condition | ||
787 | + for k, taskList in pairs(csvdb["activity_taskCsv"]) do | ||
788 | + if k == cid then | ||
789 | + for id, cfg in pairs(taskList) do | ||
790 | + if cfg.type == mainType then | ||
791 | + if subType == 1 then -- 增加数值 | ||
792 | + calTask[id] = (calTask[id] or 0) + param1 | ||
793 | + elseif subType == 2 then -- 直接赋值 | ||
794 | + calTask[id] = param1 | ||
795 | + elseif subType == 3 then -- 自定义类型 | ||
796 | + if cfg.type == 7 then -- 英雄品质收集进度 | ||
797 | + local count = 0 | ||
798 | + for _, hero in pairs(self.heros) do | ||
799 | + local unitData = csvdb["unitCsv"][hero:getProperty("type")] | ||
800 | + if unitData then | ||
801 | + if cfg.condition2 <= unitData.rare then | ||
802 | + count = count + 1 | ||
803 | + end | ||
804 | + end | ||
805 | + end | ||
806 | + if (calTask[id] or 0) < count then | ||
807 | + calTask[id] = count | ||
808 | + end | ||
809 | + elseif cfg.type == 5 then -- 英雄等级收集进度 | ||
810 | + local count = 0 | ||
811 | + for _, hero in pairs(self.heros) do | ||
812 | + if cfg.condition2 <= hero:getProperty("level") then | ||
813 | + count = count + 1 | ||
814 | + end | ||
815 | + end | ||
816 | + if (calTask[id] or 0) < count then | ||
817 | + calTask[id] = count | ||
818 | + end | ||
819 | + elseif cfg.type == 16 then -- 英雄星级收集进度 | ||
820 | + local count = 0 | ||
821 | + for _, hero in pairs(self.heros) do | ||
822 | + if cfg.condition2 <= hero:getProperty("wakeL") then | ||
823 | + count = count + 1 | ||
824 | + end | ||
825 | + end | ||
826 | + if (calTask[id] or 0) < count then | ||
827 | + calTask[id] = count | ||
828 | + end | ||
829 | + elseif cfg.type == 18 then -- 挂机累计收获id,y个 | ||
830 | + for rid, v in pairs(param1) do | ||
831 | + if cfg.condition2 == rid then | ||
832 | + calTask[id] = (calTask[id] or 0) + v | ||
833 | + end | ||
834 | + end | ||
835 | + elseif cfg.type == 19 then -- x名英雄装备y品质以上符文套装 | ||
836 | + local count = 0 | ||
837 | + for _, hero in pairs(self.heros) do | ||
838 | + local rcount = 0 | ||
839 | + for _,uid in pairs(hero:getRunes()) do | ||
840 | + if uid > 0 then | ||
841 | + local runeData = self.runeBag[uid] | ||
842 | + if runeData then | ||
843 | + local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")] | ||
844 | + | ||
845 | + if csvData and cfg.condition2 <= csvData.rarity then | ||
846 | + rcount = rcount + 1 | ||
847 | + end | ||
848 | + end | ||
849 | + end | ||
850 | + end | ||
851 | + if rcount == 6 then | ||
852 | + count = count + 1 | ||
853 | + end | ||
854 | + end | ||
855 | + calTask[id] = count | ||
856 | + elseif cfg.type == 20 then -- 开启x品质时钟箱子 | ||
857 | + if cfg.condition2 <= (param2 or 0) then | ||
858 | + calTask[id] = (calTask[id] or 0) + param2 | ||
859 | + end | ||
860 | + elseif cfg.type == 15 then -- 通关关卡 | ||
861 | + if (calTask[id] or 0) == 0 then | ||
862 | + local hangPass = self:getProperty("hangPass") | ||
863 | + local diff = math.floor(cfg.condition2 / 10000) | ||
864 | + if (hangPass[diff] or 0) >= cfg.condition1 then | ||
865 | + calTask[id] = 1 | ||
866 | + end | ||
867 | + end | ||
868 | + elseif cfg.type == 22 then -- 电台任务出勤人数 | ||
869 | + calTask[id] = (calTask[id] or 0) + (param1 or 0) | ||
870 | + elseif cfg.type == 24 then -- 代理拾荒出勤人数 | ||
871 | + calTask[id] = (calTask[id] or 0) + (param1 or 0) | ||
872 | + elseif cfg.type == 28 then -- 完成指定任务 | ||
873 | + --print(actId,param2, cfg.condition2, param1) | ||
874 | + if actId == param2 and cfg.condition2 == param1 then | ||
875 | + calTask[id] = (calTask[id] or 0) + 1 | ||
876 | + end | ||
877 | + end | ||
878 | + end | ||
879 | + end | ||
880 | + end | ||
881 | + end | ||
882 | + end | ||
883 | + self:updateProperty({field = "calTask1", value = calTask, notNotify = notNotify}) | ||
884 | + --dump(calTask) | ||
885 | + end | ||
886 | + | ||
739 | end | 887 | end |
740 | 888 | ||
741 | return RoleTask | 889 | return RoleTask |
742 | \ No newline at end of file | 890 | \ No newline at end of file |