diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index d42de71..22b437e 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -86,7 +86,8 @@ ItemId = { AdvSpecialStage = { [1]= "In", [2] = "Out", - [3] = "BOSS" + [3] = "BOSS", + [4] = "LinkChoose", } --客户端需要知道这个 AdvEventType = { @@ -94,6 +95,7 @@ AdvEventType = { In = -1, --入口 Out = -2, --出口 BOSS = -3, -- boss + LinkChoose = -4, -- 连续选择 -- 普通事件(随机) Choose = 1, --选择点 Drop = 2, --物品掉落点 diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index ba40607..b94ad7f 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -2,6 +2,7 @@ local Passive = require "adv.AdvPassive" local AdvCommon = require "adv.AdvCommon" local AdvMap = require "adv.AdvMap" +local Buff = require "adv.AdvBuff" local Adv = class("Adv") local AdvTask = import(".AdvTask") --任务相关数据搞出去 @@ -31,6 +32,7 @@ function Adv:initByInfo(advInfo) self.score = advInfo.score or {} self.lastEnemyId = advInfo.lastEId or 1 self.mapStack = advInfo.mstack or {} + self.lchoose = advInfo.lch or {} self.maps = {} for id, map in ipairs(advInfo.maps or {}) do self.maps[id] = AdvMap.new(self, id, map) @@ -48,7 +50,7 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify) self.score = self.score or {} self.lastEnemyId = 1 self.mapStack = {1} -- 最后一个为当前的地图 - + self.lchoose = self.lchoose or {} self.owner._advWheelSurfCount = nil -- 抽奖进行次数 -- 随机出地图 @@ -77,6 +79,7 @@ function Adv:clear() self.round = 0 self.lastEnemyId = 1 self.mapStack = {} + self.lchoose = {} self.maps = {} self.battle = nil end @@ -91,6 +94,7 @@ function Adv:saveDB(notNotify) advInfo.score = self.score advInfo.lastEId = self.lastEnemyId advInfo.mstack = self.mapStack + advInfo.lch = self.lchoose advInfo.maps = {} self.battle:saveDB() @@ -315,13 +319,15 @@ local function clickMonster(self, room, block, params) return true end -local function clickChoose(self, room, block, params) - local choose = params.choose - local chooseData = csvdb["event_chooseCsv"][block.event.id] +local function chooseCommon(self, room, block, chooseData, choose) if not chooseData or not chooseData["button".. choose .."cond"] then return end local cond = chooseData["button".. choose .."cond"]:toArray(true, "=") local checkCond = { + -- 没有条件 + [0] = function() + return true + end, -- 拥有道具 [1] = function() if self:cost({[cond[2]] = cond[3]}, {}, true) then @@ -339,7 +345,7 @@ local function clickChoose(self, room, block, params) [3] = function() for _, room in pairs(self:getCurMap().rooms) do for _, block in pairs(room.blocks) do - if block.event and (block.event.etype == AdvEventType.BOSS or block.event.etype == AdvEventType.Monster) then + if block:isMonster() then return end end @@ -352,10 +358,17 @@ local function clickChoose(self, room, block, params) return true end end, + -- 提交一个物品 + [5] = function () + if self:cost({[cond[2]] = cond[3]}, {}) then + return true + end + end, } - assert(not cond[1] or checkCond[cond[1]], "error cond, event_chooseCsv id :" .. block.event.id) + assert(not cond[1] or checkCond[cond[1]], "error cond, event_[link]chooseCsv id :" .. block.event.id) + if cond[1] and not checkCond[cond[1]]() then return end - local clearBlock = true + local clearBlock = chooseData.keep ~= 1 local effects = chooseData["button".. choose .."effect"]:toTableArray(true) for _, effect in ipairs(effects) do if effect[1] == 1 then @@ -378,15 +391,44 @@ local function clickChoose(self, room, block, params) [4] = function() --无事发生 end } - assert(doEffect[effect[1]], "error effect, event_chooseCsv id :" .. block.event.id) + assert(doEffect[effect[1]], "error effect, event_[link]chooseCsv id :" .. block.event.id) doEffect[effect[1]]() end - self:checkTask(Adv.TaskType.Choose, 1, block.event.id) + return true, clearBlock +end + +local function clickChoose(self, room, block, params) + local choose = params.choose + local chooseData = csvdb["event_chooseCsv"][block.event.id] + local status, clearBlock = chooseCommon(self, room, block, chooseData, choose) + if not status then return end + + if clearBlock then + block:clear() + end + return true +end + +local function clickLinkChoose(self, room, block, params) + local choose = params.choose + local chooseData = csvdb["event_linkchooseCsv"][block.event.id] + local status, clearBlock = chooseCommon(self, room, block, chooseData, choose) + if not status then return end + + -- 完成统计次数 + local idx = block.event.id % 10 + if idx == 9 or not csvdb["event_linkchooseCsv"][block.event.id + 1] then --全部完成 + local startId = math.floor(block.event.id / 10) * 10 + 1 + self.lchoose[startId] = (self.lchoose[startId] or 0) + 1 + else + self.lchoose.ing = block.event.id + 1 --后面会出现后继事件 + end if clearBlock then block:clear() end + return true end @@ -501,6 +543,7 @@ local eventCallFunc = { [AdvEventType.BOSS] = clickMonster, [AdvEventType.Monster] = clickMonster, [AdvEventType.Choose] = clickChoose, + [AdvEventType.LinkChoose] = clickLinkChoose, [AdvEventType.Drop] = clickDrop, [AdvEventType.Trader] = clickTrader, [AdvEventType.Build] = clickBuild, @@ -607,8 +650,33 @@ function Adv:usePotion(potionId, potionLevel, target) return true end +-- 地图上物品变化 +function Adv:mapItemChange(ctype) + local clist = csvdb["transform_itemCsv"][ctype] + if clist then + for roomId, room in pairs(self:getCurMap().rooms) do + for blockId, block in pairs(room.blocks) do + if block:getEventType() == AdvEventType.Drop and block.event.item then + local id = block.event.item[1] + local changeTo = nil + if clist[id] then + changeTo = {clist[id].toId, clist[id].num} + elseif clist[-1] then + changeTo = {clist[-1].toId, clist[-1].num} + end + if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then + block.event.item = changeTo + self:backBlockChange(roomId, blockId) + end + end + end + end + end +end + --敌人死亡 -function Adv:enemyDead(roomId, blockId, escape) +function Adv:enemyDead(enemy, escape) + local roomId, blockId = enemy.roomId, enemy.blockId local map = self:getCurMap() local room = self:getRoom(roomId) local block = self:getBlock(roomId, blockId) @@ -621,15 +689,20 @@ function Adv:enemyDead(roomId, blockId, escape) if escape then block:clear() else - local enemyId = block.event.id local monsterData = csvdb["event_monsterCsv"][enemyId] self:scoreChange(AdvScoreType.Kill, monsterData.type) self.battle.player:addExp(monsterData.exp) local item = block.event.item if not item then - local dropData = csvdb["event_dropCsv"][monsterData.dropid] - item = dropData["range"]:randWeight(true) + local buff = enemy:hadBuff(Buff.CHANGE_DROP) + if buff then + item = table.pack(buff:effect()) + else + local dropData = csvdb["event_dropCsv"][monsterData.dropid] + item = dropData["range"]:randWeight(true) + end + end if item[1] == 0 then diff --git a/src/adv/AdvBattle.lua b/src/adv/AdvBattle.lua index 0798008..fa84674 100644 --- a/src/adv/AdvBattle.lua +++ b/src/adv/AdvBattle.lua @@ -177,9 +177,9 @@ function Battle:afterRound() end for i = #self.enemys[mapIdx], 1, -1 do if self.enemys[mapIdx][i].isDead then - self.enemys[mapIdx][i]:clear() local enemy = table.remove(self.enemys[mapIdx], i) - self.adv:enemyDead(enemy.roomId, enemy.blockId) + self.adv:enemyDead(enemy, enemy.isDead == 1) + enemy:clear() end end diff --git a/src/adv/AdvBlock.lua b/src/adv/AdvBlock.lua index 589e520..892b843 100644 --- a/src/adv/AdvBlock.lua +++ b/src/adv/AdvBlock.lua @@ -89,9 +89,24 @@ function Block:open() randomFunc[AdvEventType.Trap] = function() local data = csvdb["event_trapCsv"][self.event.id] - for _, buffId in ipairs(data.effect:toArray(true, "=")) do + local buffs = data.effect:toArray(true, "=") + for _, buffId in ipairs(buffs) do adv.battle.player:addBuff(buffId) end + if data.target == 1 then-- 给所有敌人同样增加buff + local enemys = adv.battle.player:getTeam(2) + for k , enemy in ipairs(enemys) do + for _, buffId in ipairs(buffs) do + enemy:addBuff(buffId) + end + end + end + if data.specialEff ~= "" then + local effect = data.specialEff:toArray(true, "=") + if effect[1] == 1 then + self.room.map.adv:mapItemChange(effect[2]) + end + end adv:backTrap() self:clear() end diff --git a/src/adv/AdvBuff.lua b/src/adv/AdvBuff.lua index 1b78a10..7f52af1 100644 --- a/src/adv/AdvBuff.lua +++ b/src/adv/AdvBuff.lua @@ -18,6 +18,7 @@ Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合) Buff.SP_CHANGE = 15 -- sp变化(每回合) Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效) Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff +Buff.CHANGE_DROP = 18 -- 转换掉落 --角色一些属性的变化 local function commonAttr(_Buff, attrName) @@ -134,6 +135,12 @@ local BuffFactory = { return self.buffData.effectValue1, self.buffData.effectValue2 end end, + + [Buff.CHANGE_DROP] = function(_Buff) + _Buff._effectValue = function(self) + return self.buffData.effectValue1, self.buffData.effectValue2 + end + end, [Buff.IMMNUE_BUFF] = function(_Buff) _Buff._init = function(self, data) diff --git a/src/adv/AdvMap.lua b/src/adv/AdvMap.lua index 23e2f3c..343f497 100644 --- a/src/adv/AdvMap.lua +++ b/src/adv/AdvMap.lua @@ -175,6 +175,7 @@ createMap = function(self, mapId) local eventLib = getEventLib(self) -- 同时记录出现次数 local monsterEvents = {} --处理钥匙掉落 local haveBoss = false + local haveLChoose = false local function randomEvent(roomId, blockId, eventType) @@ -211,6 +212,18 @@ createMap = function(self, mapId) end haveBoss = true end + randomFunc[AdvEventType.LinkChoose] = function() + if haveLChoose then return false end + if self.adv.lchoose.ing then -- 有正在进行的 + event.id = self.adv.lchoose.ing + self.adv.lchoose.ing = nil + else + if randomCommon() == false then + return false + end + end + haveLChoose = true + end --怪物 randomFunc[AdvEventType.Monster] = function() @@ -351,6 +364,7 @@ getEventLib = function(self, needEventType) -- needEventType 需要的事件 ["event_clickCsv"] = AdvEventType.Click, ["event_layerCsv"] = AdvEventType.Layer, ["event_questCsv"] = AdvEventType.Task, + ["event_linkchooseCsv"] = AdvEventType.LinkChoose, } local eventLib = {} @@ -372,9 +386,17 @@ getEventLib = function(self, needEventType) -- needEventType 需要的事件 local etype = type(eventType) == "table" and eventType[data.type] or eventType if data.levelchapter == chapterId and (data.unlockType == 0 or (advEventOpenStatus[etype] or {})[data.unlockType]) then - if AdvCommon.checkIsIn(level, data.leveltype, data.levellimit) then - eventLib[etype][data.BlockEventType] = eventLib[etype][data.BlockEventType] or {} - eventLib[etype][data.BlockEventType][id] = {showup = data.showup, limit = data.limit} + local add = true + if etype == AdvEventType.LinkChoose then --link 只有起始任务并且还没完成的进入池子 + if id % 10 ~= 1 or (data.limit ~= 0 and data.limit <= (self.adv.lchoose[id] or 0)) then + add = false + end + end + if add then + if AdvCommon.checkIsIn(level, data.leveltype, data.levellimit) then + eventLib[etype][data.BlockEventType] = eventLib[etype][data.BlockEventType] or {} + eventLib[etype][data.BlockEventType][id] = {showup = data.showup, limit = data.limit} + end end end end diff --git a/src/adv/AdvPassive.lua b/src/adv/AdvPassive.lua index 24232a4..21097f0 100644 --- a/src/adv/AdvPassive.lua +++ b/src/adv/AdvPassive.lua @@ -337,8 +337,8 @@ function Passive:effect3() end --4=逃跑 function Passive:effect4() - self.owner.isDead = true --跑了 - self.owner.battle.adv:enemyDead(self.owner.roomId,self.owner.blockId, true) + self.owner.isDead = 1 --跑了 + -- self.owner.battle.adv:enemyDead(self.owner, true) end --5=给随机一个敌方增加一个buff function Passive:effect5(value) @@ -350,5 +350,12 @@ end function Passive:effect6(value) self.owner:addPassive({id = value}) end +--7=给场上队友增加buff +function Passive:effect7(value) + local firends = self.owner:getTeam(1, true) + for k , v in pairs(firends) do + self.owner:addBuff(value, self.owner) + end +end return Passive \ No newline at end of file diff --git a/src/adv/AdvPlayer.lua b/src/adv/AdvPlayer.lua index 28cbd81..2cdfc83 100644 --- a/src/adv/AdvPlayer.lua +++ b/src/adv/AdvPlayer.lua @@ -121,7 +121,7 @@ end function BaseObject:hadBuff(bType) for _, buff in ipairs(self.buffs) do if not buff.isDel and buff:getType() == bType then - return true + return buff end end end @@ -129,7 +129,7 @@ end function BaseObject:hadBuffById(bId) for _, buff in ipairs(self.buffs) do if not buff.isDel and buff.id == bId then - return true + return buff end end end diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index d523e8f..613c741 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -589,6 +589,12 @@ function RolePlugin.bind(Role) return globalCsv.adv_daily_cross_count end + function Role:getAdvElLimit() + -- todo + return globalCsv.adv_endless_daily_cross_count + end + + function Role:isFuncOpen(func) return self:getProperty("funcOpen")[func] == 1 end -- libgit2 0.21.2