Commit 36c30c5c9892f0aa4b299c080f1913a650d2213e
1 parent
46fac6f1
冒险
Showing
7 changed files
with
99 additions
and
60 deletions
Show diff stats
src/GlobalVar.lua
| @@ -55,6 +55,7 @@ ItemId = { | @@ -55,6 +55,7 @@ ItemId = { | ||
| 55 | Diamond = 3, -- 钻石 | 55 | Diamond = 3, -- 钻石 |
| 56 | BreakCost = 4, -- 突破材料 | 56 | BreakCost = 4, -- 突破材料 |
| 57 | HeroFC = {700, 701, 702, 703}, -- 通用角色碎片 | 57 | HeroFC = {700, 701, 702, 703}, -- 通用角色碎片 |
| 58 | + AdvKey = 80, -- 冒险钥匙 | ||
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | --客户端不需要知道这个 | 61 | --客户端不需要知道这个 |
| @@ -78,14 +79,13 @@ AdvEventType = { | @@ -78,14 +79,13 @@ AdvEventType = { | ||
| 78 | } | 79 | } |
| 79 | 80 | ||
| 80 | AdvBackEventType = { | 81 | AdvBackEventType = { |
| 81 | - Reward = 1 --奖励 | ||
| 82 | - HpChange = 2 --血量改变 | ||
| 83 | - AtkChange = 3 --攻击改变 | ||
| 84 | - Buff = 4 --buff 改变 | ||
| 85 | - Skill = 5 --释放技能 | ||
| 86 | - Atk = 6 --攻击动作 | ||
| 87 | - Next = 7 --进入下一层 | ||
| 88 | - End = 8 -- 结束 | ||
| 89 | - BlockChange = 9 -- 块改变 | ||
| 90 | - | 82 | + Reward = 1, --奖励 |
| 83 | + HpChange = 2, --血量改变 | ||
| 84 | + AtkChange = 3, --攻击改变 | ||
| 85 | + Buff = 4, --buff 改变 | ||
| 86 | + Skill = 5, --释放技能 | ||
| 87 | + Atk = 6, --攻击动作 | ||
| 88 | + Next = 7, --进入下一层 | ||
| 89 | + End = 8, -- 结束 | ||
| 90 | + BlockChange = 9, -- 块改变 | ||
| 91 | } | 91 | } |
| 92 | \ No newline at end of file | 92 | \ No newline at end of file |
src/adv/Adv.lua
| @@ -243,7 +243,7 @@ local function randomAdvMap(role, chapterId, level, notNotify) | @@ -243,7 +243,7 @@ local function randomAdvMap(role, chapterId, level, notNotify) | ||
| 243 | print("这个地图没有钥匙!!! mapId : " .. mapId) | 243 | print("这个地图没有钥匙!!! mapId : " .. mapId) |
| 244 | else | 244 | else |
| 245 | local event = monsterEvents[math.randomInt(1, #monsterEvents)] | 245 | local event = monsterEvents[math.randomInt(1, #monsterEvents)] |
| 246 | - event.item = {1, 1} --掉落钥匙 --todo | 246 | + event.item = {ItemId.AdvKey, 1} --掉落钥匙 --todo |
| 247 | end | 247 | end |
| 248 | end | 248 | end |
| 249 | end | 249 | end |
| @@ -269,11 +269,11 @@ function Block:open(adv, room) | @@ -269,11 +269,11 @@ function Block:open(adv, room) | ||
| 269 | randomFunc[AdvEventType.Monster] = function() | 269 | randomFunc[AdvEventType.Monster] = function() |
| 270 | self.event.mId = adv.advInfo.enemyId --给怪一个有序id 回合逻辑时使用 | 270 | self.event.mId = adv.advInfo.enemyId --给怪一个有序id 回合逻辑时使用 |
| 271 | adv.advInfo.enemyId = adv.advInfo.enemyId + 1 | 271 | adv.advInfo.enemyId = adv.advInfo.enemyId + 1 |
| 272 | - local enemy = self.battle:getEnemy(room.roomId, self.blockId) | 272 | + local enemy = adv.battle:getEnemy(room.roomId, self.blockId) |
| 273 | if enemy then | 273 | if enemy then |
| 274 | enemy:unlock(self.event.mId) | 274 | enemy:unlock(self.event.mId) |
| 275 | else | 275 | else |
| 276 | - self.battle:addEnemy(room, self) | 276 | + adv.battle:addEnemy(room, self) |
| 277 | end | 277 | end |
| 278 | end | 278 | end |
| 279 | randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster] | 279 | randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster] |
| @@ -298,7 +298,7 @@ function Block:open(adv, room) | @@ -298,7 +298,7 @@ function Block:open(adv, room) | ||
| 298 | end | 298 | end |
| 299 | end | 299 | end |
| 300 | --建筑 | 300 | --建筑 |
| 301 | - [AdvEventType.Build] = function() | 301 | + randomFunc[AdvEventType.Build] = function() |
| 302 | local data = csvdb["event_buildingCsv"][self.event.id] | 302 | local data = csvdb["event_buildingCsv"][self.event.id] |
| 303 | self.event.effect = data["range"]:randWeight(true) --随出建筑效果 | 303 | self.event.effect = data["range"]:randWeight(true) --随出建筑效果 |
| 304 | if self.event.effect[1] == 1 then --获得某道具 | 304 | if self.event.effect[1] == 1 then --获得某道具 |
| @@ -308,7 +308,7 @@ function Block:open(adv, room) | @@ -308,7 +308,7 @@ function Block:open(adv, room) | ||
| 308 | end | 308 | end |
| 309 | end | 309 | end |
| 310 | --抉择点 | 310 | --抉择点 |
| 311 | - [AdvEventType.Choose] = function() | 311 | + randomFunc[AdvEventType.Choose] = function() |
| 312 | local data = csvdb["event_chooseCsv"][self.event.id] | 312 | local data = csvdb["event_chooseCsv"][self.event.id] |
| 313 | self.event.effect = {} | 313 | self.event.effect = {} |
| 314 | for i = 1, 2 do | 314 | for i = 1, 2 do |
| @@ -325,7 +325,7 @@ function Block:open(adv, room) | @@ -325,7 +325,7 @@ function Block:open(adv, room) | ||
| 325 | randomFunc[self.event.etype]() | 325 | randomFunc[self.event.etype]() |
| 326 | end | 326 | end |
| 327 | end | 327 | end |
| 328 | - self.isOpne = true | 328 | + self.isOpen = true |
| 329 | end | 329 | end |
| 330 | 330 | ||
| 331 | local Room = class("Room") | 331 | local Room = class("Room") |
| @@ -374,14 +374,18 @@ end | @@ -374,14 +374,18 @@ end | ||
| 374 | function Room:openBlock(block, adv) | 374 | function Room:openBlock(block, adv) |
| 375 | if self.blocks[block.blockId] ~= block then return end | 375 | if self.blocks[block.blockId] ~= block then return end |
| 376 | if block.isOpen == true then return end | 376 | if block.isOpen == true then return end |
| 377 | - block:open(adv, self) | ||
| 378 | - local allOpen = true | ||
| 379 | - if not self.isBossRoom then | 377 | + if self.isBossRoom then |
| 380 | for _, _block in pairs(self.blocks) do | 378 | for _, _block in pairs(self.blocks) do |
| 381 | - if not _block.isOpen then | ||
| 382 | - allOpen = false | ||
| 383 | - break | ||
| 384 | - end | 379 | + _block:open(adv, self) |
| 380 | + end | ||
| 381 | + else | ||
| 382 | + block:open(adv, self) | ||
| 383 | + end | ||
| 384 | + local allOpen = true | ||
| 385 | + for _, _block in pairs(self.blocks) do | ||
| 386 | + if not _block.isOpen then | ||
| 387 | + allOpen = false | ||
| 388 | + break | ||
| 385 | end | 389 | end |
| 386 | end | 390 | end |
| 387 | 391 | ||
| @@ -413,7 +417,7 @@ function Adv:ctor(owner) | @@ -413,7 +417,7 @@ function Adv:ctor(owner) | ||
| 413 | self.advInfo = self.owner:getProperty("advInfo") --这个变量置空使用 table.clear | 417 | self.advInfo = self.owner:getProperty("advInfo") --这个变量置空使用 table.clear |
| 414 | self.advTeam = self.owner:getProperty("advTeam") --这个变量置空使用 table.clear | 418 | self.advTeam = self.owner:getProperty("advTeam") --这个变量置空使用 table.clear |
| 415 | self:clear() | 419 | self:clear() |
| 416 | - self.events = {} --发给客户端的事件组 | 420 | + self.backEvents = {} --发给客户端的事件组 |
| 417 | end | 421 | end |
| 418 | 422 | ||
| 419 | -- 清空自己组织的数据 | 423 | -- 清空自己组织的数据 |
| @@ -485,9 +489,10 @@ end | @@ -485,9 +489,10 @@ end | ||
| 485 | 489 | ||
| 486 | -- 随机地图 | 490 | -- 随机地图 |
| 487 | function Adv:initByChapter(chapterId, level, notNotify) | 491 | function Adv:initByChapter(chapterId, level, notNotify) |
| 492 | + level = level or 1 | ||
| 488 | randomAdvMap(self.owner, chapterId, level, notNotify) | 493 | randomAdvMap(self.owner, chapterId, level, notNotify) |
| 489 | self:initByInfo() --初始化 | 494 | self:initByInfo() --初始化 |
| 490 | - role:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam}, notNotify) | 495 | + self.owner:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam}, notNotify) |
| 491 | end | 496 | end |
| 492 | 497 | ||
| 493 | --获取,某个位置上的 room 和 block | 498 | --获取,某个位置上的 room 和 block |
| @@ -629,7 +634,7 @@ end | @@ -629,7 +634,7 @@ end | ||
| 629 | 634 | ||
| 630 | --事件点击处理 | 635 | --事件点击处理 |
| 631 | local function clickOut(self, room, block, params) | 636 | local function clickOut(self, room, block, params) |
| 632 | - if self:cost({[1] = 1}, {}) then --todo 钥匙id | 637 | + if self:cost({[ItemId.AdvKey] = 1}, {}) then |
| 633 | if self.advInfo.level >= csvdb["adv_chapterCsv"][self.advInfo.chapter].limitlevel then --关卡结束 | 638 | if self.advInfo.level >= csvdb["adv_chapterCsv"][self.advInfo.chapter].limitlevel then --关卡结束 |
| 634 | self:over(true) | 639 | self:over(true) |
| 635 | else | 640 | else |
| @@ -781,39 +786,40 @@ function Adv:clickBlock(roomId, blockId, params) | @@ -781,39 +786,40 @@ function Adv:clickBlock(roomId, blockId, params) | ||
| 781 | local block = room.blocks[blockId] | 786 | local block = room.blocks[blockId] |
| 782 | if not block then return end | 787 | if not block then return end |
| 783 | 788 | ||
| 784 | - local canOpen = false --如果未开放是否可以开放 | ||
| 785 | - local hadMonster = false -- 周围是否有解锁的怪未击败 | ||
| 786 | - for _, one in ipairs(self:getAroundBlocks(room, block)) do | ||
| 787 | - local _room, _block = one[1], one[2] | ||
| 788 | - if _block.isOpen then canOpen = true end | ||
| 789 | - if _block.isOpen and _block.event and (_block.event.etype == AdvEventType.BOSS or _block.event.etype == AdvEventType.Monster) then | ||
| 790 | - hadMonster = true | ||
| 791 | - end | ||
| 792 | - end | ||
| 793 | local status = false | 789 | local status = false |
| 790 | + local clickEvent = false | ||
| 794 | if not block.isOpen then | 791 | if not block.isOpen then |
| 792 | + local canOpen = false --如果未开放是否可以开放 | ||
| 793 | + local hadMonster = false -- 周围是否有解锁的怪未击败 | ||
| 794 | + for _, one in ipairs(self:getAroundBlocks(room, block)) do | ||
| 795 | + local _room, _block = one[1], one[2] | ||
| 796 | + if _block.isOpen then canOpen = true end | ||
| 797 | + if _block.isOpen and _block.event and (_block.event.etype == AdvEventType.BOSS or _block.event.etype == AdvEventType.Monster) then | ||
| 798 | + hadMonster = true | ||
| 799 | + end | ||
| 800 | + end | ||
| 795 | if canOpen and not hadMonster then --开放 | 801 | if canOpen and not hadMonster then --开放 |
| 796 | room:openBlock(block, self) | 802 | room:openBlock(block, self) |
| 797 | status = true | 803 | status = true |
| 798 | end | 804 | end |
| 799 | else | 805 | else |
| 806 | + clickEvent = true | ||
| 800 | --点了空地 | 807 | --点了空地 |
| 801 | if not block.event then | 808 | if not block.event then |
| 802 | return | 809 | return |
| 803 | end | 810 | end |
| 804 | --可点击的事件 | 811 | --可点击的事件 |
| 805 | - if not hadMonster and not room.isBossRoom then | 812 | + if not room.isBossRoom or block.event.etype == AdvEventType.BOSS then |
| 806 | if eventCallFunc[block.event.etype] then | 813 | if eventCallFunc[block.event.etype] then |
| 807 | status = eventCallFunc[block.event.etype](self, room, block, params) | 814 | status = eventCallFunc[block.event.etype](self, room, block, params) |
| 808 | end | 815 | end |
| 809 | end | 816 | end |
| 810 | end | 817 | end |
| 811 | - if status and block.event.etype ~= AdvEventType.Out then --出去了就不计算回合了 | 818 | + if status and (not clickEvent or (not block.event or block.event.etype ~= AdvEventType.Out)) then --出去了就不计算回合了 |
| 812 | self:backBlockChange(roomId, blockId) | 819 | self:backBlockChange(roomId, blockId) |
| 813 | self:afterRound() | 820 | self:afterRound() |
| 814 | end | 821 | end |
| 815 | - self.battle:getDB() | ||
| 816 | - role:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam}) | 822 | + self:saveDB() |
| 817 | return status | 823 | return status |
| 818 | end | 824 | end |
| 819 | 825 | ||
| @@ -840,8 +846,7 @@ function Adv:useItem(itemId, count, target) | @@ -840,8 +846,7 @@ function Adv:useItem(itemId, count, target) | ||
| 840 | end | 846 | end |
| 841 | 847 | ||
| 842 | self:afterRound() | 848 | self:afterRound() |
| 843 | - self.battle:getDB() | ||
| 844 | - role:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam}) | 849 | + self:saveDB() |
| 845 | return true | 850 | return true |
| 846 | end | 851 | end |
| 847 | 852 | ||
| @@ -870,20 +875,23 @@ function Adv:useSkill(skillId, target) | @@ -870,20 +875,23 @@ function Adv:useSkill(skillId, target) | ||
| 870 | end | 875 | end |
| 871 | 876 | ||
| 872 | self:afterRound() | 877 | self:afterRound() |
| 873 | - self.battle:getDB() | ||
| 874 | - role:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam}) | 878 | + self:saveDB() |
| 875 | return true | 879 | return true |
| 876 | end | 880 | end |
| 877 | 881 | ||
| 878 | --敌人死亡 | 882 | --敌人死亡 |
| 879 | function Adv:enemyDead(roomId, blockId) | 883 | function Adv:enemyDead(roomId, blockId) |
| 880 | - local block = self.rooms[roomId].blocks[blockId] | 884 | + local room = self.rooms[roomId] |
| 885 | + local block = room.blocks[blockId] | ||
| 881 | --死了以后掉东西 | 886 | --死了以后掉东西 |
| 882 | if block.event and (block.event.etype == AdvEventType.BOSS or block.event.etype == AdvEventType.Monster) then --处理死亡 | 887 | if block.event and (block.event.etype == AdvEventType.BOSS or block.event.etype == AdvEventType.Monster) then --处理死亡 |
| 888 | + if block.event.etype == AdvEventType.BOSS then | ||
| 889 | + room.isBossRoom = false | ||
| 890 | + end | ||
| 883 | local item = block.event.item | 891 | local item = block.event.item |
| 884 | if not item then | 892 | if not item then |
| 885 | if block.event.etype == AdvEventType.BOSS then | 893 | if block.event.etype == AdvEventType.BOSS then |
| 886 | - item = {1, 1} --todo 钥匙 | 894 | + item = {ItemId.AdvKey, 1} |
| 887 | else | 895 | else |
| 888 | local monsterData = csvdb["event_monsterCsv"][block.event.id] | 896 | local monsterData = csvdb["event_monsterCsv"][block.event.id] |
| 889 | local dropData = csvdb["event_dropCsv"][monsterData.dropid] | 897 | local dropData = csvdb["event_dropCsv"][monsterData.dropid] |
| @@ -930,7 +938,7 @@ function Adv:backBuff(enemyId, buffId, isDel) | @@ -930,7 +938,7 @@ function Adv:backBuff(enemyId, buffId, isDel) | ||
| 930 | end | 938 | end |
| 931 | -- if is player enemyId is nil | 939 | -- if is player enemyId is nil |
| 932 | function Adv:backSkill(enemyId, skillId, receiver) | 940 | function Adv:backSkill(enemyId, skillId, receiver) |
| 933 | - self:pushBackEvent(AdvBackEventType.Skill, {enemyId = enemyId, buffId = skillId, receiver = receiver}) | 941 | + self:pushBackEvent(AdvBackEventType.Skill, {enemyId = enemyId, skillId = skillId, receiver = receiver}) |
| 934 | end | 942 | end |
| 935 | 943 | ||
| 936 | function Adv:backNext() | 944 | function Adv:backNext() |
| @@ -962,4 +970,11 @@ function Adv:afterRound() | @@ -962,4 +970,11 @@ function Adv:afterRound() | ||
| 962 | end | 970 | end |
| 963 | end | 971 | end |
| 964 | 972 | ||
| 973 | +function Adv:saveDB() | ||
| 974 | + if self.battle then | ||
| 975 | + self.battle:getDB() | ||
| 976 | + end | ||
| 977 | + self.owner:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam}) | ||
| 978 | +end | ||
| 979 | + | ||
| 965 | return Adv | 980 | return Adv |
| 966 | \ No newline at end of file | 981 | \ No newline at end of file |
src/adv/AdvBattle.lua
| 1 | -local Player, Enemy = require "adv.advPlayer" | 1 | +local Player, Enemy = table.unpack(require "adv.advPlayer") |
| 2 | local Buff = require "adv.AdvBuff" | 2 | local Buff = require "adv.AdvBuff" |
| 3 | -local AdvBattle = class("Battle") | 3 | +local Battle = class("Battle") |
| 4 | function Battle:ctor(adv) | 4 | function Battle:ctor(adv) |
| 5 | self.adv = adv | 5 | self.adv = adv |
| 6 | self.player = nil --玩家 | 6 | self.player = nil --玩家 |
| @@ -63,14 +63,14 @@ function Battle:addEnemy(room, block) | @@ -63,14 +63,14 @@ function Battle:addEnemy(room, block) | ||
| 63 | table.insert(enemy.passives, {id = id}) | 63 | table.insert(enemy.passives, {id = id}) |
| 64 | end | 64 | end |
| 65 | block.event.enemy = enemy | 65 | block.event.enemy = enemy |
| 66 | - table.insert(self.enemys, Enemy.new(self, block.event.mId or 999, block.event.id, room.roomId, block.blockId, not block.isOpen, block.event.enemy)) | ||
| 67 | end | 66 | end |
| 67 | + table.insert(self.enemys, Enemy.new(self, block.event.mId or 999, block.event.id, room.roomId, block.blockId, not block.isOpen, block.event.enemy)) | ||
| 68 | end | 68 | end |
| 69 | end | 69 | end |
| 70 | 70 | ||
| 71 | function Battle:getEnemy(roomId, blockId) | 71 | function Battle:getEnemy(roomId, blockId) |
| 72 | for _, enemy in ipairs(self.enemys) do | 72 | for _, enemy in ipairs(self.enemys) do |
| 73 | - if enemy.roomId == roomId and enemy.blockId = blockId then | 73 | + if enemy.roomId == roomId and enemy.blockId == blockId then |
| 74 | return enemy | 74 | return enemy |
| 75 | end | 75 | end |
| 76 | end | 76 | end |
| @@ -87,16 +87,18 @@ end | @@ -87,16 +87,18 @@ end | ||
| 87 | function Battle:playerAtk(roomId, blockId) | 87 | function Battle:playerAtk(roomId, blockId) |
| 88 | local enemy = self:getEnemy(roomId, blockId) | 88 | local enemy = self:getEnemy(roomId, blockId) |
| 89 | if enemy then | 89 | if enemy then |
| 90 | + self.adv:backAtk(nil, enemy.id) | ||
| 90 | enemy:hurt(self.player:getHurtValue(), self.player, {hurtType = 1}) | 91 | enemy:hurt(self.player:getHurtValue(), self.player, {hurtType = 1}) |
| 91 | --是否无法反击 | 92 | --是否无法反击 |
| 92 | if not enemy:hadBuff(Buff.CANT_BACK_ATK) then | 93 | if not enemy:hadBuff(Buff.CANT_BACK_ATK) then |
| 94 | + self.adv:backAtk(enemy.id, nil) | ||
| 93 | self.player:hurt(enemy:getHurtValue(), enemy, {hurtType = 1}) | 95 | self.player:hurt(enemy:getHurtValue(), enemy, {hurtType = 1}) |
| 94 | end | 96 | end |
| 95 | end | 97 | end |
| 96 | end | 98 | end |
| 97 | --触发全员被动技能 | 99 | --触发全员被动技能 |
| 98 | function Battle:triggerPassive(condType, params) | 100 | function Battle:triggerPassive(condType, params) |
| 99 | - | 101 | + |
| 100 | end | 102 | end |
| 101 | 103 | ||
| 102 | --回合 | 104 | --回合 |
| @@ -133,4 +135,4 @@ function Battle:getDB() | @@ -133,4 +135,4 @@ function Battle:getDB() | ||
| 133 | end | 135 | end |
| 134 | end | 136 | end |
| 135 | 137 | ||
| 136 | -return AdvBattle | ||
| 137 | \ No newline at end of file | 138 | \ No newline at end of file |
| 139 | +return Battle | ||
| 138 | \ No newline at end of file | 140 | \ No newline at end of file |
src/adv/AdvPassive.lua
| @@ -25,7 +25,7 @@ Passive.ROOM_SHOW = 19 --自身所在房间被展示时,触发1次 | @@ -25,7 +25,7 @@ Passive.ROOM_SHOW = 19 --自身所在房间被展示时,触发1次 | ||
| 25 | 25 | ||
| 26 | -- 不同的开启条件 | 26 | -- 不同的开启条件 |
| 27 | local PassiveFactory = { | 27 | local PassiveFactory = { |
| 28 | - [] | 28 | + |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | function Passive:ctor(owner, data) | 31 | function Passive:ctor(owner, data) |
| @@ -80,7 +80,9 @@ end | @@ -80,7 +80,9 @@ end | ||
| 80 | function Passive:trigger(condType, params) --触发检查 | 80 | function Passive:trigger(condType, params) --触发检查 |
| 81 | if self:getCondType() ~= condType then return end | 81 | if self:getCondType() ~= condType then return end |
| 82 | if self:isActive() then return end | 82 | if self:isActive() then return end |
| 83 | - | 83 | + if self._trigger then |
| 84 | + if not self._trigger(params) then return end --检查 | ||
| 85 | + end | ||
| 84 | self.round = self.passiveData.delay --首次 | 86 | self.round = self.passiveData.delay --首次 |
| 85 | self.count = self.passiveData.count --次数 | 87 | self.count = self.passiveData.count --次数 |
| 86 | -- 没有延迟就直接触发 | 88 | -- 没有延迟就直接触发 |
| @@ -98,5 +100,6 @@ function Passive:getDB() | @@ -98,5 +100,6 @@ function Passive:getDB() | ||
| 98 | db.level = self.level | 100 | db.level = self.level |
| 99 | db.round = self.round | 101 | db.round = self.round |
| 100 | db.count = self.count | 102 | db.count = self.count |
| 103 | + return db | ||
| 101 | end | 104 | end |
| 102 | return Passive | 105 | return Passive |
| 103 | \ No newline at end of file | 106 | \ No newline at end of file |
src/adv/AdvPlayer.lua
| @@ -30,7 +30,7 @@ end | @@ -30,7 +30,7 @@ end | ||
| 30 | -- 角色初始化完以后才是 技能和被动技能 方便初始化 buff 的 释放对象 | 30 | -- 角色初始化完以后才是 技能和被动技能 方便初始化 buff 的 释放对象 |
| 31 | function BaseObject:initAfter(data) | 31 | function BaseObject:initAfter(data) |
| 32 | for _, passive in ipairs(data.passives or {}) do | 32 | for _, passive in ipairs(data.passives or {}) do |
| 33 | - table.insert(self.passives, Passive.load(self, passive)) | 33 | + table.insert(self.passives, Passive.new(self, passive)) |
| 34 | end | 34 | end |
| 35 | for _, buff in ipairs(data.buffs or {}) do | 35 | for _, buff in ipairs(data.buffs or {}) do |
| 36 | table.insert(self.buffs, Buff.load(self, buff)) | 36 | table.insert(self.buffs, Buff.load(self, buff)) |
| @@ -55,6 +55,7 @@ function BaseObject:clearRound() | @@ -55,6 +55,7 @@ function BaseObject:clearRound() | ||
| 55 | end | 55 | end |
| 56 | for i = #self.buffs, 1, -1 do | 56 | for i = #self.buffs, 1, -1 do |
| 57 | if self.buffs[i].isDel then | 57 | if self.buffs[i].isDel then |
| 58 | + self.battle.adv:backBuff(self.id, self.buffs[i].id, true) | ||
| 58 | self.buffs[i]:endBuff() | 59 | self.buffs[i]:endBuff() |
| 59 | table.remove(self.buffs, i) | 60 | table.remove(self.buffs, i) |
| 60 | end | 61 | end |
| @@ -78,6 +79,8 @@ function BaseObject:addBuff(buffId, releaser) | @@ -78,6 +79,8 @@ function BaseObject:addBuff(buffId, releaser) | ||
| 78 | end | 79 | end |
| 79 | end | 80 | end |
| 80 | table.insert(self.buffs, Buff.create(self, releaser, {id = buffId})) | 81 | table.insert(self.buffs, Buff.create(self, releaser, {id = buffId})) |
| 82 | + | ||
| 83 | + self.battle.adv:backBuff(self.id, buffId) | ||
| 81 | end | 84 | end |
| 82 | 85 | ||
| 83 | function BaseObject:hadBuff(bType) | 86 | function BaseObject:hadBuff(bType) |
| @@ -130,10 +133,17 @@ function BaseObject:getInjuredChange() | @@ -130,10 +133,17 @@ function BaseObject:getInjuredChange() | ||
| 130 | end | 133 | end |
| 131 | --重新计算属性 | 134 | --重新计算属性 |
| 132 | function BaseObject:reSetAttr(field) | 135 | function BaseObject:reSetAttr(field) |
| 136 | + local old = self[field] | ||
| 133 | self[field] = self["_" .. field] --重置一下 | 137 | self[field] = self["_" .. field] --重置一下 |
| 134 | local fieldToBuff = {atk = Buff.IMMNUE_ATK, hit = Buff.HIT_CHANGE, miss = Buff.MISS_CHANGE} | 138 | local fieldToBuff = {atk = Buff.IMMNUE_ATK, hit = Buff.HIT_CHANGE, miss = Buff.MISS_CHANGE} |
| 135 | local effect = self:getCommonBuffEffect(fieldToBuff[field]) | 139 | local effect = self:getCommonBuffEffect(fieldToBuff[field]) |
| 136 | self[field] = (self[field] + effect[0]) * (1 + effect[1]) | 140 | self[field] = (self[field] + effect[0]) * (1 + effect[1]) |
| 141 | + local delta = self[field] - old | ||
| 142 | + if delta ~= 0 then | ||
| 143 | + if field == "atk" then | ||
| 144 | + self.battle.adv:backAtkChange(self.id, delta) | ||
| 145 | + end | ||
| 146 | + end | ||
| 137 | end | 147 | end |
| 138 | 148 | ||
| 139 | --计算打出伤害加成后的值 | 149 | --计算打出伤害加成后的值 |
| @@ -208,6 +218,7 @@ function BaseObject:hurt(value, releaser, params) | @@ -208,6 +218,7 @@ function BaseObject:hurt(value, releaser, params) | ||
| 208 | end | 218 | end |
| 209 | 219 | ||
| 210 | --受伤了~ | 220 | --受伤了~ |
| 221 | + self.battle.adv:backHpChange(self.id, -value) | ||
| 211 | self.hp = math.max(0, self.hp - value) | 222 | self.hp = math.max(0, self.hp - value) |
| 212 | if self.hp == 0 then | 223 | if self.hp == 0 then |
| 213 | self.isDead = true | 224 | self.isDead = true |
| @@ -218,9 +229,11 @@ function BaseObject:recover(value, releaser, params) | @@ -218,9 +229,11 @@ function BaseObject:recover(value, releaser, params) | ||
| 218 | params = params or {} | 229 | params = params or {} |
| 219 | value = math.max(0, value) | 230 | value = math.max(0, value) |
| 220 | self.hp = math.min(self.hpMax, self.hp + value) | 231 | self.hp = math.min(self.hpMax, self.hp + value) |
| 232 | + self.battle.adv:backHpChange(self.id, value) | ||
| 221 | end | 233 | end |
| 222 | 234 | ||
| 223 | function BaseObject:releaseSkill(skillId, skillLevel, target) | 235 | function BaseObject:releaseSkill(skillId, skillLevel, target) |
| 236 | + if self:hadBuff(Buff.CANT_SKILL) then return end -- 针对 怪物 | ||
| 224 | skillLevel = skillLevel or 1 | 237 | skillLevel = skillLevel or 1 |
| 225 | local skillData = csvdb["adv_skillCsv"][skillId][skillLevel or 1] | 238 | local skillData = csvdb["adv_skillCsv"][skillId][skillLevel or 1] |
| 226 | local targetChoose = skillData.target:toArray(true, "=") | 239 | local targetChoose = skillData.target:toArray(true, "=") |
| @@ -289,6 +302,10 @@ function BaseObject:releaseSkill(skillId, skillLevel, target) | @@ -289,6 +302,10 @@ function BaseObject:releaseSkill(skillId, skillLevel, target) | ||
| 289 | targets = tempT --all | 302 | targets = tempT --all |
| 290 | end | 303 | end |
| 291 | end | 304 | end |
| 305 | + --返回客户端 | ||
| 306 | + for _, target in ipairs(targets) do | ||
| 307 | + self.battle.adv:backSkill(self.id, skillId, target.id) | ||
| 308 | + end | ||
| 292 | -- 增加buff | 309 | -- 增加buff |
| 293 | for _, buffId in ipairs(skillData.selfbuff:toArray(true, "=")) do | 310 | for _, buffId in ipairs(skillData.selfbuff:toArray(true, "=")) do |
| 294 | self:addBuff(buffId, self) | 311 | self:addBuff(buffId, self) |
| @@ -361,14 +378,14 @@ function BaseObject:getDB() | @@ -361,14 +378,14 @@ function BaseObject:getDB() | ||
| 361 | end | 378 | end |
| 362 | 379 | ||
| 363 | function BaseObject:triggerPassive(condType, params) | 380 | function BaseObject:triggerPassive(condType, params) |
| 364 | - | 381 | + |
| 365 | end | 382 | end |
| 366 | 383 | ||
| 367 | local Enemy = class("Enemy", BaseObject) | 384 | local Enemy = class("Enemy", BaseObject) |
| 368 | -function Enemy:ctor(battle, monsterId, id, roomId, blockId, lock, enemy) | 385 | +function Enemy:ctor(battle, mId, monsterId, roomId, blockId, lock, enemy) |
| 369 | Enemy.super.ctor(self, battle) | 386 | Enemy.super.ctor(self, battle) |
| 370 | - self.id = id | ||
| 371 | - self.monsterId = monsterId | 387 | + self.id = mId |
| 388 | + self.monsterId = monsterId --数据id | ||
| 372 | self.roomId = roomId | 389 | self.roomId = roomId |
| 373 | self.blockId = blockId | 390 | self.blockId = blockId |
| 374 | self.lock = lock | 391 | self.lock = lock |
| @@ -385,4 +402,4 @@ function Player:ctor(battle, data) | @@ -385,4 +402,4 @@ function Player:ctor(battle, data) | ||
| 385 | self:initData(data) | 402 | self:initData(data) |
| 386 | end | 403 | end |
| 387 | 404 | ||
| 388 | -return Player, Enemy | ||
| 389 | \ No newline at end of file | 405 | \ No newline at end of file |
| 406 | +return table.pack(Player, Enemy) | ||
| 390 | \ No newline at end of file | 407 | \ No newline at end of file |
src/models/Role.lua
| @@ -147,6 +147,7 @@ function Role:data() | @@ -147,6 +147,7 @@ function Role:data() | ||
| 147 | advPass = self:getProperty("advPass"), | 147 | advPass = self:getProperty("advPass"), |
| 148 | advInfo = self:getProperty("advInfo"), | 148 | advInfo = self:getProperty("advInfo"), |
| 149 | advItems = self:getProperty("advItems"):toNumMap(), | 149 | advItems = self:getProperty("advItems"):toNumMap(), |
| 150 | + advTeam = self:getProperty("advTeam"), | ||
| 150 | } | 151 | } |
| 151 | end | 152 | end |
| 152 | 153 |
src/models/RolePlugin.lua
| @@ -205,6 +205,7 @@ function RolePlugin.bind(Role) | @@ -205,6 +205,7 @@ function RolePlugin.bind(Role) | ||
| 205 | function Role:getAdvData() | 205 | function Role:getAdvData() |
| 206 | if not self.advData then | 206 | if not self.advData then |
| 207 | self.advData = require("adv.Adv").new(self) | 207 | self.advData = require("adv.Adv").new(self) |
| 208 | + self.advData:initByInfo() | ||
| 208 | end | 209 | end |
| 209 | return self.advData | 210 | return self.advData |
| 210 | end | 211 | end |