diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index b4f10ac..a21fc09 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -231,6 +231,8 @@ actionCodes = { Activity_crisisMilestoneRpc = 665, Activity_commonSignRpc = 666, Activity_friendHelpRpc = 667, + Activity_battleCommandRpc = 668, + Activity_actCalendaTmpTaskRpc = 659, Radio_startQuestRpc = 700, Radio_finishQuestRpc = 701, diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index 8787b93..20f91bf 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -266,6 +266,47 @@ function _M.actCalendaTaskRpc(agent, data) return true end +function _M.actCalendaTmpTaskRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local taskId = msg.id + local calTask = role:getProperty("calTask1") or {} + local record = calTask["r"] or {} + local flag = record[taskId] or 0 + if flag == 1 then return 1 end + local open, actId = role.activity:isOpen("CalendaTaskTmp") + local actData = csvdb["activity_ctrlCsv"][actId] + if not open then return 2 end + if not actData then return 3 end + + local taskList = csvdb["activity_taskCsv"][actData.condition] + if not taskList then return 4 end + local taskCfg = taskList[taskId] + if not taskCfg then return 5 end + if taskCfg.key ~= actData.condition then return 6 end + + if (calTask[taskId] or 0) < taskCfg.condition1 then return 7 end + + record[taskId] = 1 + calTask["r"] = record + + role:updateProperty({field = "calTask", value = calTask}) + + local reward, change = role:award(taskCfg.reward, {log = {desc = "calendaTask"}}) + + role:log("activity", { + activity_id = taskId, -- 活动ID(或活动指定任务的ID) + activity_type = role.activity.ActivityType.CalendaTaskTmp, -- 活动类型,见活动类型枚举表 + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + }) + + role:checkTaskEnter("FinishSpeTask", {taskId = taskId, actId = actId}) + + SendPacket(actionCodes.Activity_actCalendaTmpTaskRpc, MsgPack.pack(role:packReward(reward, change))) + + return true +end + function _M.exchangeRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) @@ -1097,11 +1138,103 @@ function _M.friendHelpRpc(agent, data) local reward, change if next(award) then - reward, change = role:award(award, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) + reward, change = role:award(award, {log = {desc = "actFriendHelp", int1 = actid}}) end role.activity:updateActData("FriendEnergy", actData) SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = result, reward = reward})) return true end +-- 战令活动奖励 +function _M.battleCommandRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local actid = msg.actid -- 活动id + local index = msg.index -- 领取的阶段id + local pay = msg.pay -- 是否是超级奖励 + + if not role.activity:isOpenById(actid, "BattleCommand") then return 1 end + local actCtrlData = csvdb["activity_ctrlCsv"][actid] + + if not actCtrlData then return end + + local actData = role.activity:getActData("BattleCommand") or {} + if pay and not actData["unlock"] then return 2 end + + local bpCfg = csvdb["activity_battlepass_rewardCsv"][actid] + if not bpCfg then return 3 end + + bpCfg = bpCfg[index] + if not bpCfg then return 4 end + + if (actData["lvl"] or 0) < bpCfg["typeId"] then return 5 end + + local record = "" + if pay then + record = actData["payR"] or "" + else + record = actData["freeR"] or "" + end + + local flag = string.char(string.getbit(record, index)) + + if flag == "1" then + return 4 + end + + record = string.setbit(record, index) + local award = "" + if pay then + actData["payR"] = record + award = bpCfg["rewardNormal"] + else + actData["freeR"] = record + award = bpCfg["rewardHigh"] + end + + role.activity:updateActData("BattleCommand", actData) + + local reward, change = role:award(award, {log = {desc = "actBattleCommand", int1 = actid, int2 = index}}) + + SendPacket(actionCodes.Activity_battleCommandRpc, MsgPack.pack(role:packReward(reward, change))) + return true +end + +function _M.buyBattleCommandLvlRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local actid = msg.actid -- 活动id + + if not role.activity:isOpenById(actid, "BattleCommand") then return 1 end + local actCtrlData = csvdb["activity_ctrlCsv"][actid] + + if not actCtrlData then return 2 end + + local bpCfg = csvdb["activity_battlepass_rewardCsv"][actid] + if not bpCfg then return 3 end + + local actData = role.activity:getActData("BattleCommand") or {} + + local curLvl = actData["lvl"] or 0 + local nextLvl = curLvl + 1 + if curLvl >= bpCfg[#bpCfg]["type"] then return 4 end + local cost = 0 + for i = 1, #bpCfg do + local cfg = bpCfg[i] + if cfg["type"] == curLvl then + cost = cfg["cost"] + break + end + end + if cost == 0 then return 5 end + + if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return 6 end + role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}}) + actData["lvl"] = nextLvl + role.activity:updateActData("BattleCommand", actData) + + SendPacket(actionCodes.Activity_buyBattleCommandLvlRpc, MsgPack.pack({})) + return true +end + return _M \ No newline at end of file diff --git a/src/csvdata b/src/csvdata index aa011fc..d79bc81 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit aa011fcf9fb290ff5a1d04e72fa1cd7f9598c9ea +Subproject commit d79bc812353a7e7f9f7e9826ea38e54e0e7339d9 diff --git a/src/models/Activity.lua b/src/models/Activity.lua index eb2326c..ea465b3 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -35,6 +35,8 @@ Activity.ActivityType = { FriendEnergy = 30, -- 好友互赠能量活动 AdvLevel = 33, -- 拾荒关卡 BattleCommand = 34, -- 战令活动 + + CalendaTaskTmp = 38, -- 新春任务活动 } local function checkActivityType(activityType) @@ -486,11 +488,78 @@ activityFunc[Activity.ActivityType.CalendaTask] = { role:checkTaskEnter("RuneQualityCollect", {}) end, + ["crossDay"] = function(self, actType, notify, actId) + local actData = self.owner:getProperty("CalTask") or {} + local record = actData["r"] or {} + local actCfg = csvdb["activity_taskCsv"][actId] + if not actCfg then return end + local change = false + for taskId, cfg in pairs(actCfg) do + if cfg["resetType"] == 1 then -- 每日充值 + record[taskId] = nil + actData[taskId] = nil + change = true + end + end + if change then + self.owner:updateProperty({field="CalTask", value=actData}) + end + end, ["close"] = function(self, actType, notify) self.owner:updateProperty({field="CalTask", value={}}) end, } +-- 活动任务 仅供春节活动使用 防冲突 +activityFunc[Activity.ActivityType.CalendaTaskTmp] = { + ["init"] = function(self, actType, isCrossDay, notify) + local calTask = self.owner:getProperty("CalTask1") + calTask = {} + local role = self.owner + local buildL = role.dinerData:getProperty("buildL") + local curLevel = buildL:getv(1, 1) + role:checkTaskEnter("DinerLevelUp", {level = curLevel}) + + role:checkTaskEnter("HeroLvlCollect", {}) + role:checkTaskEnter("HeroQualityCollect", {}) + + local curPopular = role.dinerData:getProperty("popular") + role:checkTaskEnter("DinerPopular", {count = curPopular}) + + local rLevel = role:getProperty("level") + role:checkTaskEnter("RoleLevelUp", {level = rLevel}) + + local towerInfo = role:getProperty("towerInfo") + role:checkTaskEnter("TowerPass", {level = towerInfo.l}) + --"PvpWin" + --role:checkTaskEnter("HangPass", {id = 0}) + role:checkCalendaTask(true, 15, 3) + role:checkTaskEnter("HeroStarCollect", {}) + role:checkTaskEnter("RuneQualityCollect", {}) + + end, + ["crossDay"] = function(self, actType, notify, actId) + local actData = self.owner:getProperty("CalTask1") or {} + local record = actData["r"] or {} + local actCfg = csvdb["activity_taskCsv"][actId] + if not actCfg then return end + local change = false + for taskId, cfg in pairs(actCfg) do + if cfg["resetType"] == 1 then -- 每日充值 + record[taskId] = nil + actData[taskId] = nil + change = true + end + end + if change then + self.owner:updateProperty({field="CalTask1", value=actData}) + end + end, + ["close"] = function(self, actType, notify) + self.owner:updateProperty({field="CalTask1", value={}}) + end, +} + -- 兑换 activityFunc[Activity.ActivityType.Exchange] = { ["init"] = function(self, actType, isCrossDay, notify, actId) @@ -901,7 +970,7 @@ activityFunc[Activity.ActivityType.BattleCommand] = { local data = {unlock = 0, freeR = "", payR = "", lvl = 0, sum = 0} self:updateActData(actType, data, not notify) end, - ["check"] = function(self, actType, notify, id, count) -- 检查 + ["check"] = function(self, actType, notify, id, count) -- 检查 itemid, count local isOpen, actId = self:isOpen(actType) local actData = self:getActData(actType) or {} local actCfg = csvdb["activity_ctrlCsv"][actId] @@ -909,7 +978,23 @@ activityFunc[Activity.ActivityType.BattleCommand] = { if actCfg.condition1 == "" then return end local itemId = tonumber(actCfg.condition2) if itemId == id and count > 0 then - actData["sum"] = actData["sum"] + count + local total = actData["sum"] + count + local curLvl = actData["lvl"] or 0 + if actCfg.condition == 1 then -- 代表sum需要转换为等级 + local bpCfg = csvdb["activity_battlepass_rewardCsv"][actId] + if not bpCfg then return end + for i = 1, #bpCfg do + local cfg = bpCfg[i] + if cfg["type"] > curLvl then + if total < cfg["condition"] then break end + total = total - cfg["condition"] + curLvl = curLvl + 1 + end + end + actData["lvl"] = curLvl + actData["sum"] = total + end + self:updateActData(actType, actData) end end, diff --git a/src/models/Role.lua b/src/models/Role.lua index 263e1af..2614496 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -183,6 +183,7 @@ Role.schema = { feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 calTask = {"table", {}}, -- 英雄令活动 日历任务活动 + calTask1 = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用 radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv } @@ -409,6 +410,7 @@ function Role:data() feedback = self:getProperty("feedback"), ctime = self:getProperty("ctime"), calTask = self:getProperty("calTask"), + calTask1 = self:getProperty("calTask1"), radioTask = self:getProperty("radioTask"), } end diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index a5ece28..cbf0908 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -53,6 +53,8 @@ local ItemReason = { worldBossReward = 137, -- 世界boss翻牌奖励 commonSign = 138, -- 每日活跃签到 actFriendHelp = 139,-- 好友能量互助活动 + actBattleCommand = 140, -- 活动战令 + actBuyBpLevel = 141, -- 购买活动战令等级 advHang = 301, -- 拾荒挂机 diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index da4e852..863afe6 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1809,7 +1809,7 @@ function RolePlugin.bind(Role) self:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}}) elseif rechargeData.shop == 2 then --通行证商店 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) - self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id) + self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) elseif rechargeData.shop == 3 then -- 礼包商店 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) else diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 5bbf28e..85567e0 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -288,6 +288,40 @@ local CalendaTaskListener = { } } +local CalendaTaskTmpListener = { + func = "checkCalendaTaskTmp", + listen = { + [TaskType.DrawHero] = {{1, 1, f("count")}}, + [TaskType.BonusPass]= {{2, 1, f("count")}}, + [TaskType.AdvStart]= {{3, 1}}, + [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, + [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 + [TaskType.AdvHang]= {{6, 1}}, ---- + [TaskType.HeroQualityCollect]= {{7, 3}}, + [TaskType.OverOderTask]= {{8, 1}}, + [TaskType.VillageApply]= {{9, 1}}, + [TaskType.PvpWin]= {{10, 2, f("score")}}, + [TaskType.DinerPopular]= {{11, 2, f("count")}}, + [TaskType.RoleLevelUp]= {{12, 2, f("level")}}, + [TaskType.TowerPass]= {{13, 2, f("level")}}, + [TaskType.HeroTalent]= {{14, 1}}, + [TaskType.HangPass]= {{15, 3}}, + [TaskType.HeroStarCollect]= {{16, 3}}, + [TaskType.FoodSell]= {{17, 1, f("count")}}, + [TaskType.HangGet]= {{18, 3, f("reward")}}, + [TaskType.RuneQualityCollect]= {{19, 3}}, + [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, + [TaskType.RadioTaskStart] = {{21, 1}, {22, 3, f("heroCnt")}}, + [TaskType.BonusQuick] = {{23, 1, f("count")}}, + [TaskType.AdvHangHeroCnt] = {{24, 3, f("HeroCnt")}}, + [TaskType.AdvKillBoss] = {{25, 1}}, + [TaskType.AdvMineKill] = {{26, 1}}, + [TaskType.PvpBattle] = {{27, 1}}, + [TaskType.FinishSpeTask] = {{28, 3, f("taskId"), f("actId")}}, + + } +} + local TaskListeners = { StoryListener, CommonListener, @@ -296,6 +330,7 @@ local TaskListeners = { ActivityListener, StoreListener, CalendaTaskListener, + CalendaTaskTmpListener, } local RoleTask = {} @@ -736,6 +771,119 @@ function RoleTask.bind(Role) --dump(calTask) end + function Role:checkCalendaTaskTmp(notNotify, mainType, subType, param1, param2) + --print("check calenda taskl", mainType, subType, param1, param2) + if not self.activity then return end + local open, actId = self.activity:isOpen("CalendaTaskTmp") + local actData = csvdb["activity_ctrlCsv"][actId] + if not actData then return end + if not open then return end + + local change = false + local calTask = self:getProperty("calTask1") or {} + param1 = param1 or 1 + + local cid = actData.condition + for k, taskList in pairs(csvdb["activity_taskCsv"]) do + if k == cid then + for id, cfg in pairs(taskList) do + if cfg.type == mainType then + if subType == 1 then -- 增加数值 + calTask[id] = (calTask[id] or 0) + param1 + elseif subType == 2 then -- 直接赋值 + calTask[id] = param1 + elseif subType == 3 then -- 自定义类型 + if cfg.type == 7 then -- 英雄品质收集进度 + local count = 0 + for _, hero in pairs(self.heros) do + local unitData = csvdb["unitCsv"][hero:getProperty("type")] + if unitData then + if cfg.condition2 <= unitData.rare then + count = count + 1 + end + end + end + if (calTask[id] or 0) < count then + calTask[id] = count + end + elseif cfg.type == 5 then -- 英雄等级收集进度 + local count = 0 + for _, hero in pairs(self.heros) do + if cfg.condition2 <= hero:getProperty("level") then + count = count + 1 + end + end + if (calTask[id] or 0) < count then + calTask[id] = count + end + elseif cfg.type == 16 then -- 英雄星级收集进度 + local count = 0 + for _, hero in pairs(self.heros) do + if cfg.condition2 <= hero:getProperty("wakeL") then + count = count + 1 + end + end + if (calTask[id] or 0) < count then + calTask[id] = count + end + elseif cfg.type == 18 then -- 挂机累计收获id,y个 + for rid, v in pairs(param1) do + if cfg.condition2 == rid then + calTask[id] = (calTask[id] or 0) + v + end + end + elseif cfg.type == 19 then -- x名英雄装备y品质以上符文套装 + local count = 0 + for _, hero in pairs(self.heros) do + local rcount = 0 + for _,uid in pairs(hero:getRunes()) do + if uid > 0 then + local runeData = self.runeBag[uid] + if runeData then + local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")] + + if csvData and cfg.condition2 <= csvData.rarity then + rcount = rcount + 1 + end + end + end + end + if rcount == 6 then + count = count + 1 + end + end + calTask[id] = count + elseif cfg.type == 20 then -- 开启x品质时钟箱子 + if cfg.condition2 <= (param2 or 0) then + calTask[id] = (calTask[id] or 0) + param2 + end + elseif cfg.type == 15 then -- 通关关卡 + if (calTask[id] or 0) == 0 then + local hangPass = self:getProperty("hangPass") + local diff = math.floor(cfg.condition2 / 10000) + if (hangPass[diff] or 0) >= cfg.condition1 then + calTask[id] = 1 + end + end + elseif cfg.type == 22 then -- 电台任务出勤人数 + calTask[id] = (calTask[id] or 0) + (param1 or 0) + elseif cfg.type == 24 then -- 代理拾荒出勤人数 + calTask[id] = (calTask[id] or 0) + (param1 or 0) + elseif cfg.type == 28 then -- 完成指定任务 + --print(actId,param2, cfg.condition2, param1) + if actId == param2 and cfg.condition2 == param1 then + calTask[id] = (calTask[id] or 0) + 1 + end + end + end + end + end + end + end + self:updateProperty({field = "calTask1", value = calTask, notNotify = notNotify}) + --dump(calTask) + end + end return RoleTask \ No newline at end of file -- libgit2 0.21.2