Skip to content

Commit a6d03d6

Browse files
committed
Xyz proc: update automatic material selection logic
If a must material group is passed to the xyz proc, and the min and max values match the size of that group, then if those materials are valid within the material group, the selection will be skipped
1 parent 650edea commit a6d03d6

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

proc_xyz.lua

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,14 @@ function Xyz.Target(f,lv,minc,maxc,mustbemat,exchk)
335335
end
336336
local mustg=Auxiliary.GetMustBeMaterialGroup(tp,g,tp,c,mg,REASON_XYZ)
337337
if must then mustg:Merge(must) end
338+
local orichalcumGroup
338339
if not mustbemat then
339-
mg:Merge(Duel.GetMatchingGroup(Card.IsHasEffect,tp,LOCATION_HAND+LOCATION_ONFIELD+LOCATION_GRAVE+LOCATION_REMOVED,0,nil,EFFECT_ORICHALCUM_CHAIN))
340+
orichalcumGroup=Duel.GetMatchingGroup(Card.IsHasEffect,tp,LOCATION_HAND+LOCATION_ONFIELD+LOCATION_GRAVE+LOCATION_REMOVED,0,nil,EFFECT_ORICHALCUM_CHAIN)
341+
mg:Merge(orichalcumGroup)
342+
end
343+
if (not orichalcumGroup or #orichalcumGroup==0) and (must and #must==min and #must==max) then
344+
e:SetLabelObject(mustg:Clone():KeepAlive())
345+
return true
340346
end
341347
do
342348
local extra_mats=0
@@ -479,18 +485,22 @@ function Xyz.Target2(alterf,op)
479485
local mustg=Auxiliary.GetMustBeMaterialGroup(tp,og,tp,c,mg,REASON_XYZ)
480486
if must then mustg:Merge(must) end
481487
local oc
482-
if #mustg>0 then
488+
if must and #must==min and #must==max then
483489
oc=mustg:GetFirst()
490+
elseif #mustg>0 then
491+
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
492+
local ocg=mustg:Select(tp,1,1,cancelable,nil)
493+
if ocg then
494+
oc=ocg:GetFirst()
495+
end
484496
else
485497
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
486498
local ocg=mg:FilterSelect(tp,Xyz.AlterFilter,1,1,cancelable,nil,alterf,c,e,tp,op)
487-
if not ocg then return false end
488-
oc=ocg:GetFirst()
499+
if ocg then
500+
oc=ocg:GetFirst()
501+
end
489502
end
490-
if not oc then return false end
491-
local ok=true
492-
if op then ok=op(e,tp,1,oc) end
493-
if not ok then return false end
503+
if not oc or (op and not op(e,tp,1,oc)) then return false end
494504
e:SetLabelObject(oc)
495505
return true
496506
end

0 commit comments

Comments
 (0)