Commit a80fee7cca90aa07aa063f7fc79a3a81c152d9b5
1 parent
505479c7
光环
Showing
4 changed files
with
255 additions
and
31 deletions
Show diff stats
src/adv/Adv.lua
| @@ -102,6 +102,9 @@ function Adv:initByChapter(params) | @@ -102,6 +102,9 @@ function Adv:initByChapter(params) | ||
| 102 | self.cacheUnlock = self.cacheUnlock or {} | 102 | self.cacheUnlock = self.cacheUnlock or {} |
| 103 | self.shopStatus = self.shopStatus or {} | 103 | self.shopStatus = self.shopStatus or {} |
| 104 | self.support = self.support or {} | 104 | self.support = self.support or {} |
| 105 | + if self.battle then | ||
| 106 | + self.battle:overBattle() | ||
| 107 | + end | ||
| 105 | self.battle = nil -- 清掉 老的 battle | 108 | self.battle = nil -- 清掉 老的 battle |
| 106 | self.logid = self.owner:getActionUcode() | 109 | self.logid = self.owner:getActionUcode() |
| 107 | 110 | ||
| @@ -211,7 +214,7 @@ function Adv:saveDB(notNotify) | @@ -211,7 +214,7 @@ function Adv:saveDB(notNotify) | ||
| 211 | advInfo.logid = self.logid | 214 | advInfo.logid = self.logid |
| 212 | advInfo.maps = {} | 215 | advInfo.maps = {} |
| 213 | 216 | ||
| 214 | - self.battle:saveDB() | 217 | + self.battle:saveDB(advInfo) |
| 215 | 218 | ||
| 216 | for id , map in ipairs(self.maps) do | 219 | for id , map in ipairs(self.maps) do |
| 217 | advInfo.maps[id] = map:getDB() | 220 | advInfo.maps[id] = map:getDB() |
| @@ -468,6 +471,11 @@ function Adv:initBattle(notDb) | @@ -468,6 +471,11 @@ function Adv:initBattle(notDb) | ||
| 468 | if notDb and self.level ~= 1 then | 471 | if notDb and self.level ~= 1 then |
| 469 | self.battle.player:attrChangeCondBuffCheck(1) | 472 | self.battle.player:attrChangeCondBuffCheck(1) |
| 470 | end | 473 | end |
| 474 | + | ||
| 475 | + -- 初始化 | ||
| 476 | + if notDb then | ||
| 477 | + self.battle:newBattle() | ||
| 478 | + end | ||
| 471 | end | 479 | end |
| 472 | 480 | ||
| 473 | function Adv:triggerPassive(condType, params) | 481 | function Adv:triggerPassive(condType, params) |
| @@ -1084,7 +1092,9 @@ local function clickOut(self, room, block, params, isExit) | @@ -1084,7 +1092,9 @@ local function clickOut(self, room, block, params, isExit) | ||
| 1084 | end | 1092 | end |
| 1085 | 1093 | ||
| 1086 | if #self.mapStack > 1 then -- 处于夹层中 | 1094 | if #self.mapStack > 1 then -- 处于夹层中 |
| 1095 | + local oldMapIdx = self:getCurMapIdx() | ||
| 1087 | table.remove(self.mapStack) --退出夹层 | 1096 | table.remove(self.mapStack) --退出夹层 |
| 1097 | + self.battle:iLayerChange(oldMapIdx) | ||
| 1088 | self:backLayer(-1) | 1098 | self:backLayer(-1) |
| 1089 | else --处于底层 | 1099 | else --处于底层 |
| 1090 | 1100 | ||
| @@ -1119,7 +1129,6 @@ local function clickOut(self, room, block, params, isExit) | @@ -1119,7 +1129,6 @@ local function clickOut(self, room, block, params, isExit) | ||
| 1119 | end | 1129 | end |
| 1120 | local isHaveRelay = self:isHaveRelay(self.level) | 1130 | local isHaveRelay = self:isHaveRelay(self.level) |
| 1121 | 1131 | ||
| 1122 | - self.owner:getProperty("advTeam").player = self.battle.player:getDB() -- 临时缓存住 battle 的player | ||
| 1123 | if isHaveRelay and not self.isRelay then | 1132 | if isHaveRelay and not self.isRelay then |
| 1124 | self:initByChapter({ | 1133 | self:initByChapter({ |
| 1125 | chapterId = self.chapterId, | 1134 | chapterId = self.chapterId, |
| @@ -1562,6 +1571,7 @@ local function clickClick(self, room, block, params) | @@ -1562,6 +1571,7 @@ local function clickClick(self, room, block, params) | ||
| 1562 | end | 1571 | end |
| 1563 | 1572 | ||
| 1564 | local function clickLayer(self, room, block, params) | 1573 | local function clickLayer(self, room, block, params) |
| 1574 | + local oldMapIdx = self:getCurMapIdx() | ||
| 1565 | if block.event.mapIdx then | 1575 | if block.event.mapIdx then |
| 1566 | table.insert(self.mapStack, block.event.mapIdx) --进入夹层 | 1576 | table.insert(self.mapStack, block.event.mapIdx) --进入夹层 |
| 1567 | else | 1577 | else |
| @@ -1577,6 +1587,7 @@ local function clickLayer(self, room, block, params) | @@ -1577,6 +1587,7 @@ local function clickLayer(self, room, block, params) | ||
| 1577 | self.maps[mapIdx]:initBattleAfter() | 1587 | self.maps[mapIdx]:initBattleAfter() |
| 1578 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) | 1588 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) |
| 1579 | end | 1589 | end |
| 1590 | + self.battle:iLayerChange(oldMapIdx) | ||
| 1580 | self:backLayer(1) | 1591 | self:backLayer(1) |
| 1581 | return true | 1592 | return true |
| 1582 | end | 1593 | end |
| @@ -2101,21 +2112,11 @@ function Adv:scoreChange(scoreType, score) | @@ -2101,21 +2112,11 @@ function Adv:scoreChange(scoreType, score) | ||
| 2101 | end | 2112 | end |
| 2102 | 2113 | ||
| 2103 | function Adv:getScore() | 2114 | function Adv:getScore() |
| 2104 | - self.score[AdvScoreType.Level] = math.floor(self.score[AdvScoreType.Level] or 0) | ||
| 2105 | - self.score[AdvScoreType.Task] = math.floor(self.score[AdvScoreType.Task] or 0) | ||
| 2106 | - self.score[AdvScoreType.Kill] = math.floor(self.score[AdvScoreType.Kill] or 0) | ||
| 2107 | - self.score[AdvScoreType.KillBoss] = math.floor(self.score[AdvScoreType.KillBoss] or 0) | ||
| 2108 | - self.score[AdvScoreType.ItemBack] = math.floor(self.score[AdvScoreType.ItemBack] or 0) | ||
| 2109 | - self.score[AdvScoreType.Event] = math.floor(self.score[AdvScoreType.Event] or 0) | ||
| 2110 | - self.score[AdvScoreType.Story] = math.floor(self.score[AdvScoreType.Story] or 0) | ||
| 2111 | - | ||
| 2112 | - return self.score[AdvScoreType.Level] | ||
| 2113 | - + self.score[AdvScoreType.Task] | ||
| 2114 | - + self.score[AdvScoreType.Kill] | ||
| 2115 | - + self.score[AdvScoreType.KillBoss] | ||
| 2116 | - + self.score[AdvScoreType.ItemBack] | ||
| 2117 | - + self.score[AdvScoreType.Event] | ||
| 2118 | - + self.score[AdvScoreType.Story] | 2115 | + local allScore = 0 |
| 2116 | + for _, score in pairs(self.score) do | ||
| 2117 | + allScore = allScore + math.floor(score) | ||
| 2118 | + end | ||
| 2119 | + return allScore | ||
| 2119 | end | 2120 | end |
| 2120 | 2121 | ||
| 2121 | function Adv:popBackEvents() | 2122 | function Adv:popBackEvents() |
src/adv/AdvBattle.lua
| @@ -8,6 +8,7 @@ function Battle:ctor(adv) | @@ -8,6 +8,7 @@ function Battle:ctor(adv) | ||
| 8 | self.isNewPlayer = false | 8 | self.isNewPlayer = false |
| 9 | self.enemys = {} --怪 | 9 | self.enemys = {} --怪 |
| 10 | self.builds = {} -- 建筑 | 10 | self.builds = {} -- 建筑 |
| 11 | + self.auras = {} -- 光环 | ||
| 11 | self.cachePassiveEvent = {} | 12 | self.cachePassiveEvent = {} |
| 12 | self:initPlayer() | 13 | self:initPlayer() |
| 13 | self:initEnemys() | 14 | self:initEnemys() |
| @@ -198,8 +199,10 @@ function Battle:addEnemy(room, block, mapIdx, init) | @@ -198,8 +199,10 @@ function Battle:addEnemy(room, block, mapIdx, init) | ||
| 198 | end | 199 | end |
| 199 | 200 | ||
| 200 | for _, buff in ipairs(buffs) do | 201 | for _, buff in ipairs(buffs) do |
| 201 | - enemy:addBuff(buff) | 202 | + player:addBuff(buff) |
| 202 | end | 203 | end |
| 204 | + -- 新生成的怪 加上 已有的光环buff | ||
| 205 | + player:checkAuraBuff(self:checkDiffAuraBuff({}, self:getAurasByMap())) | ||
| 203 | end | 206 | end |
| 204 | end | 207 | end |
| 205 | return player | 208 | return player |
| @@ -347,6 +350,8 @@ function Battle:afterRound() | @@ -347,6 +350,8 @@ function Battle:afterRound() | ||
| 347 | 350 | ||
| 348 | self.player:triggerPassive(Passive.AFTER_ROUND) | 351 | self.player:triggerPassive(Passive.AFTER_ROUND) |
| 349 | 352 | ||
| 353 | + self:checkAura() | ||
| 354 | + | ||
| 350 | if self.player.isDead then | 355 | if self.player.isDead then |
| 351 | self.adv:over(false, nil, -2) | 356 | self.adv:over(false, nil, -2) |
| 352 | end | 357 | end |
| @@ -435,8 +440,116 @@ function Battle:initMapEffect(ilayer) | @@ -435,8 +440,116 @@ function Battle:initMapEffect(ilayer) | ||
| 435 | end | 440 | end |
| 436 | 441 | ||
| 437 | 442 | ||
| 443 | +-- 夹层 进入退出 接口 清理玩家身上的老光环 添加新的光环 | ||
| 444 | +function Battle:iLayerChange(oldMapIdx) | ||
| 445 | + local auras = self:getActiveAuras() | ||
| 446 | + local playerBuffs = self:checkDiffAuraBuff(self:getAurasByMap(oldMapIdx), auras) | ||
| 447 | + local enemyBuffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras) | ||
| 448 | + self.player:checkAuraBuff(playerBuffs) | ||
| 449 | + for _, enemy in pairs(self.player:getTeam(2)) do | ||
| 450 | + enemy:checkAuraBuff(enemyBuffs) | ||
| 451 | + end | ||
| 452 | + self:setMapAuras(auras) | ||
| 453 | +end | ||
| 454 | + | ||
| 455 | +-- 新的 关卡 关闭旧的战斗模块 清理 玩家身上的光环效果 | ||
| 456 | +function Battle:overBattle() | ||
| 457 | + local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), {}) | ||
| 458 | + self.player:checkAuraBuff(buffs) | ||
| 459 | + self.adv.owner:getProperty("advTeam").player = self.player:getDB() -- 临时缓存住 battle 的player | ||
| 460 | +end | ||
| 461 | + | ||
| 462 | +-- 初始化 新的 关卡 | ||
| 463 | +function Battle:newBattle() | ||
| 464 | + local auras = self:getActiveAuras() | ||
| 465 | + local buffs = self:checkDiffAuraBuff({}, auras) | ||
| 466 | + self:setMapAuras(auras) | ||
| 467 | +end | ||
| 468 | + | ||
| 469 | +-- 过了回合 检查光环 | ||
| 470 | +function Battle:checkAura() | ||
| 471 | + local auras = self:getActiveAuras() | ||
| 472 | + local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras) | ||
| 473 | + self.player:checkAuraBuff(buffs) | ||
| 474 | + for _, enemy in pairs(self.player:getTeam(2)) do | ||
| 475 | + enemy:checkAuraBuff(buffs) | ||
| 476 | + end | ||
| 477 | + self:setMapAuras(auras) | ||
| 478 | +end | ||
| 479 | + | ||
| 480 | +-- 查找差异buff | ||
| 481 | +function Battle:checkDiffAuraBuff(oldAuras, newAuras) | ||
| 482 | + local auras = {} | ||
| 483 | + for aurasId , count in pairs(oldAuras) do | ||
| 484 | + auras[aurasId] = -count | ||
| 485 | + end | ||
| 486 | + for aurasId , count in pairs(newAuras) do | ||
| 487 | + auras[aurasId] = (auras[aurasId] or 0) + count | ||
| 488 | + end | ||
| 489 | + | ||
| 490 | + local buffs = {} | ||
| 491 | + for aurasId , count in pairs(auras) do | ||
| 492 | + local auraData = csvdb["adv_map_haloCsv"][aurasId] | ||
| 493 | + if auraData then | ||
| 494 | + for _, effect in ipairs(auraData.effect:toTableArray(true)) do | ||
| 495 | + temp = buffs | ||
| 496 | + for i = 1, #effect do | ||
| 497 | + temp[effect[i]] = temp[effect[i]] or {} | ||
| 498 | + temp = temp[effect[i]] | ||
| 499 | + end | ||
| 500 | + temp.count = (temp.count or 0) + count | ||
| 501 | + if newAuras[aurasId] then | ||
| 502 | + -- 加上 未消失标记 | ||
| 503 | + temp.exist = true | ||
| 504 | + end | ||
| 505 | + end | ||
| 506 | + end | ||
| 507 | + end | ||
| 508 | + return buffs | ||
| 509 | +end | ||
| 510 | + | ||
| 511 | +-- 获取所有生效的 光环 | ||
| 512 | +function Battle:getActiveAuras() | ||
| 513 | + local auras = {} | ||
| 514 | + for _, one in pairs(self.player:getAuras()) do | ||
| 515 | + auras[one] = (auras[one] or 0) + 1 | ||
| 516 | + end | ||
| 517 | + for _, enemy in pairs(self.player:getTeam(2)) do | ||
| 518 | + for _, one in pairs(enemy:getAuras()) do | ||
| 519 | + auras[one] = (auras[one] or 0) + 1 | ||
| 520 | + end | ||
| 521 | + end | ||
| 522 | + for _, build in pairs(self:getBuilds()) do | ||
| 523 | + for _, one in pairs(build:getAuras()) do | ||
| 524 | + auras[one] = (auras[one] or 0) + 1 | ||
| 525 | + end | ||
| 526 | + end | ||
| 527 | + return auras | ||
| 528 | +end | ||
| 529 | + | ||
| 530 | +function Battle:setMapAuras(auras) | ||
| 531 | + self.auras[self.adv:getCurMapIdx()] = auras | ||
| 532 | +end | ||
| 533 | + | ||
| 534 | +function Battle:getAurasByMap(mapIdx) | ||
| 535 | + mapIdx = mapIdx or self.adv:getCurMapIdx() | ||
| 536 | + local auras = self.auras[mapIdx] or {} | ||
| 537 | + return auras | ||
| 538 | +end | ||
| 539 | + | ||
| 540 | +function Battle:getBuilds() | ||
| 541 | + local team = {} | ||
| 542 | + for _, build in pairs(self.builds[self.adv:getCurMapIdx()]) do | ||
| 543 | + if not build.isDead and not build.lock then -- 已经翻开的 | ||
| 544 | + table.insert(team, build) | ||
| 545 | + end | ||
| 546 | + end | ||
| 547 | + return team | ||
| 548 | +end | ||
| 549 | + | ||
| 550 | + | ||
| 438 | --写入数据 | 551 | --写入数据 |
| 439 | -function Battle:saveDB() | 552 | +function Battle:saveDB(advInfo) |
| 440 | for idx, mapEnemys in pairs(self.enemys) do | 553 | for idx, mapEnemys in pairs(self.enemys) do |
| 441 | for _, enemy in ipairs(mapEnemys) do | 554 | for _, enemy in ipairs(mapEnemys) do |
| 442 | local block = self.adv:getBlock(enemy.roomId, enemy.blockId, idx) | 555 | local block = self.adv:getBlock(enemy.roomId, enemy.blockId, idx) |
| @@ -453,6 +566,7 @@ function Battle:saveDB() | @@ -453,6 +566,7 @@ function Battle:saveDB() | ||
| 453 | end | 566 | end |
| 454 | end | 567 | end |
| 455 | end | 568 | end |
| 569 | + advInfo.auras = self.auras | ||
| 456 | end | 570 | end |
| 457 | 571 | ||
| 458 | return Battle | 572 | return Battle |
| 459 | \ No newline at end of file | 573 | \ No newline at end of file |
src/adv/AdvBuff.lua
| @@ -460,7 +460,18 @@ function Buff:initNew(release, data) | @@ -460,7 +460,18 @@ function Buff:initNew(release, data) | ||
| 460 | end | 460 | end |
| 461 | end | 461 | end |
| 462 | 462 | ||
| 463 | -function Buff:createAfter() | 463 | +function Buff:createAfter(layer) |
| 464 | + layer = layer or 1 | ||
| 465 | + local otype, maxLayer = self:getOverlay() | ||
| 466 | + if otype then | ||
| 467 | + self.layer = layer | ||
| 468 | + if maxLayer ~= 0 then | ||
| 469 | + self.layer = math.min(maxLayer, self.layer) | ||
| 470 | + end | ||
| 471 | + else | ||
| 472 | + self.layer = 1 | ||
| 473 | + end | ||
| 474 | + | ||
| 464 | if self._init then | 475 | if self._init then |
| 465 | self:_init() | 476 | self:_init() |
| 466 | end | 477 | end |
| @@ -647,12 +658,13 @@ function Buff:getOverlay() | @@ -647,12 +658,13 @@ function Buff:getOverlay() | ||
| 647 | end | 658 | end |
| 648 | 659 | ||
| 649 | -- 叠加 | 660 | -- 叠加 |
| 650 | -function Buff:overlay(releaser, data) | 661 | +function Buff:overlay(releaser, data, layer) |
| 651 | local otype, maxLayer = self:getOverlay() | 662 | local otype, maxLayer = self:getOverlay() |
| 652 | if self.isDel or not otype then -- 新获得的 (不可叠加相当于新获得的) | 663 | if self.isDel or not otype then -- 新获得的 (不可叠加相当于新获得的) |
| 653 | - self.isDel = false | ||
| 654 | self:endBuff() | 664 | self:endBuff() |
| 665 | + self.isDel = false | ||
| 655 | self:initNew(releaser, data) | 666 | self:initNew(releaser, data) |
| 667 | + self:createAfter(layer) | ||
| 656 | else | 668 | else |
| 657 | -- 重置回合 次数 | 669 | -- 重置回合 次数 |
| 658 | self.roundSpace = 0 | 670 | self.roundSpace = 0 |
| @@ -665,7 +677,7 @@ function Buff:overlay(releaser, data) | @@ -665,7 +677,7 @@ function Buff:overlay(releaser, data) | ||
| 665 | 677 | ||
| 666 | self.release = releaser or self.release | 678 | self.release = releaser or self.release |
| 667 | -- 叠加层数 | 679 | -- 叠加层数 |
| 668 | - self.layer = self.layer + 1 | 680 | + self.layer = self.layer + layer |
| 669 | if maxLayer ~= 0 then | 681 | if maxLayer ~= 0 then |
| 670 | self.layer = math.min(maxLayer, self.layer) | 682 | self.layer = math.min(maxLayer, self.layer) |
| 671 | end | 683 | end |
| @@ -676,14 +688,32 @@ function Buff:overlay(releaser, data) | @@ -676,14 +688,32 @@ function Buff:overlay(releaser, data) | ||
| 676 | end | 688 | end |
| 677 | 689 | ||
| 678 | -- 扣减层数 | 690 | -- 扣减层数 |
| 679 | -function Buff:uncover() | ||
| 680 | - if self.layer <= 1 then | 691 | +function Buff:uncover(layer, isAura) |
| 692 | + layer = layer or 1 | ||
| 693 | + local oldLayer = self.layer | ||
| 694 | + | ||
| 695 | + self.layer = self.layer - layer | ||
| 696 | + | ||
| 697 | + if self.layer <= 0 then | ||
| 681 | self.isDel = true | 698 | self.isDel = true |
| 682 | end | 699 | end |
| 683 | 700 | ||
| 684 | - self.layer = self.layer - 1 | ||
| 685 | - if self._uncover then | ||
| 686 | - self:_uncover() | 701 | + if isAura then |
| 702 | + if layer == -1 then | ||
| 703 | + self.layer = 0 | ||
| 704 | + self.isDel = true | ||
| 705 | + else | ||
| 706 | + self.layer = math.max(1, self.layer) | ||
| 707 | + self.isDel = false | ||
| 708 | + end | ||
| 709 | + end | ||
| 710 | + | ||
| 711 | + if self.isDel then return end | ||
| 712 | + | ||
| 713 | + if oldLayer ~= self.layer then | ||
| 714 | + if self._uncover then | ||
| 715 | + self:_uncover() | ||
| 716 | + end | ||
| 687 | end | 717 | end |
| 688 | end | 718 | end |
| 689 | 719 |
src/adv/AdvPlayer.lua
| @@ -143,7 +143,8 @@ function BaseObject:getDisablePassiveCount() | @@ -143,7 +143,8 @@ function BaseObject:getDisablePassiveCount() | ||
| 143 | return count | 143 | return count |
| 144 | end | 144 | end |
| 145 | 145 | ||
| 146 | -function BaseObject:addBuff(buffId, releaser) | 146 | +function BaseObject:addBuff(buffId, releaser, layer) |
| 147 | + layer = layer or 1 | ||
| 147 | local buffData = csvdb["adv_map_buffCsv"][buffId] | 148 | local buffData = csvdb["adv_map_buffCsv"][buffId] |
| 148 | if not buffData then return end | 149 | if not buffData then return end |
| 149 | for _, buff in ipairs(self.buffs) do | 150 | for _, buff in ipairs(self.buffs) do |
| @@ -157,7 +158,7 @@ function BaseObject:addBuff(buffId, releaser) | @@ -157,7 +158,7 @@ function BaseObject:addBuff(buffId, releaser) | ||
| 157 | local oldBuff = self:getBuffById(buffId) | 158 | local oldBuff = self:getBuffById(buffId) |
| 158 | if oldBuff then | 159 | if oldBuff then |
| 159 | if not oldBuff:checkKeep() then return end | 160 | if not oldBuff:checkKeep() then return end |
| 160 | - oldBuff:overlay(releaser, {}) -- 叠加 | 161 | + oldBuff:overlay(releaser, {}, layer) -- 叠加 |
| 161 | else | 162 | else |
| 162 | -- 不能保持的buff 也加不上去 | 163 | -- 不能保持的buff 也加不上去 |
| 163 | if not Buff.checkKeep({ | 164 | if not Buff.checkKeep({ |
| @@ -167,7 +168,7 @@ function BaseObject:addBuff(buffId, releaser) | @@ -167,7 +168,7 @@ function BaseObject:addBuff(buffId, releaser) | ||
| 167 | }) then return end | 168 | }) then return end |
| 168 | local buff = Buff.create(self, releaser, {id = buffId}) | 169 | local buff = Buff.create(self, releaser, {id = buffId}) |
| 169 | table.insert(self.buffs, buff) | 170 | table.insert(self.buffs, buff) |
| 170 | - buff:createAfter() | 171 | + buff:createAfter(layer) |
| 171 | end | 172 | end |
| 172 | self:triggerPassive(Passive.GET_BUFF, {trigger = releaser, buffId = buffId}) | 173 | self:triggerPassive(Passive.GET_BUFF, {trigger = releaser, buffId = buffId}) |
| 173 | self:triggerPassive(Passive.PLAYER_BUFF_CLASSIFY, {trigger = releaser, classify = buffData.classify}) | 174 | self:triggerPassive(Passive.PLAYER_BUFF_CLASSIFY, {trigger = releaser, classify = buffData.classify}) |
| @@ -224,6 +225,30 @@ end | @@ -224,6 +225,30 @@ end | ||
| 224 | function BaseObject:reSetSpMax() | 225 | function BaseObject:reSetSpMax() |
| 225 | end | 226 | end |
| 226 | 227 | ||
| 228 | +function BaseObject:checkAuraBuff(buffs) | ||
| 229 | +end | ||
| 230 | + | ||
| 231 | +function BaseObject:getAuras() | ||
| 232 | + local auras = {} | ||
| 233 | + if self:is("Enemy") then | ||
| 234 | + local halo = csvdb["event_monsterCsv"][self.monsterId].halo | ||
| 235 | + if halo then | ||
| 236 | + for _, one in ipairs(halo:toArray(true, "=")) do | ||
| 237 | + table.insert(auras, one) | ||
| 238 | + end | ||
| 239 | + end | ||
| 240 | + elseif self:is("Build") then | ||
| 241 | + local halo = csvdb["event_buildingCsv"][self.id].halo | ||
| 242 | + if halo then | ||
| 243 | + for _, one in ipairs(halo:toArray(true, "=")) do | ||
| 244 | + table.insert(auras, one) | ||
| 245 | + end | ||
| 246 | + end | ||
| 247 | + end | ||
| 248 | + | ||
| 249 | + return auras | ||
| 250 | +end | ||
| 251 | + | ||
| 227 | 252 | ||
| 228 | -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 | 253 | -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 |
| 229 | function BaseObject:getCommonBuffEffect(bType, otherCond) | 254 | function BaseObject:getCommonBuffEffect(bType, otherCond) |
| @@ -625,6 +650,33 @@ function Enemy:getClassify() | @@ -625,6 +650,33 @@ function Enemy:getClassify() | ||
| 625 | return csvdb["event_monsterCsv"][self.monsterId].classify | 650 | return csvdb["event_monsterCsv"][self.monsterId].classify |
| 626 | end | 651 | end |
| 627 | 652 | ||
| 653 | +-- 0=所有 1=怪物 2=玩家 | ||
| 654 | +function Enemy:checkAuraBuff(buffs) | ||
| 655 | + local needBuffs = {} | ||
| 656 | + | ||
| 657 | + for buffId, info in pairs(buffs[0] or {}) do | ||
| 658 | + needBuffs[buffId] = needBuffs[buffId] or {} | ||
| 659 | + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count | ||
| 660 | + needBuffs[buffId].exist = info.exist | ||
| 661 | + end | ||
| 662 | + | ||
| 663 | + for buffId, info in pairs(buffs[1] or {}) do | ||
| 664 | + needBuffs[buffId] = needBuffs[buffId] or {} | ||
| 665 | + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count | ||
| 666 | + needBuffs[buffId].exist = info.exist | ||
| 667 | + end | ||
| 668 | + | ||
| 669 | + for buffId, info in pairs(needBuffs) do | ||
| 670 | + if info.count < 0 then | ||
| 671 | + local buff = self:getBuffById(buffId) | ||
| 672 | + if buff then | ||
| 673 | + buff:uncover(info.exist and -info.count or -1, true) | ||
| 674 | + end | ||
| 675 | + elseif count > 0 then | ||
| 676 | + self:addBuff(buffId, nil, info.count) | ||
| 677 | + end | ||
| 678 | + end | ||
| 679 | +end | ||
| 628 | 680 | ||
| 629 | function Enemy:kill() | 681 | function Enemy:kill() |
| 630 | self:hurt(self.hp, self.battle.player, {hurtType = 5}) | 682 | self:hurt(self.hp, self.battle.player, {hurtType = 5}) |
| @@ -775,6 +827,33 @@ function Player:addBuff(buffId, releaser) | @@ -775,6 +827,33 @@ function Player:addBuff(buffId, releaser) | ||
| 775 | end | 827 | end |
| 776 | return status | 828 | return status |
| 777 | end | 829 | end |
| 830 | +-- 0=所有 1=怪物 2=玩家 | ||
| 831 | +function Player:checkAuraBuff(buffs) | ||
| 832 | + local needBuffs = {} | ||
| 833 | + | ||
| 834 | + for buffId, info in pairs(buffs[0] or {}) do | ||
| 835 | + needBuffs[buffId] = needBuffs[buffId] or {} | ||
| 836 | + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count | ||
| 837 | + needBuffs[buffId].exist = info.exist | ||
| 838 | + end | ||
| 839 | + | ||
| 840 | + for buffId, info in pairs(buffs[2] or {}) do | ||
| 841 | + needBuffs[buffId] = needBuffs[buffId] or {} | ||
| 842 | + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count | ||
| 843 | + needBuffs[buffId].exist = info.exist | ||
| 844 | + end | ||
| 845 | + | ||
| 846 | + for buffId, info in pairs(needBuffs) do | ||
| 847 | + if info.count < 0 then | ||
| 848 | + local buff = self:getBuffById(buffId) | ||
| 849 | + if buff then | ||
| 850 | + buff:uncover(info.exist and -info.count or -1, true) | ||
| 851 | + end | ||
| 852 | + elseif info.count > 0 then | ||
| 853 | + self:addBuff(buffId, nil, info.count) | ||
| 854 | + end | ||
| 855 | + end | ||
| 856 | +end | ||
| 778 | 857 | ||
| 779 | function Player:isPlayer() | 858 | function Player:isPlayer() |
| 780 | return true | 859 | return true |