Commit 7828ffd0d78c0cb074911bc82a944efa105aa6ec

Authored by zhouhaihai
1 parent e38b9c49

冒险 连续选择点 和 地图因子

@@ -86,7 +86,8 @@ ItemId = { @@ -86,7 +86,8 @@ ItemId = {
86 AdvSpecialStage = { 86 AdvSpecialStage = {
87 [1]= "In", 87 [1]= "In",
88 [2] = "Out", 88 [2] = "Out",
89 - [3] = "BOSS" 89 + [3] = "BOSS",
  90 + [4] = "LinkChoose",
90 } 91 }
91 --客户端需要知道这个 92 --客户端需要知道这个
92 AdvEventType = { 93 AdvEventType = {
@@ -94,6 +95,7 @@ AdvEventType = { @@ -94,6 +95,7 @@ AdvEventType = {
94 In = -1, --入口 95 In = -1, --入口
95 Out = -2, --出口 96 Out = -2, --出口
96 BOSS = -3, -- boss 97 BOSS = -3, -- boss
  98 + LinkChoose = -4, -- 连续选择
97 -- 普通事件(随机) 99 -- 普通事件(随机)
98 Choose = 1, --选择点 100 Choose = 1, --选择点
99 Drop = 2, --物品掉落点 101 Drop = 2, --物品掉落点
@@ -2,6 +2,7 @@ local Passive = require "adv.AdvPassive" @@ -2,6 +2,7 @@ local Passive = require "adv.AdvPassive"
2 2
3 local AdvCommon = require "adv.AdvCommon" 3 local AdvCommon = require "adv.AdvCommon"
4 local AdvMap = require "adv.AdvMap" 4 local AdvMap = require "adv.AdvMap"
  5 +local Buff = require "adv.AdvBuff"
5 6
6 local Adv = class("Adv") 7 local Adv = class("Adv")
7 local AdvTask = import(".AdvTask") --任务相关数据搞出去 8 local AdvTask = import(".AdvTask") --任务相关数据搞出去
@@ -31,6 +32,7 @@ function Adv:initByInfo(advInfo) @@ -31,6 +32,7 @@ function Adv:initByInfo(advInfo)
31 self.score = advInfo.score or {} 32 self.score = advInfo.score or {}
32 self.lastEnemyId = advInfo.lastEId or 1 33 self.lastEnemyId = advInfo.lastEId or 1
33 self.mapStack = advInfo.mstack or {} 34 self.mapStack = advInfo.mstack or {}
  35 + self.lchoose = advInfo.lch or {}
34 self.maps = {} 36 self.maps = {}
35 for id, map in ipairs(advInfo.maps or {}) do 37 for id, map in ipairs(advInfo.maps or {}) do
36 self.maps[id] = AdvMap.new(self, id, map) 38 self.maps[id] = AdvMap.new(self, id, map)
@@ -48,7 +50,7 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify) @@ -48,7 +50,7 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify)
48 self.score = self.score or {} 50 self.score = self.score or {}
49 self.lastEnemyId = 1 51 self.lastEnemyId = 1
50 self.mapStack = {1} -- 最后一个为当前的地图 52 self.mapStack = {1} -- 最后一个为当前的地图
51 - 53 + self.lchoose = self.lchoose or {}
52 self.owner._advWheelSurfCount = nil -- 抽奖进行次数 54 self.owner._advWheelSurfCount = nil -- 抽奖进行次数
53 55
54 -- 随机出地图 56 -- 随机出地图
@@ -77,6 +79,7 @@ function Adv:clear() @@ -77,6 +79,7 @@ function Adv:clear()
77 self.round = 0 79 self.round = 0
78 self.lastEnemyId = 1 80 self.lastEnemyId = 1
79 self.mapStack = {} 81 self.mapStack = {}
  82 + self.lchoose = {}
80 self.maps = {} 83 self.maps = {}
81 self.battle = nil 84 self.battle = nil
82 end 85 end
@@ -91,6 +94,7 @@ function Adv:saveDB(notNotify) @@ -91,6 +94,7 @@ function Adv:saveDB(notNotify)
91 advInfo.score = self.score 94 advInfo.score = self.score
92 advInfo.lastEId = self.lastEnemyId 95 advInfo.lastEId = self.lastEnemyId
93 advInfo.mstack = self.mapStack 96 advInfo.mstack = self.mapStack
  97 + advInfo.lch = self.lchoose
94 advInfo.maps = {} 98 advInfo.maps = {}
95 99
96 self.battle:saveDB() 100 self.battle:saveDB()
@@ -315,13 +319,15 @@ local function clickMonster(self, room, block, params) @@ -315,13 +319,15 @@ local function clickMonster(self, room, block, params)
315 return true 319 return true
316 end 320 end
317 321
318 -local function clickChoose(self, room, block, params)  
319 - local choose = params.choose  
320 - local chooseData = csvdb["event_chooseCsv"][block.event.id] 322 +local function chooseCommon(self, room, block, chooseData, choose)
321 if not chooseData or not chooseData["button".. choose .."cond"] then return end 323 if not chooseData or not chooseData["button".. choose .."cond"] then return end
322 324
323 local cond = chooseData["button".. choose .."cond"]:toArray(true, "=") 325 local cond = chooseData["button".. choose .."cond"]:toArray(true, "=")
324 local checkCond = { 326 local checkCond = {
  327 + -- 没有条件
  328 + [0] = function()
  329 + return true
  330 + end,
325 -- 拥有道具 331 -- 拥有道具
326 [1] = function() 332 [1] = function()
327 if self:cost({[cond[2]] = cond[3]}, {}, true) then 333 if self:cost({[cond[2]] = cond[3]}, {}, true) then
@@ -339,7 +345,7 @@ local function clickChoose(self, room, block, params) @@ -339,7 +345,7 @@ local function clickChoose(self, room, block, params)
339 [3] = function() 345 [3] = function()
340 for _, room in pairs(self:getCurMap().rooms) do 346 for _, room in pairs(self:getCurMap().rooms) do
341 for _, block in pairs(room.blocks) do 347 for _, block in pairs(room.blocks) do
342 - if block.event and (block.event.etype == AdvEventType.BOSS or block.event.etype == AdvEventType.Monster) then 348 + if block:isMonster() then
343 return 349 return
344 end 350 end
345 end 351 end
@@ -352,10 +358,17 @@ local function clickChoose(self, room, block, params) @@ -352,10 +358,17 @@ local function clickChoose(self, room, block, params)
352 return true 358 return true
353 end 359 end
354 end, 360 end,
  361 + -- 提交一个物品
  362 + [5] = function ()
  363 + if self:cost({[cond[2]] = cond[3]}, {}) then
  364 + return true
  365 + end
  366 + end,
355 } 367 }
356 - assert(not cond[1] or checkCond[cond[1]], "error cond, event_chooseCsv id :" .. block.event.id) 368 + assert(not cond[1] or checkCond[cond[1]], "error cond, event_[link]chooseCsv id :" .. block.event.id)
  369 +
357 if cond[1] and not checkCond[cond[1]]() then return end 370 if cond[1] and not checkCond[cond[1]]() then return end
358 - local clearBlock = true 371 + local clearBlock = chooseData.keep ~= 1
359 local effects = chooseData["button".. choose .."effect"]:toTableArray(true) 372 local effects = chooseData["button".. choose .."effect"]:toTableArray(true)
360 for _, effect in ipairs(effects) do 373 for _, effect in ipairs(effects) do
361 if effect[1] == 1 then 374 if effect[1] == 1 then
@@ -378,15 +391,44 @@ local function clickChoose(self, room, block, params) @@ -378,15 +391,44 @@ local function clickChoose(self, room, block, params)
378 [4] = function() --无事发生 391 [4] = function() --无事发生
379 end 392 end
380 } 393 }
381 - assert(doEffect[effect[1]], "error effect, event_chooseCsv id :" .. block.event.id) 394 + assert(doEffect[effect[1]], "error effect, event_[link]chooseCsv id :" .. block.event.id)
382 doEffect[effect[1]]() 395 doEffect[effect[1]]()
383 end 396 end
384 -  
385 self:checkTask(Adv.TaskType.Choose, 1, block.event.id) 397 self:checkTask(Adv.TaskType.Choose, 1, block.event.id)
  398 + return true, clearBlock
  399 +end
  400 +
  401 +local function clickChoose(self, room, block, params)
  402 + local choose = params.choose
  403 + local chooseData = csvdb["event_chooseCsv"][block.event.id]
  404 + local status, clearBlock = chooseCommon(self, room, block, chooseData, choose)
  405 + if not status then return end
  406 +
  407 + if clearBlock then
  408 + block:clear()
  409 + end
  410 + return true
  411 +end
  412 +
  413 +local function clickLinkChoose(self, room, block, params)
  414 + local choose = params.choose
  415 + local chooseData = csvdb["event_linkchooseCsv"][block.event.id]
  416 + local status, clearBlock = chooseCommon(self, room, block, chooseData, choose)
  417 + if not status then return end
  418 +
  419 + -- 完成统计次数
  420 + local idx = block.event.id % 10
  421 + if idx == 9 or not csvdb["event_linkchooseCsv"][block.event.id + 1] then --全部完成
  422 + local startId = math.floor(block.event.id / 10) * 10 + 1
  423 + self.lchoose[startId] = (self.lchoose[startId] or 0) + 1
  424 + else
  425 + self.lchoose.ing = block.event.id + 1 --后面会出现后继事件
  426 + end
386 427
387 if clearBlock then 428 if clearBlock then
388 block:clear() 429 block:clear()
389 end 430 end
  431 +
390 return true 432 return true
391 end 433 end
392 434
@@ -501,6 +543,7 @@ local eventCallFunc = { @@ -501,6 +543,7 @@ local eventCallFunc = {
501 [AdvEventType.BOSS] = clickMonster, 543 [AdvEventType.BOSS] = clickMonster,
502 [AdvEventType.Monster] = clickMonster, 544 [AdvEventType.Monster] = clickMonster,
503 [AdvEventType.Choose] = clickChoose, 545 [AdvEventType.Choose] = clickChoose,
  546 + [AdvEventType.LinkChoose] = clickLinkChoose,
504 [AdvEventType.Drop] = clickDrop, 547 [AdvEventType.Drop] = clickDrop,
505 [AdvEventType.Trader] = clickTrader, 548 [AdvEventType.Trader] = clickTrader,
506 [AdvEventType.Build] = clickBuild, 549 [AdvEventType.Build] = clickBuild,
@@ -607,8 +650,33 @@ function Adv:usePotion(potionId, potionLevel, target) @@ -607,8 +650,33 @@ function Adv:usePotion(potionId, potionLevel, target)
607 return true 650 return true
608 end 651 end
609 652
  653 +-- 地图上物品变化
  654 +function Adv:mapItemChange(ctype)
  655 + local clist = csvdb["transform_itemCsv"][ctype]
  656 + if clist then
  657 + for roomId, room in pairs(self:getCurMap().rooms) do
  658 + for blockId, block in pairs(room.blocks) do
  659 + if block:getEventType() == AdvEventType.Drop and block.event.item then
  660 + local id = block.event.item[1]
  661 + local changeTo = nil
  662 + if clist[id] then
  663 + changeTo = {clist[id].toId, clist[id].num}
  664 + elseif clist[-1] then
  665 + changeTo = {clist[-1].toId, clist[-1].num}
  666 + end
  667 + if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then
  668 + block.event.item = changeTo
  669 + self:backBlockChange(roomId, blockId)
  670 + end
  671 + end
  672 + end
  673 + end
  674 + end
  675 +end
  676 +
610 --敌人死亡 677 --敌人死亡
611 -function Adv:enemyDead(roomId, blockId, escape) 678 +function Adv:enemyDead(enemy, escape)
  679 + local roomId, blockId = enemy.roomId, enemy.blockId
612 local map = self:getCurMap() 680 local map = self:getCurMap()
613 local room = self:getRoom(roomId) 681 local room = self:getRoom(roomId)
614 local block = self:getBlock(roomId, blockId) 682 local block = self:getBlock(roomId, blockId)
@@ -621,15 +689,20 @@ function Adv:enemyDead(roomId, blockId, escape) @@ -621,15 +689,20 @@ function Adv:enemyDead(roomId, blockId, escape)
621 if escape then 689 if escape then
622 block:clear() 690 block:clear()
623 else 691 else
624 -  
625 local enemyId = block.event.id 692 local enemyId = block.event.id
626 local monsterData = csvdb["event_monsterCsv"][enemyId] 693 local monsterData = csvdb["event_monsterCsv"][enemyId]
627 self:scoreChange(AdvScoreType.Kill, monsterData.type) 694 self:scoreChange(AdvScoreType.Kill, monsterData.type)
628 self.battle.player:addExp(monsterData.exp) 695 self.battle.player:addExp(monsterData.exp)
629 local item = block.event.item 696 local item = block.event.item
630 if not item then 697 if not item then
631 - local dropData = csvdb["event_dropCsv"][monsterData.dropid]  
632 - item = dropData["range"]:randWeight(true) 698 + local buff = enemy:hadBuff(Buff.CHANGE_DROP)
  699 + if buff then
  700 + item = table.pack(buff:effect())
  701 + else
  702 + local dropData = csvdb["event_dropCsv"][monsterData.dropid]
  703 + item = dropData["range"]:randWeight(true)
  704 + end
  705 +
633 end 706 end
634 707
635 if item[1] == 0 then 708 if item[1] == 0 then
src/adv/AdvBattle.lua
@@ -177,9 +177,9 @@ function Battle:afterRound() @@ -177,9 +177,9 @@ function Battle:afterRound()
177 end 177 end
178 for i = #self.enemys[mapIdx], 1, -1 do 178 for i = #self.enemys[mapIdx], 1, -1 do
179 if self.enemys[mapIdx][i].isDead then 179 if self.enemys[mapIdx][i].isDead then
180 - self.enemys[mapIdx][i]:clear()  
181 local enemy = table.remove(self.enemys[mapIdx], i) 180 local enemy = table.remove(self.enemys[mapIdx], i)
182 - self.adv:enemyDead(enemy.roomId, enemy.blockId) 181 + self.adv:enemyDead(enemy, enemy.isDead == 1)
  182 + enemy:clear()
183 end 183 end
184 end 184 end
185 185
src/adv/AdvBlock.lua
@@ -89,9 +89,24 @@ function Block:open() @@ -89,9 +89,24 @@ function Block:open()
89 89
90 randomFunc[AdvEventType.Trap] = function() 90 randomFunc[AdvEventType.Trap] = function()
91 local data = csvdb["event_trapCsv"][self.event.id] 91 local data = csvdb["event_trapCsv"][self.event.id]
92 - for _, buffId in ipairs(data.effect:toArray(true, "=")) do 92 + local buffs = data.effect:toArray(true, "=")
  93 + for _, buffId in ipairs(buffs) do
93 adv.battle.player:addBuff(buffId) 94 adv.battle.player:addBuff(buffId)
94 end 95 end
  96 + if data.target == 1 then-- 给所有敌人同样增加buff
  97 + local enemys = adv.battle.player:getTeam(2)
  98 + for k , enemy in ipairs(enemys) do
  99 + for _, buffId in ipairs(buffs) do
  100 + enemy:addBuff(buffId)
  101 + end
  102 + end
  103 + end
  104 + if data.specialEff ~= "" then
  105 + local effect = data.specialEff:toArray(true, "=")
  106 + if effect[1] == 1 then
  107 + self.room.map.adv:mapItemChange(effect[2])
  108 + end
  109 + end
95 adv:backTrap() 110 adv:backTrap()
96 self:clear() 111 self:clear()
97 end 112 end
src/adv/AdvBuff.lua
@@ -18,6 +18,7 @@ Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合) @@ -18,6 +18,7 @@ Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合)
18 Buff.SP_CHANGE = 15 -- sp变化(每回合) 18 Buff.SP_CHANGE = 15 -- sp变化(每回合)
19 Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效) 19 Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效)
20 Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff 20 Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff
  21 +Buff.CHANGE_DROP = 18 -- 转换掉落
21 22
22 --角色一些属性的变化 23 --角色一些属性的变化
23 local function commonAttr(_Buff, attrName) 24 local function commonAttr(_Buff, attrName)
@@ -134,6 +135,12 @@ local BuffFactory = { @@ -134,6 +135,12 @@ local BuffFactory = {
134 return self.buffData.effectValue1, self.buffData.effectValue2 135 return self.buffData.effectValue1, self.buffData.effectValue2
135 end 136 end
136 end, 137 end,
  138 +
  139 + [Buff.CHANGE_DROP] = function(_Buff)
  140 + _Buff._effectValue = function(self)
  141 + return self.buffData.effectValue1, self.buffData.effectValue2
  142 + end
  143 + end,
137 144
138 [Buff.IMMNUE_BUFF] = function(_Buff) 145 [Buff.IMMNUE_BUFF] = function(_Buff)
139 _Buff._init = function(self, data) 146 _Buff._init = function(self, data)
src/adv/AdvMap.lua
@@ -175,6 +175,7 @@ createMap = function(self, mapId) @@ -175,6 +175,7 @@ createMap = function(self, mapId)
175 local eventLib = getEventLib(self) -- 同时记录出现次数 175 local eventLib = getEventLib(self) -- 同时记录出现次数
176 local monsterEvents = {} --处理钥匙掉落 176 local monsterEvents = {} --处理钥匙掉落
177 local haveBoss = false 177 local haveBoss = false
  178 + local haveLChoose = false
178 179
179 180
180 local function randomEvent(roomId, blockId, eventType) 181 local function randomEvent(roomId, blockId, eventType)
@@ -211,6 +212,18 @@ createMap = function(self, mapId) @@ -211,6 +212,18 @@ createMap = function(self, mapId)
211 end 212 end
212 haveBoss = true 213 haveBoss = true
213 end 214 end
  215 + randomFunc[AdvEventType.LinkChoose] = function()
  216 + if haveLChoose then return false end
  217 + if self.adv.lchoose.ing then -- 有正在进行的
  218 + event.id = self.adv.lchoose.ing
  219 + self.adv.lchoose.ing = nil
  220 + else
  221 + if randomCommon() == false then
  222 + return false
  223 + end
  224 + end
  225 + haveLChoose = true
  226 + end
214 227
215 --怪物 228 --怪物
216 randomFunc[AdvEventType.Monster] = function() 229 randomFunc[AdvEventType.Monster] = function()
@@ -351,6 +364,7 @@ getEventLib = function(self, needEventType) -- needEventType 需要的事件 @@ -351,6 +364,7 @@ getEventLib = function(self, needEventType) -- needEventType 需要的事件
351 ["event_clickCsv"] = AdvEventType.Click, 364 ["event_clickCsv"] = AdvEventType.Click,
352 ["event_layerCsv"] = AdvEventType.Layer, 365 ["event_layerCsv"] = AdvEventType.Layer,
353 ["event_questCsv"] = AdvEventType.Task, 366 ["event_questCsv"] = AdvEventType.Task,
  367 + ["event_linkchooseCsv"] = AdvEventType.LinkChoose,
354 368
355 } 369 }
356 local eventLib = {} 370 local eventLib = {}
@@ -372,9 +386,17 @@ getEventLib = function(self, needEventType) -- needEventType 需要的事件 @@ -372,9 +386,17 @@ getEventLib = function(self, needEventType) -- needEventType 需要的事件
372 local etype = type(eventType) == "table" and eventType[data.type] or eventType 386 local etype = type(eventType) == "table" and eventType[data.type] or eventType
373 387
374 if data.levelchapter == chapterId and (data.unlockType == 0 or (advEventOpenStatus[etype] or {})[data.unlockType]) then 388 if data.levelchapter == chapterId and (data.unlockType == 0 or (advEventOpenStatus[etype] or {})[data.unlockType]) then
375 - if AdvCommon.checkIsIn(level, data.leveltype, data.levellimit) then  
376 - eventLib[etype][data.BlockEventType] = eventLib[etype][data.BlockEventType] or {}  
377 - eventLib[etype][data.BlockEventType][id] = {showup = data.showup, limit = data.limit} 389 + local add = true
  390 + if etype == AdvEventType.LinkChoose then --link 只有起始任务并且还没完成的进入池子
  391 + if id % 10 ~= 1 or (data.limit ~= 0 and data.limit <= (self.adv.lchoose[id] or 0)) then
  392 + add = false
  393 + end
  394 + end
  395 + if add then
  396 + if AdvCommon.checkIsIn(level, data.leveltype, data.levellimit) then
  397 + eventLib[etype][data.BlockEventType] = eventLib[etype][data.BlockEventType] or {}
  398 + eventLib[etype][data.BlockEventType][id] = {showup = data.showup, limit = data.limit}
  399 + end
378 end 400 end
379 end 401 end
380 end 402 end
src/adv/AdvPassive.lua
@@ -337,8 +337,8 @@ function Passive:effect3() @@ -337,8 +337,8 @@ function Passive:effect3()
337 end 337 end
338 --4=逃跑 338 --4=逃跑
339 function Passive:effect4() 339 function Passive:effect4()
340 - self.owner.isDead = true --跑了  
341 - self.owner.battle.adv:enemyDead(self.owner.roomId,self.owner.blockId, true) 340 + self.owner.isDead = 1 --跑了
  341 + -- self.owner.battle.adv:enemyDead(self.owner, true)
342 end 342 end
343 --5=给随机一个敌方增加一个buff 343 --5=给随机一个敌方增加一个buff
344 function Passive:effect5(value) 344 function Passive:effect5(value)
@@ -350,5 +350,12 @@ end @@ -350,5 +350,12 @@ end
350 function Passive:effect6(value) 350 function Passive:effect6(value)
351 self.owner:addPassive({id = value}) 351 self.owner:addPassive({id = value})
352 end 352 end
  353 +--7=给场上队友增加buff
  354 +function Passive:effect7(value)
  355 + local firends = self.owner:getTeam(1, true)
  356 + for k , v in pairs(firends) do
  357 + self.owner:addBuff(value, self.owner)
  358 + end
  359 +end
353 360
354 return Passive 361 return Passive
355 \ No newline at end of file 362 \ No newline at end of file
src/adv/AdvPlayer.lua
@@ -121,7 +121,7 @@ end @@ -121,7 +121,7 @@ end
121 function BaseObject:hadBuff(bType) 121 function BaseObject:hadBuff(bType)
122 for _, buff in ipairs(self.buffs) do 122 for _, buff in ipairs(self.buffs) do
123 if not buff.isDel and buff:getType() == bType then 123 if not buff.isDel and buff:getType() == bType then
124 - return true 124 + return buff
125 end 125 end
126 end 126 end
127 end 127 end
@@ -129,7 +129,7 @@ end @@ -129,7 +129,7 @@ end
129 function BaseObject:hadBuffById(bId) 129 function BaseObject:hadBuffById(bId)
130 for _, buff in ipairs(self.buffs) do 130 for _, buff in ipairs(self.buffs) do
131 if not buff.isDel and buff.id == bId then 131 if not buff.isDel and buff.id == bId then
132 - return true 132 + return buff
133 end 133 end
134 end 134 end
135 end 135 end
src/models/RolePlugin.lua
@@ -589,6 +589,12 @@ function RolePlugin.bind(Role) @@ -589,6 +589,12 @@ function RolePlugin.bind(Role)
589 return globalCsv.adv_daily_cross_count 589 return globalCsv.adv_daily_cross_count
590 end 590 end
591 591
  592 + function Role:getAdvElLimit()
  593 + -- todo
  594 + return globalCsv.adv_endless_daily_cross_count
  595 + end
  596 +
  597 +
592 function Role:isFuncOpen(func) 598 function Role:isFuncOpen(func)
593 return self:getProperty("funcOpen")[func] == 1 599 return self:getProperty("funcOpen")[func] == 1
594 end 600 end