Commit 1ffc16b9a1583fccd06df72e83691546a4e1c15d
1 parent
f45d3a7b
冒险 选择点和 建筑
Showing
3 changed files
with
118 additions
and
50 deletions
Show diff stats
src/adv/Adv.lua
| @@ -538,7 +538,7 @@ local function clickMonster(self, room, block, params) | @@ -538,7 +538,7 @@ local function clickMonster(self, room, block, params) | ||
| 538 | return true | 538 | return true |
| 539 | end | 539 | end |
| 540 | 540 | ||
| 541 | -local function chooseCommon(self, room, block, chooseData, choose) | 541 | +local function chooseCommon(self, room, block, chooseData, choose, tag) |
| 542 | if not chooseData or not chooseData["button".. choose .."cond"] then return end | 542 | if not chooseData or not chooseData["button".. choose .."cond"] then return end |
| 543 | 543 | ||
| 544 | local cond = chooseData["button".. choose .."cond"]:toArray(true, "=") | 544 | local cond = chooseData["button".. choose .."cond"]:toArray(true, "=") |
| @@ -589,25 +589,37 @@ local function chooseCommon(self, room, block, chooseData, choose) | @@ -589,25 +589,37 @@ local function chooseCommon(self, room, block, chooseData, choose) | ||
| 589 | return true | 589 | return true |
| 590 | end | 590 | end |
| 591 | end, | 591 | end, |
| 592 | - } | ||
| 593 | - assert(not cond[1] or checkCond[cond[1]], "error cond, event_[link]chooseCsv id :" .. block.event.id) | 592 | + [7] = function() |
| 593 | + local buff = self.battle.player:getBuffById(cond[2]) | ||
| 594 | + if buff and buff:getLayer() >= cond[3] then | ||
| 595 | + return true | ||
| 596 | + end | ||
| 597 | + end, | ||
| 598 | + [8] = function() | ||
| 599 | + return self:isHaveArtifact(cond[2]) | ||
| 600 | + end | ||
| 601 | + } | ||
| 602 | + assert(not cond[1] or checkCond[cond[1]], "error cond, event_" .. (tag or "choose") .. "Csv id :" .. block.event.id) | ||
| 594 | 603 | ||
| 595 | if cond[1] and not checkCond[cond[1]]() then return end | 604 | if cond[1] and not checkCond[cond[1]]() then return end |
| 596 | local clearBlock = chooseData.keep ~= 1 | 605 | local clearBlock = chooseData.keep ~= 1 |
| 597 | local effects = chooseData["button".. choose .."effect"]:toTableArray(true) | 606 | local effects = chooseData["button".. choose .."effect"]:toTableArray(true) |
| 598 | for _, effect in ipairs(effects) do | 607 | for _, effect in ipairs(effects) do |
| 599 | - if effect[1] == 1 then | ||
| 600 | - local reward = csvdb["event_dropCsv"][effect[2]]["range"]:randWeight(true) | ||
| 601 | - effect[2] = reward[1] | ||
| 602 | - effect[3] = reward[2] | ||
| 603 | - end | ||
| 604 | - | ||
| 605 | local doEffect = { | 608 | local doEffect = { |
| 606 | [1] = function() -- 获得某道具N个 | 609 | [1] = function() -- 获得某道具N个 |
| 607 | - self:backReward(self:award({[effect[2]] = effect[3]}, {})) | 610 | + local count = effect[3] or 1 |
| 611 | + local reward = {} | ||
| 612 | + for i = 1, count do | ||
| 613 | + local item = csvdb["event_dropCsv"][effect[2]]["range"]:randWeight(true) | ||
| 614 | + reward[item[1]] = (reward[item[1]] or 0) + item[2] | ||
| 615 | + end | ||
| 616 | + self:backReward(self:award(reward, {})) | ||
| 608 | end, | 617 | end, |
| 609 | [2] = function() --获得冒险buff | 618 | [2] = function() --获得冒险buff |
| 610 | - self.battle.player:addBuff(effect[2]) | 619 | + local layer = effect[3] or 1 |
| 620 | + for i = 1, layer do | ||
| 621 | + self.battle.player:addBuff(effect[2]) | ||
| 622 | + end | ||
| 611 | end, | 623 | end, |
| 612 | [3] = function() --发现怪物 | 624 | [3] = function() --发现怪物 |
| 613 | self:getCurMap():addNewMonsterRand(effect[2], {room, block}) | 625 | self:getCurMap():addNewMonsterRand(effect[2], {room, block}) |
| @@ -615,25 +627,74 @@ local function chooseCommon(self, room, block, chooseData, choose) | @@ -615,25 +627,74 @@ local function chooseCommon(self, room, block, chooseData, choose) | ||
| 615 | end, | 627 | end, |
| 616 | [4] = function() --无事发生 | 628 | [4] = function() --无事发生 |
| 617 | end, | 629 | end, |
| 630 | + [5] = function() --5=属性枚举=数值;直接增加玩家属性 | ||
| 631 | + local attr | ||
| 632 | + if effect[3] == 0 then | ||
| 633 | + attr = "sp" | ||
| 634 | + else | ||
| 635 | + attr = AttsEnumEx[effect[3]] | ||
| 636 | + if not AdvAttsEnum[attr] then return end | ||
| 637 | + end | ||
| 638 | + self.battle.player:addBaseAttr(attr, effect[4], effect[2]) | ||
| 639 | + end, | ||
| 640 | + [6] = function() -- 商店 | ||
| 641 | + block:updateEvent({ | ||
| 642 | + etype = AdvEventType.Trader, | ||
| 643 | + id = effect[2] | ||
| 644 | + }) | ||
| 645 | + block:randomEvent() | ||
| 646 | + clearBlock = false | ||
| 647 | + end, | ||
| 648 | + [7] = function() -- 建筑 | ||
| 649 | + block:updateEvent({ | ||
| 650 | + etype = AdvEventType.Build, | ||
| 651 | + id = effect[2] | ||
| 652 | + }) | ||
| 653 | + block:randomEvent() | ||
| 654 | + clearBlock = false | ||
| 655 | + end, | ||
| 656 | + [8] = function() -- 选择 | ||
| 657 | + block:updateEvent({ | ||
| 658 | + etype = AdvEventType.Choose, | ||
| 659 | + id = effect[2] | ||
| 660 | + }) | ||
| 661 | + block:randomEvent() | ||
| 662 | + clearBlock = false | ||
| 663 | + end, | ||
| 664 | + [9] = function() -- click | ||
| 665 | + block:updateEvent({ | ||
| 666 | + etype = AdvEventType.Click, | ||
| 667 | + id = effect[2] | ||
| 668 | + }) | ||
| 669 | + block:randomEvent() | ||
| 670 | + clearBlock = false | ||
| 671 | + end, | ||
| 672 | + [10] = function() -- 陷阱 | ||
| 673 | + block:updateEvent({ | ||
| 674 | + etype = AdvEventType.Trap, | ||
| 675 | + id = effect[2] | ||
| 676 | + }) | ||
| 677 | + block:randomEvent() | ||
| 678 | + clearBlock = false | ||
| 679 | + end, | ||
| 618 | [11] = function() -- 获得神器 | 680 | [11] = function() -- 获得神器 |
| 619 | self:waitChooseArtifact() --等待获取神器 | 681 | self:waitChooseArtifact() --等待获取神器 |
| 620 | end | 682 | end |
| 621 | } | 683 | } |
| 622 | - assert(doEffect[effect[1]], "error effect, event_[link]chooseCsv id :" .. block.event.id) | 684 | + assert(doEffect[effect[1]], "error effect, event_" .. (tag or "choose") .. "Csv id :" .. block.event.id) |
| 623 | doEffect[effect[1]]() | 685 | doEffect[effect[1]]() |
| 624 | end | 686 | end |
| 625 | - self:checkTask(Adv.TaskType.Choose, 1, block.event.id) | ||
| 626 | - self:checkAchievement(Adv.AchievType.Choose, 1, block.event.id) | ||
| 627 | - self:checkAdvUnlock(3, block.event.id) | ||
| 628 | return true, clearBlock | 687 | return true, clearBlock |
| 629 | end | 688 | end |
| 630 | 689 | ||
| 631 | local function clickChoose(self, room, block, params) | 690 | local function clickChoose(self, room, block, params) |
| 632 | local choose = params.choose | 691 | local choose = params.choose |
| 633 | local chooseData = csvdb["event_chooseCsv"][block.event.id] | 692 | local chooseData = csvdb["event_chooseCsv"][block.event.id] |
| 634 | - local status, clearBlock = chooseCommon(self, room, block, chooseData, choose) | 693 | + local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "choose") |
| 635 | if not status then return end | 694 | if not status then return end |
| 636 | - | 695 | + self:checkAdvUnlock(3, block.event.id) |
| 696 | + self:checkTask(Adv.TaskType.Choose, 1, block.event.id) | ||
| 697 | + self:checkAchievement(Adv.AchievType.Choose, 1, block.event.id) | ||
| 637 | if clearBlock then | 698 | if clearBlock then |
| 638 | block:clear() | 699 | block:clear() |
| 639 | end | 700 | end |
| @@ -643,7 +704,7 @@ end | @@ -643,7 +704,7 @@ end | ||
| 643 | local function clickLinkChoose(self, room, block, params) | 704 | local function clickLinkChoose(self, room, block, params) |
| 644 | local choose = params.choose | 705 | local choose = params.choose |
| 645 | local chooseData = csvdb["event_linkchooseCsv"][block.event.id] | 706 | local chooseData = csvdb["event_linkchooseCsv"][block.event.id] |
| 646 | - local status, clearBlock = chooseCommon(self, room, block, chooseData, choose) | 707 | + local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "link") |
| 647 | if not status then return end | 708 | if not status then return end |
| 648 | 709 | ||
| 649 | -- 完成统计次数 | 710 | -- 完成统计次数 |
| @@ -694,31 +755,14 @@ local function clickTrader(self, room, block, params) | @@ -694,31 +755,14 @@ local function clickTrader(self, room, block, params) | ||
| 694 | end | 755 | end |
| 695 | 756 | ||
| 696 | local function clickBuild(self, room, block, params) | 757 | local function clickBuild(self, room, block, params) |
| 697 | - local buildData = csvdb["event_buildingCsv"][block.event.id] | ||
| 698 | - if not buildData then return end-- 偷偷改表了 | ||
| 699 | - if not block.event.effect then return end -- 没有效果 气人不 | ||
| 700 | - local clearBlock = true | ||
| 701 | - local effect = block.event.effect | ||
| 702 | - --todo 效果生效 | ||
| 703 | - local doEffect = { | ||
| 704 | - [1] = function() -- 获得某道具N个 | ||
| 705 | - self:backReward(self:award({[effect[2]] = effect[3]}, {})) | ||
| 706 | - end, | ||
| 707 | - [2] = function() --获得冒险buff | ||
| 708 | - self.battle.player:addBuff(effect[2]) | ||
| 709 | - end, | ||
| 710 | - [3] = function() --发现怪物 | ||
| 711 | - self:getCurMap():addNewMonsterRand(effect[2], {room, block}) | ||
| 712 | - clearBlock = false | ||
| 713 | - end, | ||
| 714 | - [4] = function() --无事发生 | ||
| 715 | - end | ||
| 716 | - } | ||
| 717 | - assert(doEffect[effect[1]], "error effect, event_buildingCsv id :" .. block.event.id) | ||
| 718 | - if not self:cost(buildData.required:toNumMap(), {}) then return end | ||
| 719 | - doEffect[effect[1]]() | 758 | + local choose = params.choose |
| 759 | + local chooseData = csvdb["event_buildingCsv"][block.event.id] | ||
| 760 | + local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build") | ||
| 761 | + if not status then return end | ||
| 762 | + | ||
| 720 | self:checkTask(Adv.TaskType.Build, 1, block.event.id) | 763 | self:checkTask(Adv.TaskType.Build, 1, block.event.id) |
| 721 | self:checkAchievement(Adv.AchievType.Build, 1, block.event.id) | 764 | self:checkAchievement(Adv.AchievType.Build, 1, block.event.id) |
| 765 | + | ||
| 722 | if clearBlock then | 766 | if clearBlock then |
| 723 | block:clear() | 767 | block:clear() |
| 724 | end | 768 | end |
src/adv/AdvBuff.lua
| @@ -247,7 +247,7 @@ local BuffFactory = { | @@ -247,7 +247,7 @@ local BuffFactory = { | ||
| 247 | 247 | ||
| 248 | [Buff.CLEAR_BUFF] = function(_Buff) | 248 | [Buff.CLEAR_BUFF] = function(_Buff) |
| 249 | _Buff._init = function(self, data) | 249 | _Buff._init = function(self, data) |
| 250 | - for _, buff in ipairs(self.buffs) do -- 挂上就清除一下子 | 250 | + for _, buff in ipairs(self.owner.buffs) do -- 挂上就清除一下子 |
| 251 | if not buff.isDel and self:canEffect(buff.id) and not self.isDel then | 251 | if not buff.isDel and self:canEffect(buff.id) and not self.isDel then |
| 252 | if not buff.isDel and not self.isDel then | 252 | if not buff.isDel and not self.isDel then |
| 253 | self:effect() | 253 | self:effect() |
| @@ -629,6 +629,10 @@ function Buff:doEffectChange(effect) | @@ -629,6 +629,10 @@ function Buff:doEffectChange(effect) | ||
| 629 | return effect * (1 + change) | 629 | return effect * (1 + change) |
| 630 | end | 630 | end |
| 631 | 631 | ||
| 632 | +function Buff:getLayer() | ||
| 633 | + return self.layer | ||
| 634 | +end | ||
| 635 | + | ||
| 632 | function Buff:getDB() | 636 | function Buff:getDB() |
| 633 | local db = {} | 637 | local db = {} |
| 634 | if self._getDB then | 638 | if self._getDB then |
src/adv/AdvPlayer.lua
| @@ -575,19 +575,39 @@ function Player:addExp(value) | @@ -575,19 +575,39 @@ function Player:addExp(value) | ||
| 575 | local delta = level - self.level | 575 | local delta = level - self.level |
| 576 | if delta > 0 then | 576 | if delta > 0 then |
| 577 | for attr, _ in pairs(AdvAttsEnum) do | 577 | for attr, _ in pairs(AdvAttsEnum) do |
| 578 | - if attr == "hp" then | ||
| 579 | - self[attr] = self[attr] + self.growth[attr] * delta | ||
| 580 | - self._hpMax = self._hpMax + self.growth[attr] * delta | ||
| 581 | - self:reSetHpMax() | ||
| 582 | - else | ||
| 583 | - self["_" .. attr] = self["_" .. attr] + self.growth[attr] * delta | ||
| 584 | - self:reSetAttr(attr) | ||
| 585 | - end | 578 | + self:addBaseAttr(attr, self.growth[attr] * delta) |
| 586 | end | 579 | end |
| 587 | end | 580 | end |
| 588 | self.level = level | 581 | self.level = level |
| 589 | self.exp = newExp | 582 | self.exp = newExp |
| 590 | end | 583 | end |
| 584 | +--vtype 0/1 值/% | ||
| 585 | +function Player:addBaseAttr(attr, value, vtype) | ||
| 586 | + local attrName = attr | ||
| 587 | + if attr == "hp" then | ||
| 588 | + attrName = "hpMax" | ||
| 589 | + elseif attr = "sp" then | ||
| 590 | + attrName = "spMax" | ||
| 591 | + end | ||
| 592 | + local baseName = "_" .. attrName | ||
| 593 | + if not self[baseName] then return end | ||
| 594 | + local oldV = self[baseName] | ||
| 595 | + | ||
| 596 | + local change = value | ||
| 597 | + if vtype == 1 then | ||
| 598 | + change = oldV * value / 100 | ||
| 599 | + end | ||
| 600 | + self[baseName] = self[baseName] + change | ||
| 601 | + if attr == "hp" then | ||
| 602 | + self.hp = self.hp + change | ||
| 603 | + self:reSetHpMax() | ||
| 604 | + elseif attr == "sp" then | ||
| 605 | + self.sp = self.sp + change | ||
| 606 | + self:reSetSpMax() | ||
| 607 | + else | ||
| 608 | + self:reSetAttr(attr) | ||
| 609 | + end | ||
| 610 | +end | ||
| 591 | 611 | ||
| 592 | --cType 0 or nil 值 1 百分比 | 612 | --cType 0 or nil 值 1 百分比 |
| 593 | function Player:changeSp(value, cType) | 613 | function Player:changeSp(value, cType) |