Commit 9cffb42ba8ecd94a49734caae5255dd9d26de9bf
1 parent
36c30c5c
抉择点 建筑
Showing
1 changed file
with
19 additions
and
15 deletions
Show diff stats
src/adv/Adv.lua
| ... | ... | @@ -525,11 +525,11 @@ function Adv:getAroundBlocks(room, block) |
| 525 | 525 | end |
| 526 | 526 | |
| 527 | 527 | --随机一个空的位置生成怪, 如果没有就没有 |
| 528 | -function Adv:addNewMonsterRand() | |
| 528 | +function Adv:addNewMonsterRand(monsterId) | |
| 529 | 529 | local pool = {} |
| 530 | 530 | for _, room in pairs(self.rooms) do |
| 531 | - for _, block in pairs(self.blocks) do | |
| 532 | - if not block.event then | |
| 531 | + for _, block in pairs(room.blocks) do | |
| 532 | + if block.isOpen and not block.event then | |
| 533 | 533 | table.insert(pool, {room, block}) |
| 534 | 534 | end |
| 535 | 535 | end |
| ... | ... | @@ -538,13 +538,14 @@ function Adv:addNewMonsterRand() |
| 538 | 538 | local idx = math.randomInt(1, #pool) |
| 539 | 539 | local room, block = pool[idx][1], pool[idx][2] |
| 540 | 540 | |
| 541 | - local event = {mId = self.advInfo.enemyId} | |
| 541 | + local event = {etype = AdvEventType.Monster, mId = self.advInfo.enemyId} | |
| 542 | 542 | self.advInfo.enemyId = self.advInfo.enemyId + 1 |
| 543 | - | |
| 544 | - local eventLib = getEventLib(self.advInfo.chapter, self.advInfo.level, AdvEventType.Monster) | |
| 545 | - if not next(eventLib[AdvEventType.Monster]) then return false end | |
| 546 | - event.id = math.randWeight(eventLib[AdvEventType.Monster], "showup") | |
| 547 | - | |
| 543 | + if not monsterId then | |
| 544 | + local eventLib = getEventLib(self.advInfo.chapter, self.advInfo.level, AdvEventType.Monster) | |
| 545 | + if not next(eventLib[AdvEventType.Monster]) then return false end | |
| 546 | + monsterId = math.randWeight(eventLib[AdvEventType.Monster], "showup") | |
| 547 | + end | |
| 548 | + event.id = monsterId | |
| 548 | 549 | block.event = event |
| 549 | 550 | room.info.event[block.blockId] = event |
| 550 | 551 | self.battle:addEnemy(room, block) |
| ... | ... | @@ -604,6 +605,7 @@ function Adv:award(gift, params) |
| 604 | 605 | items = items:incrv(itemId, count) |
| 605 | 606 | end |
| 606 | 607 | end |
| 608 | + | |
| 607 | 609 | self.owner:updateProperty({field = "advItems", value = items, notNotify = params.notNotify}) |
| 608 | 610 | return tgift |
| 609 | 611 | end |
| ... | ... | @@ -692,8 +694,8 @@ local function clickChoose(self, room, block, params) |
| 692 | 694 | end |
| 693 | 695 | end, |
| 694 | 696 | } |
| 695 | - assert(checkCond[cond[1]], "error cond, event_chooseCsv id :" .. block.event.id) | |
| 696 | - if not checkCond[cond[1]]() then return end | |
| 697 | + assert(not cond[1] or checkCond[cond[1]], "error cond, event_chooseCsv id :" .. block.event.id) | |
| 698 | + if cond[1] and not checkCond[cond[1]]() then return end | |
| 697 | 699 | |
| 698 | 700 | local effect = block.event.effect[choose] |
| 699 | 701 | local doEffect = { |
| ... | ... | @@ -704,8 +706,10 @@ local function clickChoose(self, room, block, params) |
| 704 | 706 | self.battle.player:addBuff(effect[2]) |
| 705 | 707 | end, |
| 706 | 708 | [3] = function() --发现怪物 |
| 707 | - local r, b = self:addNewMonsterRand() | |
| 708 | - self:backBlockChange(r.roomId, b.blockId) | |
| 709 | + local r, b = self:addNewMonsterRand(effect[2]) | |
| 710 | + if r then | |
| 711 | + self:backBlockChange(r.roomId, b.blockId) | |
| 712 | + end | |
| 709 | 713 | end, |
| 710 | 714 | [4] = function() --无事发生 |
| 711 | 715 | end |
| ... | ... | @@ -755,8 +759,8 @@ local function clickBuild(self, room, block, params) |
| 755 | 759 | self.battle.player:addBuff(effect[2]) |
| 756 | 760 | end, |
| 757 | 761 | [3] = function() --发现怪物 |
| 758 | - local r, b = self:addNewMonsterRand() | |
| 759 | - self:backBlockChange(r.roomId, b.blockId) | |
| 762 | + local r, b = self:addNewMonsterRand(effect[2]) | |
| 763 | + if r then self:backBlockChange(r.roomId, b.blockId) end | |
| 760 | 764 | end, |
| 761 | 765 | [4] = function() --无事发生 |
| 762 | 766 | end | ... | ... |