Commit 7828ffd0d78c0cb074911bc82a944efa105aa6ec

Authored by zhouhaihai
1 parent e38b9c49

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

src/GlobalVar.lua
... ... @@ -86,7 +86,8 @@ ItemId = {
86 86 AdvSpecialStage = {
87 87 [1]= "In",
88 88 [2] = "Out",
89   - [3] = "BOSS"
  89 + [3] = "BOSS",
  90 + [4] = "LinkChoose",
90 91 }
91 92 --客户端需要知道这个
92 93 AdvEventType = {
... ... @@ -94,6 +95,7 @@ AdvEventType = {
94 95 In = -1, --入口
95 96 Out = -2, --出口
96 97 BOSS = -3, -- boss
  98 + LinkChoose = -4, -- 连续选择
97 99 -- 普通事件(随机)
98 100 Choose = 1, --选择点
99 101 Drop = 2, --物品掉落点
... ...
src/adv/Adv.lua
... ... @@ -2,6 +2,7 @@ local Passive = require "adv.AdvPassive"
2 2  
3 3 local AdvCommon = require "adv.AdvCommon"
4 4 local AdvMap = require "adv.AdvMap"
  5 +local Buff = require "adv.AdvBuff"
5 6  
6 7 local Adv = class("Adv")
7 8 local AdvTask = import(".AdvTask") --任务相关数据搞出去
... ... @@ -31,6 +32,7 @@ function Adv:initByInfo(advInfo)
31 32 self.score = advInfo.score or {}
32 33 self.lastEnemyId = advInfo.lastEId or 1
33 34 self.mapStack = advInfo.mstack or {}
  35 + self.lchoose = advInfo.lch or {}
34 36 self.maps = {}
35 37 for id, map in ipairs(advInfo.maps or {}) do
36 38 self.maps[id] = AdvMap.new(self, id, map)
... ... @@ -48,7 +50,7 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify)
48 50 self.score = self.score or {}
49 51 self.lastEnemyId = 1
50 52 self.mapStack = {1} -- 最后一个为当前的地图
51   -
  53 + self.lchoose = self.lchoose or {}
52 54 self.owner._advWheelSurfCount = nil -- 抽奖进行次数
53 55  
54 56 -- 随机出地图
... ... @@ -77,6 +79,7 @@ function Adv:clear()
77 79 self.round = 0
78 80 self.lastEnemyId = 1
79 81 self.mapStack = {}
  82 + self.lchoose = {}
80 83 self.maps = {}
81 84 self.battle = nil
82 85 end
... ... @@ -91,6 +94,7 @@ function Adv:saveDB(notNotify)
91 94 advInfo.score = self.score
92 95 advInfo.lastEId = self.lastEnemyId
93 96 advInfo.mstack = self.mapStack
  97 + advInfo.lch = self.lchoose
94 98 advInfo.maps = {}
95 99  
96 100 self.battle:saveDB()
... ... @@ -315,13 +319,15 @@ local function clickMonster(self, room, block, params)
315 319 return true
316 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 323 if not chooseData or not chooseData["button".. choose .."cond"] then return end
322 324  
323 325 local cond = chooseData["button".. choose .."cond"]:toArray(true, "=")
324 326 local checkCond = {
  327 + -- 没有条件
  328 + [0] = function()
  329 + return true
  330 + end,
325 331 -- 拥有道具
326 332 [1] = function()
327 333 if self:cost({[cond[2]] = cond[3]}, {}, true) then
... ... @@ -339,7 +345,7 @@ local function clickChoose(self, room, block, params)
339 345 [3] = function()
340 346 for _, room in pairs(self:getCurMap().rooms) do
341 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 349 return
344 350 end
345 351 end
... ... @@ -352,10 +358,17 @@ local function clickChoose(self, room, block, params)
352 358 return true
353 359 end
354 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 370 if cond[1] and not checkCond[cond[1]]() then return end
358   - local clearBlock = true
  371 + local clearBlock = chooseData.keep ~= 1
359 372 local effects = chooseData["button".. choose .."effect"]:toTableArray(true)
360 373 for _, effect in ipairs(effects) do
361 374 if effect[1] == 1 then
... ... @@ -378,15 +391,44 @@ local function clickChoose(self, room, block, params)
378 391 [4] = function() --无事发生
379 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 395 doEffect[effect[1]]()
383 396 end
384   -
385 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 428 if clearBlock then
388 429 block:clear()
389 430 end
  431 +
390 432 return true
391 433 end
392 434  
... ... @@ -501,6 +543,7 @@ local eventCallFunc = {
501 543 [AdvEventType.BOSS] = clickMonster,
502 544 [AdvEventType.Monster] = clickMonster,
503 545 [AdvEventType.Choose] = clickChoose,
  546 + [AdvEventType.LinkChoose] = clickLinkChoose,
504 547 [AdvEventType.Drop] = clickDrop,
505 548 [AdvEventType.Trader] = clickTrader,
506 549 [AdvEventType.Build] = clickBuild,
... ... @@ -607,8 +650,33 @@ function Adv:usePotion(potionId, potionLevel, target)
607 650 return true
608 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 680 local map = self:getCurMap()
613 681 local room = self:getRoom(roomId)
614 682 local block = self:getBlock(roomId, blockId)
... ... @@ -621,15 +689,20 @@ function Adv:enemyDead(roomId, blockId, escape)
621 689 if escape then
622 690 block:clear()
623 691 else
624   -
625 692 local enemyId = block.event.id
626 693 local monsterData = csvdb["event_monsterCsv"][enemyId]
627 694 self:scoreChange(AdvScoreType.Kill, monsterData.type)
628 695 self.battle.player:addExp(monsterData.exp)
629 696 local item = block.event.item
630 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 706 end
634 707  
635 708 if item[1] == 0 then
... ...
src/adv/AdvBattle.lua
... ... @@ -177,9 +177,9 @@ function Battle:afterRound()
177 177 end
178 178 for i = #self.enemys[mapIdx], 1, -1 do
179 179 if self.enemys[mapIdx][i].isDead then
180   - self.enemys[mapIdx][i]:clear()
181 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 183 end
184 184 end
185 185  
... ...
src/adv/AdvBlock.lua
... ... @@ -89,9 +89,24 @@ function Block:open()
89 89  
90 90 randomFunc[AdvEventType.Trap] = function()
91 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 94 adv.battle.player:addBuff(buffId)
94 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 110 adv:backTrap()
96 111 self:clear()
97 112 end
... ...
src/adv/AdvBuff.lua
... ... @@ -18,6 +18,7 @@ Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合)
18 18 Buff.SP_CHANGE = 15 -- sp变化(每回合)
19 19 Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效)
20 20 Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff
  21 +Buff.CHANGE_DROP = 18 -- 转换掉落
21 22  
22 23 --角色一些属性的变化
23 24 local function commonAttr(_Buff, attrName)
... ... @@ -134,6 +135,12 @@ local BuffFactory = {
134 135 return self.buffData.effectValue1, self.buffData.effectValue2
135 136 end
136 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 145 [Buff.IMMNUE_BUFF] = function(_Buff)
139 146 _Buff._init = function(self, data)
... ...
src/adv/AdvMap.lua
... ... @@ -175,6 +175,7 @@ createMap = function(self, mapId)
175 175 local eventLib = getEventLib(self) -- 同时记录出现次数
176 176 local monsterEvents = {} --处理钥匙掉落
177 177 local haveBoss = false
  178 + local haveLChoose = false
178 179  
179 180  
180 181 local function randomEvent(roomId, blockId, eventType)
... ... @@ -211,6 +212,18 @@ createMap = function(self, mapId)
211 212 end
212 213 haveBoss = true
213 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 229 randomFunc[AdvEventType.Monster] = function()
... ... @@ -351,6 +364,7 @@ getEventLib = function(self, needEventType) -- needEventType 需要的事件
351 364 ["event_clickCsv"] = AdvEventType.Click,
352 365 ["event_layerCsv"] = AdvEventType.Layer,
353 366 ["event_questCsv"] = AdvEventType.Task,
  367 + ["event_linkchooseCsv"] = AdvEventType.LinkChoose,
354 368  
355 369 }
356 370 local eventLib = {}
... ... @@ -372,9 +386,17 @@ getEventLib = function(self, needEventType) -- needEventType 需要的事件
372 386 local etype = type(eventType) == "table" and eventType[data.type] or eventType
373 387  
374 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 400 end
379 401 end
380 402 end
... ...
src/adv/AdvPassive.lua
... ... @@ -337,8 +337,8 @@ function Passive:effect3()
337 337 end
338 338 --4=逃跑
339 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 342 end
343 343 --5=给随机一个敌方增加一个buff
344 344 function Passive:effect5(value)
... ... @@ -350,5 +350,12 @@ end
350 350 function Passive:effect6(value)
351 351 self.owner:addPassive({id = value})
352 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 361 return Passive
355 362 \ No newline at end of file
... ...
src/adv/AdvPlayer.lua
... ... @@ -121,7 +121,7 @@ end
121 121 function BaseObject:hadBuff(bType)
122 122 for _, buff in ipairs(self.buffs) do
123 123 if not buff.isDel and buff:getType() == bType then
124   - return true
  124 + return buff
125 125 end
126 126 end
127 127 end
... ... @@ -129,7 +129,7 @@ end
129 129 function BaseObject:hadBuffById(bId)
130 130 for _, buff in ipairs(self.buffs) do
131 131 if not buff.isDel and buff.id == bId then
132   - return true
  132 + return buff
133 133 end
134 134 end
135 135 end
... ...
src/models/RolePlugin.lua
... ... @@ -589,6 +589,12 @@ function RolePlugin.bind(Role)
589 589 return globalCsv.adv_daily_cross_count
590 590 end
591 591  
  592 + function Role:getAdvElLimit()
  593 + -- todo
  594 + return globalCsv.adv_endless_daily_cross_count
  595 + end
  596 +
  597 +
592 598 function Role:isFuncOpen(func)
593 599 return self:getProperty("funcOpen")[func] == 1
594 600 end
... ...