diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index d832dc3..b4b9ab9 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -121,6 +121,10 @@ actionCodes = { Hero_changeSparkRpc = 227, Hero_saveGeniusTreeRpc = 228, Hero_stickersConvertRpc = 229, --兑换英雄贴纸 + Hero_trainStartRpc = 230, --开始魔鬼训练 + Hero_trainFinishRpc = 231, + Hero_trainTaskRewardRpc = 232, --领取魔鬼训练营任务 + Hero_trainQuickRpc = 233, --魔鬼训练营加速 Hang_startRpc = 251, Hang_checkRpc = 252, diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index d4f3a35..0d953ed 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -688,19 +688,36 @@ function _M.test(role, pms) if id > 100 then actid = tonum(pms.pm2, 0) end - --local hero = require ("actions.HeroAction") - --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) + --if id == 1 then + -- local hero = require ("actions.HeroAction") + -- local ret = hero.trainStartRpc({role = role}, MsgPack.pack({id = 1})) + -- if ret ~= true then + -- return ret + -- end + --elseif id == 2 then + -- local hero = require ("actions.HeroAction") + -- local ret = hero.trainFinishRpc({role = role}, MsgPack.pack({id = 1})) + -- if ret ~= true then + -- return ret + -- end + --elseif id == 3 then + -- local hero = require ("actions.HeroAction") + -- local ret = hero.trainQuickRpc({role = role}, MsgPack.pack({id = 1})) + -- if ret ~= true then + -- return ret + -- end + --end --role:sendMail(13, nil, "1=2", {111}) - local file = io.open("draw_hero_"..id..".csv", "a") - for i=1, 10000 do - local heroIds = _M.drawHero(role, id, actid) - for k, v in ipairs(heroIds) do - print((i - 1)* 10 + k, v) - file:write(v.."\n") - end - end - io.close(file) + --local file = io.open("draw_hero_"..id..".csv", "a") + --for i=1, 10000 do + -- local heroIds = _M.drawHero(role, id, actid) + -- for k, v in ipairs(heroIds) do + -- print((i - 1)* 10 + k, v) + -- file:write(v.."\n") + -- end + --end + --io.close(file) return "成功" end diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 358465b..779f52b 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -117,6 +117,8 @@ function _M.wakeRpc(agent, data) local hero = role.heros[msg.id] if not hero then return 1 end if hero:getProperty("wakeL") >= #csvdb["unit_wakeCsv"] then return 2 end + if hero:getProperty("trainTs") ~= 0 then return 9 end + local typ = hero:getProperty("type") local wakeData = csvdb["unit_wakeCsv"][hero:getProperty("wakeL")] if not wakeData then return 3 end @@ -180,6 +182,8 @@ function _M.wakeRpc(agent, data) role:checkTaskEnter("HeroStarCollect", {}) role:checkTaskEnter("HeroStartSum", {}) + role:checkTaskEnter("SSRHeroStarSum", {}) + role:checkTaskEnter("SRHeroStarSum", {}) return true end @@ -1435,4 +1439,149 @@ function _M.stickersConvertRpc(agent, data) return true end +function _M.trainStartRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local hero = role.heros[msg.id] + if not hero then return 1 end + local rare = hero:getRare() + if rare ~= HeroQuality.SSR and rare ~= HeroQuality.SR then return 2 end + local trainTimeCfg = (rare == HeroQuality.SSR and globalCsv.training_camp_ssr or globalCsv.training_camp_sr) + local trainCostCfg = (rare == HeroQuality.SSR and globalCsv.training_camp_ssr_cost or globalCsv.training_camp_sr_cost) + dump(trainTimeCfg) + dump(trainCostCfg) + + local curLevel = hero:getProperty("wakeL") + local trainTs = hero:getProperty("trainTs") + local sparkInfo = hero:getProperty("spark") + print(msg.id, rare, curLevel) + if trainTs ~= 0 then return 3 end + + local sec = trainTimeCfg[curLevel] or 0 + if sec == 0 then return 4 end + + if not trainCostCfg[curLevel] then return 10 end + + local costs = trainCostCfg[curLevel]:toNumMap() + + if not role:checkItemEnough(costs) then return 5 end + + -- 大于等于7的时候需要装备火花才能升 + if curLevel >= 7 then + if #sparkInfo == 0 then + return 6 + end + local ok = false + for _, info in ipairs(sparkInfo) do + local cfg = csvdb["sparkCsv"][info.cfg_id][info.level or 0] + if not cfg then return 7 end + if cfg.star == curLevel then + ok = true + break + end + end + if not ok then return 8 end + end + + if not role:costItems(costs, {log = {desc = "trainHero", int1 = hero:getProperty("type")}}) then return 9 end + + hero:updateProperty({field="trainTs", value = skynet.timex() + sec}) + + hero:mylog({desc = "trainHeroStart", int1 = hero:getProperty("type"), int2 = curLevel}) + + SendPacket(actionCodes.Hero_trainStartRpc, '') + + return true +end + +function _M.trainQuickRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local hero = role.heros[msg.id] + if not hero then return 1 end + local trainTs = hero:getProperty("trainTs") + if trainTs == 0 then return 2 end + local timeNow = skynet.timex() + if timeNow >= trainTs then return 3 end + + local h = math.ceil((trainTs - timeNow)/3600) + + local cost = {[ItemId.Jade] = h * (globalCsv.training_camp_quick or 60)} + if not role:checkItemEnough(cost) then return 4 end + + if not role:costItems(cost, {log = {desc = "trainQuickHero", int1 = hero:getProperty("type")}}) then return 9 end + + hero:updateProperty({field="trainTs", value = skynet.timex()}) + + hero:mylog({desc = "trainQuick", int1 = hero:getProperty("type")}) + + SendPacket(actionCodes.Hero_trainQuickRpc, '') + + return true +end + + +function _M.trainFinishRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local hero = role.heros[msg.id] + if not hero then return 1 end + + local curLevel = hero:getProperty("wakeL") + local trainTs = hero:getProperty("trainTs") + local typ = hero:getProperty("type") + if trainTs == 0 then return 2 end + if skynet.timex() < trainTs then return 3 end + + hero:updateProperty({field = "wakeL", delta = 1}) + hero:updateProperty({field = "trainTs", value = 0}) + + curLevel = curLevel + 1 + role:checkTaskEnter("Wake", {heroType = typ, wakeL = curLevel}) + if curLevel == 3 then -- 解锁cg + role:checkTaskEnter("WakeCG", {heroType = typ}) + role:checkTaskEnter("WakeCGSum", {count = 1}) + end + + if curLevel >= 4 then --自动觉醒技能 + local new = hero:increGeniusTree() + hero:updateProperty({field = "genius", value = new}) + end + hero:mylog({desc = "trainFinish", int1 = hero:getProperty("type")}) + + SendPacket(actionCodes.Hero_trainFinishRpc, '') + + role:checkTaskEnter("HeroStarCollect", {}) + role:checkTaskEnter("HeroStartSum", {}) + role:checkTaskEnter("SSRHeroStarSum", {}) + role:checkTaskEnter("SRHeroStarSum", {}) + + return true +end + +function _M.actCalendaTaskRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local taskId = msg.id + local trainTask = role:getProperty("trainTask") or {} + local record = trainTask["r"] or {} + local flag = record[taskId] or 0 + if flag == 1 then return 1 end + local taskCfg = csvdb["training_camp_taskCsv"][taskId] + if not taskCfg then return 2 end + + if (trainTask[taskId] or 0) < taskCfg.condition1 then return 3 end + + record[taskId] = 1 + trainTask["r"] = record + + role:updateProperty({field = "trainTask", value = trainTask}) + + local reward, change = role:award(taskCfg.reward, {log = {desc = "trainTask"}}) + + SendPacket(actionCodes.Hero_trainTaskRewardRpc, MsgPack.pack(role:packReward(reward, change))) + + return true +end + return _M diff --git a/src/csvdata b/src/csvdata index 6883d56..007bdd1 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 6883d567759b8f50bf1bace2d7e53e658083fa75 +Subproject commit 007bdd1f580a9f31e64e55ac6e1cb72387ed3698 diff --git a/src/models/Hero.lua b/src/models/Hero.lua index 2ab0067..e3caa87 100644 --- a/src/models/Hero.lua +++ b/src/models/Hero.lua @@ -19,6 +19,7 @@ Hero.schema = { faith = {"number", 0}, -- 信赖 spark = {"table", {}}, -- 火花属性 genius = {"string", "" }, --天赋点 4=10201 5=10201 6=10203 7=10204 + trainTs = {"number", 0}, -- 魔鬼训练营截止时间 0为未训练 } function Hero:ctor( properties ) @@ -113,6 +114,7 @@ function Hero:data() faith = self:getProperty("faith"), spark = self:getProperty("spark"), genius = self:getProperty("genius"), + trainTs = self:getProperty("trainTs"), } end diff --git a/src/models/Role.lua b/src/models/Role.lua index 1049b2b..904ee5c 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -218,6 +218,7 @@ Role.schema = { worldChangePoints = {"table", {}}, -- 世界变动积分 {[1]= 转盘抽取次数, [2]= 获得的积分, [3]=魔导石消耗, [4]= 虹光玉消耗} worldLineReward = {"table", {}}, -- 世界积分 领取记录 {[id] = 1} del = {"number", 0}, -- 标记删除 0=未删除,1=已删除 + trainTask = {"table", {}}, -- 训练营任务 } @@ -463,6 +464,7 @@ function Role:data() bgId = self:getProperty("bgId"), worldChangePoints = self:getProperty("worldChangePoints"), worldLineReward = self:getProperty("worldLineReward"), + trainTask = self:getProperty("trainTask"), } end diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index b653287..558cd5f 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -74,6 +74,8 @@ local ItemReason = { regularWorldBossMilestone = 158, -- 常规世界boss伤害里程碑 regularWorldBossBattle = 159, -- 常规世界boss战斗奖励 itemConvertDevilTicket = 160, -- 兑换魔鬼训练营门票 + trainHero = 161, -- 魔鬼训练开始 + trainQuickHero = 162, -- 魔鬼训练加速 diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 7d93509..383feac 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -185,6 +185,8 @@ function RolePlugin.bind(Role) itemType = itemCfg.type end self:checkTaskEnter("AddItem", {id = itemId, count = count, type = itemType}) + elseif count < 0 then + self:checkTaskEnter("CostItem", {id = itemId, count = count}) end -- 对数量筛查 count = checkItemCount(self, itemId, count) @@ -647,6 +649,8 @@ function RolePlugin.bind(Role) self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job, ssrCount = ssrCount}, params.notNotify) self:checkTaskEnter("HeroQualityCollect", {}) self:checkTaskEnter("HeroStartSum", {}) + self:checkTaskEnter("SSRHeroStarSum", {}) + self:checkTaskEnter("SRHeroStarSum", {}) if not params.notNotify then local heroResponse = {} diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index ab5bba3..91f735a 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -19,6 +19,8 @@ local TaskType = { DrawHeroLimitPack = 14, -- 抽卡限时礼貌 -- count HeroStartSum = 15, -- 英雄星级总数 WakeCGSum = 16, -- 累计解锁xx张CG + SSRHeroStarSum = 17, -- SSR英雄星级总数 + SRHeroStarSum = 18, -- SR英雄星级总数 --装备相关 @@ -117,6 +119,7 @@ local TaskType = { Rename = 913, -- 重命名 CostJade = 914, -- 消耗虹光玉 BuyLimitPack = 915, -- 购买指定id礼包触发 + CostItem = 916, -- 消耗道具 --功能未实现 todo AdvShop = 1002, -- 冒险商城 @@ -351,6 +354,16 @@ local ReturnerTask = { listen = CalendaTaskListener["listen"] } +local TraningCampTask = { + func = "checkTraingCampTask", + listen = { + [TaskType.HangPass]= {{1, 3}}, + [TaskType.SSRHeroStarSum] = {{2, 3}}, + [TaskType.SRHeroStarSum] = {{3, 3}}, + [TaskType.CostItem] = {{4, 3, f("id"), f("count")}}, + } +} + local TaskListeners = { StoryListener, CommonListener, @@ -362,6 +375,7 @@ local TaskListeners = { BattleCommandTaskListener, ReturnerTask, NewUserTaskListener, + TraningCampTask, } local RoleTask = {} @@ -900,6 +914,54 @@ function RoleTask.bind(Role) self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) end + function Role:checkTraingCampTask(notNotify, mainType, subType, param1, param2) + local trainTask = self:getProperty("trainTask") or {} + param1 = param1 or 1 + + for id, cfg in pairs(csvdb["training_camp_taskCsv"]) do + if cfg.type == mainType then + if subType == 1 then -- 增加数值 + trainTask[id] = (trainTask[id] or 0) + param1 + elseif subType == 2 then -- 直接赋值 + trainTask[id] = param1 + elseif subType == 3 then -- 自定义类型 + if cfg.type == 1 then -- 通关关卡 + if (trainTask[id] or 0) == 0 then + if self:checkHangPass(cfg.condition2) then + trainTask[id] = 1 + end + end + elseif cfg.type == 2 then --玩家拥有SR拾荒者总星级达到xxx + local count = 0 + for _, hero in pairs(self.heros) do + if hero:getRare() == HeroQuality.SR then + count = count + hero:getProperty("wakeL") + end + end + if (trainTask[id] or 0) < count then + trainTask[id] = count + end + elseif cfg.type == 3 then --玩家拥有SR拾荒者总星级达到xxx + local count = 0 + for _, hero in pairs(self.heros) do + if hero:getRare() == HeroQuality.SSR then + count = count + hero:getProperty("wakeL") + end + end + if (trainTask[id] or 0) < count then + trainTask[id] = count + end + elseif cfg.type == 4 then -- 消耗指定id道具多少个 + if cfg.condition2 == param1 then + trainTask[id] = (trainTask[id] or 0) + (param2 or 0) + end + end + end + end + end + self:updateProperty({field = "trainTask", value = trainTask, notNotify = notNotify}) + end + end return RoleTask -- libgit2 0.21.2