From cb071e8d9088275ab8f35e10aac47aa4d862a967 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Mon, 8 Jun 2020 17:41:41 +0800 Subject: [PATCH] 多条件选项 --- src/adv/Adv.lua | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- src/adv/AdvBlock.lua | 4 ++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index 86c7f47..9720179 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -1031,7 +1031,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) if not choose then return end if not chooseData or not chooseData["button".. choose .."cond"] then return end - local cond = chooseData["button".. choose .."cond"]:toArray(true, "=") + local conds = chooseData["button".. choose .."cond"]:toTableArray(true) local checkCond = { -- 没有条件 [0] = function() @@ -1106,10 +1106,54 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) [10] = function(_, artifactId) return not self:isHaveArtifact(artifactId) end, + -- 11 = 地图上没有指定id 的怪 + [11] = function(_, monsterId) + for _, room in pairs(self:getCurMap().rooms) do + for _, block in pairs(room.blocks) do + if block:isMonster() then + if not monsterId then return false end + if block.event.id == monsterId then + return false + end + end + end + end + return true + end, + -- 12 = 地图上没有指定id 的建筑 + [12] = function(_, buildId) + for _, room in pairs(self:getCurMap().rooms) do + for _, block in pairs(room.blocks) do + if block:isBuild() then + if not buildId then return false end + if block.event.id == buildId then + return false + end + end + end + end + return true + end, + -- 13 = 地图上没有指定的 选择点 + [13] = function(_, chooseId) + for _, room in pairs(self:getCurMap().rooms) do + for _, block in pairs(room.blocks) do + if block:isChoose() then + if not chooseId then return false end + if block.event.id == chooseId then + return false + end + end + end + end + return true + end, } - assert(not cond[1] or checkCond[cond[1]], "error cond, event_" .. (tag or "choose") .. "Csv id :" .. block.event.id) - - if cond[1] and not checkCond[cond[1]](table.unpack(cond)) then return end + for _, cond in ipairs(conds) do + assert(not cond[1] or checkCond[cond[1]], "error cond, event_" .. (tag or "choose") .. "Csv id :" .. block.event.id) + if cond[1] and not checkCond[cond[1]](table.unpack(cond)) then return end + end + local clearBlock = chooseData.keep ~= 1 local effects = chooseData["button".. choose .."effect"]:toTableArray(true) for _, effect in ipairs(effects) do diff --git a/src/adv/AdvBlock.lua b/src/adv/AdvBlock.lua index b6f75fa..28cb7bb 100644 --- a/src/adv/AdvBlock.lua +++ b/src/adv/AdvBlock.lua @@ -25,6 +25,10 @@ function Block:isBuild() return self:getEventType() == AdvEventType.Build end +function Block:isChoose() + return self:getEventType() == AdvEventType.Choose +end + function Block:getEventType() return self.event and self.event.etype end -- libgit2 0.21.2