Commit cb071e8d9088275ab8f35e10aac47aa4d862a967

Authored by zhouhaihai
1 parent 6ba840cb

多条件选项

Showing 2 changed files with 52 additions and 4 deletions   Show diff stats
@@ -1031,7 +1031,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) @@ -1031,7 +1031,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
1031 if not choose then return end 1031 if not choose then return end
1032 if not chooseData or not chooseData["button".. choose .."cond"] then return end 1032 if not chooseData or not chooseData["button".. choose .."cond"] then return end
1033 1033
1034 - local cond = chooseData["button".. choose .."cond"]:toArray(true, "=") 1034 + local conds = chooseData["button".. choose .."cond"]:toTableArray(true)
1035 local checkCond = { 1035 local checkCond = {
1036 -- 没有条件 1036 -- 没有条件
1037 [0] = function() 1037 [0] = function()
@@ -1106,10 +1106,54 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) @@ -1106,10 +1106,54 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
1106 [10] = function(_, artifactId) 1106 [10] = function(_, artifactId)
1107 return not self:isHaveArtifact(artifactId) 1107 return not self:isHaveArtifact(artifactId)
1108 end, 1108 end,
  1109 + -- 11 = 地图上没有指定id 的怪
  1110 + [11] = function(_, monsterId)
  1111 + for _, room in pairs(self:getCurMap().rooms) do
  1112 + for _, block in pairs(room.blocks) do
  1113 + if block:isMonster() then
  1114 + if not monsterId then return false end
  1115 + if block.event.id == monsterId then
  1116 + return false
  1117 + end
  1118 + end
  1119 + end
  1120 + end
  1121 + return true
  1122 + end,
  1123 + -- 12 = 地图上没有指定id 的建筑
  1124 + [12] = function(_, buildId)
  1125 + for _, room in pairs(self:getCurMap().rooms) do
  1126 + for _, block in pairs(room.blocks) do
  1127 + if block:isBuild() then
  1128 + if not buildId then return false end
  1129 + if block.event.id == buildId then
  1130 + return false
  1131 + end
  1132 + end
  1133 + end
  1134 + end
  1135 + return true
  1136 + end,
  1137 + -- 13 = 地图上没有指定的 选择点
  1138 + [13] = function(_, chooseId)
  1139 + for _, room in pairs(self:getCurMap().rooms) do
  1140 + for _, block in pairs(room.blocks) do
  1141 + if block:isChoose() then
  1142 + if not chooseId then return false end
  1143 + if block.event.id == chooseId then
  1144 + return false
  1145 + end
  1146 + end
  1147 + end
  1148 + end
  1149 + return true
  1150 + end,
1109 } 1151 }
1110 - assert(not cond[1] or checkCond[cond[1]], "error cond, event_" .. (tag or "choose") .. "Csv id :" .. block.event.id)  
1111 -  
1112 - if cond[1] and not checkCond[cond[1]](table.unpack(cond)) then return end 1152 + for _, cond in ipairs(conds) do
  1153 + assert(not cond[1] or checkCond[cond[1]], "error cond, event_" .. (tag or "choose") .. "Csv id :" .. block.event.id)
  1154 + if cond[1] and not checkCond[cond[1]](table.unpack(cond)) then return end
  1155 + end
  1156 +
1113 local clearBlock = chooseData.keep ~= 1 1157 local clearBlock = chooseData.keep ~= 1
1114 local effects = chooseData["button".. choose .."effect"]:toTableArray(true) 1158 local effects = chooseData["button".. choose .."effect"]:toTableArray(true)
1115 for _, effect in ipairs(effects) do 1159 for _, effect in ipairs(effects) do
src/adv/AdvBlock.lua
@@ -25,6 +25,10 @@ function Block:isBuild() @@ -25,6 +25,10 @@ function Block:isBuild()
25 return self:getEventType() == AdvEventType.Build 25 return self:getEventType() == AdvEventType.Build
26 end 26 end
27 27
  28 +function Block:isChoose()
  29 + return self:getEventType() == AdvEventType.Choose
  30 +end
  31 +
28 function Block:getEventType() 32 function Block:getEventType()
29 return self.event and self.event.etype 33 return self.event and self.event.etype
30 end 34 end