Commit c198a77a authored by Vury Leo's avatar Vury Leo

move allow_extras to runtime

parent 71f7c749
......@@ -3474,9 +3474,8 @@ function Fusion.AddFusionProcedure(c, opts)
c:RegisterEffect(e)
end
---@param allow_extras boolean whether to allow extra materials for checking propose
function Fusion.BasicCondition(tc,slots,matfilter,fgoalcheck,allow_extras,selected)
return function(e,g,gc,chkf)
function Fusion.BasicCondition(tc,slots,matfilter,fgoalcheck,selected)
return function(e,g,gc,chkf,allow_extras)
if not g then return false end
-- Collect cards and apply global matfilter
......@@ -4251,9 +4250,9 @@ function Fusion.CanCompleteFromMappings(e,sel,eg,slots,matfilter,fgoalcheck,tc,g
end
end
-- delegate to FusionCondition (allow_extras=true)
local search_cond=Fusion.BasicCondition(tc,rem_slots,matfilter,fgoalcheck,true,sel)
if search_cond(e,rem_pool,gc,chkf) then
-- delegate to BasicCondition (allow_extras=true)
local cond=Fusion.BasicCondition(tc,rem_slots,matfilter,fgoalcheck,sel)
if cond(e,rem_pool,gc,chkf,true--[[allow_extras]]) then
Fusion.LockedCodes=old_locked
return true
end
......@@ -4389,8 +4388,8 @@ function Fusion.BuildPatterns(opts)
end
-- Helper: combine multiple patterns into one condition function
function Fusion.MultiCondition(tc,patterns,allow_extras)
return function(e,g,gc,chkf,selected)
function Fusion.MultiCondition(tc,patterns)
return function(e,g,gc,chkf,selected,allow_extras)
if not g then return false end
local locked=Fusion.LockedCodes
for _,pat in ipairs(patterns) do
......@@ -4405,8 +4404,8 @@ function Fusion.MultiCondition(tc,patterns,allow_extras)
end
end
if ok then
local cond=Fusion.BasicCondition(tc,pat.slots,pat.matfilter,pat.fgoalcheck,allow_extras,selected)
if cond(e,g,gc,chkf) then
local cond=Fusion.BasicCondition(tc,pat.slots,pat.matfilter,pat.fgoalcheck,selected)
if cond(e,g,gc,chkf,allow_extras) then
return true
end
end
......@@ -4463,7 +4462,7 @@ function Fusion.MultiOperation(tc,patterns)
max_req=math.min(max_req,eg:GetCount())
-- strict condition uses only active patterns
local strict_cond=Fusion.MultiCondition(tc,active_patterns,false)
local cond=Fusion.MultiCondition(tc,active_patterns)
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FMATERIAL)
local sg=selected and selected:Clone() or Group.CreateGroup()
......@@ -4475,7 +4474,7 @@ function Fusion.MultiOperation(tc,patterns)
end
while true do
local finishable=sg:GetCount()>=min_req and strict_cond(e,sg,gc,chkf)
local finishable=sg:GetCount()>=min_req and cond(e,sg,gc,chkf,false--[[allow_extras]])
local addable=Group.CreateGroup()
-- check fcheck on the *current* sg
......@@ -4552,14 +4551,17 @@ function Fusion.PatternIncludesCode(pat,code)
return false
end
--- A “seeded” condition that first tries CanCompleteFromMappings on each pattern,
--- then, if none complete, falls back to the strict DFS.
--- A “seeded” condition that first tries CanCompleteFromMappings on each pattern
--- @param tc Card
--- @param patterns table[]
function Fusion.FusionCondition(tc,patterns)
return function(e,g,gc,chkf)
return function(e,g,gc,chkf,opts)
if not g then return false end
opts=opts or {}
local allow_extras=true
if opts.allow_extras==false then
allow_extras=false
end
-- build your seed group
local selected=Group.CreateGroup()
if gc then selected:AddCard(gc) end
......@@ -4568,12 +4570,32 @@ function Fusion.FusionCondition(tc,patterns)
local must_materials=Duel.GetMustMaterial(e:GetHandler():GetOwner(),EFFECT_MUST_BE_FMATERIAL)
selected:Merge(must_materials)
-- attempt “search mode” on each pattern
if allow_extras then
-- attempt "search mode" on each pattern
local locked=Fusion.LockedCodes
for _,pat in ipairs(patterns) do
-- skip patterns that don't include all locked codes
local ok=true
if locked then
for _,code in ipairs(locked) do
if not Fusion.PatternIncludesCode(pat,code) then
ok=false
break
end
end
end
if ok then
if Fusion.CanCompleteFromMappings(e,selected,g,pat.slots,pat.matfilter,pat.fgoalcheck or aux.TRUE,tc,gc,chkf) then
return true
end
end
end
else
-- attempt "strict mode"
if Fusion.MultiCondition(tc,patterns)(e,g,gc,chkf,allow_extras) then
return true
end
end
return false
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment