Commit b71a819081da541ad962158706e1cd3656390e8e

Authored by zhouhaihai
1 parent e1355da3

动态改变 一些buff

@@ -115,7 +115,7 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt @@ -115,7 +115,7 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt
115 self.maps = {} 115 self.maps = {}
116 self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay) 116 self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay)
117 117
118 - self:initBattle() 118 + self:initBattle(true)
119 119
120 self:initLayerTask() 120 self:initLayerTask()
121 121
@@ -371,7 +371,7 @@ function Adv:clearAdvUnlockCache() @@ -371,7 +371,7 @@ function Adv:clearAdvUnlockCache()
371 self.cacheUnlock = {} 371 self.cacheUnlock = {}
372 end 372 end
373 373
374 -function Adv:initBattle() 374 +function Adv:initBattle(notDb)
375 self.battle = require("adv.AdvBattle").new(self) 375 self.battle = require("adv.AdvBattle").new(self)
376 for _, passiveC in ipairs(self.cachePassiveEvent or {}) do 376 for _, passiveC in ipairs(self.cachePassiveEvent or {}) do
377 self.battle:triggerPassive(passiveC[1], passiveC[2]) 377 self.battle:triggerPassive(passiveC[1], passiveC[2])
@@ -382,6 +382,10 @@ function Adv:initBattle() @@ -382,6 +382,10 @@ function Adv:initBattle()
382 for idx, map in pairs(self.maps) do 382 for idx, map in pairs(self.maps) do
383 map:initBattleAfter() 383 map:initBattleAfter()
384 end 384 end
  385 + --下层
  386 + if notDb and self.level ~= 1 then
  387 + self.battle.player:attrChangeCondBuffCheck(1)
  388 + end
385 end 389 end
386 390
387 function Adv:triggerPassive(condType, params) 391 function Adv:triggerPassive(condType, params)
@@ -758,6 +762,10 @@ function Adv:award(gift, params) @@ -758,6 +762,10 @@ function Adv:award(gift, params)
758 if items ~= oldItems then 762 if items ~= oldItems then
759 self.owner:updateProperty({field = "advItems", value = items, notNotify = params.notNotify}) 763 self.owner:updateProperty({field = "advItems", value = items, notNotify = params.notNotify})
760 end 764 end
  765 +
  766 + if tgift[ItemId.OldCoin] then
  767 + self.battle.player:attrChangeCondBuffCheck(0)
  768 + end
761 return tgift 769 return tgift
762 end 770 end
763 771
src/adv/AdvBuff.lua
@@ -35,7 +35,7 @@ Buff.Buff_NO_PASSIVE_MONSTER = 31 -- 地图被动刷新不出来怪物 @@ -35,7 +35,7 @@ Buff.Buff_NO_PASSIVE_MONSTER = 31 -- 地图被动刷新不出来怪物
35 35
36 --角色一些属性的变化 36 --角色一些属性的变化
37 local function commonAttr(_Buff, attrName) 37 local function commonAttr(_Buff, attrName)
38 - _Buff._init = function(self, data) --初始化变化值 38 + _Buff._init = function(self) --初始化变化值
39 self.owner:reSetAttr(attrName) 39 self.owner:reSetAttr(attrName)
40 end 40 end
41 _Buff._effectValue = function(self) 41 _Buff._effectValue = function(self)
@@ -55,38 +55,19 @@ local function commonAttr(_Buff, attrName) @@ -55,38 +55,19 @@ local function commonAttr(_Buff, attrName)
55 end 55 end
56 end 56 end
57 local function commonAttCond(_Buff, attrName) 57 local function commonAttCond(_Buff, attrName)
58 - _Buff._init = function(self, data) --初始化变化值  
59 - self._changeV = self:_calculate()  
60 - self:_reSetAttr(true) 58 + _Buff._init = function(self) --初始化变化值
  59 + self:_reSetAttr()
61 end 60 end
62 _Buff._overlay = function(self) 61 _Buff._overlay = function(self)
63 - self._changeV = (self._changeV or 0) + self:_calculate()  
64 - self:_reSetAttr(true) 62 + self:_reSetAttr()
65 end 63 end
66 _Buff._uncover = function(self) 64 _Buff._uncover = function(self)
67 - self._changeV = self._changeV - self._changeV / (self.layer + 1)  
68 self:_reSetAttr() 65 self:_reSetAttr()
69 end 66 end
70 67
71 - _Buff._hpChange = function(self)  
72 - local oldHpMax = self.owner.hpMax  
73 - self.owner:reSetHpMax()  
74 -  
75 - local curValue = self.owner.hpMax - oldHpMax  
76 - if curValue > 0 then  
77 - self.owner:recover(curValue, self.release) -- 防止release不存在,地图点buff  
78 - elseif curValue < 0 then  
79 - self.owner:hurt(self.release and self.release:getHurtValue(-curValue) or -curValue, self.release, {hurtType = 2, buffId = self.id})  
80 - end  
81 - end  
82 -  
83 - _Buff._reSetAttr = function(self, isInit) 68 + _Buff._reSetAttr = function(self)
84 if attrName == "hp" then 69 if attrName == "hp" then
85 - if isInit then  
86 - self:_hpChange()  
87 - else  
88 - self.owner:reSetHpMax()  
89 - end 70 + self.owner:reSetHpMax()
90 else 71 else
91 self.owner:reSetAttr(attrName) 72 self.owner:reSetAttr(attrName)
92 end 73 end
@@ -95,27 +76,37 @@ local function commonAttCond(_Buff, attrName) @@ -95,27 +76,37 @@ local function commonAttCond(_Buff, attrName)
95 _Buff._calculate = function(self) 76 _Buff._calculate = function(self)
96 local effectCount = 0 77 local effectCount = 0
97 if self.buffData.effectValue4 == 0 then 78 if self.buffData.effectValue4 == 0 then
98 - effectCount = self.owner.battle.adv.owner:getProperty("advItems"):getv(ItemId.OldCoin, 0) 79 + effectCount = self.owner.battle.adv.owner:getProperty("advItems"):getv(ItemId.OldCoin, 0) / tonumber(self.buffData.effectValue5)
  80 + elseif self.buffData.effectValue4 == 1 then
  81 + effectCount = self.owner.battle.adv.level
  82 + elseif self.buffData.effectValue4 == 2 then
  83 + local buff = self.owner.battle.player:getBuffById(tonumber(self.buffData.effectValue5))
  84 + effectCount = buff.layer
99 end 85 end
100 - return self.buffData.effectValue2 * effectCount / tonumber(self.buffData.effectValue5) 86 + return self.buffData.effectValue2 * effectCount
101 end 87 end
102 - _Buff._initDB = function(self, data)  
103 - self._changeV = data.cv 88 +
  89 + _Buff.getEffectBy = function(self)
  90 + local cond = nil
  91 + if self.buffData.effectValue4 == 2 then
  92 + cond = tonumber(self.buffData.effectValue5)
  93 + end
  94 + return self.buffData.effectValue4, attrName, cond
104 end 95 end
  96 +
105 _Buff._effectValue = function(self) 97 _Buff._effectValue = function(self)
106 - return self.buffData.effectValue1, self._changeV, attrName 98 + print(self:_calculate() * self.layer)
  99 + return self.buffData.effectValue1, self:_calculate() * self.layer, attrName
107 end 100 end
  101 +
108 _Buff._endBuff = function(self, data) 102 _Buff._endBuff = function(self, data)
109 self:_reSetAttr() 103 self:_reSetAttr()
110 end 104 end
111 - _Buff._getDB = function(self)  
112 - return {cv = self._changeV}  
113 - end  
114 end 105 end
115 106
116 local BuffFactory = { 107 local BuffFactory = {
117 [Buff.HP_CHANGE] = function(_Buff) 108 [Buff.HP_CHANGE] = function(_Buff)
118 - _Buff._init = function(self, data) --初始化变化值 109 + _Buff._init = function(self) --初始化变化值
119 self._changeV = self:_calculate() 110 self._changeV = self:_calculate()
120 end 111 end
121 _Buff._overlay = function(self) 112 _Buff._overlay = function(self)
@@ -161,13 +152,13 @@ local BuffFactory = { @@ -161,13 +152,13 @@ local BuffFactory = {
161 end, 152 end,
162 153
163 [Buff.HP_MAX_CHANGE] = function(_Buff) 154 [Buff.HP_MAX_CHANGE] = function(_Buff)
164 - _Buff._init = function(self, data) --初始化变化值 155 + _Buff._init = function(self) --初始化变化值
165 self._changeV = self:_calculate() 156 self._changeV = self:_calculate()
166 - self:_hpChange() 157 + self.owner:reSetHpMax()
167 end 158 end
168 _Buff._overlay = function(self) 159 _Buff._overlay = function(self)
169 self._changeV = (self._changeV or 0) + self:_calculate() 160 self._changeV = (self._changeV or 0) + self:_calculate()
170 - self:_hpChange() 161 + self.owner:reSetHpMax()
171 end 162 end
172 163
173 _Buff._uncover = function(self) 164 _Buff._uncover = function(self)
@@ -175,19 +166,6 @@ local BuffFactory = { @@ -175,19 +166,6 @@ local BuffFactory = {
175 self.owner:reSetHpMax() 166 self.owner:reSetHpMax()
176 end 167 end
177 168
178 - -- 提高生命上限的时候要相应提高生命值  
179 - _Buff._hpChange = function(self)  
180 - local oldHpMax = self.owner.hpMax  
181 - self.owner:reSetHpMax()  
182 -  
183 - local curValue = self.owner.hpMax - oldHpMax  
184 - if curValue > 0 then  
185 - self.owner:recover(curValue, self.release) -- 防止release不存在,地图点buff  
186 - elseif curValue < 0 then  
187 - self.owner:hurt(self.release and self.release:getHurtValue(-curValue) or -curValue, self.release, {hurtType = 2, buffId = self.id})  
188 - end  
189 - end  
190 -  
191 _Buff._calculate = function(self) 169 _Buff._calculate = function(self)
192 local curValue = 0 170 local curValue = 0
193 if self.buffData.effectValue1 == 0 then --固定值 171 if self.buffData.effectValue1 == 0 then --固定值
@@ -258,7 +236,7 @@ local BuffFactory = { @@ -258,7 +236,7 @@ local BuffFactory = {
258 end, 236 end,
259 237
260 [Buff.CLEAR_BUFF] = function(_Buff) 238 [Buff.CLEAR_BUFF] = function(_Buff)
261 - _Buff._init = function(self, data) 239 + _Buff._init = function(self)
262 for _, buff in ipairs(self.owner.buffs) do -- 挂上就清除一下子 240 for _, buff in ipairs(self.owner.buffs) do -- 挂上就清除一下子
263 if not buff.isDel and self:canEffect(buff.id) and not self.isDel then 241 if not buff.isDel and self:canEffect(buff.id) and not self.isDel then
264 if not buff.isDel and not self.isDel then 242 if not buff.isDel and not self.isDel then
@@ -326,7 +304,7 @@ local BuffFactory = { @@ -326,7 +304,7 @@ local BuffFactory = {
326 end, 304 end,
327 305
328 [Buff.SP_MAX_CHANGE] = function(_Buff) 306 [Buff.SP_MAX_CHANGE] = function(_Buff)
329 - _Buff._init = function(self, data) --初始化变化值 307 + _Buff._init = function(self) --初始化变化值
330 self:_spChange() 308 self:_spChange()
331 end 309 end
332 _Buff._overlay = function(self) 310 _Buff._overlay = function(self)
@@ -444,8 +422,11 @@ function Buff:initNew(release, data) @@ -444,8 +422,11 @@ function Buff:initNew(release, data)
444 if self.buffData.effectTime > 0 then 422 if self.buffData.effectTime > 0 then
445 self.count = self.buffData.effectTime 423 self.count = self.buffData.effectTime
446 end 424 end
  425 +end
  426 +
  427 +function Buff:createAfter()
447 if self._init then 428 if self._init then
448 - self:_init(data) 429 + self:_init()
449 end 430 end
450 end 431 end
451 432
src/adv/AdvPlayer.lua
@@ -68,9 +68,13 @@ function BaseObject:clearRound() @@ -68,9 +68,13 @@ function BaseObject:clearRound()
68 end 68 end
69 for i = #self.buffs, 1, -1 do 69 for i = #self.buffs, 1, -1 do
70 if self.buffs[i].isDel then 70 if self.buffs[i].isDel then
71 - self.battle.adv:backBuff(self.monsterId, self.buffs[i].id, true)  
72 - self.buffs[i]:endBuff() 71 + local buff = self.buffs[i]
  72 + self.battle.adv:backBuff(self.monsterId, buff.id, true)
73 table.remove(self.buffs, i) 73 table.remove(self.buffs, i)
  74 + buff:endBuff()
  75 + if self.attrChangeCondBuffCheck then
  76 + self:attrChangeCondBuffCheck(2, buff.id)
  77 + end
74 end 78 end
75 end 79 end
76 end 80 end
@@ -142,7 +146,9 @@ function BaseObject:addBuff(buffId, releaser) @@ -142,7 +146,9 @@ function BaseObject:addBuff(buffId, releaser)
142 buffData = buffData, 146 buffData = buffData,
143 releaseId = releaser and releaser.monsterId or nil 147 releaseId = releaser and releaser.monsterId or nil
144 }) then return end 148 }) then return end
145 - table.insert(self.buffs, Buff.create(self, releaser, {id = buffId})) 149 + local buff = Buff.create(self, releaser, {id = buffId})
  150 + table.insert(self.buffs, buff)
  151 + buff:createAfter()
146 end 152 end
147 self:triggerPassive(Passive.GET_BUFF, {buffId = buffId}) 153 self:triggerPassive(Passive.GET_BUFF, {buffId = buffId})
148 self.battle.adv:backBuff(self.monsterId, buffId) 154 self.battle.adv:backBuff(self.monsterId, buffId)
@@ -160,8 +166,11 @@ function BaseObject:delBuffById(bId) @@ -160,8 +166,11 @@ function BaseObject:delBuffById(bId)
160 for idx, buff in ipairs(self.buffs) do 166 for idx, buff in ipairs(self.buffs) do
161 if buff.id == bId then 167 if buff.id == bId then
162 self.battle.adv:backBuff(self.monsterId, buff.id, true) 168 self.battle.adv:backBuff(self.monsterId, buff.id, true)
163 - buff:endBuff()  
164 table.remove(self.buffs, idx) 169 table.remove(self.buffs, idx)
  170 + buff:endBuff()
  171 + if self.attrChangeCondBuffCheck then
  172 + self:attrChangeCondBuffCheck(2, bId)
  173 + end
165 return buff 174 return buff
166 end 175 end
167 end 176 end
@@ -639,9 +648,31 @@ end @@ -639,9 +648,31 @@ end
639 648
640 function Player:addBuff(buffId, releaser) 649 function Player:addBuff(buffId, releaser)
641 Player.super.addBuff(self, buffId, releaser) 650 Player.super.addBuff(self, buffId, releaser)
  651 + self.battle.player:attrChangeCondBuffCheck(2, buffId)
642 self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) 652 self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId)
643 end 653 end
644 654
  655 +function Player:attrChangeCondBuffCheck(etype, cond)
  656 + local effect = {}
  657 + for _, buff in ipairs(self.buffs) do
  658 + if not buff.isDel and (buff:getType() == Buff.ATTR_CHANGE_COND) then
  659 + local _et, _attr, _co = buff:getEffectBy()
  660 + if etype == _et and (not _co or _co == cond) then
  661 + effect[_attr] = 1
  662 + end
  663 +
  664 + end
  665 + end
  666 + dump(effect)
  667 + for attrName, _ in pairs(effect) do
  668 + if attrName == "hp" then
  669 + self:reSetHpMax()
  670 + else
  671 + self:reSetAttr(attrName)
  672 + end
  673 + end
  674 +end
  675 +
645 function Player:getDB() 676 function Player:getDB()
646 local db = Player.super.getDB(self) 677 local db = Player.super.getDB(self)
647 for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do 678 for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do