Commit e90b4d203a4d9da793a8cba61e8814371c28670c

Authored by zhouhaihai
1 parent 058a0cbb

战斗buff

src/adv/AdvBattle.lua
... ... @@ -160,6 +160,7 @@ function Battle:battleBegin(roomId, blockId, params)
160 160 -- 玩家没死就是怪死了
161 161 if player.hp > 0 then
162 162 enemy:hurt(enemy.hp, self.player, {hurtType = 5})
  163 + self.player:effectBattleBuff()
163 164 end
164 165 self.player:hurt(math.max(0, math.ceil(self.player.hp - player.hp)), enemy, {hurtType = 5}) --战斗血量只会变少
165 166 self.player:changeSp(math.min(0, math.floor(player.sp - self.player.sp)) , 0) --战斗魔力只会变少
... ...
src/adv/AdvBuff.lua
... ... @@ -17,6 +17,7 @@ Buff.CANT_SKILL = 13 -- 禁止技能
17 17 Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合)
18 18 Buff.SP_CHANGE = 15 -- sp变化(每回合)
19 19 Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效)
  20 +Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff
20 21  
21 22 --角色一些属性的变化
22 23 local function commonAttr(_Buff, attrName)
... ... @@ -224,9 +225,7 @@ function Buff:ctor(owner, id)
224 225 self.buffData = csvdb["adv_map_buffCsv"][self.id]
225 226 self.isDel = false
226 227 self.roundSpace = 0 --生效间隔
227   - self.turnSpace = 0 --生效间隔
228 228 self.round = 0 --剩余的回合
229   - self.turn = 0 --剩余战斗内回合
230 229 self.count = -1 -- 可生效的次数 -1 无次数限制
231 230  
232 231 if BuffFactory[self.buffData.type] then
... ... @@ -249,7 +248,6 @@ end
249 248 function Buff:initNew(release, data)
250 249 self.release = release or self.owner
251 250 self.round = self.buffData.round
252   - self.turn = self.buffData.turn
253 251 if self.buffData.effectTime > 0 then
254 252 self.count = self.buffData.effectTime
255 253 end
... ... @@ -277,11 +275,6 @@ function Buff:initByDB(data)
277 275 end
278 276 end
279 277  
280   -function Buff:battleEnd()
281   - if self.buffData.turn ~= 0 then
282   - self.isDel = true -- turn类型buff战斗结束后移除
283   - end
284   -end
285 278  
286 279 function Buff:afterRound()
287 280 if self.isDel or self.owner.isDead or self.buffData.round == 0 then return end
... ...
src/adv/AdvPlayer.lua
... ... @@ -444,6 +444,14 @@ function Player:changeSp(value, cType)
444 444 self.battle.adv:pushBackEvent(AdvBackEventType.SpChange)
445 445 end
446 446  
  447 +--战斗结束了扣战斗buff次数
  448 +function Player:effectBattleBuff()
  449 + for _, buff in ipairs(self.buffs) do
  450 + if not buff.isDel and buff:getType() == Buff.BATTLE_BUFF then
  451 + buff:effect()
  452 + end
  453 + end
  454 +end
447 455  
448 456 function Player:getDB()
449 457 local db = Player.super.getDB(self)
... ...