From d232676aa51f3cbb880888e83b4dc0a8bcfdd91b Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Thu, 12 Mar 2020 19:50:25 +0800 Subject: [PATCH] 功能解锁 冒险返回 --- src/GlobalVar.lua | 22 +++++++++++++++++----- src/actions/AdvAction.lua | 3 ++- src/actions/HangAction.lua | 7 +++++++ src/actions/HeroAction.lua | 1 + src/actions/PvpAction.lua | 2 ++ src/actions/RoleAction.lua | 8 ++++++++ src/actions/TowerAction.lua | 2 ++ src/adv/Adv.lua | 40 ++++++++++++++++------------------------ src/adv/AdvPassive.lua | 2 ++ src/adv/AdvPlayer.lua | 43 +++++++++++++++++++++++++++---------------- src/models/RolePlugin.lua | 14 ++++++++++++++ 11 files changed, 98 insertions(+), 46 deletions(-) diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index 6239ee0..f5fe51c 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -66,6 +66,18 @@ FuncOpenType = { TimeBoxSlot = 8, -- 时钟箱槽 } +-- 关卡通关相关的 功能开放 对应 guide_unlock +FuncUnlock = { + GetHero = 1, -- 招募 + TaskAchiv = 2, -- 任务成就 + BonusBattle = 3, -- 奖励关卡 + DifficultHang = 4, --困难难度 + Tower = 5, -- 电波塔 + Diner = 6, -- 餐厅 + Pvp = 7, --竞技场 + Adv = 8, -- 冒险 +} + TypeIsFunc = {} for _, v in pairs(FuncOpenType) do TypeIsFunc[v] = true @@ -139,16 +151,16 @@ AdvBackEventType = { AtkChange = 3, --攻击改变 Buff = 4, --buff 改变 Skill = 5, --释放技能 - Atk = 6, --攻击动作 + BaseAttrChange = 6, -- 基础属性变化 Next = 7, --进入下一层 End = 8, -- 结束 BlockChange = 9, -- 块改变 SpChange = 10, --体力改变 Dead = 11, --怪死亡 - DefChange = 12, -- 防御变化 - Passive = 13, -- 獲得被動 - TurnEnd = 14, -- 回合结束 - Miss = 15, -- miss + Trader = 12, -- 召唤商人 + Monster = 13, -- 召唤怪物 + + Cost = 16, -- 消耗道具 Trap = 17, --陷阱 Layer = 18, --切换层 diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index 5e6f4fb..fd86914 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -85,7 +85,8 @@ function _M.startAdvRpc( agent, data ) local layer = msg.layer or 1 --选择层数 local format = msg.format --编队 local supportIdx = msg.supportIdx --选择的支援效果 - + if not role:isFuncUnlock(FuncUnlock.Adv) then return end + --上一个关卡结束才可以开始新的关卡 if role:getAdvData():isRunning() then return 8 end diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 51703db..74c9440 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -71,6 +71,10 @@ function _M.startRpc( agent, data ) local carbonData = csvdb["idle_battleCsv"][carbonId] if not carbonData then return 1 end + if math.floor(carbonId / 10000) ~= 1 then + if not role:isFuncUnlock(FuncUnlock.DifficultHang) then return end + end + local hangPass = role:getProperty("hangPass") for _, preCarbonId in ipairs(carbonData.prepose:toArray(true, "=")) do @@ -413,6 +417,9 @@ function _M.startBonusBattleRpc(agent, data) local msg = MsgPack.unpack(data) local id = msg.id + if not role:isFuncUnlock(FuncUnlock.BonusBattle) then return end + + local bonusData = csvdb["bonus_battleCsv"][id] if not bonusData then return 1 end local hangPass = role:getProperty("hangPass") diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 5e153a9..ba6155d 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -713,6 +713,7 @@ function _M.drawHeroRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) + if not role:isFuncUnlock(FuncUnlock.GetHero) then return end local pool = msg.pool -- 1 2 3 local drawType = msg.type -- 1 单抽 2 十连 diff --git a/src/actions/PvpAction.lua b/src/actions/PvpAction.lua index 9d334bf..37c0490 100644 --- a/src/actions/PvpAction.lua +++ b/src/actions/PvpAction.lua @@ -92,6 +92,8 @@ function _M.infoRpc(agent, data) local roleId = role:getProperty("id") local msg = MsgPack.unpack(data) local ptype = msg.ptype or 1 + + if not role:isFuncUnlock(FuncUnlock.Pvp) then return end local response = {} if ptype == 1 then -- 普通pvp diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 90af90b..0af47fb 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -622,6 +622,9 @@ end function _M.taskRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) + + if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end + local taskType = msg.type -- 1 日常 2 周长 local taskId = msg.id --任务id local roleField = {"dTask", "wTask"} @@ -652,6 +655,9 @@ end function _M.taskActiveRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) + + if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end + local taskType = msg.type -- 1 日常 2 周长 local taskId = msg.id --任务id local roleField = {"dTask", "wTask"} @@ -681,6 +687,8 @@ function _M.achiveRpc(agent, data) local msg = MsgPack.unpack(data) local taskId = msg.id --任务id + if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end + local achiveTask = csvdb["achievementCsv"][taskId] if not achiveTask then return end diff --git a/src/actions/TowerAction.lua b/src/actions/TowerAction.lua index 5455bb9..cc06a80 100644 --- a/src/actions/TowerAction.lua +++ b/src/actions/TowerAction.lua @@ -52,6 +52,8 @@ function _M.startBattleRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) local id = msg.id + + if not role:isFuncUnlock(FuncUnlock.Tower) then return end local towerInfo = role:getProperty("towerInfo") diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index c1c11c3..7d134bd 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -979,6 +979,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) end, [3] = function() --发现怪物 self:getCurMap():addNewMonsterRand(effect[2], {room, block}) + self:pushBackEvent(AdvBackEventType.Monster, {id = effect[2]}) clearBlock = false end, [4] = function() --无事发生 @@ -999,6 +1000,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) id = effect[2] }) block:randomEvent() + self:pushBackEvent(AdvBackEventType.Trader, {id = effect[2]}) clearBlock = false end, [7] = function() -- 建筑 @@ -1386,6 +1388,7 @@ function Adv:doActive(activeId, target) }) target:randomEvent() self:backBlockChange(target.room.roomId, target.blockId) + self:pushBackEvent(AdvBackEventType.Trader, {id = traderId}) end end return true @@ -1398,6 +1401,7 @@ function Adv:doActive(activeId, target) self.battle:removeEnemyById(target.id) self:getCurMap():addNewMonsterRand(monsterId, {self:getRoom(target.roomId), self:getBlock(target.roomId, target.blockId)}) self:backBlockChange(target.roomId, target.blockId) + self:pushBackEvent(AdvBackEventType.Monster, {id = monsterId}) end end return true @@ -1490,6 +1494,18 @@ function Adv:doActive(activeId, target) return true end + doActiveEffect[12] = function(_, vtype, attrType, value) + local attr + if attrType == 0 then + attr = "sp" + else + attr = AttsEnumEx[attrType] + if not AdvAttsEnum[attr] then return end + end + self.battle.player:addBaseAttr(attr, value, vtype) + return true + end + for _, effect in ipairs(activeData.effect:toArray()) do local cur = effect:toArray(true, "=") if doActiveEffect[cur[1]] then @@ -1612,36 +1628,12 @@ function Adv:backReward(items, params) params = params or {} self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId}) end --- if is player enemyId is nil ---isMax 是否是改变血量上限 -function Adv:backHpChange(enemyId, change, isMax) - self:pushBackEvent(AdvBackEventType.HpChange, {enemyId = enemyId, change = change, isMax = isMax}) -end - --- if is player enemyId is nil -function Adv:backAtkChange(enemyId, change) - self:pushBackEvent(AdvBackEventType.AtkChange, {enemyId = enemyId, change = change}) -end -- if is player enemyId is nil -function Adv:backDefChange(enemyId, change) - self:pushBackEvent(AdvBackEventType.DefChange, {enemyId = enemyId, change = change}) -end - --- if is player enemyId is nil -function Adv:backBuff(enemyId, buffId, isDel) - self:pushBackEvent(AdvBackEventType.Buff, {enemyId = enemyId, buffId = buffId, isDel = isDel}) -end --- if is player enemyId is nil function Adv:backSkill(enemyId, skillId, receiver) self:pushBackEvent(AdvBackEventType.Skill, {enemyId = enemyId, skillId = skillId, receiver = receiver}) end --- if is player enemyId is nil -function Adv:backPassive(enemyId, passiveId) - self:pushBackEvent(AdvBackEventType.Passive, {enemyId = enemyId, passiveId = passiveId}) -end - function Adv:backNext() self:pushBackEvent(AdvBackEventType.Next, {}) end diff --git a/src/adv/AdvPassive.lua b/src/adv/AdvPassive.lua index 95d70e2..2e52a29 100644 --- a/src/adv/AdvPassive.lua +++ b/src/adv/AdvPassive.lua @@ -423,6 +423,8 @@ function Passive:effect5(monsterId) end end self.owner.battle.adv:getCurMap():addNewMonsterRand(monsterId) + self.owner.battle.adv:pushBackEvent(AdvBackEventType.Monster, {id = monsterId}) + end --6=给所有场上怪物增加buff diff --git a/src/adv/AdvPlayer.lua b/src/adv/AdvPlayer.lua index 0a6c641..0695282 100644 --- a/src/adv/AdvPlayer.lua +++ b/src/adv/AdvPlayer.lua @@ -69,7 +69,6 @@ function BaseObject:clearRound() for i = #self.buffs, 1, -1 do if self.buffs[i].isDel then local buff = self.buffs[i] - self.battle.adv:backBuff(self.monsterId, buff.id, true) table.remove(self.buffs, i) buff:endBuff() if self.attrChangeCondBuffCheck then @@ -102,8 +101,6 @@ function BaseObject:addPassive(params) local level = params.level or 1 if not skillData[level] then return end table.insert(self.passives, Passive.new(self, { id = skillId, level = level })) - - self.battle.adv:backPassive(self.monsterId, skillId) end function BaseObject:getPassiveIdx(passive) @@ -151,7 +148,6 @@ function BaseObject:addBuff(buffId, releaser) buff:createAfter() end self:triggerPassive(Passive.GET_BUFF, {buffId = buffId}) - self.battle.adv:backBuff(self.monsterId, buffId) return true end @@ -166,7 +162,6 @@ end function BaseObject:delBuffById(bId) for idx, buff in ipairs(self.buffs) do if buff.id == bId then - self.battle.adv:backBuff(self.monsterId, buff.id, true) table.remove(self.buffs, idx) buff:endBuff() if self.attrChangeCondBuffCheck then @@ -293,13 +288,6 @@ function BaseObject:reSetAttr(field) local effect = self:getAttrBuffChange(field) self[field] = math.ceil((self[field] + effect[0]) * (1 + effect[1])) local delta = self[field] - old - if delta ~= 0 then - if field == "atk" then - self.battle.adv:backAtkChange(self.monsterId, delta) - elseif field == "def" then - self.battle.adv:backDefChange(self.monsterId, delta) - end - end end -- 重新计算 血量上限 @@ -394,7 +382,10 @@ function BaseObject:hurt(value, releaser, params) end --受伤了~ - self.battle.adv:backHpChange(self.monsterId, -value) + if self:is("Player") and params.hurtType ~= 5 then + self.battle.adv:pushBackEvent(AdvBackEventType.HpChange, {change = -value}) + end + if params.hurtType ~= 5 then -- 非客户端发回的伤害 返回更新地块 if self.roomId and self.blockId then self.battle.adv:backBlockChange(self.roomId, self.blockId) @@ -423,7 +414,7 @@ function BaseObject:recover(value, releaser, params) params = params or {} value = math.max(0, math.ceil(value)) self.hp = math.min(self.hpMax, self.hp + value) - self.battle.adv:backHpChange(self.monsterId, value) + self.battle.adv:pushBackEvent(AdvBackEventType.HpChange, {change = value}) end function BaseObject:addSpecialSkill(skillId, skillLevel, target) @@ -516,6 +507,10 @@ end function BaseObject:changeSp() end +function BaseObject:is(what) + return self["is" .. what] and self["is" .. what](self) +end + local Enemy = class("Enemy", BaseObject) function Enemy:ctor(battle, mId, monsterId, roomId, blockId, lock, enemy, mapIdx) Enemy.super.ctor(self, battle) @@ -532,6 +527,10 @@ function Enemy:unlock(id) self.lock = nil end +function Enemy:isEnemy() + return true +end + local Player = class("Player", BaseObject) function Player:ctor(battle, data) Player.super.ctor(self, battle) @@ -567,7 +566,7 @@ function Player:addExp(value) local delta = level - self.level if delta > 0 then for attr, _ in pairs(AdvAttsEnum) do - self:addBaseAttr(attr, self.growth[attr] * delta) + self:addBaseAttr(attr, self.growth[attr] * delta, 0, true) end self.battle.adv:pushBackEvent(AdvBackEventType.Level, {level = level, delta = delta}) end @@ -576,7 +575,7 @@ function Player:addExp(value) return value end --vtype 0/1 值/% -function Player:addBaseAttr(attr, value, vtype) +function Player:addBaseAttr(attr, value, vtype, ignoreBack) local attrName = attr if attr == "hp" then attrName = "hpMax" @@ -601,6 +600,10 @@ function Player:addBaseAttr(attr, value, vtype) else self:reSetAttr(attr) end + + if not ignoreBack then + self.battle.adv:pushBackEvent(AdvBackEventType.BaseAttrChange, {type = AdvAttsEnum[attr] or 0, change = change}) + end end --cType 0 or nil 值 1 百分比 @@ -649,6 +652,7 @@ function Player:addBuff(buffId, releaser) if status then self.battle.player:attrChangeCondBuffCheck(2, buffId) self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) + self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId}) end return status end @@ -673,6 +677,10 @@ function Player:attrChangeCondBuffCheck(etype, cond) end end +function Player:isPlayer() + return true +end + function Player:getDB() local db = Player.super.getDB(self) for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do @@ -705,6 +713,9 @@ end function Build:hurt() end +function Build:isBuild() + return true +end --0 全部 1 怪物 2 玩家 function Build:getTeam(nType, noSelf, mapIdx, includeLock) noSelf = false -- 不管怎么都取不到自己 diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index a4fdede..f667231 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -692,7 +692,21 @@ function RolePlugin.bind(Role) return globalCsv.adv_endless_daily_cross_count end + -- 走 guide_unlock 表的 被动解锁 + function Role:isFuncUnlock(func) + if not func then return true end -- 没有就是解锁了 + local data = csvdb["guide_unlockCsv"][func] + if not data then return true end -- 没有就是解锁了 + + local hangPass = role:getProperty("hangPass") + if hangPass[data.carbonId] then + return true + else + return false + end + end + -- 走 unlock 表的主动解锁 function Role:isFuncOpen(func) return self:getProperty("funcOpen")[func] == 1 end -- libgit2 0.21.2