Commit 0d405dc35916da85e18bd0cfa8c674caf0cdf820
1 parent
1a1a6375
Buff生命周期调整,被动加buff传入releaser
Showing
4 changed files
with
22 additions
and
34 deletions
Show diff stats
src/adv/AdvBattle.lua
| ... | ... | @@ -109,6 +109,11 @@ function Battle:playerAtk(roomId, blockId) |
| 109 | 109 | self:doBattleTurn(enemy, self.player) |
| 110 | 110 | end |
| 111 | 111 | end |
| 112 | + if not self.player.isDead then | |
| 113 | + self.player:battleEnd() | |
| 114 | + elseif not enemy.isDead then | |
| 115 | + enemy:battleEnd() | |
| 116 | + end | |
| 112 | 117 | end |
| 113 | 118 | end |
| 114 | 119 | --战斗内回合逻辑 | ... | ... |
src/adv/AdvBuff.lua
| ... | ... | @@ -3,7 +3,7 @@ local Buff = class("Buff") |
| 3 | 3 | |
| 4 | 4 | Buff.HP_CHANGE = 1 --生命变化(每回合生效) |
| 5 | 5 | Buff.HP_MAX_CHANGE = 2 --生命上限变化(状态) |
| 6 | -Buff.ATK_CHANGE = 3 --攻击变化(状态) | |
| 6 | +Buff.ATTR_CHANGE = 3 --属性变化(状态) | |
| 7 | 7 | Buff.IMMNUE_ATK = 4 -- 免疫普通攻击 |
| 8 | 8 | Buff.BACK_HURT = 5 -- 伤害反弹 |
| 9 | 9 | Buff.HURT_CHANGE = 6 -- 伤害变化 |
| ... | ... | @@ -16,9 +16,6 @@ Buff.CLEAR_BUFF = 12 -- 清除buff |
| 16 | 16 | Buff.CANT_SKILL = 13 -- 禁止技能 |
| 17 | 17 | Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合) |
| 18 | 18 | Buff.POWER_CHANGE = 15 -- 体力变化(每回合) |
| 19 | -Buff.HIT_CHANGE = 16 -- 命中变化(状态) | |
| 20 | -Buff.MISS_CHANGE = 17 -- 闪避变化(状态) | |
| 21 | -Buff.DEF_CHANGE = 18 -- 防御变化(状态) | |
| 22 | 19 | |
| 23 | 20 | --角色一些属性的变化 |
| 24 | 21 | local function commonAttr(_Buff, attrName) |
| ... | ... | @@ -108,22 +105,10 @@ local BuffFactory = { |
| 108 | 105 | return {cv = self._changeV} |
| 109 | 106 | end |
| 110 | 107 | end, |
| 111 | - [Buff.ATK_CHANGE] = function(_Buff) | |
| 112 | - commonAttr(_Buff, "atk") | |
| 108 | + [Buff.ATTR_CHANGE] = function(_Buff) | |
| 109 | + local attrName = AttsEnumEx[self.buffData.effectValue3] | |
| 110 | + commonAttr(_Buff, attrName) | |
| 113 | 111 | end, |
| 114 | - | |
| 115 | - [Buff.HIT_CHANGE] = function(_Buff) | |
| 116 | - commonAttr(_Buff, "hit") | |
| 117 | - end, | |
| 118 | - | |
| 119 | - [Buff.MISS_CHANGE] = function(_Buff) | |
| 120 | - commonAttr(_Buff, "miss") | |
| 121 | - end, | |
| 122 | - | |
| 123 | - [Buff.DEF_CHANGE] = function(_Buff) | |
| 124 | - commonAttr(_Buff, "miss") | |
| 125 | - end, | |
| 126 | - | |
| 127 | 112 | [Buff.BACK_HURT] = function(_Buff) |
| 128 | 113 | _Buff._effectValue = function(self) |
| 129 | 114 | return self.buffData.effectValue1, self.buffData.effectValue2, self.buffData.effectValue3 |
| ... | ... | @@ -219,7 +204,6 @@ function Buff:ctor(owner, id) |
| 219 | 204 | self.id = id |
| 220 | 205 | self.buffData = csvdb["adv_buffCsv"][self.id] |
| 221 | 206 | self.isDel = false |
| 222 | - self.ifRoundEnd = false | |
| 223 | 207 | self.roundSpace = 0 --生效间隔 |
| 224 | 208 | self.turnSpace = 0 --生效间隔 |
| 225 | 209 | self.round = 0 --剩余的回合 |
| ... | ... | @@ -274,10 +258,10 @@ function Buff:initByDB(data) |
| 274 | 258 | end |
| 275 | 259 | end |
| 276 | 260 | |
| 277 | -function Buff:battleBegin() | |
| 278 | - if self.isDel or self.owner.isDead or self.buffData.turn == 0 then return end | |
| 279 | - self.turn = self.buffData.turn | |
| 280 | - self.ifRoundEnd = true -- turn类型buff战斗结束后移除 | |
| 261 | +function Buff:battleEnd() | |
| 262 | + if self.buffData.turn ~= 0 then | |
| 263 | + self.isDel = true -- turn类型buff战斗结束后移除 | |
| 264 | + end | |
| 281 | 265 | end |
| 282 | 266 | |
| 283 | 267 | function Buff:beforeTurn() |
| ... | ... | @@ -326,10 +310,6 @@ function Buff:afterRound() |
| 326 | 310 | if self._afterRound then |
| 327 | 311 | self:_afterRound() |
| 328 | 312 | end |
| 329 | - if self.ifRoundEnd then -- turn类型buff战斗结束后移除 | |
| 330 | - self.isDel = true | |
| 331 | - return | |
| 332 | - end | |
| 333 | 313 | if self.buffData.roundTime > 0 then |
| 334 | 314 | self.turnSpace = self.buffData.roundTime |
| 335 | 315 | end | ... | ... |
src/adv/AdvPassive.lua
| ... | ... | @@ -202,7 +202,7 @@ function Passive:ctor(owner, data) |
| 202 | 202 | self.count = data.count or self.passiveData.count --触发剩余次数 |
| 203 | 203 | self.delay = data.delay or self.passiveData.delayRound --触发延迟回合数 |
| 204 | 204 | self.turn = 0 --战斗内回合数 |
| 205 | - self.delayturn = 0 --战斗内延迟回合数 | |
| 205 | + self.delayturn = self.passiveData.delayTurn --战斗内延迟回合数 | |
| 206 | 206 | |
| 207 | 207 | self.effects = self.passiveData.effect:toTableArray(true) |
| 208 | 208 | self.filters = {} |
| ... | ... | @@ -342,12 +342,12 @@ function Passive:effect0(value) |
| 342 | 342 | end |
| 343 | 343 | --1=自身获得buff |
| 344 | 344 | function Passive:effect1(value) |
| 345 | - self.owner:addBuff(value) | |
| 345 | + self.owner:addBuff(value, self.owner) | |
| 346 | 346 | end |
| 347 | 347 | --2=触发目标获得buff |
| 348 | 348 | function Passive:effect2(value, trigger) |
| 349 | 349 | if trigger then |
| 350 | - trigger:addBuff(value) | |
| 350 | + trigger:addBuff(value, self.owner) | |
| 351 | 351 | end |
| 352 | 352 | end |
| 353 | 353 | --3=翻开自己所在格子 |
| ... | ... | @@ -363,7 +363,7 @@ end |
| 363 | 363 | function Passive:effect5(value) |
| 364 | 364 | local monsters = self.owner.battle.player:getTeam(2) |
| 365 | 365 | local randomId = math.random( 1, #monsters ) |
| 366 | - monsters[randomId]:addBuff(value) | |
| 366 | + monsters[randomId]:addBuff(value, self.owner) | |
| 367 | 367 | end |
| 368 | 368 | --6=给自己加一個被動技能 |
| 369 | 369 | function Passive:effect6(value) | ... | ... |
src/adv/AdvPlayer.lua
| ... | ... | @@ -60,7 +60,7 @@ function BaseObject:afterRound() |
| 60 | 60 | passive:afterRound(self) |
| 61 | 61 | end |
| 62 | 62 | for _, buff in ipairs(self.buffs) do |
| 63 | - buff:afterRound(self) | |
| 63 | + buff:afterRound() | |
| 64 | 64 | end |
| 65 | 65 | end |
| 66 | 66 | |
| ... | ... | @@ -98,8 +98,11 @@ function BaseObject:battleBegin() |
| 98 | 98 | for _, passive in ipairs(self.passives) do |
| 99 | 99 | passive:battleBegin() |
| 100 | 100 | end |
| 101 | +end | |
| 102 | + | |
| 103 | +function BaseObject:battleEnd() | |
| 101 | 104 | for _, buff in ipairs(self.buffs) do |
| 102 | - buff:battleBegin() | |
| 105 | + buff:battleEnd() | |
| 103 | 106 | end |
| 104 | 107 | end |
| 105 | 108 | ... | ... |